From 5fb2be806e3e37651e71a29b687e1d6a3dd00b9d Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 1 Feb 2017 16:50:36 +0300 Subject: [PATCH] cleanup --- ...xtEditorHighlightingPassRegistrarImpl.java | 136 ++++++++---------- .../com/intellij/openapi/wm/ToolWindow.java | 6 +- .../openapi/wm/ToolWindowManager.java | 20 +-- 3 files changed, 72 insertions(+), 90 deletions(-) diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorHighlightingPassRegistrarImpl.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorHighlightingPassRegistrarImpl.java index 13006ade86eb..755180212c3d 100644 --- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorHighlightingPassRegistrarImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorHighlightingPassRegistrarImpl.java @@ -116,48 +116,42 @@ public class TextEditorHighlightingPassRegistrarImpl extends TextEditorHighlight } final TIntObjectHashMap id2Pass = new TIntObjectHashMap<>(); final TIntArrayList passesRefusedToCreate = new TIntArrayList(); - myRegisteredPassFactories.forEachKey(new TIntProcedure() { - @Override - public boolean execute(int passId) { - if (ArrayUtil.find(passesToIgnore, passId) != -1) { - return true; - } - PassConfig passConfig = myRegisteredPassFactories.get(passId); - TextEditorHighlightingPassFactory factory = passConfig.passFactory; - final TextEditorHighlightingPass pass = factory.createHighlightingPass(psiFile, editor); - - if (pass == null) { - passesRefusedToCreate.add(passId); - } - else { - // init with editor's colors scheme - pass.setColorsScheme(editor.getColorsScheme()); - - TIntArrayList ids = new TIntArrayList(passConfig.completionPredecessorIds.length); - for (int id : passConfig.completionPredecessorIds) { - if (myRegisteredPassFactories.containsKey(id)) ids.add(id); - } - pass.setCompletionPredecessorIds(ids.isEmpty() ? ArrayUtil.EMPTY_INT_ARRAY : ids.toNativeArray()); - ids = new TIntArrayList(passConfig.startingPredecessorIds.length); - for (int id : passConfig.startingPredecessorIds) { - if (myRegisteredPassFactories.containsKey(id)) ids.add(id); - } - pass.setStartingPredecessorIds(ids.isEmpty() ? ArrayUtil.EMPTY_INT_ARRAY : ids.toNativeArray()); - pass.setId(passId); - id2Pass.put(passId, pass); - } + myRegisteredPassFactories.forEachKey(passId -> { + if (ArrayUtil.find(passesToIgnore, passId) != -1) { return true; } + PassConfig passConfig = myRegisteredPassFactories.get(passId); + TextEditorHighlightingPassFactory factory = passConfig.passFactory; + final TextEditorHighlightingPass pass = factory.createHighlightingPass(psiFile, editor); + + if (pass == null) { + passesRefusedToCreate.add(passId); + } + else { + // init with editor's colors scheme + pass.setColorsScheme(editor.getColorsScheme()); + + TIntArrayList ids = new TIntArrayList(passConfig.completionPredecessorIds.length); + for (int id : passConfig.completionPredecessorIds) { + if (myRegisteredPassFactories.containsKey(id)) ids.add(id); + } + pass.setCompletionPredecessorIds(ids.isEmpty() ? ArrayUtil.EMPTY_INT_ARRAY : ids.toNativeArray()); + ids = new TIntArrayList(passConfig.startingPredecessorIds.length); + for (int id : passConfig.startingPredecessorIds) { + if (myRegisteredPassFactories.containsKey(id)) ids.add(id); + } + pass.setStartingPredecessorIds(ids.isEmpty() ? ArrayUtil.EMPTY_INT_ARRAY : ids.toNativeArray()); + pass.setId(passId); + id2Pass.put(passId, pass); + } + return true; }); DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject); final FileStatusMap statusMap = daemonCodeAnalyzer.getFileStatusMap(); - passesRefusedToCreate.forEach(new TIntProcedure() { - @Override - public boolean execute(int passId) { - statusMap.markFileUpToDate(document, passId); - return true; - } + passesRefusedToCreate.forEach(passId -> { + statusMap.markFileUpToDate(document, passId); + return true; }); return (List)Arrays.asList(id2Pass.getValues()); @@ -169,20 +163,17 @@ public class TextEditorHighlightingPassRegistrarImpl extends TextEditorHighlight @NotNull final Document document, @NotNull final HighlightInfoProcessor highlightInfoProcessor) { final THashSet ids = new THashSet<>(); - myRegisteredPassFactories.forEachKey(new TIntProcedure() { - @Override - public boolean execute(int passId) { - PassConfig passConfig = myRegisteredPassFactories.get(passId); - TextEditorHighlightingPassFactory factory = passConfig.passFactory; - if (factory instanceof MainHighlightingPassFactory) { - final TextEditorHighlightingPass pass = ((MainHighlightingPassFactory)factory).createMainHighlightingPass(psiFile, document, highlightInfoProcessor); - if (pass != null) { - ids.add(pass); - pass.setId(passId); - } + myRegisteredPassFactories.forEachKey(passId -> { + PassConfig passConfig = myRegisteredPassFactories.get(passId); + TextEditorHighlightingPassFactory factory = passConfig.passFactory; + if (factory instanceof MainHighlightingPassFactory) { + final TextEditorHighlightingPass pass = ((MainHighlightingPassFactory)factory).createMainHighlightingPass(psiFile, document, highlightInfoProcessor); + if (pass != null) { + ids.add(pass); + pass.setId(passId); } - return true; } + return true; }); return new ArrayList<>(ids); } @@ -190,38 +181,29 @@ public class TextEditorHighlightingPassRegistrarImpl extends TextEditorHighlight private void checkForCycles() { final TIntObjectHashMap transitivePredecessors = new TIntObjectHashMap<>(); - myRegisteredPassFactories.forEachEntry(new TIntObjectProcedure() { - @Override - public boolean execute(int passId, PassConfig config) { - TIntHashSet allPredecessors = new TIntHashSet(config.completionPredecessorIds); - allPredecessors.addAll(config.startingPredecessorIds); - transitivePredecessors.put(passId, allPredecessors); - allPredecessors.forEach(new TIntProcedure() { - @Override - public boolean execute(int predecessorId) { - PassConfig predecessor = myRegisteredPassFactories.get(predecessorId); - if (predecessor == null) return true; - TIntHashSet transitives = transitivePredecessors.get(predecessorId); - if (transitives == null) { - transitives = new TIntHashSet(); - transitivePredecessors.put(predecessorId, transitives); - } - transitives.addAll(predecessor.completionPredecessorIds); - transitives.addAll(predecessor.startingPredecessorIds); - return true; - } - }); - return true; - } - }); - transitivePredecessors.forEachKey(new TIntProcedure() { - @Override - public boolean execute(int passId) { - if (transitivePredecessors.get(passId).contains(passId)) { - throw new IllegalArgumentException("There is a cycle introduced involving pass " + myRegisteredPassFactories.get(passId).passFactory); + myRegisteredPassFactories.forEachEntry((passId, config) -> { + TIntHashSet allPredecessors = new TIntHashSet(config.completionPredecessorIds); + allPredecessors.addAll(config.startingPredecessorIds); + transitivePredecessors.put(passId, allPredecessors); + allPredecessors.forEach(predecessorId -> { + PassConfig predecessor = myRegisteredPassFactories.get(predecessorId); + if (predecessor == null) return true; + TIntHashSet transitives = transitivePredecessors.get(predecessorId); + if (transitives == null) { + transitives = new TIntHashSet(); + transitivePredecessors.put(predecessorId, transitives); } + transitives.addAll(predecessor.completionPredecessorIds); + transitives.addAll(predecessor.startingPredecessorIds); return true; + }); + return true; + }); + transitivePredecessors.forEachKey(passId -> { + if (transitivePredecessors.get(passId).contains(passId)) { + throw new IllegalArgumentException("There is a cycle introduced involving pass " + myRegisteredPassFactories.get(passId).passFactory); } + return true; }); } diff --git a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindow.java b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindow.java index 9460fd2c3f36..87a2c876e543 100644 --- a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindow.java +++ b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindow.java @@ -107,7 +107,7 @@ public interface ToolWindow extends BusyObject { void setType(@NotNull ToolWindowType type, @Nullable Runnable runnable); /** - * @return window icon. Returns null if window has no icon. + * @return window icon. Returns {@code null} if window has no icon. */ Icon getIcon(); @@ -117,7 +117,7 @@ public interface ToolWindow extends BusyObject { void setIcon(Icon icon); /** - * @return window title. Returns null if window has no title. + * @return window title. Returns {@code null} if window has no title. */ String getTitle(); @@ -175,7 +175,7 @@ public interface ToolWindow extends BusyObject { /** * - * @param show if false stripe button would be hidden + * @param show if {@code false} stripe button would be hidden */ void setShowStripeButton(boolean show); diff --git a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.java b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.java index 96fbb41189ad..f73c98ce2d03 100644 --- a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.java +++ b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.java @@ -39,15 +39,15 @@ public abstract class ToolWindowManager { /** * Register specified tool window into IDE window system. - * @param id id of tool window to be registered. - * @param component component which represents tool window content. + * @param id {@code id} of tool window to be registered. + * @param component {@code component} which represents tool window content. * May be null. Content can be further added via content manager for this tool window (See {@link ToolWindow#getContentManager()}) * @param anchor the default anchor for first registration. It uses only first time the - * tool window with the specified id is being registered into the window system. + * tool window with the specified {@code id} is being registered into the window system. * After the first registration window's anchor is stored in project file - * and anchor is ignored. + * and {@code anchor} is ignored. * @exception IllegalArgumentException if the same window is already installed or one - * of the parameters is null. + * of the parameters is {@code null}. * @return tool window * @deprecated {@link ToolWindowManager#registerToolWindow(String, boolean, ToolWindowAnchor)} */ @@ -129,26 +129,26 @@ public abstract class ToolWindowManager { public abstract void activateEditorComponent(); /** - * @return true if and only if editor component is active. + * @return {@code true} if and only if editor component is active. */ public abstract boolean isEditorComponentActive(); /** - * @return array of ids of all registered tool windows. + * @return array of {@code id}s of all registered tool windows. */ @NotNull public abstract String[] getToolWindowIds(); /** - * @return ID of currently active tool window or null if there is no active + * @return {@code ID} of currently active tool window or {@code null} if there is no active * tool window. */ @Nullable public abstract String getActiveToolWindowId(); /** - * @return registered tool window with specified id. If there is no registered - * tool window with specified id then the method returns null. + * @return registered tool window with specified {@code id}. If there is no registered + * tool window with specified {@code id} then the method returns {@code null}. */ public abstract ToolWindow getToolWindow(String id);