mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
faster ClsParameter.getName
This commit is contained in:
@@ -88,7 +88,7 @@ public class JavaEditorFileSwapper extends EditorFileSwapper {
|
||||
if (!(clsClass instanceof ClsClassImpl)) return null;
|
||||
|
||||
PsiClass sourceClass = ((ClsClassImpl)clsClass).getSourceMirrorClass();
|
||||
if (sourceClass == null || sourceClass == clsClass) return null;
|
||||
if (sourceClass == null) return null;
|
||||
|
||||
VirtualFile result = sourceClass.getContainingFile().getVirtualFile();
|
||||
assert result != null;
|
||||
|
||||
@@ -271,6 +271,7 @@ public class MethodSignatureUtil {
|
||||
}
|
||||
|
||||
public static boolean areParametersErasureEqual(PsiMethod method1, PsiMethod method2) {
|
||||
if (method1.getParameterList().getParametersCount() != method2.getParameterList().getParametersCount()) return false;
|
||||
return areSignaturesErasureEqual(method1.getSignature(PsiSubstitutor.EMPTY), method2.getSignature(PsiSubstitutor.EMPTY));
|
||||
}
|
||||
|
||||
|
||||
@@ -571,6 +571,8 @@ public class ClsClassImpl extends ClsRepositoryPsiElement<PsiClassStub<?>> imple
|
||||
if (!(parent instanceof PsiClassOwner)) return null;
|
||||
|
||||
PsiClassOwner fileNavigationElement = (PsiClassOwner)parent.getNavigationElement();
|
||||
if (fileNavigationElement == parent) return null;
|
||||
|
||||
for (PsiClass aClass : fileNavigationElement.getClasses()) {
|
||||
if (name.equals(aClass.getName())) return aClass;
|
||||
}
|
||||
@@ -602,19 +604,19 @@ public class ClsClassImpl extends ClsRepositoryPsiElement<PsiClassStub<?>> imple
|
||||
}
|
||||
|
||||
PsiClass aClass = getSourceMirrorClass();
|
||||
return aClass != null && aClass != this ? aClass.getNavigationElement() : this;
|
||||
return aClass != null ? aClass.getNavigationElement() : this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemPresentation getPresentation() {
|
||||
PsiClass aClass = getSourceMirrorClass();
|
||||
return aClass != null && aClass != this ? aClass.getPresentation() : ItemPresentationProviders.getItemPresentation(this);
|
||||
return aClass != null ? aClass.getPresentation() : ItemPresentationProviders.getItemPresentation(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getElementIcon(final int flags) {
|
||||
PsiClass aClass = getSourceMirrorClass();
|
||||
return aClass != null && aClass != this ? aClass.getIcon(flags) : PsiClassImplUtil.getClassIcon(flags, this);
|
||||
return aClass != null ? aClass.getIcon(flags) : PsiClassImplUtil.getClassIcon(flags, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -257,7 +257,7 @@ public class ClsFieldImpl extends ClsRepositoryPsiElement<PsiFieldStub> implemen
|
||||
|
||||
PsiClass sourceClassMirror = ((ClsClassImpl)getParent()).getSourceMirrorClass();
|
||||
PsiElement sourceFieldMirror = sourceClassMirror != null ? sourceClassMirror.findFieldByName(getName(), false) : null;
|
||||
return sourceFieldMirror != null && sourceFieldMirror != this ? sourceFieldMirror.getNavigationElement() : this;
|
||||
return sourceFieldMirror != null ? sourceFieldMirror.getNavigationElement() : this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,6 +42,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
@@ -363,16 +364,16 @@ public class ClsMethodImpl extends ClsRepositoryPsiElement<PsiMethodStub> implem
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
public PsiMethod getSourceMirrorMethod() {
|
||||
PsiClass sourceClassMirror = ((ClsClassImpl)getParent()).getSourceMirrorClass();
|
||||
if (sourceClassMirror == null) return this;
|
||||
if (sourceClassMirror == null) return null;
|
||||
for (PsiMethod sourceMethod : sourceClassMirror.findMethodsByName(getName(), false)) {
|
||||
if (MethodSignatureUtil.areParametersErasureEqual(this, sourceMethod)) {
|
||||
return sourceMethod;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -386,7 +387,7 @@ public class ClsMethodImpl extends ClsRepositoryPsiElement<PsiMethodStub> implem
|
||||
}
|
||||
|
||||
final PsiMethod method = getSourceMirrorMethod();
|
||||
return method != this ? method.getNavigationElement() : this;
|
||||
return method != null ? method.getNavigationElement() : this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -66,13 +66,14 @@ public class ClsParameterImpl extends ClsRepositoryPsiElement<PsiParameterStub>
|
||||
|
||||
ClsMethodImpl method = (ClsMethodImpl)getDeclarationScope();
|
||||
PsiMethod sourceMethod = method.getSourceMirrorMethod();
|
||||
if (sourceMethod == method) {
|
||||
if (sourceMethod == null) {
|
||||
final PsiParameterStubImpl parameterStub = (PsiParameterStubImpl) getStub();
|
||||
if (!parameterStub.isAutoGeneratedName()) {
|
||||
return parameterStub.getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
assert sourceMethod != method;
|
||||
myName = sourceMethod.getParameterList().getParameters()[getIndex()].getName();
|
||||
}
|
||||
return myName;
|
||||
|
||||
Reference in New Issue
Block a user