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;
}
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;
}
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);
}
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) };
}
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);
}
}
Aggregations