Search in sources :

Example 1 with GrNameValuePairStub

use of org.jetbrains.plugins.groovy.lang.psi.stubs.GrNameValuePairStub in project intellij-community by JetBrains.

the class GrNameValuePairElementType method createStub.

@NotNull
@Override
public GrNameValuePairStub createStub(@NotNull GrAnnotationNameValuePair psi, StubElement parentStub) {
    String name = psi.getName();
    GrAnnotationMemberValue value = psi.getValue();
    return new GrNameValuePairStub(parentStub, name, value == null ? null : value.getText());
}
Also used : GrAnnotationMemberValue(org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationMemberValue) GrNameValuePairStub(org.jetbrains.plugins.groovy.lang.psi.stubs.GrNameValuePairStub) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with GrNameValuePairStub

use of org.jetbrains.plugins.groovy.lang.psi.stubs.GrNameValuePairStub in project intellij-community by JetBrains.

the class GrAnnotationNameValuePairImpl method getName.

@Override
@Nullable
public String getName() {
    GrNameValuePairStub stub = getStub();
    if (stub != null) {
        return stub.getName();
    }
    final PsiElement nameId = getNameIdentifierGroovy();
    return nameId != null ? nameId.getText() : null;
}
Also used : GrNameValuePairStub(org.jetbrains.plugins.groovy.lang.psi.stubs.GrNameValuePairStub) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with GrNameValuePairStub

use of org.jetbrains.plugins.groovy.lang.psi.stubs.GrNameValuePairStub in project intellij-community by JetBrains.

the class GrAnnotationNameValuePairImpl method getDetachedValue.

@Override
@Nullable
public PsiAnnotationMemberValue getDetachedValue() {
    GrNameValuePairStub stub = getStub();
    if (stub != null) {
        String text = stub.getValue();
        PsiAnnotationMemberValue result = SoftReference.dereference(myDetachedValue);
        if (result == null) {
            GrAnnotation annotation = GroovyPsiElementFactory.getInstance(getProject()).createAnnotationFromText("@F(" + text + ")", this);
            ((LightVirtualFile) annotation.getContainingFile().getViewProvider().getVirtualFile()).setWritable(false);
            PsiAnnotationMemberValue value = annotation.findAttributeValue(null);
            myDetachedValue = new SoftReference<>(result = value);
        }
        return result;
    }
    return getValue();
}
Also used : GrNameValuePairStub(org.jetbrains.plugins.groovy.lang.psi.stubs.GrNameValuePairStub) GrAnnotation(org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

GrNameValuePairStub (org.jetbrains.plugins.groovy.lang.psi.stubs.GrNameValuePairStub)3 Nullable (org.jetbrains.annotations.Nullable)2 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)1 NotNull (org.jetbrains.annotations.NotNull)1 GrAnnotation (org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation)1 GrAnnotationMemberValue (org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationMemberValue)1