Search in sources :

Example 1 with CoverageSuitesBundle

use of com.intellij.coverage.CoverageSuitesBundle in project intellij-community by JetBrains.

the class GenerateCoverageReportAction method actionPerformed.

public void actionPerformed(final AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();
    final Project project = e.getProject();
    assert project != null;
    final CoverageDataManager coverageDataManager = CoverageDataManager.getInstance(project);
    final CoverageSuitesBundle currentSuite = coverageDataManager.getCurrentSuitesBundle();
    final CoverageEngine coverageEngine = currentSuite.getCoverageEngine();
    final ExportToHTMLDialog dialog = coverageEngine.createGenerateReportDialog(project, dataContext, currentSuite);
    dialog.reset();
    if (!dialog.showAndGet()) {
        return;
    }
    dialog.apply();
    coverageEngine.generateReport(project, dataContext, currentSuite);
}
Also used : Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) ExportToHTMLDialog(com.intellij.codeInspection.export.ExportToHTMLDialog) CoverageDataManager(com.intellij.coverage.CoverageDataManager) CoverageEngine(com.intellij.coverage.CoverageEngine) CoverageSuitesBundle(com.intellij.coverage.CoverageSuitesBundle)

Example 2 with CoverageSuitesBundle

use of com.intellij.coverage.CoverageSuitesBundle in project intellij-community by JetBrains.

the class GenerateCoverageReportAction method update.

public void update(final AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();
    final Presentation presentation = e.getPresentation();
    presentation.setEnabled(false);
    presentation.setVisible(false);
    final Project project = e.getProject();
    if (project != null) {
        final CoverageSuitesBundle currentSuite = CoverageDataManager.getInstance(project).getCurrentSuitesBundle();
        if (currentSuite != null) {
            final CoverageEngine coverageEngine = currentSuite.getCoverageEngine();
            if (coverageEngine.isReportGenerationAvailable(project, dataContext, currentSuite)) {
                presentation.setEnabled(true);
                presentation.setVisible(true);
            }
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) Presentation(com.intellij.openapi.actionSystem.Presentation) CoverageEngine(com.intellij.coverage.CoverageEngine) CoverageSuitesBundle(com.intellij.coverage.CoverageSuitesBundle)

Example 3 with CoverageSuitesBundle

use of com.intellij.coverage.CoverageSuitesBundle in project intellij-community by JetBrains.

the class ShowCoveringTestsAction method getTraceFiles.

@Nullable
private static File[] getTraceFiles(Project project) {
    final CoverageSuitesBundle currentSuite = CoverageDataManager.getInstance(project).getCurrentSuitesBundle();
    if (currentSuite == null)
        return null;
    final List<File> files = new ArrayList<>();
    for (CoverageSuite coverageSuite : currentSuite.getSuites()) {
        final String filePath = coverageSuite.getCoverageDataFileName();
        final String dirName = FileUtil.getNameWithoutExtension(new File(filePath).getName());
        final File parentDir = new File(filePath).getParentFile();
        final File tracesDir = new File(parentDir, dirName);
        final File[] suiteFiles = tracesDir.listFiles();
        if (suiteFiles != null) {
            Collections.addAll(files, suiteFiles);
        }
    }
    return files.isEmpty() ? null : files.toArray(new File[files.size()]);
}
Also used : CoverageSuite(com.intellij.coverage.CoverageSuite) File(java.io.File) CoverageSuitesBundle(com.intellij.coverage.CoverageSuitesBundle) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with CoverageSuitesBundle

use of com.intellij.coverage.CoverageSuitesBundle in project intellij-community by JetBrains.

the class TrackCoverageAction method selectSubCoverage.

private void selectSubCoverage() {
    final CoverageDataManager coverageDataManager = CoverageDataManager.getInstance(myProperties.getProject());
    final CoverageSuitesBundle currentSuite = coverageDataManager.getCurrentSuitesBundle();
    if (currentSuite != null) {
        final AbstractTestProxy test = myModel.getTreeView().getSelectedTest();
        List<String> testMethods = new ArrayList<>();
        if (test != null && !test.isInProgress()) {
            final List<? extends AbstractTestProxy> list = test.getAllTests();
            for (AbstractTestProxy proxy : list) {
                final Location location = proxy.getLocation(myProperties.getProject(), myProperties.getScope());
                if (location != null) {
                    final PsiElement element = location.getPsiElement();
                    final String name = currentSuite.getCoverageEngine().getTestMethodName(element, proxy);
                    if (name != null) {
                        testMethods.add(name);
                    }
                }
            }
        }
        coverageDataManager.selectSubCoverage(currentSuite, testMethods);
    }
}
Also used : ArrayList(java.util.ArrayList) AbstractTestProxy(com.intellij.execution.testframework.AbstractTestProxy) CoverageDataManager(com.intellij.coverage.CoverageDataManager) CoverageSuitesBundle(com.intellij.coverage.CoverageSuitesBundle) PsiElement(com.intellij.psi.PsiElement) Location(com.intellij.execution.Location)

Example 5 with CoverageSuitesBundle

use of com.intellij.coverage.CoverageSuitesBundle in project intellij-community by JetBrains.

the class SelectInCoverageView method selectIn.

public void selectIn(final SelectInContext context, final boolean requestFocus) {
    final CoverageSuitesBundle suitesBundle = CoverageDataManager.getInstance(myProject).getCurrentSuitesBundle();
    if (suitesBundle != null) {
        final CoverageViewManager coverageViewManager = CoverageViewManager.getInstance(myProject);
        final CoverageView coverageView = coverageViewManager.getToolwindow(suitesBundle);
        coverageView.select(context.getVirtualFile());
        coverageViewManager.activateToolwindow(coverageView, requestFocus);
    }
}
Also used : CoverageSuitesBundle(com.intellij.coverage.CoverageSuitesBundle)

Aggregations

CoverageSuitesBundle (com.intellij.coverage.CoverageSuitesBundle)7 Project (com.intellij.openapi.project.Project)4 CoverageDataManager (com.intellij.coverage.CoverageDataManager)3 CoverageEngine (com.intellij.coverage.CoverageEngine)2 CoverageSuite (com.intellij.coverage.CoverageSuite)2 DataContext (com.intellij.openapi.actionSystem.DataContext)2 PsiElement (com.intellij.psi.PsiElement)2 File (java.io.File)2 Nullable (org.jetbrains.annotations.Nullable)2 HintManager (com.intellij.codeInsight.hint.HintManager)1 ImplementationViewComponent (com.intellij.codeInsight.hint.ImplementationViewComponent)1 ExportToHTMLDialog (com.intellij.codeInspection.export.ExportToHTMLDialog)1 Location (com.intellij.execution.Location)1 AbstractTestProxy (com.intellij.execution.testframework.AbstractTestProxy)1 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)1 Presentation (com.intellij.openapi.actionSystem.Presentation)1 Logger (com.intellij.openapi.diagnostic.Logger)1 Editor (com.intellij.openapi.editor.Editor)1 ProgressManager (com.intellij.openapi.progress.ProgressManager)1 PanelWithText (com.intellij.openapi.ui.PanelWithText)1