mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
+8
-6
@@ -45,6 +45,7 @@ import com.intellij.util.containers.HashSet;
|
||||
import gnu.trove.Equality;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.IllegalDataException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -65,13 +66,14 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
|
||||
private InspectionNode myToolNode;
|
||||
|
||||
private static final Object lock = new Object();
|
||||
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 final Map<RefEntity, CommonProblemDescriptor[]> myProblemElements = Collections.synchronizedMap(new THashMap<RefEntity, CommonProblemDescriptor[]>(
|
||||
TObjectHashingStrategy.IDENTITY));
|
||||
private final Map<String, Set<RefEntity>> myContents = Collections.synchronizedMap(new THashMap<String, Set<RefEntity>>(1)); // keys can be null
|
||||
private final Set<RefModule> myModulesProblems = Collections.synchronizedSet(new THashSet<RefModule>(TObjectHashingStrategy.IDENTITY));
|
||||
private final Map<CommonProblemDescriptor, RefEntity> myProblemToElements = Collections.synchronizedMap(new THashMap<CommonProblemDescriptor, RefEntity>(TObjectHashingStrategy.IDENTITY));
|
||||
private DescriptorComposer myComposer;
|
||||
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 final Map<RefEntity, Set<QuickFix>> myQuickFixActions = Collections.synchronizedMap(new THashMap<RefEntity, Set<QuickFix>>(TObjectHashingStrategy.IDENTITY));
|
||||
private final Map<RefEntity, CommonProblemDescriptor[]> myIgnoredElements = Collections.synchronizedMap(new THashMap<RefEntity, CommonProblemDescriptor[]>(TObjectHashingStrategy.IDENTITY));
|
||||
|
||||
private Map<RefEntity, CommonProblemDescriptor[]> myOldProblemElements = null;
|
||||
protected static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.DescriptorProviderInspection");
|
||||
|
||||
+2
-2
@@ -17,9 +17,9 @@ package com.intellij.codeInspection.ui;
|
||||
|
||||
|
||||
import com.intellij.util.containers.FactoryMap;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ExcludedInspectionTreeNodesManager {
|
||||
@Nullable
|
||||
@Override
|
||||
protected Set<Object> create(Class key) {
|
||||
return new HashSet<>();
|
||||
return new THashSet<>();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+1
-16
@@ -45,7 +45,7 @@ import com.intellij.psi.util.PsiUtilCore;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class InspectionResultsViewComparator implements Comparator {
|
||||
private static final Logger LOG = Logger.getInstance("#" + InspectionResultsViewComparator.class.getName());
|
||||
private static final Logger LOG = Logger.getInstance(InspectionResultsViewComparator.class);
|
||||
|
||||
public boolean areEqual(Object o1, Object o2) {
|
||||
return o1.getClass().equals(o2.getClass()) && compare(o1, o2) == 0;
|
||||
@@ -173,26 +173,11 @@ public class InspectionResultsViewComparator implements Comparator {
|
||||
return entity2 != null ? 1 : 0;
|
||||
}
|
||||
|
||||
private static int compareLineNumbers(final Object userObject, final OfflineProblemDescriptor descriptor) {
|
||||
if (userObject instanceof RefElement) {
|
||||
final RefElement refElement = (RefElement)userObject;
|
||||
final PsiElement psiElement = refElement.getElement();
|
||||
if (psiElement != null) {
|
||||
Document document = PsiDocumentManager.getInstance(psiElement.getProject()).getDocument(psiElement.getContainingFile());
|
||||
if (document != null) {
|
||||
return descriptor.getLine() - document.getLineNumber(psiElement.getTextOffset()) -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static class InspectionResultsViewComparatorHolder {
|
||||
private static final InspectionResultsViewComparator ourInstance = new InspectionResultsViewComparator();
|
||||
}
|
||||
|
||||
public static InspectionResultsViewComparator getInstance() {
|
||||
|
||||
return InspectionResultsViewComparatorHolder.ourInstance;
|
||||
}
|
||||
}
|
||||
|
||||
+50
-37
@@ -20,6 +20,7 @@ import com.intellij.codeInspection.reference.RefEntity;
|
||||
import com.intellij.concurrency.JobSchedulerImpl;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.util.ProgressIndicatorUtils;
|
||||
import com.intellij.openapi.progress.util.ReadTask;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -44,6 +45,8 @@ import java.util.Set;
|
||||
* @author Dmitry Batkovich
|
||||
*/
|
||||
class InspectionViewPsiTreeChangeAdapter extends PsiTreeChangeAdapter {
|
||||
private final static int MAX_UPDATES_FOR_CANCELLABLE_ACTION = 100;
|
||||
|
||||
private final InspectionResultsView myView;
|
||||
private final MergingUpdateQueue myUpdater;
|
||||
private final BoundedTaskExecutor myExecutor;
|
||||
@@ -74,60 +77,70 @@ class InspectionViewPsiTreeChangeAdapter extends PsiTreeChangeAdapter {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
final Project project = view.getProject();
|
||||
synchronized (myView.getTreeStructureUpdateLock()) {
|
||||
InspectionTreeNode root = myView.getTree().getRoot();
|
||||
boolean[] needUpdateUI = {false};
|
||||
processNodesIfNeed(root, (node) -> {
|
||||
if (node instanceof CachedInspectionTreeNode) {
|
||||
//indicator.checkCanceled();
|
||||
RefEntity element = ((CachedInspectionTreeNode)node).getElement();
|
||||
if (element instanceof RefElement) {
|
||||
final SmartPsiElementPointer pointer = ((RefElement)element).getPointer();
|
||||
VirtualFile strictVirtualFile = pointer.getVirtualFile();
|
||||
if (strictVirtualFile == null || !strictVirtualFile.isValid()) {
|
||||
final PsiFile file = pointer.getContainingFile();
|
||||
if (file != null && file.isValid()) {
|
||||
strictVirtualFile = file.getVirtualFile();
|
||||
|
||||
final Runnable runnable = () -> {
|
||||
synchronized (myView.getTreeStructureUpdateLock()) {
|
||||
InspectionTreeNode root = myView.getTree().getRoot();
|
||||
boolean[] needUpdateUI = {false};
|
||||
processNodesIfNeed(root, (node) -> {
|
||||
if (node instanceof CachedInspectionTreeNode) {
|
||||
RefEntity element = ((CachedInspectionTreeNode)node).getElement();
|
||||
if (element instanceof RefElement) {
|
||||
final SmartPsiElementPointer pointer = ((RefElement)element).getPointer();
|
||||
VirtualFile strictVirtualFile = pointer.getVirtualFile();
|
||||
if (strictVirtualFile == null || !strictVirtualFile.isValid()) {
|
||||
final PsiFile file = pointer.getContainingFile();
|
||||
if (file != null && file.isValid()) {
|
||||
strictVirtualFile = file.getVirtualFile();
|
||||
}
|
||||
}
|
||||
if (strictVirtualFile == null || files.contains(strictVirtualFile)) {
|
||||
((CachedInspectionTreeNode)node).dropCache(project);
|
||||
if (!needUpdateUI[0]) {
|
||||
needUpdateUI[0] = true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (strictVirtualFile == null || files.contains(strictVirtualFile)) {
|
||||
else {
|
||||
((CachedInspectionTreeNode)node).dropCache(project);
|
||||
if (!needUpdateUI[0]) {
|
||||
needUpdateUI[0] = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
((CachedInspectionTreeNode)node).dropCache(project);
|
||||
if (!needUpdateUI[0]) {
|
||||
needUpdateUI[0] = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (needUpdateUI[0]) {
|
||||
UIUtil.invokeLaterIfNeeded(() -> {
|
||||
myView.invalidate();
|
||||
myView.repaint();
|
||||
if (myView.isUpdating()) {
|
||||
myView.updateRightPanelLoading();
|
||||
} else {
|
||||
myView.syncRightPanel();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (needUpdateUI[0]) {
|
||||
UIUtil.invokeLaterIfNeeded(() -> {
|
||||
myView.invalidate();
|
||||
myView.repaint();
|
||||
if (myView.isUpdating()) {
|
||||
myView.updateRightPanelLoading();
|
||||
}
|
||||
else {
|
||||
myView.syncRightPanel();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (updates.length > MAX_UPDATES_FOR_CANCELLABLE_ACTION) {
|
||||
ProgressManager.getInstance().executeNonCancelableSection(runnable);
|
||||
} else {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCanceled(@NotNull ProgressIndicator indicator) {
|
||||
if (!myView.isDisposed()) {
|
||||
ProgressIndicatorUtils.scheduleWithWriteActionPriority(myExecutor, this);
|
||||
for (Update update : updates) {
|
||||
myUpdater.queue(update);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user