diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java index fe7073c2c570..c7f8832fbe0a 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java @@ -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) { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorFactoryImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorFactoryImpl.java index 4ad7e498ccae..543e1d7d5776 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorFactoryImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorFactoryImpl.java @@ -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(); + if (list == null) list = new SmartList<>(); list.add(editor); } } diff --git a/plugins/copyright/src/com/maddyhome/idea/copyright/util/FileTypeUtil.java b/plugins/copyright/src/com/maddyhome/idea/copyright/util/FileTypeUtil.java index 92458f842706..44732ffdc3ec 100644 --- a/plugins/copyright/src/com/maddyhome/idea/copyright/util/FileTypeUtil.java +++ b/plugins/copyright/src/com/maddyhome/idea/copyright/util/FileTypeUtil.java @@ -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 set = new HashSet(getMap().values()); + Set set = new HashSet<>(getMap().values()); return set.toArray(new FileType[set.size()]); } @@ -269,19 +269,19 @@ public class FileTypeUtil { } private void createMappings() { - Set maps = new HashSet(); + Set maps = new HashSet<>(); maps.add(StdFileTypes.DTD); maps.add(StdFileTypes.XML); mappings.put(StdFileTypes.XML, maps); - maps = new HashSet(); + maps = new HashSet<>(); maps.add(StdFileTypes.HTML); maps.add(StdFileTypes.XHTML); mappings.put(StdFileTypes.HTML, maps); - maps = new HashSet(); + 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 map = new HashMap(); + LOG.debug("loadFileTypes"); + Map 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 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 types; - private final Map> mappings = new HashMap>(); - private final Set noSeparators = new HashSet(); + private final Map> mappings = new HashMap<>(); + private final Set noSeparators = new HashSet<>(); - private static final Logger logger = Logger.getInstance(FileTypeUtil.class.getName()); + private static final Logger LOG = Logger.getInstance(FileTypeUtil.class.getName()); } \ No newline at end of file