use of com.intellij.psi.search.GlobalSearchScope in project buck by facebook.
the class BuckAutoDepsContributor method getVirtualFileFromClassname.
@Nullable
public VirtualFile getVirtualFileFromClassname(String classname) {
GlobalSearchScope scope = GlobalSearchScope.allScope(mProject);
PsiClass psiClass = JavaPsiFacade.getInstance(mProject).findClass(classname, scope);
if (psiClass == null) {
return null;
}
PsiFile psiFile = psiClass.getContainingFile();
if (psiFile == null) {
return null;
}
return psiFile.getVirtualFile();
}
use of com.intellij.psi.search.GlobalSearchScope in project intellij-community by JetBrains.
the class GroovyConsoleUtil method hasGroovyAll.
static boolean hasGroovyAll(Module module) {
final GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
final JavaPsiFacade facade = JavaPsiFacade.getInstance(module.getProject());
return (facade.findClass("org.apache.commons.cli.CommandLineParser", scope) != null || facade.findClass("groovyjarjarcommonscli.CommandLineParser", scope) != null) && facade.findClass("groovy.ui.GroovyMain", scope) != null;
}
use of com.intellij.psi.search.GlobalSearchScope in project intellij-community by JetBrains.
the class DetectClassesToRunTest method testRerunFailedTestWithDependency.
public void testRerunFailedTestWithDependency() throws Exception {
final PsiClass aClass = myFixture.addClass("package a; public class ATest {" + " @org.testng.annotations.Test()\n" + " public void testTwo(){}\n " + " @org.testng.annotations.Test(dependsOnMethods = \"testTwo\")\n" + //parameterized
" public void testOne(String s){}\n" + "}");
final LinkedHashMap<PsiClass, Map<PsiMethod, List<String>>> classes = new LinkedHashMap<>();
classes.put(aClass, new HashMap<>());
final GlobalSearchScope projectScope = GlobalSearchScope.projectScope(getProject());
final SMTestProxy testProxy = new SMTestProxy("testOne", false, "java:test://a.ATest.testOne[a]");
testProxy.setLocator(new JavaTestLocator());
RerunFailedTestsAction.includeFailedTestWithDependencies(classes, projectScope, getProject(), testProxy);
assertEquals(1, classes.size());
final Map<PsiMethod, List<String>> params = classes.get(aClass);
assertContainsElements(params.keySet(), aClass.getMethods());
final List<String> paramsToRerun = params.get(aClass.findMethodsByName("testOne", false)[0]);
assertEquals(1, paramsToRerun.size());
assertContainsElements(paramsToRerun, "a");
}
use of com.intellij.psi.search.GlobalSearchScope in project intellij-community by JetBrains.
the class TestNGTestDiscoveryRunnableState method createSearchingForTestsTask.
@Override
public SearchingForTestsTask createSearchingForTestsTask() {
return new SearchingForTestsTask(myServerSocket, getConfiguration(), myTempFile) {
@Override
protected void search() throws CantRunException {
myClasses.clear();
final TestData data = getConfiguration().getPersistantData();
final Pair<String, String> position = data.TEST_OBJECT.equals(TestType.SOURCE.getType()) ? Pair.create(data.getMainClassName(), data.getMethodName()) : null;
final Set<String> patterns = TestDiscoverySearchHelper.search(getProject(), position, data.getChangeList(), getConfiguration().getFrameworkPrefix());
final Module module = getConfiguration().getConfigurationModule().getModule();
final GlobalSearchScope searchScope = module != null ? GlobalSearchScope.moduleWithDependenciesScope(module) : GlobalSearchScope.projectScope(getProject());
TestNGTestPattern.fillTestObjects(myClasses, patterns, TestSearchScope.MODULE_WITH_DEPENDENCIES, getConfiguration(), searchScope);
}
@Override
protected void onFound() {
super.onFound();
writeClassesPerModule(myClasses);
}
};
}
use of com.intellij.psi.search.GlobalSearchScope in project intellij-community by JetBrains.
the class TestClassBrowser method getFilter.
public ClassFilter.ClassFilterWithScope getFilter() throws MessageInfoException {
TestNGConfiguration config = new TestNGConfiguration("<no-name>", getProject(), TestNGConfigurationType.getInstance().getConfigurationFactories()[0]);
editor.applyEditorTo(config);
GlobalSearchScope scope = getSearchScope(config.getModules());
if (scope == null) {
scope = GlobalSearchScope.allScope(getProject());
}
return new TestClassFilter(scope, getProject(), false);
}
Aggregations