Search in sources :

Example 6 with SmaliClassTypeElement

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

the class ClassReferenceTest method testJavaReferenceFromSmaliInDumbMode.

/**
     * Test a reference to a java class from a smali class, while in dumb mode
     */
public void testJavaReferenceFromSmaliInDumbMode() throws Exception {
    SmaliClassTypeElement typeElement = (SmaliClassTypeElement) configureByFileText(".class public Lblah; .super L<ref>java/lang/Object;", "blah.smali");
    Assert.assertNotNull(typeElement);
    Assert.assertEquals("Object", typeElement.getName());
    DumbServiceImpl.getInstance(getProject()).setDumb(true);
    PsiClass psiClass = typeElement.resolve();
    Assert.assertNull(psiClass);
    DumbServiceImpl.getInstance(getProject()).setDumb(false);
}
Also used : SmaliClassTypeElement(org.jf.smalidea.psi.impl.SmaliClassTypeElement) PsiClass(com.intellij.psi.PsiClass)

Example 7 with SmaliClassTypeElement

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

the class ClassReferenceTest method testSmaliReferenceFromSmali.

/**
     * Test a reference to a smali class from a smali class
     */
public void testSmaliReferenceFromSmali() throws Exception {
    createFile("blarg.smali", ".class public Lblarg; .super Ljava/lang/Object;");
    SmaliClassTypeElement typeElement = (SmaliClassTypeElement) configureByFileText(".class public Lblah; .super L<ref>blarg;", "blah.smali");
    Assert.assertEquals("blarg", typeElement.getName());
    SmaliClass smaliClass = (SmaliClass) typeElement.resolve();
    Assert.assertNotNull(smaliClass);
    Assert.assertEquals("blarg", smaliClass.getQualifiedName());
    JavaResolveResult resolveResult = typeElement.advancedResolve(false);
    Assert.assertNotNull(resolveResult.getElement());
    Assert.assertEquals("blarg", ((PsiClass) resolveResult.getElement()).getQualifiedName());
    JavaResolveResult[] resolveResults = typeElement.multiResolve(false);
    Assert.assertEquals(1, resolveResults.length);
    Assert.assertNotNull(resolveResults[0].getElement());
    Assert.assertEquals("blarg", ((PsiClass) resolveResults[0].getElement()).getQualifiedName());
}
Also used : SmaliClass(org.jf.smalidea.psi.impl.SmaliClass) SmaliClassTypeElement(org.jf.smalidea.psi.impl.SmaliClassTypeElement) JavaResolveResult(com.intellij.psi.JavaResolveResult)

Example 8 with SmaliClassTypeElement

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

the class ClassReferenceTest method testJavaReferenceFromSmali.

/**
     * Test a reference to a java class from a smali class
     */
public void testJavaReferenceFromSmali() throws Exception {
    SmaliClassTypeElement typeElement = (SmaliClassTypeElement) configureByFileText(".class public Lblah; .super L<ref>java/lang/Object;", "blah.smali");
    Assert.assertNotNull(typeElement);
    Assert.assertEquals("Object", typeElement.getName());
    PsiClass psiClass = typeElement.resolve();
    Assert.assertNotNull(psiClass);
    Assert.assertEquals("java.lang.Object", psiClass.getQualifiedName());
    JavaResolveResult resolveResult = typeElement.advancedResolve(false);
    Assert.assertNotNull(resolveResult.getElement());
    Assert.assertEquals("java.lang.Object", ((PsiClass) resolveResult.getElement()).getQualifiedName());
    JavaResolveResult[] resolveResults = typeElement.multiResolve(false);
    Assert.assertEquals(1, resolveResults.length);
    Assert.assertNotNull(resolveResults[0].getElement());
    Assert.assertEquals("java.lang.Object", ((PsiClass) resolveResults[0].getElement()).getQualifiedName());
}
Also used : SmaliClassTypeElement(org.jf.smalidea.psi.impl.SmaliClassTypeElement) PsiClass(com.intellij.psi.PsiClass) JavaResolveResult(com.intellij.psi.JavaResolveResult)

Aggregations

SmaliClassTypeElement (org.jf.smalidea.psi.impl.SmaliClassTypeElement)8 SmaliClassType (org.jf.smalidea.psi.impl.SmaliClassType)5 SmaliFile (org.jf.smalidea.psi.impl.SmaliFile)5 JavaResolveResult (com.intellij.psi.JavaResolveResult)2 PsiClass (com.intellij.psi.PsiClass)2 SmaliClass (org.jf.smalidea.psi.impl.SmaliClass)2