This commit is contained in:
Alexey Kudravtsev
2014-11-06 11:22:18 +03:00
parent 7dbf18ea22
commit bbc93e4304
7 changed files with 28 additions and 15 deletions
@@ -50,15 +50,27 @@ public class RefCountHolder {
private final Map<PsiAnchor, Boolean> myDclsUsedMap = ContainerUtil.newConcurrentMap();
private final Map<PsiReference, PsiImportStatementBase> myImportStatements = ContainerUtil.newConcurrentMap();
private final AtomicReference<ProgressIndicator> myState = new AtomicReference<ProgressIndicator>(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<RefCountHolder> {
// 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<ProgressIndicator, RefCountHolder> map = new ConcurrentHashMap<ProgressIndicator, RefCountHolder>();
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() {
@@ -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) {
@@ -152,6 +152,7 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable
}
}
@NotNull
public static List<VirtualFile> toVf(@NotNull int[] ids) {
List<VirtualFile> res = new ArrayList<VirtualFile>();
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<VirtualFile> list = toVf(backIds);
return toVfString(list);
}
@NotNull
private static String toVfString(@NotNull Collection<VirtualFile> list) {
List<VirtualFile> sub = new ArrayList<VirtualFile>(list).subList(0, Math.min(list.size(), 100));
return list.size() + " files: " + StringUtil.join(sub, new Function<VirtualFile, String>() {
@@ -42,6 +42,7 @@ public class CheckLevelHighlightInfoHolder extends HighlightInfoHolder {
return myHolder.getColorsScheme();
}
@NotNull
@Override
public PsiFile getContextFile() {
return myHolder.getContextFile();
@@ -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;
}
@@ -45,12 +45,6 @@ public abstract class PropertyProviderFinder extends AntDomRecursiveVisitor {
}
}
@Nullable
protected static <K, V> V getCachedResult(@Nullable final DomElement context, final Key<Map<K, V>> cacheKind, K key) {
final Map<K, V> cached = cacheKind.get(context);
return cached != null? cached.get(key) : null;
}
public enum Stage {
RESOLVE_MAP_BUILDING_STAGE, TARGETS_WALKUP_STAGE
}
@@ -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;
}