Search in sources :

Example 1 with GlobalSearchScope

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();
}
Also used : GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) PsiClass(com.intellij.psi.PsiClass) PsiFile(com.intellij.psi.PsiFile) Nullable(javax.annotation.Nullable)

Example 2 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 3 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 4 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 5 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)

Aggregations

GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)519 Project (com.intellij.openapi.project.Project)159 NotNull (org.jetbrains.annotations.NotNull)147 VirtualFile (com.intellij.openapi.vfs.VirtualFile)116 Module (com.intellij.openapi.module.Module)105 Nullable (org.jetbrains.annotations.Nullable)83 PsiClass (com.intellij.psi.PsiClass)63 PsiElement (com.intellij.psi.PsiElement)45 ArrayList (java.util.ArrayList)43 PsiFile (com.intellij.psi.PsiFile)39 THashSet (gnu.trove.THashSet)23 List (java.util.List)21 SearchScope (com.intellij.psi.search.SearchScope)20 PsiDirectory (com.intellij.psi.PsiDirectory)19 JavaPsiFacade (com.intellij.psi.JavaPsiFacade)18 ContainerUtil (com.intellij.util.containers.ContainerUtil)18 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)17 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)17 StringUtil (com.intellij.openapi.util.text.StringUtil)17 com.intellij.psi (com.intellij.psi)17