mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-117584 more stubs for annotations. Optimization for argument searching
This commit is contained in:
+27
-15
@@ -23,6 +23,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiImplUtil;
|
||||
import com.intellij.psi.impl.light.LightClassReference;
|
||||
import com.intellij.psi.meta.PsiMetaData;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.PairFunction;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -82,10 +83,6 @@ public class GrAnnotationImpl extends GrStubElementBase<GrAnnotationStub> implem
|
||||
|
||||
@NotNull
|
||||
public GrAnnotationArgumentList getParameterList() {
|
||||
final GrAnnotationStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.getPsiElement().getParameterList();
|
||||
}
|
||||
return findNotNullChildByClass(GrAnnotationArgumentList.class);
|
||||
}
|
||||
|
||||
@@ -105,29 +102,44 @@ public class GrAnnotationImpl extends GrStubElementBase<GrAnnotationStub> implem
|
||||
|
||||
@Nullable
|
||||
public PsiJavaCodeReferenceElement getNameReferenceElement() {
|
||||
final GrAnnotationStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.getPsiElement().getNameReferenceElement();
|
||||
}
|
||||
final GroovyResolveResult resolveResult = resolveWithStub();
|
||||
|
||||
final GroovyResolveResult resolveResult = getClassReference().advancedResolve();
|
||||
final PsiElement resolved = resolveResult.getElement();
|
||||
if (!(resolved instanceof PsiClass)) return null;
|
||||
|
||||
if (resolved instanceof PsiClass) {
|
||||
return new LightClassReference(getManager(), getClassReference().getText(), (PsiClass)resolved, resolveResult.getSubstitutor());
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
return new LightClassReference(getManager(), getClassReference().getText(), (PsiClass)resolved, resolveResult.getSubstitutor());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private GroovyResolveResult resolveWithStub() {
|
||||
final GrAnnotationStub stub = getStub();
|
||||
final GrCodeReferenceElement reference = stub != null ? stub.getPsiElement().getClassReference() : getClassReference();
|
||||
return reference.advancedResolve();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiAnnotationMemberValue findAttributeValue(@Nullable String attributeName) {
|
||||
final GrAnnotationStub stub = getStub();
|
||||
if (stub != null) {
|
||||
final GrAnnotation stubbedPsi = stub.getPsiElement();
|
||||
final PsiAnnotationMemberValue value = PsiImplUtil.findAttributeValue(stubbedPsi, attributeName);
|
||||
if (value == null || !PsiTreeUtil.isAncestor(stubbedPsi, value, true)) { // if value is a default value we can use it
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return PsiImplUtil.findAttributeValue(this, attributeName);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiAnnotationMemberValue findDeclaredAttributeValue(@NonNls final String attributeName) {
|
||||
final GrAnnotationStub stub = getStub();
|
||||
if (stub != null) {
|
||||
final GrAnnotation stubbedPsi = stub.getPsiElement();
|
||||
final PsiAnnotationMemberValue value = PsiImplUtil.findDeclaredAttributeValue(stubbedPsi, attributeName);
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return PsiImplUtil.findDeclaredAttributeValue(this, attributeName);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user