Search in sources :

Example 51 with PsiMethod

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

the class ObscureThrownExceptionsPredicate method satisfiedBy.

@Override
public boolean satisfiedBy(PsiElement element) {
    if (!(element instanceof PsiReferenceList)) {
        return false;
    }
    final PsiReferenceList throwsList = (PsiReferenceList) element;
    if (throwsList.getReferenceElements().length < 2) {
        return false;
    }
    final PsiElement parent = element.getParent();
    if (!(parent instanceof PsiMethod)) {
        return false;
    }
    final PsiMethod method = (PsiMethod) parent;
    return method.getThrowsList().equals(element);
}
Also used : PsiMethod(com.intellij.psi.PsiMethod) PsiReferenceList(com.intellij.psi.PsiReferenceList) PsiElement(com.intellij.psi.PsiElement)

Example 52 with PsiMethod

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

the class ExtractClassTest method testPublicVisibility.

public void testPublicVisibility() throws Exception {
    doTest((rootDir, rootAfter) -> {
        PsiClass aClass = myJavaFacade.findClass("Test", GlobalSearchScope.projectScope(myProject));
        assertNotNull("Class Test not found", aClass);
        final ArrayList<PsiMethod> methods = new ArrayList<>();
        methods.add(aClass.findMethodsByName("foos", false)[0]);
        final ArrayList<PsiField> fields = new ArrayList<>();
        fields.add(aClass.findFieldByName("myT", false));
        final ExtractClassProcessor processor = new ExtractClassProcessor(aClass, fields, methods, new ArrayList<>(), "", null, "Extracted", PsiModifier.PUBLIC, false, Collections.<MemberInfo>emptyList());
        processor.run();
        LocalFileSystem.getInstance().refresh(false);
        FileDocumentManager.getInstance().saveAllDocuments();
    });
}
Also used : PsiMethod(com.intellij.psi.PsiMethod) PsiField(com.intellij.psi.PsiField) PsiClass(com.intellij.psi.PsiClass) ArrayList(java.util.ArrayList) ExtractClassProcessor(com.intellij.refactoring.extractclass.ExtractClassProcessor)

Example 53 with PsiMethod

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

the class ExtractClassTest method doTestField.

private void doTestField(final String conflicts, final boolean generateGettersSetters) throws Exception {
    doTest((rootDir, rootAfter) -> {
        PsiClass aClass = myJavaFacade.findClass("Test", GlobalSearchScope.projectScope(myProject));
        assertNotNull("Class Test not found", aClass);
        final ArrayList<PsiMethod> methods = new ArrayList<>();
        final ArrayList<PsiField> fields = new ArrayList<>();
        fields.add(aClass.findFieldByName("myT", false));
        doTest(aClass, methods, fields, conflicts, generateGettersSetters);
    });
}
Also used : PsiMethod(com.intellij.psi.PsiMethod) PsiField(com.intellij.psi.PsiField) PsiClass(com.intellij.psi.PsiClass) ArrayList(java.util.ArrayList)

Example 54 with PsiMethod

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

the class ExtractClassTest method doTestMethod.

private void doTestMethod(final String methodName, final String conflicts, final String qualifiedName) throws Exception {
    doTest((rootDir, rootAfter) -> {
        PsiClass aClass = myJavaFacade.findClass(qualifiedName, GlobalSearchScope.projectScope(myProject));
        assertNotNull("Class Test not found", aClass);
        final ArrayList<PsiMethod> methods = new ArrayList<>();
        methods.add(aClass.findMethodsByName(methodName, false)[0]);
        doTest(aClass, methods, new ArrayList<>(), conflicts, false);
    });
}
Also used : PsiMethod(com.intellij.psi.PsiMethod) PsiClass(com.intellij.psi.PsiClass) ArrayList(java.util.ArrayList)

Example 55 with PsiMethod

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

the class MakeMethodStaticTest method testInnerStaticClassUsed.

public void testInnerStaticClassUsed() throws Exception {
    configureByFile("/refactoring/makeMethodStatic/beforeInnerStaticClassUsed.java");
    PsiElement element = TargetElementUtil.findTargetElement(myEditor, TargetElementUtil.ELEMENT_NAME_ACCEPTED);
    assertTrue(element instanceof PsiMethod);
    assertFalse(MakeStaticUtil.isParameterNeeded((PsiMethod) element));
}
Also used : PsiMethod(com.intellij.psi.PsiMethod) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PsiMethod (com.intellij.psi.PsiMethod)232 PsiClass (com.intellij.psi.PsiClass)97 PsiElement (com.intellij.psi.PsiElement)71 ArrayList (java.util.ArrayList)24 NotNull (org.jetbrains.annotations.NotNull)22 Nullable (org.jetbrains.annotations.Nullable)19 Project (com.intellij.openapi.project.Project)16 PsiField (com.intellij.psi.PsiField)13 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)12 Location (com.intellij.execution.Location)11 JavaEvaluator (com.android.tools.klint.client.api.JavaEvaluator)9 PsiReference (com.intellij.psi.PsiReference)9 PsiFile (com.intellij.psi.PsiFile)8 PsiAnnotation (com.intellij.psi.PsiAnnotation)7 List (java.util.List)7 Nullable (com.android.annotations.Nullable)6 Module (com.intellij.openapi.module.Module)6 PsiType (com.intellij.psi.PsiType)6 SearchScope (com.intellij.psi.search.SearchScope)6 PsiParameter (com.intellij.psi.PsiParameter)5