Search in sources :

Example 1 with SmaliClassTypeElement

use of org.jf.smalidea.psi.impl.SmaliClassTypeElement 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 2 with SmaliClassTypeElement

use of org.jf.smalidea.psi.impl.SmaliClassTypeElement 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 3 with SmaliClassTypeElement

use of org.jf.smalidea.psi.impl.SmaliClassTypeElement 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 4 with SmaliClassTypeElement

use of org.jf.smalidea.psi.impl.SmaliClassTypeElement 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 5 with SmaliClassTypeElement

use of org.jf.smalidea.psi.impl.SmaliClassTypeElement 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

SmaliClassTypeElement (org.jf.smalidea.psi.impl.SmaliClassTypeElement)8 SmaliClassType (org.jf.smalidea.psi.impl.SmaliClassType)5 SmaliFile (org.jf.smalidea.psi.impl.SmaliFile)5 JavaResolveResult (com.intellij.psi.JavaResolveResult)2 PsiClass (com.intellij.psi.PsiClass)2 SmaliClass (org.jf.smalidea.psi.impl.SmaliClass)2