mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
data races
This commit is contained in:
+4
-3
@@ -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.
|
||||
@@ -54,7 +54,7 @@ import java.awt.event.KeyEvent;
|
||||
import java.util.*;
|
||||
|
||||
public class UnusedDeclarationPresentation extends DefaultInspectionToolPresentation {
|
||||
private Map<String, Set<RefEntity>> myPackageContents = new HashMap<String, Set<RefEntity>>();
|
||||
private final Map<String, Set<RefEntity>> myPackageContents = Collections.synchronizedMap(new HashMap<String, Set<RefEntity>>());
|
||||
|
||||
private Map<String, Set<RefEntity>> myOldPackageContents = null;
|
||||
|
||||
@@ -335,7 +335,7 @@ public class UnusedDeclarationPresentation extends DefaultInspectionToolPresenta
|
||||
@Override
|
||||
public void updateContent() {
|
||||
getTool().checkForReachables(getContext());
|
||||
myPackageContents = new HashMap<String, Set<RefEntity>>();
|
||||
myPackageContents.clear();
|
||||
getContext().getRefManager().iterate(new RefJavaVisitor() {
|
||||
@Override public void visitElement(@NotNull RefEntity refEntity) {
|
||||
if (!(refEntity instanceof RefJavaElement)) return;//dead code doesn't work with refModule | refPackage
|
||||
@@ -378,6 +378,7 @@ public class UnusedDeclarationPresentation extends DefaultInspectionToolPresenta
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<String, Set<RefEntity>> getContent() {
|
||||
return myPackageContents;
|
||||
|
||||
+2
-3
@@ -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.
|
||||
@@ -79,8 +79,7 @@ public abstract class InspectionRVContentProvider {
|
||||
InspectionToolPresentation presentation = context.getPresentation(wrapper);
|
||||
Map<String, Set<RefEntity>> content = presentation.getContent();
|
||||
Map<RefEntity, CommonProblemDescriptor[]> problems = presentation.getProblemElements();
|
||||
Map<String, Set<RefEntity>> contents = content == null ? new HashMap<String, Set<RefEntity>>() : content;
|
||||
appendToolNodeContent(context, toolNode, parentNode, showStructure, contents, problems, null);
|
||||
appendToolNodeContent(context, toolNode, parentNode, showStructure, content, problems, null);
|
||||
}
|
||||
|
||||
public abstract void appendToolNodeContent(@NotNull GlobalInspectionContextImpl context,
|
||||
|
||||
+14
-16
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -55,23 +55,21 @@ public class InspectionRVContentProviderImpl extends InspectionRVContentProvider
|
||||
final SearchScope searchScope = context.getCurrentScope().toSearchScope();
|
||||
if (searchScope instanceof LocalSearchScope) {
|
||||
final Map<String, Set<RefEntity>> contents = presentation.getContent();
|
||||
if (contents != null) {
|
||||
final Map<RefEntity, CommonProblemDescriptor[]> problemElements = presentation.getProblemElements();
|
||||
for (Set<RefEntity> entities : contents.values()) {
|
||||
for (Iterator<RefEntity> iterator = entities.iterator(); iterator.hasNext(); ) {
|
||||
RefEntity entity = iterator.next();
|
||||
if (entity instanceof RefElement) {
|
||||
final PsiElement element = ((RefElement)entity).getElement();
|
||||
if (element != null) {
|
||||
final TextRange range = element.getTextRange();
|
||||
if (range != null && ((LocalSearchScope)searchScope).containsRange(element.getContainingFile(), range)) {
|
||||
continue;
|
||||
}
|
||||
final Map<RefEntity, CommonProblemDescriptor[]> problemElements = presentation.getProblemElements();
|
||||
for (Set<RefEntity> entities : contents.values()) {
|
||||
for (Iterator<RefEntity> iterator = entities.iterator(); iterator.hasNext(); ) {
|
||||
RefEntity entity = iterator.next();
|
||||
if (entity instanceof RefElement) {
|
||||
final PsiElement element = ((RefElement)entity).getElement();
|
||||
if (element != null) {
|
||||
final TextRange range = element.getTextRange();
|
||||
if (range != null && ((LocalSearchScope)searchScope).containsRange(element.getContainingFile(), range)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
problemElements.remove(entity);
|
||||
iterator.remove();
|
||||
}
|
||||
problemElements.remove(entity);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,7 +104,7 @@ public class InspectionRVContentProviderImpl extends InspectionRVContentProvider
|
||||
};
|
||||
InspectionToolPresentation presentation = context.getPresentation(toolWrapper);
|
||||
final Set<RefModule> moduleProblems = presentation.getModuleProblems();
|
||||
if (moduleProblems != null && !moduleProblems.isEmpty()) {
|
||||
if (!moduleProblems.isEmpty()) {
|
||||
Set<RefEntity> entities = contents.get("");
|
||||
if (entities == null) {
|
||||
entities = new HashSet<RefEntity>();
|
||||
|
||||
+34
-49
@@ -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.
|
||||
@@ -42,6 +42,7 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.IllegalDataException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -63,13 +64,13 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
|
||||
protected InspectionNode myToolNode;
|
||||
|
||||
private static final Object lock = new Object();
|
||||
private Map<RefEntity, CommonProblemDescriptor[]> myProblemElements;
|
||||
private Map<String, Set<RefEntity>> myContents = null;
|
||||
private Set<RefModule> myModulesProblems = null;
|
||||
private Map<CommonProblemDescriptor, RefEntity> myProblemToElements;
|
||||
private final Map<RefEntity, CommonProblemDescriptor[]> myProblemElements = Collections.synchronizedMap(new THashMap<RefEntity, CommonProblemDescriptor[]>());
|
||||
private final Map<String, Set<RefEntity>> myContents = Collections.synchronizedMap(new com.intellij.util.containers.HashMap<String, Set<RefEntity>>()); // keys can be null
|
||||
private final Set<RefModule> myModulesProblems = Collections.synchronizedSet(new THashSet<RefModule>());
|
||||
private final Map<CommonProblemDescriptor, RefEntity> myProblemToElements = Collections.synchronizedMap(new THashMap<CommonProblemDescriptor, RefEntity>());
|
||||
private DescriptorComposer myComposer;
|
||||
private Map<RefEntity, Set<QuickFix>> myQuickFixActions;
|
||||
private Map<RefEntity, CommonProblemDescriptor[]> myIgnoredElements;
|
||||
private final Map<RefEntity, Set<QuickFix>> myQuickFixActions = Collections.synchronizedMap(new com.intellij.util.containers.HashMap<RefEntity, Set<QuickFix>>());
|
||||
private final Map<RefEntity, CommonProblemDescriptor[]> myIgnoredElements = Collections.synchronizedMap(new com.intellij.util.containers.HashMap<RefEntity, CommonProblemDescriptor[]>());
|
||||
|
||||
private Map<RefEntity, CommonProblemDescriptor[]> myOldProblemElements = null;
|
||||
protected static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.DescriptorProviderInspection");
|
||||
@@ -223,13 +224,16 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
|
||||
if (view == null || !(refElement instanceof RefElement)) {
|
||||
return;
|
||||
}
|
||||
InspectionNode toolNode = myToolNode;
|
||||
if (toolNode == null) {
|
||||
final InspectionNode toolNode;
|
||||
if (myToolNode == null) {
|
||||
final HighlightSeverity currentSeverity = getSeverity((RefElement)refElement);
|
||||
view.addTool(myToolWrapper, HighlightDisplayLevel.find(currentSeverity), context.getUIOptions().GROUP_BY_SEVERITY);
|
||||
toolNode = view.addTool(myToolWrapper, HighlightDisplayLevel.find(currentSeverity), context.getUIOptions().GROUP_BY_SEVERITY);
|
||||
}
|
||||
else if (toolNode.isTooBigForOnlineRefresh()) {
|
||||
return;
|
||||
else {
|
||||
toolNode = myToolNode;
|
||||
if (toolNode.isTooBigForOnlineRefresh()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
final Map<RefEntity, CommonProblemDescriptor[]> problems = new HashMap<RefEntity, CommonProblemDescriptor[]>();
|
||||
problems.put(refElement, descriptors);
|
||||
@@ -246,8 +250,8 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
|
||||
@Override
|
||||
public void run() {
|
||||
if (!isDisposed()) {
|
||||
view.getProvider().appendToolNodeContent(context, myToolNode,
|
||||
(InspectionTreeNode)myToolNode.getParent(), context.getUIOptions().SHOW_STRUCTURE,
|
||||
view.getProvider().appendToolNodeContent(context, toolNode,
|
||||
(InspectionTreeNode)toolNode.getParent(), context.getUIOptions().SHOW_STRUCTURE,
|
||||
contents, problems, (DefaultTreeModel)view.getTree().getModel());
|
||||
context.addView(view);
|
||||
}
|
||||
@@ -275,7 +279,7 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
|
||||
final File file = new File(fileName);
|
||||
final CharArrayWriter writer = new CharArrayWriter();
|
||||
if (!file.exists()) {
|
||||
writer.append("<").append(InspectionsBundle.message("inspection.problems")).append(" " + GlobalInspectionContextImpl.LOCAL_TOOL_ATTRIBUTE + "=\"")
|
||||
writer.append("<").append(InspectionsBundle.message("inspection.problems")).append(" " + GlobalInspectionContextBase.LOCAL_TOOL_ATTRIBUTE + "=\"")
|
||||
.append(Boolean.toString(myToolWrapper instanceof LocalInspectionToolWrapper)).append("\">\n");
|
||||
}
|
||||
for (Object o : list) {
|
||||
@@ -393,14 +397,14 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
|
||||
myOldProblemElements = null;
|
||||
|
||||
synchronized (lock) {
|
||||
myProblemElements = null;
|
||||
myProblemToElements = null;
|
||||
myQuickFixActions = null;
|
||||
myIgnoredElements = null;
|
||||
myProblemElements.clear();
|
||||
myProblemToElements.clear();
|
||||
myQuickFixActions.clear();
|
||||
myIgnoredElements.clear();
|
||||
myContents.clear();
|
||||
myModulesProblems.clear();
|
||||
}
|
||||
|
||||
myContents = null;
|
||||
myModulesProblems = null;
|
||||
isDisposed = true;
|
||||
}
|
||||
|
||||
@@ -525,8 +529,8 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
|
||||
|
||||
@Override
|
||||
public void updateContent() {
|
||||
myContents = new com.intellij.util.containers.HashMap<String, Set<RefEntity>>();
|
||||
myModulesProblems = new HashSet<RefModule>();
|
||||
myContents.clear();
|
||||
myModulesProblems.clear();
|
||||
final Set<RefEntity> elements = getProblemElements().keySet();
|
||||
for (RefEntity element : elements) {
|
||||
if (getContext().getUIOptions().FILTER_RESOLVED_ITEMS && getIgnoredElements().containsKey(element)) continue;
|
||||
@@ -545,6 +549,7 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<String, Set<RefEntity>> getContent() {
|
||||
return myContents;
|
||||
@@ -553,8 +558,7 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
|
||||
@Override
|
||||
public Map<String, Set<RefEntity>> getOldContent() {
|
||||
if (myOldProblemElements == null) return null;
|
||||
final com.intellij.util.containers.HashMap<String, Set<RefEntity>>
|
||||
oldContents = new com.intellij.util.containers.HashMap<String, Set<RefEntity>>();
|
||||
final Map<String, Set<RefEntity>> oldContents = new com.intellij.util.containers.HashMap<String, Set<RefEntity>>();
|
||||
final Set<RefEntity> elements = myOldProblemElements.keySet();
|
||||
for (RefEntity element : elements) {
|
||||
String groupName = element instanceof RefElement ? element.getRefManager().getGroupName((RefElement)element) : element.getName();
|
||||
@@ -573,6 +577,7 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
|
||||
return oldContents;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<RefModule> getModuleProblems() {
|
||||
return myModulesProblems;
|
||||
@@ -719,12 +724,7 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
|
||||
@Override
|
||||
@NotNull
|
||||
public Map<RefEntity, CommonProblemDescriptor[]> getProblemElements() {
|
||||
synchronized (lock) {
|
||||
if (myProblemElements == null) {
|
||||
myProblemElements = Collections.synchronizedMap(new THashMap<RefEntity, CommonProblemDescriptor[]>());
|
||||
}
|
||||
return myProblemElements;
|
||||
}
|
||||
return myProblemElements;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -735,32 +735,17 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
|
||||
|
||||
@NotNull
|
||||
private Map<CommonProblemDescriptor, RefEntity> getProblemToElements() {
|
||||
synchronized (lock) {
|
||||
if (myProblemToElements == null) {
|
||||
myProblemToElements = Collections.synchronizedMap(new THashMap<CommonProblemDescriptor, RefEntity>());
|
||||
}
|
||||
return myProblemToElements;
|
||||
}
|
||||
return myProblemToElements;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Map<RefEntity, Set<QuickFix>> getQuickFixActions() {
|
||||
synchronized (lock) {
|
||||
if (myQuickFixActions == null) {
|
||||
myQuickFixActions = Collections.synchronizedMap(new com.intellij.util.containers.HashMap<RefEntity, Set<QuickFix>>());
|
||||
}
|
||||
return myQuickFixActions;
|
||||
}
|
||||
return myQuickFixActions;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Map<RefEntity, CommonProblemDescriptor[]> getIgnoredElements() {
|
||||
synchronized (lock) {
|
||||
if (myIgnoredElements == null) {
|
||||
myIgnoredElements = Collections.synchronizedMap(new com.intellij.util.containers.HashMap<RefEntity, CommonProblemDescriptor[]>());
|
||||
}
|
||||
return myIgnoredElements;
|
||||
}
|
||||
return myIgnoredElements;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+3
-1
@@ -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.
|
||||
@@ -45,6 +45,7 @@ public interface InspectionToolPresentation extends ProblemDescriptionsProcessor
|
||||
|
||||
boolean hasReportedProblems();
|
||||
|
||||
@NotNull
|
||||
Map<String, Set<RefEntity>> getContent();
|
||||
|
||||
Map<String, Set<RefEntity>> getOldContent();
|
||||
@@ -63,6 +64,7 @@ public interface InspectionToolPresentation extends ProblemDescriptionsProcessor
|
||||
@NotNull
|
||||
HTMLComposerImpl getComposer();
|
||||
void exportResults(@NotNull final Element parentNode, @NotNull RefEntity refEntity);
|
||||
@NotNull
|
||||
Set<RefModule> getModuleProblems();
|
||||
@Nullable
|
||||
QuickFixAction[] getQuickFixes(@NotNull final RefEntity[] refElements);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -19,7 +19,10 @@ package com.intellij.codeInspection.ui.actions;
|
||||
import com.intellij.codeEditor.printing.ExportToHTMLSettings;
|
||||
import com.intellij.codeInspection.InspectionApplication;
|
||||
import com.intellij.codeInspection.InspectionsBundle;
|
||||
import com.intellij.codeInspection.ex.*;
|
||||
import com.intellij.codeInspection.ex.GlobalInspectionContextImpl;
|
||||
import com.intellij.codeInspection.ex.InspectionToolWrapper;
|
||||
import com.intellij.codeInspection.ex.ScopeToolState;
|
||||
import com.intellij.codeInspection.ex.Tools;
|
||||
import com.intellij.codeInspection.export.ExportToHTMLDialog;
|
||||
import com.intellij.codeInspection.export.HTMLExportFrameMaker;
|
||||
import com.intellij.codeInspection.export.HTMLExportUtil;
|
||||
@@ -247,9 +250,7 @@ public class ExportHTMLAction extends AnAction implements DumbAware {
|
||||
for (InspectionToolWrapper toolWrapper : toolWrappers) {
|
||||
InspectionToolPresentation presentation = myView.getGlobalInspectionContext().getPresentation(toolWrapper);
|
||||
final Map<String, Set<RefEntity>> toolContent = presentation.getContent();
|
||||
if (toolContent != null) {
|
||||
content.putAll(toolContent);
|
||||
}
|
||||
content.putAll(toolContent);
|
||||
}
|
||||
|
||||
final Set<RefEntity> defaultPackageEntities = content.remove(null);
|
||||
@@ -285,9 +286,7 @@ public class ExportHTMLAction extends AnAction implements DumbAware {
|
||||
for (InspectionToolWrapper toolWrapper : toolWrappers) {
|
||||
InspectionToolPresentation presentation = myView.getGlobalInspectionContext().getPresentation(toolWrapper);
|
||||
final Set<RefModule> problems = presentation.getModuleProblems();
|
||||
if (problems != null) {
|
||||
modules.addAll(problems);
|
||||
}
|
||||
modules.addAll(problems);
|
||||
}
|
||||
|
||||
final List<RefModule> sortedModules = new ArrayList<RefModule>(modules);
|
||||
|
||||
Reference in New Issue
Block a user