Search in sources :

Example 6 with SmaliFile

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

the class SmaliClassTypeElementTest method testSimpleInnerClass.

public void testSimpleInnerClass() {
    myFixture.addFileToProject("Outer.java", "" + "public class Outer {" + "   public static class Inner {" + "   }" + "}");
    String text = ".class public Lsmali; " + ".super LOuter$In<ref>ner;";
    SmaliFile file = (SmaliFile) myFixture.addFileToProject("smali.smali", text.replace("<ref>", ""));
    SmaliClassTypeElement typeElement = (SmaliClassTypeElement) file.findReferenceAt(text.indexOf("<ref>"));
    Assert.assertNotNull(typeElement);
    SmaliClassType type = typeElement.getType();
    Assert.assertEquals("Outer.Inner", typeElement.getQualifiedName());
    Assert.assertEquals("Outer.Inner", type.getCanonicalText());
}
Also used : SmaliFile(org.jf.smalidea.psi.impl.SmaliFile) SmaliClassTypeElement(org.jf.smalidea.psi.impl.SmaliClassTypeElement) SmaliClassType(org.jf.smalidea.psi.impl.SmaliClassType)

Example 7 with SmaliFile

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

the class SmaliClassTypeElementTest method testGetType.

public void testGetType() {
    myFixture.addFileToProject("my/blarg.smali", ".class public Lmy/blarg; " + ".super Ljava/lang/Object;");
    String text = ".class public Lmy/pkg/blah; " + ".super Lmy/bl<ref>arg;";
    SmaliFile file = (SmaliFile) myFixture.addFileToProject("my/pkg/blah.smali", text.replace("<ref>", ""));
    SmaliClassTypeElement typeElement = (SmaliClassTypeElement) file.findReferenceAt(text.indexOf("<ref>"));
    Assert.assertNotNull(typeElement);
    SmaliClassType type = typeElement.getType();
    Assert.assertEquals("blarg", typeElement.getName());
    Assert.assertEquals("my.blarg", typeElement.getCanonicalText());
    Assert.assertEquals("blarg", type.getClassName());
    Assert.assertEquals("my.blarg", type.getCanonicalText());
    SmaliClass resolvedClass = (SmaliClass) typeElement.resolve();
    Assert.assertNotNull(resolvedClass);
    Assert.assertEquals("my.blarg", resolvedClass.getQualifiedName());
    resolvedClass = (SmaliClass) type.resolve();
    Assert.assertNotNull(resolvedClass);
    Assert.assertEquals("my.blarg", resolvedClass.getQualifiedName());
}
Also used : SmaliFile(org.jf.smalidea.psi.impl.SmaliFile) SmaliClass(org.jf.smalidea.psi.impl.SmaliClass) SmaliClassTypeElement(org.jf.smalidea.psi.impl.SmaliClassTypeElement) SmaliClassType(org.jf.smalidea.psi.impl.SmaliClassType)

Example 8 with SmaliFile

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

the class SmaliClassTypeElementTest method testComplexInnerClass.

public void testComplexInnerClass() {
    myFixture.addFileToProject("my/Outer$blah.java", "" + "package my;" + "public class Outer$blah {" + "   public static class Inner {" + "   }" + "   public static class Inner$blah {" + "   }" + "}");
    String text = ".class public Lsmali; " + ".super Lmy/Outer$blah$In<ref>ner$blah;";
    SmaliFile file = (SmaliFile) myFixture.addFileToProject("smali.smali", text.replace("<ref>", ""));
    SmaliClassTypeElement typeElement = (SmaliClassTypeElement) file.findReferenceAt(text.indexOf("<ref>"));
    Assert.assertNotNull(typeElement);
    SmaliClassType type = typeElement.getType();
    Assert.assertEquals("my.Outer$blah.Inner$blah", typeElement.getQualifiedName());
    Assert.assertEquals("my.Outer$blah.Inner$blah", type.getCanonicalText());
    text = ".class public Lsmali2; " + ".super Lmy/Outer$blah$In<ref>ner;";
    file = (SmaliFile) myFixture.addFileToProject("smali2.smali", text.replace("<ref>", ""));
    typeElement = (SmaliClassTypeElement) file.findReferenceAt(text.indexOf("<ref>"));
    Assert.assertNotNull(typeElement);
    type = typeElement.getType();
    Assert.assertEquals("my.Outer$blah.Inner", typeElement.getQualifiedName());
    Assert.assertEquals("my.Outer$blah.Inner", type.getCanonicalText());
}
Also used : SmaliFile(org.jf.smalidea.psi.impl.SmaliFile) SmaliClassTypeElement(org.jf.smalidea.psi.impl.SmaliClassTypeElement) SmaliClassType(org.jf.smalidea.psi.impl.SmaliClassType)

Example 9 with SmaliFile

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

the class SmaliClassTypeElementTest method testInnerClassTrailingDollar.

public void testInnerClassTrailingDollar() {
    myFixture.addFileToProject("my/Outer$blah.java", "" + "package my;" + "public class Outer$ {" + "   public static class Inner$ {" + "   }" + "}");
    String text = ".class public Lsmali; " + ".super Lmy/Outer$$In<ref>ner$;";
    SmaliFile file = (SmaliFile) myFixture.addFileToProject("smali.smali", text.replace("<ref>", ""));
    SmaliClassTypeElement typeElement = (SmaliClassTypeElement) file.findReferenceAt(text.indexOf("<ref>"));
    Assert.assertNotNull(typeElement);
    SmaliClassType type = typeElement.getType();
    Assert.assertEquals("my.Outer$.Inner$", typeElement.getQualifiedName());
    Assert.assertEquals("my.Outer$.Inner$", type.getCanonicalText());
}
Also used : SmaliFile(org.jf.smalidea.psi.impl.SmaliFile) SmaliClassTypeElement(org.jf.smalidea.psi.impl.SmaliClassTypeElement) SmaliClassType(org.jf.smalidea.psi.impl.SmaliClassType)

Example 10 with SmaliFile

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

the class SmaliClassTypeElementTest method testInnerClassWithPackage.

public void testInnerClassWithPackage() {
    myFixture.addFileToProject("my/Outer.java", "" + "package my;" + "public class Outer {" + "   public static class Inner {" + "   }" + "}");
    String text = ".class public Lsmali; " + ".super Lmy/Outer$In<ref>ner;";
    SmaliFile file = (SmaliFile) myFixture.addFileToProject("smali.smali", text.replace("<ref>", ""));
    SmaliClassTypeElement typeElement = (SmaliClassTypeElement) file.findReferenceAt(text.indexOf("<ref>"));
    Assert.assertNotNull(typeElement);
    SmaliClassType type = typeElement.getType();
    Assert.assertEquals("my.Outer.Inner", typeElement.getQualifiedName());
    Assert.assertEquals("my.Outer.Inner", type.getCanonicalText());
}
Also used : SmaliFile(org.jf.smalidea.psi.impl.SmaliFile) SmaliClassTypeElement(org.jf.smalidea.psi.impl.SmaliClassTypeElement) SmaliClassType(org.jf.smalidea.psi.impl.SmaliClassType)

Aggregations

SmaliFile (org.jf.smalidea.psi.impl.SmaliFile)42 SmaliClass (org.jf.smalidea.psi.impl.SmaliClass)28 PsiElement (com.intellij.psi.PsiElement)7 SmaliMethod (org.jf.smalidea.psi.impl.SmaliMethod)7 SmaliModifierList (org.jf.smalidea.psi.impl.SmaliModifierList)7 PsiClass (com.intellij.psi.PsiClass)5 PsiField (com.intellij.psi.PsiField)5 MethodImplementation (org.jf.dexlib2.iface.MethodImplementation)5 SmaliClassType (org.jf.smalidea.psi.impl.SmaliClassType)5 SmaliClassTypeElement (org.jf.smalidea.psi.impl.SmaliClassTypeElement)5 Instruction (org.jf.dexlib2.iface.instruction.Instruction)3 SmaliField (org.jf.smalidea.psi.impl.SmaliField)3 PsiPrimitiveType (com.intellij.psi.PsiPrimitiveType)2 PsiTypeElement (com.intellij.psi.PsiTypeElement)2 SmaliAnnotation (org.jf.smalidea.psi.impl.SmaliAnnotation)2 SmaliExtendsList (org.jf.smalidea.psi.impl.SmaliExtendsList)2 SmaliImplementsList (org.jf.smalidea.psi.impl.SmaliImplementsList)2 SmaliInstruction (org.jf.smalidea.psi.impl.SmaliInstruction)2 SmaliLiteral (org.jf.smalidea.psi.impl.SmaliLiteral)2 DebugProcess (com.intellij.debugger.engine.DebugProcess)1