use of org.jf.smalidea.psi.impl.SmaliLiteral in project smali by JesusFreke.
the class SmaliLiteralTest method doTest.
private void doTest(long expectedValue, String literalValue) {
String text = ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + ".method blah()V\n" + " .registers <ref>" + literalValue + "\n" + " return-void\n" + ".end method";
SmaliFile file = (SmaliFile) myFixture.addFileToProject("my/pkg/blah.smali", text.replace("<ref>", ""));
PsiElement leafElement = file.findElementAt(text.indexOf("<ref>"));
Assert.assertNotNull(leafElement);
SmaliLiteral literalElement = (SmaliLiteral) leafElement.getParent();
Assert.assertNotNull(literalElement);
Assert.assertEquals(expectedValue, literalElement.getIntegralValue());
}
use of org.jf.smalidea.psi.impl.SmaliLiteral in project smali by JesusFreke.
the class SmaliAnnotationTest method testDefaultValue.
public void testDefaultValue() {
SmaliFile file = (SmaliFile) myFixture.addFileToProject("AnnotationWithDefaultValue.smali", "" + ".class public abstract interface annotation LAnnotationWithValues;\n" + ".super Ljava/lang/Object;\n" + ".implements Ljava/lang/annotation/Annotation;\n" + "\n" + ".method public abstract intValue()I\n" + ".end method\n" + "\n" + ".annotation system Ldalvik/annotation/AnnotationDefault;\n" + " value = .subannotation LAnnotationWithValues;\n" + " intValue = 4\n" + " .end subannotation\n" + ".end annotation\n" + "\n");
SmaliClass smaliClass = file.getPsiClass();
Assert.assertNotNull(smaliClass);
SmaliMethod method = smaliClass.getMethods()[0];
Assert.assertEquals("intValue", method.getName());
PsiAnnotationMemberValue defaultValue = method.getDefaultValue();
Assert.assertTrue(defaultValue instanceof SmaliLiteral);
Assert.assertEquals(4, ((SmaliLiteral) defaultValue).getIntegralValue());
}
Aggregations