mirror of
https://github.com/revanced/smali.git
synced 2025-05-22 00:37:04 +02:00
Implement SmaliAnnotation.getQualifiedName() and related tests
This commit is contained in:
parent
010b0fb998
commit
3bd51ea4e4
@ -58,7 +58,11 @@ public class SmaliAnnotation extends SmaliStubBasedPsiElement<SmaliAnnotationStu
|
||||
}
|
||||
|
||||
@Nullable @Override public String getQualifiedName() {
|
||||
return null;
|
||||
SmaliClassTypeElement classType = findChildByClass(SmaliClassTypeElement.class);
|
||||
if (classType == null) {
|
||||
return null;
|
||||
}
|
||||
return classType.getJavaType();
|
||||
}
|
||||
|
||||
@Nullable @Override public PsiJavaCodeReferenceElement getNameReferenceElement() {
|
||||
|
@ -148,8 +148,7 @@ public class SmaliClassModifierListTest extends LightCodeInsightFixtureTestCase
|
||||
SmaliAnnotation[] annotations = modifierList.getAnnotations();
|
||||
Assert.assertEquals(1, annotations.length);
|
||||
|
||||
// TODO: use PsiAnnotation.getQualifiedName() instead, once it has been implemented
|
||||
Assert.assertEquals(".annotation Lmy/pkg/anno; .end annotation", annotations[0].getText());
|
||||
Assert.assertEquals("my.pkg.anno", annotations[0].getQualifiedName());
|
||||
|
||||
SmaliAnnotation[] applicableAnnotations = modifierList.getApplicableAnnotations();
|
||||
Assert.assertEquals(1, applicableAnnotations.length);
|
||||
@ -168,6 +167,22 @@ public class SmaliClassModifierListTest extends LightCodeInsightFixtureTestCase
|
||||
Assert.assertEquals(0, modifierList.getApplicableAnnotations().length);
|
||||
}
|
||||
|
||||
// TODO: test modifierList.findAnnotation once PsiAnnotation.getQualifiedName has been implemented
|
||||
public void testFindAnnotation() {
|
||||
final SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali",
|
||||
".class public final Lmy/pkg/blah;\n" +
|
||||
".annotation Lanno; .end annotation\n" +
|
||||
".super Ljava/lang/Object;\n" +
|
||||
".annotation Lmy/pkg/anno; .end annotation\n" +
|
||||
".annotation Lmy/pkg/anno2; .end annotation\n" +
|
||||
".annotation Lmy/pkg/anno3; .end annotation\n");
|
||||
|
||||
SmaliClass smaliClass = file.getPsiClass();
|
||||
SmaliModifierList modifierList = smaliClass.getModifierList();
|
||||
|
||||
SmaliAnnotation smaliAnnotation = modifierList.findAnnotation("my.pkg.anno2");
|
||||
Assert.assertNotNull(smaliAnnotation);
|
||||
Assert.assertEquals("my.pkg.anno2", smaliAnnotation.getQualifiedName());
|
||||
}
|
||||
|
||||
// TODO: test modifierList.addAnnotation once implemented
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user