show ProcessHandler.addProcessListener() as sibling-overridden, optimisations

This commit is contained in:
Alexey Kudravtsev
2016-04-15 12:38:23 +03:00
parent d1109c59d8
commit 67e5371da1
3 changed files with 17 additions and 13 deletions
@@ -67,12 +67,16 @@ public class FindSuperElementsHelper {
return Pair.getFirst(getSiblingInfoInheritedViaSubClass(method));
}
// returns super method, sub class
// returns (super method, sub class) or null if can't find any siblings
public static Pair<PsiMethod, PsiClass> getSiblingInfoInheritedViaSubClass(@NotNull final PsiMethod method) {
if (!method.hasModifierProperty(PsiModifier.PUBLIC)) return null;
if (method.hasModifierProperty(PsiModifier.STATIC)) return null;
boolean canHaveSiblingSuper = !method.hasModifierProperty(PsiModifier.ABSTRACT) &&
!method.hasModifierProperty(PsiModifier.STATIC) &&
method.hasModifierProperty(PsiModifier.PUBLIC) &&
!method.hasModifierProperty(PsiModifier.FINAL) &&
!method.hasModifierProperty(PsiModifier.NATIVE);
if (!canHaveSiblingSuper) return null;
final PsiClass containingClass = method.getContainingClass();
if (containingClass == null || containingClass.isInterface()) {
if (containingClass == null || containingClass.isInterface() || containingClass.hasModifierProperty(PsiModifier.FINAL)) {
return null;
}
if (CommonClassNames.JAVA_LANG_OBJECT.equals(containingClass.getQualifiedName())) {
@@ -180,8 +180,8 @@ public class JavaLineMarkerProvider extends LineMarkerProviderDescriptor {
}
}
if (!methods.isEmpty()) {
collectOverridingMethods(methods, result);
collectSiblingInheritedMethods(methods, result);
collectOverridingMethods(methods, result);
}
}
@@ -189,11 +189,6 @@ public class JavaLineMarkerProvider extends LineMarkerProviderDescriptor {
@NotNull Collection<LineMarkerInfo> result) {
for (PsiMethod method : methods) {
ProgressManager.checkCanceled();
PsiClass aClass = method.getContainingClass();
if (aClass == null || aClass.hasModifierProperty(PsiModifier.FINAL) || aClass.isInterface()) continue;
boolean canHaveSiblingSuper = !method.hasModifierProperty(PsiModifier.ABSTRACT) && !method.hasModifierProperty(PsiModifier.STATIC) && method.hasModifierProperty(PsiModifier.PUBLIC)&& !method.hasModifierProperty(PsiModifier.FINAL)&& !method.hasModifierProperty(PsiModifier.NATIVE);
if (!canHaveSiblingSuper) continue;
PsiMethod siblingInheritedViaSubClass = FindSuperElementsHelper.getSiblingInheritedViaSubClass(method);
if (siblingInheritedViaSubClass == null) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -17,10 +17,11 @@ package com.intellij.ide.util;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiJavaFile;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.impl.FindSuperElementsHelper;
import com.intellij.testFramework.IdeaTestUtil;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
@@ -37,9 +38,13 @@ public class JavaSuperMethodTest extends LightDaemonAnalyzerTestCase {
return "/codeInsight/gotosuper/";
}
@Override
protected Sdk getProjectJDK() {
return IdeaTestUtil.getMockJdk18();
}
public void testDoNotGoToSiblingInheritanceIfInLibrary() throws Throwable {
configureByFile(getBasePath() + "OverridingLibrary.java");
PsiJavaFile file = (PsiJavaFile)getFile();
PsiClass aThread = getJavaFacade().findClass("java.lang.Thread");
PsiMethod startMethod = aThread.findMethodsByName("start", false)[0];