Search in sources :

Example 31 with SmaliFile

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

the class SmaliClassTest method testName.

public void testName() {
    SmaliFile file = (SmaliFile) myFixture.addFileToProject("my/pkg/blah.smali", ".class public Lmy/pkg/blah; .super Ljava/lang/Object;");
    SmaliClass smaliClass = file.getPsiClass();
    Assert.assertEquals("my.pkg.blah", smaliClass.getQualifiedName());
    Assert.assertEquals("my.pkg", smaliClass.getPackageName());
    Assert.assertEquals("blah", smaliClass.getName());
}
Also used : SmaliFile(org.jf.smalidea.psi.impl.SmaliFile) SmaliClass(org.jf.smalidea.psi.impl.SmaliClass)

Example 32 with SmaliFile

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

the class SmaliClassTest method testEmptyPackageName.

public void testEmptyPackageName() {
    SmaliFile file = (SmaliFile) myFixture.addFileToProject("my/pkg/blah.smali", ".class public Lblah; .super Ljava/lang/Object;");
    SmaliClass smaliClass = file.getPsiClass();
    Assert.assertEquals("blah", smaliClass.getQualifiedName());
    Assert.assertEquals("", smaliClass.getPackageName());
}
Also used : SmaliFile(org.jf.smalidea.psi.impl.SmaliFile) SmaliClass(org.jf.smalidea.psi.impl.SmaliClass)

Example 33 with SmaliFile

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

the class SmaliCodeFragmentFactoryTest method testRegisterType.

public void testRegisterType() throws NoDataException {
    SmaliFile smaliFile = (SmaliFile) configureByText(SmaliFileType.INSTANCE, registerTypeTestText.replace("<ref>", ""));
    int refOffset = registerTypeTestText.indexOf("<ref>");
    PsiElement context = smaliFile.findElementAt(refOffset);
    assertVariableType(context.getParent(), "v1", "java.util.Random");
    assertVariableType(context.getParent(), "v0", "java.io.Serializable");
}
Also used : SmaliFile(org.jf.smalidea.psi.impl.SmaliFile) PsiElement(com.intellij.psi.PsiElement)

Example 34 with SmaliFile

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

the class SmaliCodeFragmentFactoryTest method testCompletion.

public void testCompletion() throws NoDataException {
    SmaliFile smaliFile = (SmaliFile) configureByText(SmaliFileType.INSTANCE, completionTestClass);
    PsiElement context = smaliFile.getPsiClass().getMethods()[0].getInstructions().get(0);
    assertCompletionContains("v", context, new String[] { "v2", "v3" }, new String[] { "v0", "v1", "p0", "p1" });
    assertCompletionContains("p", context, new String[] { "p0", "p1" }, new String[] { "v0", "v1", "v2", "v3" });
    context = smaliFile.getPsiClass().getMethods()[0].getInstructions().get(2);
    assertCompletionContains("v", context, new String[] { "v1", "v2", "v3" }, new String[] { "v0", "p0", "p1" });
    assertCompletionContains("p", context, new String[] { "p0", "p1" }, new String[] { "v0", "v1", "v2", "v3" });
    context = smaliFile.getPsiClass().getMethods()[0].getInstructions().get(6);
    assertCompletionContains("v", context, new String[] { "v0", "v1", "v2", "v3" }, new String[] { "p0", "p1" });
    assertCompletionContains("p", context, new String[] { "p0", "p1" }, new String[] {});
}
Also used : SmaliFile(org.jf.smalidea.psi.impl.SmaliFile) PsiElement(com.intellij.psi.PsiElement)

Example 35 with SmaliFile

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

the class SmaliCodeFragmentFactoryTest method testUnknownClass.

public void testUnknownClass() {
    String modifiedText = registerTypeTestText.replace("Random", "Rnd");
    SmaliFile smaliFile = (SmaliFile) configureByText(SmaliFileType.INSTANCE, modifiedText.replace("<ref>", ""));
    int refOffset = modifiedText.indexOf("<ref>");
    PsiElement context = smaliFile.findElementAt(refOffset);
    assertVariableType(context.getParent(), "v1", "java.lang.Object");
    assertVariableType(context.getParent(), "v0", "java.lang.Object");
}
Also used : SmaliFile(org.jf.smalidea.psi.impl.SmaliFile) PsiElement(com.intellij.psi.PsiElement)

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