use of com.intellij.coverage.view.DirectoryCoverageViewExtension in project intellij-plugins by JetBrains.
the class KarmaCoverageEngine method createCoverageViewExtension.
@Override
public CoverageViewExtension createCoverageViewExtension(final Project project, final CoverageSuitesBundle suiteBundle, CoverageViewManager.StateBean stateBean) {
return new DirectoryCoverageViewExtension(project, getCoverageAnnotator(project), suiteBundle, stateBean) {
@Override
public AbstractTreeNode createRootNode() {
VirtualFile rootDir = findRootDir(project, suiteBundle);
if (rootDir == null) {
rootDir = myProject.getBaseDir();
}
PsiDirectory psiRootDir = PsiManager.getInstance(myProject).findDirectory(rootDir);
return new CoverageListRootNode(myProject, psiRootDir, mySuitesBundle, myStateBean);
}
};
}
use of com.intellij.coverage.view.DirectoryCoverageViewExtension in project intellij by bazelbuild.
the class BlazeCoverageEngine method createCoverageViewExtension.
@Nullable
@Override
public CoverageViewExtension createCoverageViewExtension(Project project, CoverageSuitesBundle suites, StateBean stateBean) {
WorkspaceRoot root = WorkspaceRoot.fromProjectSafe(project);
if (root == null) {
return null;
}
Set<File> topLevelDirectories = getTopLevelDirectories(suites);
if (topLevelDirectories.isEmpty()) {
return null;
}
CoverageAnnotator annotator = getCoverageAnnotator(project);
return new DirectoryCoverageViewExtension(project, annotator, suites, stateBean) {
private List<AbstractTreeNode> topLevelNodes;
@Override
public AbstractTreeNode createRootNode() {
if (topLevelDirectories.size() == 1) {
File file = topLevelDirectories.iterator().next();
return new CoverageListRootNode(project, resolveFile(project, file), suites, stateBean);
}
return new CoverageListRootNode(project, resolveFile(project, root.directory()), suites, stateBean) {
@Override
public Collection<? extends AbstractTreeNode> getChildren() {
return getRootChildren(this);
}
};
}
@Override
public List<AbstractTreeNode> getChildrenNodes(AbstractTreeNode node) {
if (node instanceof CoverageListRootNode && topLevelDirectories.size() != 1) {
return getRootChildren((CoverageListRootNode) node);
}
return super.getChildrenNodes(node).stream().filter(treeNode -> !isLeaf(treeNode) || getPercentage(0, treeNode) != null).collect(Collectors.toList());
}
private List<AbstractTreeNode> getRootChildren(CoverageListRootNode root) {
if (topLevelNodes == null) {
topLevelNodes = ReadAction.compute(() -> getTopLevelNodes(project, suites, stateBean));
for (AbstractTreeNode node : topLevelNodes) {
node.setParent(root);
}
}
return topLevelNodes;
}
};
}
Aggregations