Search in sources :

Example 66 with PsiClass

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

the class TestClassFilter method getTestCase.

private static PsiClass getTestCase(final SourceScope sourceScope, final Module module) throws JUnitUtil.NoJUnitException {
    if (sourceScope == null)
        throw new JUnitUtil.NoJUnitException();
    final JUnitUtil.NoJUnitException[] ex = new JUnitUtil.NoJUnitException[1];
    final PsiClass testCase = ApplicationManager.getApplication().runReadAction(new Computable<PsiClass>() {

        @Override
        public PsiClass compute() {
            if (TestObject.isJUnit5(module, sourceScope, sourceScope.getProject())) {
                return null;
            }
            try {
                return module == null ? JUnitUtil.getTestCaseClass(sourceScope) : JUnitUtil.getTestCaseClass(module);
            } catch (JUnitUtil.NoJUnitException e) {
                ex[0] = e;
                return null;
            }
        }
    });
    if (ex[0] != null)
        throw ex[0];
    return testCase;
}
Also used : PsiClass(com.intellij.psi.PsiClass)

Example 67 with PsiClass

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

the class TestMethods method getTestPresentation.

@Nullable
public static String getTestPresentation(AbstractTestProxy testInfo, Project project, GlobalSearchScope searchScope) {
    final Location location = testInfo.getLocation(project, searchScope);
    final PsiElement element = location != null ? location.getPsiElement() : null;
    if (element instanceof PsiMethod) {
        final PsiClass containingClass = location instanceof MethodLocation ? ((MethodLocation) location).getContainingClass() : location instanceof PsiMemberParameterizedLocation ? ((PsiMemberParameterizedLocation) location).getContainingClass() : ((PsiMethod) element).getContainingClass();
        if (containingClass != null) {
            final String proxyName = testInfo.getName();
            final String methodName = ((PsiMethod) element).getName();
            return JavaExecutionUtil.getRuntimeQualifiedName(containingClass) + "," + (proxyName.contains(methodName) ? proxyName.substring(proxyName.indexOf(methodName)) : methodName);
        }
    }
    return null;
}
Also used : PsiMethod(com.intellij.psi.PsiMethod) PsiClass(com.intellij.psi.PsiClass) MethodLocation(com.intellij.execution.junit2.info.MethodLocation) PsiElement(com.intellij.psi.PsiElement) PsiMemberParameterizedLocation(com.intellij.execution.junit2.PsiMemberParameterizedLocation) MethodLocation(com.intellij.execution.junit2.info.MethodLocation) Location(com.intellij.execution.Location) PsiMemberParameterizedLocation(com.intellij.execution.junit2.PsiMemberParameterizedLocation) Nullable(org.jetbrains.annotations.Nullable)

Example 68 with PsiClass

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

the class FormRenameHandler method invoke.

public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
    Form[] forms = Form.DATA_KEY.getData(dataContext);
    if (forms == null || forms.length != 1)
        return;
    PsiClass boundClass = forms[0].getClassToBind();
    RefactoringActionHandlerFactory.getInstance().createRenameHandler().invoke(project, new PsiElement[] { boundClass }, dataContext);
}
Also used : PsiClass(com.intellij.psi.PsiClass)

Example 69 with PsiClass

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

the class UIDesignerFavoriteNodeProvider method createPathFromUrl.

public Object[] createPathFromUrl(final Project project, final String url, final String moduleName) {
    final PsiManager psiManager = PsiManager.getInstance(project);
    final PsiClass classToBind = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(url, GlobalSearchScope.allScope(project));
    if (classToBind == null)
        return null;
    return new Object[] { new Form(classToBind) };
}
Also used : PsiClass(com.intellij.psi.PsiClass) PsiManager(com.intellij.psi.PsiManager)

Example 70 with PsiClass

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

the class PyJavaImportCandidateProvider method addImportCandidates.

@Override
public void addImportCandidates(PsiReference reference, String name, AutoImportQuickFix quickFix) {
    final PsiElement element = reference.getElement();
    final Project project = element.getProject();
    Module module = ModuleUtil.findModuleForPsiElement(element);
    GlobalSearchScope scope = module == null ? ProjectScope.getAllScope(project) : module.getModuleWithDependenciesAndLibrariesScope(false);
    PsiShortNamesCache cache = PsiShortNamesCache.getInstance(project);
    final PsiClass[] classesByName = cache.getClassesByName(name, scope);
    for (PsiClass psiClass : classesByName) {
        final String qualifiedName = psiClass.getQualifiedName();
        if (qualifiedName == null) {
            continue;
        }
        final QualifiedName packageQName = QualifiedName.fromDottedString(qualifiedName).removeLastComponent();
        quickFix.addImport(psiClass, psiClass.getContainingFile(), packageQName);
    }
}
Also used : Project(com.intellij.openapi.project.Project) PsiShortNamesCache(com.intellij.psi.search.PsiShortNamesCache) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) QualifiedName(com.intellij.psi.util.QualifiedName) PsiClass(com.intellij.psi.PsiClass) Module(com.intellij.openapi.module.Module) PsiElement(com.intellij.psi.PsiElement)

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