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());
}
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());
}
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");
}
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[] {});
}
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");
}
Aggregations