Search in sources :

Example 21 with GlobalSearchScope

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;
}
Also used : JavaPsiFacade(com.intellij.psi.JavaPsiFacade) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope)

Example 22 with GlobalSearchScope

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");
}
Also used : SMTestProxy(com.intellij.execution.testframework.sm.runner.SMTestProxy) PsiMethod(com.intellij.psi.PsiMethod) PsiClass(com.intellij.psi.PsiClass) LinkedHashMap(java.util.LinkedHashMap) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) List(java.util.List) JavaTestLocator(com.intellij.execution.testframework.JavaTestLocator) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 23 with GlobalSearchScope

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);
        }
    };
}
Also used : SearchingForTestsTask(com.theoryinpractice.testng.configuration.SearchingForTestsTask) TestData(com.theoryinpractice.testng.model.TestData) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) Module(com.intellij.openapi.module.Module)

Example 24 with GlobalSearchScope

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);
}
Also used : GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) TestNGConfiguration(com.theoryinpractice.testng.configuration.TestNGConfiguration) TestClassFilter(com.theoryinpractice.testng.model.TestClassFilter)

Example 25 with GlobalSearchScope

use of com.intellij.psi.search.GlobalSearchScope in project kotlin by JetBrains.

the class JavaElementFinder method findPackage.

@Override
public PsiPackage findPackage(@NotNull String qualifiedNameString) {
    if (!FqNamesUtilKt.isValidJavaFqName(qualifiedNameString)) {
        return null;
    }
    FqName fqName = new FqName(qualifiedNameString);
    // allScope() because the contract says that the whole project
    GlobalSearchScope allScope = GlobalSearchScope.allScope(project);
    if (lightClassGenerationSupport.packageExists(fqName, allScope)) {
        return new KtLightPackage(psiManager, fqName, allScope);
    }
    return null;
}
Also used : GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) FqName(org.jetbrains.kotlin.name.FqName)

Aggregations

GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)485 Project (com.intellij.openapi.project.Project)145 NotNull (org.jetbrains.annotations.NotNull)134 VirtualFile (com.intellij.openapi.vfs.VirtualFile)106 Module (com.intellij.openapi.module.Module)101 Nullable (org.jetbrains.annotations.Nullable)78 PsiClass (com.intellij.psi.PsiClass)53 ArrayList (java.util.ArrayList)37 PsiFile (com.intellij.psi.PsiFile)32 PsiElement (com.intellij.psi.PsiElement)31 THashSet (gnu.trove.THashSet)22 SearchScope (com.intellij.psi.search.SearchScope)19 PsiDirectory (com.intellij.psi.PsiDirectory)18 ContainerUtil (com.intellij.util.containers.ContainerUtil)18 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)17 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)17 com.intellij.psi (com.intellij.psi)17 List (java.util.List)17 StringUtil (com.intellij.openapi.util.text.StringUtil)15 JavaPsiFacade (com.intellij.psi.JavaPsiFacade)15