sync inspections tree construction (IDEA-137887)

This commit is contained in:
Anna Kozlova
2015-03-24 21:04:03 +01:00
parent f1963ba59b
commit c3738d4cb7
2 changed files with 21 additions and 10 deletions
@@ -62,7 +62,7 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
@NotNull
private final GlobalInspectionContextImpl myContext;
protected static String ourOutputPath;
protected InspectionNode myToolNode;
private InspectionNode myToolNode;
private static final Object lock = new Object();
private final Map<RefEntity, CommonProblemDescriptor[]> myProblemElements = Collections.synchronizedMap(new THashMap<RefEntity, CommonProblemDescriptor[]>());
@@ -77,6 +77,8 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
protected static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.DescriptorProviderInspection");
private boolean isDisposed;
private final Object myToolLock = new Object();
public DefaultInspectionToolPresentation(@NotNull InspectionToolWrapper toolWrapper, @NotNull GlobalInspectionContextImpl context) {
myToolWrapper = toolWrapper;
myContext = context;
@@ -226,14 +228,16 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
return;
}
final InspectionNode toolNode;
if (myToolNode == null) {
final HighlightSeverity currentSeverity = getSeverity((RefElement)refElement);
toolNode = view.addTool(myToolWrapper, HighlightDisplayLevel.find(currentSeverity), context.getUIOptions().GROUP_BY_SEVERITY);
}
else {
toolNode = myToolNode;
if (toolNode.isTooBigForOnlineRefresh()) {
return;
synchronized (myToolLock) {
if (myToolNode == null) {
final HighlightSeverity currentSeverity = getSeverity((RefElement)refElement);
toolNode = view.addTool(myToolWrapper, HighlightDisplayLevel.find(currentSeverity), context.getUIOptions().GROUP_BY_SEVERITY);
}
else {
toolNode = myToolNode;
if (toolNode.isTooBigForOnlineRefresh()) {
return;
}
}
}
final Map<RefEntity, CommonProblemDescriptor[]> problems = new HashMap<RefEntity, CommonProblemDescriptor[]>();
@@ -262,6 +266,13 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
}
}
public void setToolNode(InspectionNode toolNode) {
synchronized (myToolLock) {
myToolNode = toolNode;
}
}
protected boolean isDisposed() {
return isDisposed;
}
@@ -469,7 +469,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren
myProvider.appendToolNodeContent(myGlobalInspectionContext, toolNode, parentNode, showStructure);
InspectionToolPresentation presentation = myGlobalInspectionContext.getPresentation(toolWrapper);
toolNode = presentation.createToolNode(myGlobalInspectionContext, toolNode, myProvider, parentNode, showStructure);
((DefaultInspectionToolPresentation)presentation).myToolNode = toolNode;
((DefaultInspectionToolPresentation)presentation).setToolNode(toolNode);
registerActionShortcuts(presentation);
return toolNode;