Search in sources :

Example 1 with SmaliFieldReference

use of org.jf.smalidea.psi.impl.SmaliFieldReference in project smali by JesusFreke.

the class FieldReferenceTest method testJavaReferenceFromSmali.

/**
     * Test a reference to a java field from a smali class
     */
public void testJavaReferenceFromSmali() throws Exception {
    String text = ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + ".method public blah()V\n" + "    .locals 1\n" + "    sget-object v0, Ljava/lang/System;->o<ref>ut:Ljava/io/PrintStream;\n" + "    return-void\n" + ".end method";
    SmaliFieldReference fieldReference = (SmaliFieldReference) configureByFileText(text, "blah.smali");
    Assert.assertNotNull(fieldReference);
    Assert.assertEquals("out", fieldReference.getName());
    Assert.assertNotNull(fieldReference.getFieldType());
    Assert.assertEquals("java.io.PrintStream", fieldReference.getFieldType().getType().getCanonicalText());
    PsiField resolvedField = fieldReference.resolve();
    Assert.assertNotNull(resolvedField);
    Assert.assertEquals("out", resolvedField.getName());
    Assert.assertNotNull(resolvedField.getContainingClass());
    Assert.assertEquals("java.lang.System", resolvedField.getContainingClass().getQualifiedName());
    Assert.assertEquals("java.io.PrintStream", resolvedField.getType().getCanonicalText());
}
Also used : SmaliFieldReference(org.jf.smalidea.psi.impl.SmaliFieldReference) PsiField(com.intellij.psi.PsiField)

Example 2 with SmaliFieldReference

use of org.jf.smalidea.psi.impl.SmaliFieldReference in project smali by JesusFreke.

the class FieldReferenceTest method testSmaliReferenceFromSmali.

/**
     * Test a reference to a smali field from a smali class
     */
public void testSmaliReferenceFromSmali() throws Exception {
    createFile("blarg.smali", ".class public Lblarg; .super Ljava/lang/Object;" + ".field public static blort:I");
    String text = ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + ".method public blah()V\n" + "    .locals 1\n" + "    sget v0, Lblarg;->bl<ref>ort:I\n" + "    return-void\n" + ".end method";
    SmaliFieldReference fieldReference = (SmaliFieldReference) configureByFileText(text, "blah.smali");
    Assert.assertNotNull(fieldReference);
    Assert.assertEquals("blort", fieldReference.getName());
    Assert.assertNotNull(fieldReference.getFieldType());
    Assert.assertEquals("int", fieldReference.getFieldType().getType().getCanonicalText());
    PsiField resolvedField = fieldReference.resolve();
    Assert.assertNotNull(resolvedField);
    Assert.assertEquals("blort", resolvedField.getName());
    Assert.assertNotNull(resolvedField.getContainingClass());
    Assert.assertEquals("blarg", resolvedField.getContainingClass().getQualifiedName());
    Assert.assertEquals("int", resolvedField.getType().getCanonicalText());
}
Also used : SmaliFieldReference(org.jf.smalidea.psi.impl.SmaliFieldReference) PsiField(com.intellij.psi.PsiField)

Aggregations

PsiField (com.intellij.psi.PsiField)2 SmaliFieldReference (org.jf.smalidea.psi.impl.SmaliFieldReference)2