From bbc93e43040a048956d8ab222c2b0a0af4e07e7d Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 31 Oct 2014 19:23:42 +0300 Subject: [PATCH] cleanup --- .../daemon/impl/RefCountHolder.java | 22 ++++++++++++++----- .../impl/PostHighlightingPassFactory.java | 1 + .../psi/refResolve/RefResolveServiceImpl.java | 3 +++ .../impl/CheckLevelHighlightInfoHolder.java | 1 + .../impl/analysis/HighlightInfoHolder.java | 5 +++-- .../lang/ant/dom/PropertyProviderFinder.java | 6 ----- .../designSurface/DesignerEditorPanel.java | 5 ++++- 7 files changed, 28 insertions(+), 15 deletions(-) diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java index 0b0511478ed9..5d37121e78b8 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java @@ -50,15 +50,27 @@ public class RefCountHolder { private final Map myDclsUsedMap = ContainerUtil.newConcurrentMap(); private final Map myImportStatements = ContainerUtil.newConcurrentMap(); private final AtomicReference myState = new AtomicReference(VIRGIN); - private static final ProgressIndicator VIRGIN = new DaemonProgressIndicator(); // just created or cleared - private static final ProgressIndicator READY = new DaemonProgressIndicator(); + // contains actual info + private static final ProgressIndicator READY = new DaemonProgressIndicator() { + @Override + public String toString() { + return "READY"; + } + }; + // just created or cleared + private static final ProgressIndicator VIRGIN = new DaemonProgressIndicator() { + @Override + public String toString() { + return "VIRGIN"; + } + }; private volatile ProgressIndicator analyzedUnder; private static class HolderReference extends SoftReference { // Map holding hard references to RefCountHolder for each highlighting pass (identified by its progress indicator) // there can be multiple passes running simultaneously (one actual and several passes just canceled and winding down but still alive) // so there is a chance they overlap the usage of RCH - // As soon as everybody finished using RCH, map become empty and the RefCountHolder is eligible for gc + // As soon as everybody finished using RCH, map becomes empty and the RefCountHolder is eligible for gc private final Map map = new ConcurrentHashMap(); public HolderReference(@NotNull RefCountHolder holder) { @@ -69,8 +81,6 @@ public class RefCountHolder { RefCountHolder holder = get(); assert holder != null: "no way"; map.put(indicator, holder); - holder = get(); - assert holder != null: "can't be!"; } private RefCountHolder release(@NotNull ProgressIndicator indicator) { @@ -123,7 +133,7 @@ public class RefCountHolder { private RefCountHolder(@NotNull PsiFile file) { myFile = file; - log("c: created: ", myState.get(), " for ", file); + log("c: created for ", file); } private void clear() { diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPassFactory.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPassFactory.java index e471389866b2..4b31eaf87c01 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPassFactory.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPassFactory.java @@ -83,6 +83,7 @@ public class PostHighlightingPassFactory extends AbstractProjectComponent implem return create(file, document, null, highlightInfoProcessor); } + @NotNull private PostHighlightingPass create(@NotNull final PsiFile file, @NotNull Document document, Editor editor, @NotNull HighlightInfoProcessor highlightInfoProcessor) { diff --git a/java/java-impl/src/com/intellij/psi/refResolve/RefResolveServiceImpl.java b/java/java-impl/src/com/intellij/psi/refResolve/RefResolveServiceImpl.java index d6c1593d61ef..42ff85fc1c21 100644 --- a/java/java-impl/src/com/intellij/psi/refResolve/RefResolveServiceImpl.java +++ b/java/java-impl/src/com/intellij/psi/refResolve/RefResolveServiceImpl.java @@ -152,6 +152,7 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable } } + @NotNull public static List toVf(@NotNull int[] ids) { List res = new ArrayList(); for (int id : ids) { @@ -163,11 +164,13 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable return res; } + @NotNull public static String toVfString(@NotNull int[] backIds) { List list = toVf(backIds); return toVfString(list); } + @NotNull private static String toVfString(@NotNull Collection list) { List sub = new ArrayList(list).subList(0, Math.min(list.size(), 100)); return list.size() + " files: " + StringUtil.join(sub, new Function() { diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/CheckLevelHighlightInfoHolder.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/CheckLevelHighlightInfoHolder.java index 67e54ab812fb..71f1adfb3c17 100644 --- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/CheckLevelHighlightInfoHolder.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/CheckLevelHighlightInfoHolder.java @@ -42,6 +42,7 @@ public class CheckLevelHighlightInfoHolder extends HighlightInfoHolder { return myHolder.getColorsScheme(); } + @NotNull @Override public PsiFile getContextFile() { return myHolder.getContextFile(); diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightInfoHolder.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightInfoHolder.java index 490947a3a696..249725003bc1 100644 --- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightInfoHolder.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightInfoHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -95,11 +95,12 @@ public class HighlightInfoHolder { return myContextFile.getProject(); } + @NotNull public PsiFile getContextFile() { return myContextFile; } - private boolean accepted(HighlightInfo info) { + private boolean accepted(@NotNull HighlightInfo info) { for (HighlightInfoFilter filter : myFilters) { if (!filter.accept(info, getContextFile())) return false; } diff --git a/plugins/ant/src/com/intellij/lang/ant/dom/PropertyProviderFinder.java b/plugins/ant/src/com/intellij/lang/ant/dom/PropertyProviderFinder.java index 7421e57d9fd5..38d5027133e1 100644 --- a/plugins/ant/src/com/intellij/lang/ant/dom/PropertyProviderFinder.java +++ b/plugins/ant/src/com/intellij/lang/ant/dom/PropertyProviderFinder.java @@ -45,12 +45,6 @@ public abstract class PropertyProviderFinder extends AntDomRecursiveVisitor { } } - @Nullable - protected static V getCachedResult(@Nullable final DomElement context, final Key> cacheKind, K key) { - final Map cached = cacheKind.get(context); - return cached != null? cached.get(key) : null; - } - public enum Stage { RESOLVE_MAP_BUILDING_STAGE, TARGETS_WALKUP_STAGE } diff --git a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/DesignerEditorPanel.java b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/DesignerEditorPanel.java index 87f9e2cb3332..d1c7987c5319 100644 --- a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/DesignerEditorPanel.java +++ b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/DesignerEditorPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -94,6 +94,7 @@ public abstract class DesignerEditorPanel extends JPanel private final static String ERROR_STACK_CARD = "stack"; private final static String ERROR_NO_STACK_CARD = "no_stack"; + @NotNull private final DesignerEditor myEditor; private final Project myProject; private Module myModule; @@ -521,6 +522,8 @@ public abstract class DesignerEditorPanel extends JPanel return ModuleUtilCore.findModuleForFile(file, project); } + + @NotNull public final DesignerEditor getEditor() { return myEditor; }