mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
BackgroundUpdaterTask speedup, part two
don't call ArrayList#contains and sort it every single time, use tree set instead of
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -373,12 +373,10 @@ public class MarkerType {
|
||||
|
||||
private static class SubclassUpdater extends ListBackgroundUpdaterTask {
|
||||
private final PsiClass myClass;
|
||||
private final PsiElementListCellRenderer<NavigatablePsiElement> myRenderer;
|
||||
|
||||
private SubclassUpdater(@NotNull PsiClass aClass, @NotNull PsiElementListCellRenderer<NavigatablePsiElement> renderer) {
|
||||
super(aClass.getProject(), SEARCHING_FOR_OVERRIDDEN_METHODS);
|
||||
super(aClass.getProject(), SEARCHING_FOR_OVERRIDDEN_METHODS, ((Comparator)renderer.getComparator()));
|
||||
myClass = aClass;
|
||||
myRenderer = renderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -410,7 +408,7 @@ public class MarkerType {
|
||||
}), true).forEach(new CommonProcessors.CollectProcessor<PsiClass>() {
|
||||
@Override
|
||||
public boolean process(final PsiClass o) {
|
||||
if (!updateComponent(o, myRenderer.getComparator())) {
|
||||
if (!updateComponent(o)) {
|
||||
indicator.cancel();
|
||||
}
|
||||
ProgressManager.checkCanceled();
|
||||
@@ -421,7 +419,7 @@ public class MarkerType {
|
||||
FunctionalExpressionSearch.search(myClass).forEach(new CommonProcessors.CollectProcessor<PsiFunctionalExpression>() {
|
||||
@Override
|
||||
public boolean process(final PsiFunctionalExpression expr) {
|
||||
if (!updateComponent(expr, myRenderer.getComparator())) {
|
||||
if (!updateComponent(expr)) {
|
||||
indicator.cancel();
|
||||
}
|
||||
ProgressManager.checkCanceled();
|
||||
@@ -433,12 +431,10 @@ public class MarkerType {
|
||||
|
||||
private static class OverridingMethodsUpdater extends ListBackgroundUpdaterTask {
|
||||
private final PsiMethod myMethod;
|
||||
private final PsiElementListCellRenderer myRenderer;
|
||||
|
||||
private OverridingMethodsUpdater(@NotNull PsiMethod method, @NotNull PsiElementListCellRenderer renderer) {
|
||||
super(method.getProject(), SEARCHING_FOR_OVERRIDING_METHODS);
|
||||
super(method.getProject(), SEARCHING_FOR_OVERRIDING_METHODS, renderer.getComparator());
|
||||
myMethod = method;
|
||||
myRenderer = renderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -466,7 +462,7 @@ public class MarkerType {
|
||||
new CommonProcessors.CollectProcessor<PsiMethod>() {
|
||||
@Override
|
||||
public boolean process(PsiMethod psiMethod) {
|
||||
if (!updateComponent(psiMethod, myRenderer.getComparator())) {
|
||||
if (!updateComponent(psiMethod)) {
|
||||
indicator.cancel();
|
||||
}
|
||||
ProgressManager.checkCanceled();
|
||||
@@ -478,7 +474,7 @@ public class MarkerType {
|
||||
FunctionalExpressionSearch.search(psiClass).forEach(new CommonProcessors.CollectProcessor<PsiFunctionalExpression>() {
|
||||
@Override
|
||||
public boolean process(final PsiFunctionalExpression expr) {
|
||||
if (!updateComponent(expr, myRenderer.getComparator())) {
|
||||
if (!updateComponent(expr)) {
|
||||
indicator.cancel();
|
||||
}
|
||||
ProgressManager.checkCanceled();
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -422,7 +422,7 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
|
||||
private PsiElement[] myElements;
|
||||
|
||||
private ImplementationsUpdaterTask(@NotNull PsiElement element, final Editor editor, final String caption, boolean includeSelf) {
|
||||
super(element.getProject(), ImplementationSearcher.SEARCHING_FOR_IMPLEMENTATIONS);
|
||||
super(element.getProject(), ImplementationSearcher.SEARCHING_FOR_IMPLEMENTATIONS, null);
|
||||
myCaption = caption;
|
||||
myEditor = editor;
|
||||
myElement = element;
|
||||
@@ -462,7 +462,7 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
|
||||
|
||||
@Override
|
||||
protected void processElement(PsiElement element) {
|
||||
if (!updateComponent(element, null)) {
|
||||
if (!updateComponent(element)) {
|
||||
indicator.cancel();
|
||||
}
|
||||
indicator.checkCanceled();
|
||||
|
||||
+4
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -20,7 +20,6 @@ import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.ContainerProvider;
|
||||
import com.intellij.codeInsight.TargetElementUtil;
|
||||
import com.intellij.codeInsight.navigation.actions.GotoDeclarationAction;
|
||||
import com.intellij.ide.util.PsiElementListCellRenderer;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.navigation.NavigationItem;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
@@ -37,7 +36,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
public class GotoImplementationHandler extends GotoTargetHandler {
|
||||
@Override
|
||||
@@ -138,11 +136,10 @@ public class GotoImplementationHandler extends GotoTargetHandler {
|
||||
private final Editor myEditor;
|
||||
private final int myOffset;
|
||||
private final GotoData myGotoData;
|
||||
private final Map<Object, PsiElementListCellRenderer> renderers = new HashMap<>();
|
||||
private final PsiReference myReference;
|
||||
|
||||
ImplementationsUpdaterTask(@NotNull GotoData gotoData, @NotNull Editor editor, int offset, final PsiReference reference) {
|
||||
super(gotoData.source.getProject(), ImplementationSearcher.SEARCHING_FOR_IMPLEMENTATIONS);
|
||||
super(gotoData.source.getProject(), ImplementationSearcher.SEARCHING_FOR_IMPLEMENTATIONS, createComparator(new HashMap<>(), gotoData));
|
||||
myEditor = editor;
|
||||
myOffset = offset;
|
||||
myGotoData = gotoData;
|
||||
@@ -153,7 +150,7 @@ public class GotoImplementationHandler extends GotoTargetHandler {
|
||||
public void run(@NotNull final ProgressIndicator indicator) {
|
||||
super.run(indicator);
|
||||
for (PsiElement element : myGotoData.targets) {
|
||||
if (!updateComponent(element, createComparator(renderers, myGotoData))) {
|
||||
if (!updateComponent(element)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -163,7 +160,7 @@ public class GotoImplementationHandler extends GotoTargetHandler {
|
||||
indicator.checkCanceled();
|
||||
if (!TargetElementUtil.getInstance().acceptImplementationForReference(myReference, element)) return;
|
||||
if (myGotoData.addTarget(element)) {
|
||||
if (!updateComponent(element, createComparator(renderers, myGotoData))) {
|
||||
if (!updateComponent(element)) {
|
||||
indicator.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -34,13 +34,15 @@ import com.intellij.psi.search.PsiElementProcessor;
|
||||
import com.intellij.psi.search.PsiElementProcessorAdapter;
|
||||
import com.intellij.psi.search.searches.OverridingMethodsSearch;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.CommonProcessors;
|
||||
import com.intellij.util.NullableFunction;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.Processors;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
|
||||
@@ -321,12 +323,10 @@ public class GroovyMarkerTypes {
|
||||
|
||||
private static class OverridingMethodsUpdater extends ListBackgroundUpdaterTask {
|
||||
private final GrMethod myMethod;
|
||||
private final PsiElementListCellRenderer myRenderer;
|
||||
|
||||
public OverridingMethodsUpdater(GrMethod method, PsiElementListCellRenderer renderer) {
|
||||
super(method.getProject(), MarkerType.SEARCHING_FOR_OVERRIDING_METHODS);
|
||||
super(method.getProject(), MarkerType.SEARCHING_FOR_OVERRIDING_METHODS, renderer.getComparator());
|
||||
myMethod = method;
|
||||
myRenderer = renderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -344,7 +344,7 @@ public class GroovyMarkerTypes {
|
||||
new CommonProcessors.CollectProcessor<PsiMethod>() {
|
||||
@Override
|
||||
public boolean process(PsiMethod psiMethod) {
|
||||
if (!updateComponent(com.intellij.psi.impl.PsiImplUtil.handleMirror(psiMethod), myRenderer.getComparator())) {
|
||||
if (!updateComponent(com.intellij.psi.impl.PsiImplUtil.handleMirror(psiMethod))) {
|
||||
indicator.cancel();
|
||||
}
|
||||
indicator.checkCanceled();
|
||||
|
||||
Reference in New Issue
Block a user