Search in sources :

Example 21 with PsiClass

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

the class TestClassBrowser method init.

private void init(TreeClassChooser chooser) {
    String s = getText();
    PsiClass psiclass = findClass(s);
    if (psiclass == null)
        return;
    com.intellij.psi.PsiDirectory psidirectory = psiclass.getContainingFile().getContainingDirectory();
    if (psidirectory != null)
        chooser.selectDirectory(psidirectory);
    chooser.select(psiclass);
}
Also used : PsiClass(com.intellij.psi.PsiClass)

Example 22 with PsiClass

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

the class TestNGTestGroup method fillTestObjects.

@Override
public void fillTestObjects(Map<PsiClass, Map<PsiMethod, List<String>>> classes) throws CantRunException {
    final TestData data = myConfig.getPersistantData();
    //for a group, we include all classes
    final SourceScope sourceScope = data.getScope().getSourceScope(myConfig);
    final TestClassFilter classFilter = new TestClassFilter(sourceScope != null ? sourceScope.getGlobalSearchScope() : GlobalSearchScope.allScope(myConfig.getProject()), myConfig.getProject(), true, true);
    PsiClass[] testClasses = TestNGUtil.getAllTestClasses(classFilter, false);
    if (testClasses != null) {
        for (PsiClass c : testClasses) {
            classes.put(c, new LinkedHashMap<>());
        }
    }
}
Also used : SourceScope(com.intellij.execution.testframework.SourceScope) PsiClass(com.intellij.psi.PsiClass)

Example 23 with PsiClass

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

the class DetectClassesToRunTest method doTestMethodConfiguration.

private void doTestMethodConfiguration(PsiClass aClass, PsiClass secondaryClass, PsiMethod configMethod, PsiMethod... expectedMethods) throws CantRunException {
    final TestNGConfiguration configuration = new TestNGConfiguration("testOne", getProject(), TestNGConfigurationType.getInstance().getConfigurationFactories()[0]);
    final TestData data = configuration.getPersistantData();
    data.TEST_OBJECT = TestType.METHOD.getType();
    data.METHOD_NAME = "testOne";
    data.setScope(TestSearchScope.SINGLE_MODULE);
    configuration.setModule(data.setMainClass(aClass));
    final TestNGTestObject testObject = TestNGTestObject.fromConfig(configuration);
    assertNotNull(testObject);
    final LinkedHashMap<PsiClass, Map<PsiMethod, List<String>>> classes = new LinkedHashMap<>();
    testObject.fillTestObjects(classes);
    assertContainsElements(classes.keySet(), aClass);
    final Map<PsiMethod, List<String>> methods = classes.get(aClass);
    assertContainsElements(methods.keySet(), expectedMethods);
    if (secondaryClass != null) {
        final Map<PsiMethod, List<String>> configMethods = classes.get(secondaryClass);
        assertTrue(configMethods != null);
        assertTrue(configMethods.containsKey(configMethod));
    }
}
Also used : TestData(com.theoryinpractice.testng.model.TestData) PsiMethod(com.intellij.psi.PsiMethod) TestNGTestObject(com.theoryinpractice.testng.model.TestNGTestObject) PsiClass(com.intellij.psi.PsiClass) List(java.util.List) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 24 with PsiClass

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

the class DetectClassesToRunTest method testOneMethodWithDependencies.

@Test
public void testOneMethodWithDependencies() 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" + "  public void testOne(){}\n" + "}");
    doTestMethodConfiguration(aClass, aClass.getMethods());
}
Also used : PsiClass(com.intellij.psi.PsiClass) Test(org.testng.annotations.Test)

Example 25 with PsiClass

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

the class GroovyStubNotificationProvider method decorateStubFile.

private static EditorNotificationPanel decorateStubFile(final VirtualFile file, final Project project) {
    final EditorNotificationPanel panel = new EditorNotificationPanel();
    panel.setText("This stub is generated for Groovy class to make Groovy-Java cross-compilation possible");
    panel.createActionLabel("Go to the Groovy class", () -> DumbService.getInstance(project).withAlternativeResolveEnabled(() -> {
        final PsiClass original = findClassByStub(project, file);
        if (original != null) {
            original.navigate(true);
        }
    }));
    panel.createActionLabel("Exclude from stub generation", () -> DumbService.getInstance(project).withAlternativeResolveEnabled(() -> {
        final PsiClass psiClass = findClassByStub(project, file);
        if (psiClass != null) {
            ExcludeFromStubGenerationAction.doExcludeFromStubGeneration(psiClass.getContainingFile());
        }
    }));
    return panel;
}
Also used : EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) PsiClass(com.intellij.psi.PsiClass)

Aggregations

PsiClass (com.intellij.psi.PsiClass)594 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