Search in sources :

Example 1 with PerlVariableDeclarationStub

use of com.perl5.lang.perl.psi.stubs.variables.PerlVariableDeclarationStub in project Perl5-IDEA by Camelcade.

the class PerlVariableDeclarationElementMixin method getNamespaceName.

@Override
@NotNull
public String getNamespaceName() {
    PerlVariableDeclarationStub stub = getGreenStub();
    if (stub != null) {
        return stub.getNamespaceName();
    }
    String qualifierName = getVariable().getExplicitNamespaceName();
    if (StringUtil.isNotEmpty(qualifierName)) {
        return qualifierName;
    }
    return PerlPackageUtil.getContextNamespaceName(getVariable());
}
Also used : PerlVariableDeclarationStub(com.perl5.lang.perl.psi.stubs.variables.PerlVariableDeclarationStub) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with PerlVariableDeclarationStub

use of com.perl5.lang.perl.psi.stubs.variables.PerlVariableDeclarationStub in project Perl5-IDEA by Camelcade.

the class PerlVariableDeclarationElementMixin method getDeclaredType.

@Nullable
@Override
public String getDeclaredType() {
    PerlVariableAnnotations variableAnnotations = getVariableAnnotations();
    if (variableAnnotations != null) {
        String type = variableAnnotations.getType();
        if (type != null) {
            return type;
        }
    }
    PerlVariableDeclarationStub stub = getStub();
    if (stub != null) {
        return stub.getDeclaredType();
    } else {
        return getLocallyDeclaredType();
    }
}
Also used : PerlVariableAnnotations(com.perl5.lang.perl.psi.utils.PerlVariableAnnotations) PerlVariableDeclarationStub(com.perl5.lang.perl.psi.stubs.variables.PerlVariableDeclarationStub) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with PerlVariableDeclarationStub

use of com.perl5.lang.perl.psi.stubs.variables.PerlVariableDeclarationStub in project Perl5-IDEA by Camelcade.

the class PerlVariableDeclarationElementMixin method getPsiDeclaredValue.

@NotNull
public PerlValue getPsiDeclaredValue() {
    PerlVariableDeclarationStub stub = getGreenStub();
    if (stub != null) {
        return stub.getDeclaredValue();
    }
    PerlVariableDeclarationExpr declaration = getPerlDeclaration();
    return declaration == null ? UNKNOWN_VALUE : PerlScalarValue.create(declaration.getDeclarationType());
}
Also used : PerlVariableDeclarationStub(com.perl5.lang.perl.psi.stubs.variables.PerlVariableDeclarationStub) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with PerlVariableDeclarationStub

use of com.perl5.lang.perl.psi.stubs.variables.PerlVariableDeclarationStub in project Perl5-IDEA by Camelcade.

the class PerlVariableDeclarationElementMixin method getVariableAnnotations.

@Override
@Nullable
public PerlVariableAnnotations getVariableAnnotations() {
    PerlVariableAnnotations variableAnnotations;
    PerlVariableDeclarationStub stub = getGreenStub();
    if (stub != null) {
        variableAnnotations = stub.getVariableAnnotations();
    } else {
        // re-parsing
        variableAnnotations = getLocalVariableAnnotations();
    }
    if (variableAnnotations != null) {
        return variableAnnotations;
    }
    return getExternalVariableAnnotations();
}
Also used : PerlVariableAnnotations(com.perl5.lang.perl.psi.utils.PerlVariableAnnotations) PerlVariableDeclarationStub(com.perl5.lang.perl.psi.stubs.variables.PerlVariableDeclarationStub) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with PerlVariableDeclarationStub

use of com.perl5.lang.perl.psi.stubs.variables.PerlVariableDeclarationStub in project Perl5-IDEA by Camelcade.

the class PerlVariableStubElementType method serialize.

@Override
public void serialize(@NotNull PerlVariableDeclarationStub stub, @NotNull StubOutputStream dataStream) throws IOException {
    dataStream.writeName(stub.getNamespaceName());
    dataStream.writeName(stub.getVariableName());
    stub.getDeclaredValue().serialize(dataStream);
    dataStream.writeByte(stub.getActualType().ordinal());
    PerlVariableAnnotations annotations = stub.getVariableAnnotations();
    if (annotations == null) {
        dataStream.writeBoolean(false);
    } else {
        dataStream.writeBoolean(true);
        annotations.serialize(dataStream);
    }
}
Also used : PerlVariableAnnotations(com.perl5.lang.perl.psi.utils.PerlVariableAnnotations)

Aggregations

PerlVariableDeclarationStub (com.perl5.lang.perl.psi.stubs.variables.PerlVariableDeclarationStub)4 PerlVariableAnnotations (com.perl5.lang.perl.psi.utils.PerlVariableAnnotations)3 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2