mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -235,8 +235,11 @@ public class DaemonListeners implements Disposable {
|
||||
Project editorProject = editor.getProject();
|
||||
// worthBothering() checks for getCachedPsiFile, so call getPsiFile here
|
||||
PsiFile file = editorProject == null ? null : PsiDocumentManager.getInstance(editorProject).getPsiFile(document);
|
||||
if (!editor.getComponent().isShowing() || !worthBothering(document, editorProject)) {
|
||||
LOG.debug("Not worth: " + file);
|
||||
boolean showing = editor.getComponent().isShowing();
|
||||
boolean worthBothering = worthBothering(document, editorProject);
|
||||
if (!showing || !worthBothering) {
|
||||
LOG.debug("Not worth bothering about editor created for : " + file + " because editor isShowing(): " +
|
||||
showing + "; project is open and file is mine: " + worthBothering);
|
||||
return;
|
||||
}
|
||||
repaintErrorStripeRenderer(editor, myProject);
|
||||
@@ -420,7 +423,7 @@ public class DaemonListeners implements Disposable {
|
||||
}
|
||||
|
||||
private class MyCommandListener extends CommandAdapter {
|
||||
private final Object myCutActionName = myActionManager.getAction(IdeActions.ACTION_EDITOR_CUT).getTemplatePresentation().getText();
|
||||
private final String myCutActionName = myActionManager.getAction(IdeActions.ACTION_EDITOR_CUT).getTemplatePresentation().getText();
|
||||
|
||||
@Override
|
||||
public void commandStarted(CommandEvent event) {
|
||||
|
||||
+10
-16
@@ -59,13 +59,10 @@ public class EditorFactoryImpl extends EditorFactory implements ApplicationCompo
|
||||
@Override
|
||||
public void projectOpened(final Project project) {
|
||||
// validate all editors are disposed after fireProjectClosed() was called, because it's the place where editor should be released
|
||||
Disposer.register(project, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
final Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
|
||||
final boolean isLastProjectClosed = openProjects.length == 0;
|
||||
validateEditorsAreReleased(project, isLastProjectClosed);
|
||||
}
|
||||
Disposer.register(project, () -> {
|
||||
final Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
|
||||
final boolean isLastProjectClosed = openProjects.length == 0;
|
||||
validateEditorsAreReleased(project, isLastProjectClosed);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -79,12 +76,9 @@ public class EditorFactoryImpl extends EditorFactory implements ApplicationCompo
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
ModalityStateListener myModalityStateListener = new ModalityStateListener() {
|
||||
@Override
|
||||
public void beforeModalityStateChanged(boolean entering) {
|
||||
for (Editor editor : myEditors) {
|
||||
((EditorImpl)editor).beforeModalityStateChanged();
|
||||
}
|
||||
ModalityStateListener myModalityStateListener = entering -> {
|
||||
for (Editor editor : myEditors) {
|
||||
((EditorImpl)editor).beforeModalityStateChanged();
|
||||
}
|
||||
};
|
||||
LaterInvocator.addModalityStateListener(myModalityStateListener, ApplicationManager.getApplication());
|
||||
@@ -196,7 +190,7 @@ public class EditorFactoryImpl extends EditorFactory implements ApplicationCompo
|
||||
myEditorFactoryEventDispatcher.getMulticaster().editorCreated(new EditorFactoryEvent(this, editor));
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("number of Editor's:" + myEditors.size());
|
||||
LOG.debug("number of Editors after create: " + myEditors.size());
|
||||
}
|
||||
|
||||
return editor;
|
||||
@@ -214,7 +208,7 @@ public class EditorFactoryImpl extends EditorFactory implements ApplicationCompo
|
||||
finally {
|
||||
myEditors.remove(editor);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("number of Editor's:" + myEditors.size());
|
||||
LOG.debug("number of Editors after release: " + myEditors.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -227,7 +221,7 @@ public class EditorFactoryImpl extends EditorFactory implements ApplicationCompo
|
||||
for (Editor editor : myEditors) {
|
||||
Project project1 = editor.getProject();
|
||||
if (editor.getDocument().equals(document) && (project == null || project1 == null || project1.equals(project))) {
|
||||
if (list == null) list = new SmartList<Editor>();
|
||||
if (list == null) list = new SmartList<>();
|
||||
list.add(editor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ public class FileTypeUtil {
|
||||
preview.append(open).append('\n');
|
||||
}
|
||||
|
||||
if (template.length() > 0) {
|
||||
if (!template.isEmpty()) {
|
||||
String[] lines = template.split("\n", -1);
|
||||
for (String line : lines) {
|
||||
if (options.isTrim()) {
|
||||
@@ -152,7 +152,7 @@ public class FileTypeUtil {
|
||||
line = StringUtil.trimEnd(line, close);
|
||||
preview.append(leader).append(pre);
|
||||
int len = 0;
|
||||
if (pre.length() > 0 && line.length() > 0) {
|
||||
if (pre.length() > 0 && !line.isEmpty()) {
|
||||
preview.append(' ');
|
||||
len++;
|
||||
}
|
||||
@@ -221,7 +221,7 @@ public class FileTypeUtil {
|
||||
}
|
||||
|
||||
public FileType[] getSupportedTypes() {
|
||||
HashSet<FileType> set = new HashSet<FileType>(getMap().values());
|
||||
Set<FileType> set = new HashSet<>(getMap().values());
|
||||
return set.toArray(new FileType[set.size()]);
|
||||
}
|
||||
|
||||
@@ -269,19 +269,19 @@ public class FileTypeUtil {
|
||||
}
|
||||
|
||||
private void createMappings() {
|
||||
Set<FileType> maps = new HashSet<FileType>();
|
||||
Set<FileType> maps = new HashSet<>();
|
||||
maps.add(StdFileTypes.DTD);
|
||||
maps.add(StdFileTypes.XML);
|
||||
|
||||
mappings.put(StdFileTypes.XML, maps);
|
||||
|
||||
maps = new HashSet<FileType>();
|
||||
maps = new HashSet<>();
|
||||
maps.add(StdFileTypes.HTML);
|
||||
maps.add(StdFileTypes.XHTML);
|
||||
|
||||
mappings.put(StdFileTypes.HTML, maps);
|
||||
|
||||
maps = new HashSet<FileType>();
|
||||
maps = new HashSet<>();
|
||||
maps.add(StdFileTypes.JSP);
|
||||
|
||||
mappings.put(StdFileTypes.JSP, maps);
|
||||
@@ -293,7 +293,7 @@ public class FileTypeUtil {
|
||||
}
|
||||
|
||||
private static boolean isSupportedType(FileType type) {
|
||||
if (type.isBinary() || type.getName().indexOf("IDEA") >= 0 || "GUI_DESIGNER_FORM".equals(type.getName())) {
|
||||
if (type.isBinary() || type.getName().contains("IDEA") || "GUI_DESIGNER_FORM".equals(type.getName())) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
@@ -323,14 +323,14 @@ public class FileTypeUtil {
|
||||
}
|
||||
|
||||
private void loadFileTypes() {
|
||||
logger.debug("loadFileTypes");
|
||||
Map<String, FileType> map = new HashMap<String, FileType>();
|
||||
LOG.debug("loadFileTypes");
|
||||
Map<String, FileType> map = new HashMap<>();
|
||||
for (FileType ftype : FileTypeManager.getInstance().getRegisteredFileTypes()) {
|
||||
// Ignore binary files
|
||||
// Ignore IDEA specific file types (PROJECT, MODULE, WORKSPACE)
|
||||
// Ignore GUI Designer files
|
||||
if (isSupportedType(ftype)) {
|
||||
logger.debug("adding " + ftype.getName());
|
||||
LOG.debug("adding " + ftype.getName());
|
||||
Iterator<FileType> iter = mappings.keySet().iterator();
|
||||
FileType type = ftype;
|
||||
while (iter.hasNext()) {
|
||||
@@ -344,7 +344,7 @@ public class FileTypeUtil {
|
||||
map.put(ftype.getName(), type);
|
||||
}
|
||||
else {
|
||||
logger.debug("ignoring " + ftype.getName());
|
||||
LOG.debug("ignoring " + ftype.getName());
|
||||
}
|
||||
}
|
||||
types = map;
|
||||
@@ -368,8 +368,8 @@ public class FileTypeUtil {
|
||||
}
|
||||
|
||||
private Map<String, FileType> types;
|
||||
private final Map<FileType, Set<FileType>> mappings = new HashMap<FileType, Set<FileType>>();
|
||||
private final Set<FileType> noSeparators = new HashSet<FileType>();
|
||||
private final Map<FileType, Set<FileType>> mappings = new HashMap<>();
|
||||
private final Set<FileType> noSeparators = new HashSet<>();
|
||||
|
||||
private static final Logger logger = Logger.getInstance(FileTypeUtil.class.getName());
|
||||
private static final Logger LOG = Logger.getInstance(FileTypeUtil.class.getName());
|
||||
}
|
||||
Reference in New Issue
Block a user