Search in sources :

Example 11 with SmaliMethod

use of org.jf.smalidea.psi.impl.SmaliMethod 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());
}
Also used : SmaliFile(org.jf.smalidea.psi.impl.SmaliFile) SmaliClass(org.jf.smalidea.psi.impl.SmaliClass) SmaliMethod(org.jf.smalidea.psi.impl.SmaliMethod) SmaliLiteral(org.jf.smalidea.psi.impl.SmaliLiteral)

Aggregations

SmaliMethod (org.jf.smalidea.psi.impl.SmaliMethod)11 SmaliClass (org.jf.smalidea.psi.impl.SmaliClass)7 SmaliFile (org.jf.smalidea.psi.impl.SmaliFile)7 MethodImplementation (org.jf.dexlib2.iface.MethodImplementation)5 Instruction (org.jf.dexlib2.iface.instruction.Instruction)4 SmaliInstruction (org.jf.smalidea.psi.impl.SmaliInstruction)3 PsiLocalVariable (com.intellij.psi.PsiLocalVariable)2 StackFrameProxy (com.intellij.debugger.engine.jdi.StackFrameProxy)1 JavaCodeFragment (com.intellij.psi.JavaCodeFragment)1 JavaRecursiveElementVisitor (com.intellij.psi.JavaRecursiveElementVisitor)1 PsiElement (com.intellij.psi.PsiElement)1 PsiModifierList (com.intellij.psi.PsiModifierList)1 LocalVariableImpl (com.sun.tools.jdi.LocalVariableImpl)1 LocationImpl (com.sun.tools.jdi.LocationImpl)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Nullable (javax.annotation.Nullable)1 Nullable (org.jetbrains.annotations.Nullable)1 AnalyzedInstruction (org.jf.dexlib2.analysis.AnalyzedInstruction)1 RegisterType (org.jf.dexlib2.analysis.RegisterType)1 StringReference (org.jf.dexlib2.iface.reference.StringReference)1