Search in sources :

Example 1 with SmaliFieldStub

use of org.jf.smalidea.psi.stub.SmaliFieldStub in project smali by JesusFreke.

the class SmaliField method getName.

@Nullable
@Override
public String getName() {
    SmaliFieldStub stub = getStub();
    if (stub != null) {
        return stub.getName();
    }
    SmaliMemberName smaliMemberName = findChildByClass(SmaliMemberName.class);
    if (smaliMemberName == null || smaliMemberName.getText().isEmpty()) {
        return null;
    }
    return smaliMemberName.getText();
}
Also used : SmaliFieldStub(org.jf.smalidea.psi.stub.SmaliFieldStub) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with SmaliFieldStub

use of org.jf.smalidea.psi.stub.SmaliFieldStub in project smali by JesusFreke.

the class SmaliFieldElementType method createStub.

@Override
public SmaliFieldStub createStub(@NotNull SmaliField psi, StubElement parentStub) {
    try {
        String fieldSmaliTypeName;
        SmaliTypeElement typeElement = psi.getTypeElement();
        if (typeElement != null) {
            fieldSmaliTypeName = typeElement.getSmaliName();
        } else {
            fieldSmaliTypeName = "Ljava/lang/Object;";
        }
        return new SmaliFieldStub(parentStub, psi.getName(), fieldSmaliTypeName);
    } catch (IndexNotReadyException ex) {
        System.out.println(psi.getName());
        throw ex;
    }
}
Also used : SmaliFieldStub(org.jf.smalidea.psi.stub.SmaliFieldStub) SmaliTypeElement(org.jf.smalidea.psi.impl.SmaliTypeElement) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException)

Example 3 with SmaliFieldStub

use of org.jf.smalidea.psi.stub.SmaliFieldStub in project smali by JesusFreke.

the class SmaliField method getType.

@NotNull
@Override
public PsiType getType() {
    SmaliFieldStub stub = getStub();
    if (stub != null) {
        return NameUtils.resolveSmaliToPsiType(this, stub.getSmaliTypeName());
    }
    PsiTypeElement typeElement = getTypeElement();
    if (typeElement == null) {
        // If we don't have a type (i.e. syntax error), use Object as a safe-ish fallback
        PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory();
        return factory.createTypeFromText("java.lang.Object", this);
    }
    return getTypeElement().getType();
}
Also used : SmaliFieldStub(org.jf.smalidea.psi.stub.SmaliFieldStub) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

SmaliFieldStub (org.jf.smalidea.psi.stub.SmaliFieldStub)3 IndexNotReadyException (com.intellij.openapi.project.IndexNotReadyException)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1 SmaliTypeElement (org.jf.smalidea.psi.impl.SmaliTypeElement)1