Search in sources :

Example 86 with PsiClass

use of com.intellij.psi.PsiClass 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 87 with PsiClass

use of com.intellij.psi.PsiClass in project smali by JesusFreke.

the class ClassRenameTest method doRename.

private void doRename(String oldQualifiedName, String newName) throws Exception {
    PsiClass testClass = myJavaFacade.findClass(oldQualifiedName, GlobalSearchScope.allScope(getProject()));
    RenameProcessor processor = new RenameProcessor(getProject(), testClass, newName, false, false);
    processor.run();
    PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
    FileDocumentManager.getInstance().saveAllDocuments();
}
Also used : RenameProcessor(com.intellij.refactoring.rename.RenameProcessor) PsiClass(com.intellij.psi.PsiClass)

Example 88 with PsiClass

use of com.intellij.psi.PsiClass in project smali by JesusFreke.

the class FieldRenameTest method doRename.

private void doRename(String containingClass, String oldFieldName, String newFieldName) throws Exception {
    PsiClass testClass = myJavaFacade.findClass(containingClass, GlobalSearchScope.allScope(getProject()));
    PsiField field = testClass.findFieldByName(oldFieldName, false);
    RenameProcessor processor = new RenameProcessor(getProject(), field, newFieldName, false, false);
    processor.run();
    PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
    FileDocumentManager.getInstance().saveAllDocuments();
}
Also used : RenameProcessor(com.intellij.refactoring.rename.RenameProcessor) PsiField(com.intellij.psi.PsiField) PsiClass(com.intellij.psi.PsiClass)

Example 89 with PsiClass

use of com.intellij.psi.PsiClass in project smali by JesusFreke.

the class SmaliMethodReference method getContainingClass.

@Nullable
public PsiClass getContainingClass() {
    SmaliClassTypeElement containingClassReference = getContainingType();
    if (containingClassReference == null) {
        return null;
    }
    PsiClass containingClass = containingClassReference.resolve();
    if (containingClass == null) {
        return null;
    }
    return containingClass;
}
Also used : PsiClass(com.intellij.psi.PsiClass) Nullable(org.jetbrains.annotations.Nullable)

Example 90 with PsiClass

use of com.intellij.psi.PsiClass in project intellij-community by JetBrains.

the class ClassObjectRenderer method getFullValueEvaluator.

@Nullable
@Override
public XFullValueEvaluator getFullValueEvaluator(final EvaluationContextImpl evaluationContext, final ValueDescriptorImpl valueDescriptor) {
    return new JavaValue.JavaFullValueEvaluator(DebuggerBundle.message("message.node.navigate"), evaluationContext) {

        @Override
        public void evaluate(@NotNull XFullValueEvaluationCallback callback) {
            Value value = valueDescriptor.getValue();
            ClassType type = ((ClassType) value.type());
            Method nameMethod = type.concreteMethodByName("getName", "()Ljava/lang/String;");
            if (nameMethod != null) {
                try {
                    final DebugProcessImpl process = evaluationContext.getDebugProcess();
                    Value res = process.invokeMethod(evaluationContext, (ObjectReference) value, nameMethod, Collections.emptyList());
                    if (res instanceof StringReference) {
                        callback.evaluated("");
                        final String line = ((StringReference) res).value();
                        ApplicationManager.getApplication().runReadAction(() -> {
                            final PsiClass psiClass = DebuggerUtils.findClass(line, valueDescriptor.getProject(), process.getSearchScope());
                            if (psiClass != null) {
                                DebuggerUIUtil.invokeLater(() -> psiClass.navigate(true));
                            }
                        });
                    }
                } catch (EvaluateException e) {
                    LOG.info("Exception while getting type name", e);
                }
            }
        }

        @Override
        public boolean isShowValuePopup() {
            return false;
        }
    };
}
Also used : EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) JavaValue(com.intellij.debugger.engine.JavaValue) PsiClass(com.intellij.psi.PsiClass) NotNull(org.jetbrains.annotations.NotNull) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PsiClass (com.intellij.psi.PsiClass)598 PsiElement (com.intellij.psi.PsiElement)113 PsiMethod (com.intellij.psi.PsiMethod)97 Nullable (org.jetbrains.annotations.Nullable)75 NotNull (org.jetbrains.annotations.NotNull)60 Project (com.intellij.openapi.project.Project)59 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)57 Module (com.intellij.openapi.module.Module)55 PsiFile (com.intellij.psi.PsiFile)49 VirtualFile (com.intellij.openapi.vfs.VirtualFile)47 ArrayList (java.util.ArrayList)37 PsiField (com.intellij.psi.PsiField)36 JavaPsiFacade (com.intellij.psi.JavaPsiFacade)25 Location (com.intellij.execution.Location)20 File (java.io.File)16 HashSet (java.util.HashSet)16 PsiClassType (com.intellij.psi.PsiClassType)15 PsiPackage (com.intellij.psi.PsiPackage)15 List (java.util.List)15 PsiType (com.intellij.psi.PsiType)13