use of com.intellij.rt.coverage.data.LineData in project intellij by bazelbuild.
the class BlazeCoverageRunner method fromFileData.
private static LineData[] fromFileData(FileData fileData) {
LineData[] lines = new LineData[maxLineNumber(fileData) + 1];
fileData.lineHits.forEachEntry((line, hits) -> {
LineData newLine = new LineData(line, null);
newLine.setHits(hits);
lines[line] = newLine;
return true;
});
return lines;
}
use of com.intellij.rt.coverage.data.LineData in project intellij-plugins by JetBrains.
the class JstdCoverageEngine method convertClassDataToLineHits.
private static List<CoverageReport.LineHits> convertClassDataToLineHits(@NotNull ClassData classData) {
int lineCount = classData.getLines().length;
List<CoverageReport.LineHits> lineHitsList = ContainerUtil.newArrayListWithCapacity(lineCount);
for (int lineInd = 0; lineInd < lineCount; lineInd++) {
LineData lineData = classData.getLineData(lineInd);
if (lineData != null) {
CoverageReport.LineHits lineHits = new CoverageReport.LineHits(lineData.getLineNumber(), lineData.getHits());
lineHitsList.add(lineHits);
}
}
return lineHitsList;
}
use of com.intellij.rt.coverage.data.LineData in project intellij-plugins by JetBrains.
the class JstdCoverageRunner method readProjectData.
@NotNull
private static ProjectData readProjectData(@NotNull File dataFile) throws IOException {
CoverageReport report = CoverageSerializationUtils.readLCOV(dataFile);
ProjectData projectData = new ProjectData();
for (Map.Entry<String, List<CoverageReport.LineHits>> entry : report.getInfo().entrySet()) {
String filePath = SimpleCoverageAnnotator.getFilePath(entry.getKey());
ClassData classData = projectData.getOrCreateClassData(filePath);
int max = 0;
List<CoverageReport.LineHits> lineHitsList = entry.getValue();
if (lineHitsList.size() > 0) {
CoverageReport.LineHits lastLineHits = lineHitsList.get(lineHitsList.size() - 1);
max = lastLineHits.getLineNumber();
}
LineData[] lines = new LineData[max + 1];
for (CoverageReport.LineHits lineHits : lineHitsList) {
LineData lineData = new LineData(lineHits.getLineNumber(), null);
lineData.setHits(lineHits.getHits());
lines[lineHits.getLineNumber()] = lineData;
}
classData.setLines(lines);
}
return projectData;
}
use of com.intellij.rt.coverage.data.LineData in project intellij-community by JetBrains.
the class PackageAnnotator method collectClassCoverageInformation.
private void collectClassCoverageInformation(final File classFile, @Nullable final PsiClass psiClass, final PackageCoverageInfo packageCoverageInfo, final ProjectData projectInfo, final Map<String, ClassCoverageInfo> toplevelClassCoverage, final String className, final String toplevelClassSrcFQName) {
final ClassCoverageInfo toplevelClassCoverageInfo = new ClassCoverageInfo();
final ClassData classData = projectInfo.getClassData(className);
if (classData != null && classData.getLines() != null) {
final Object[] lines = classData.getLines();
for (Object l : lines) {
if (l instanceof LineData) {
final LineData lineData = (LineData) l;
if (lineData.getStatus() == LineCoverage.FULL) {
toplevelClassCoverageInfo.fullyCoveredLineCount++;
} else if (lineData.getStatus() == LineCoverage.PARTIAL) {
toplevelClassCoverageInfo.partiallyCoveredLineCount++;
}
toplevelClassCoverageInfo.totalLineCount++;
packageCoverageInfo.totalLineCount++;
}
}
boolean touchedClass = false;
final Collection methodSigs = classData.getMethodSigs();
for (final Object nameAndSig : methodSigs) {
final int covered = classData.getStatus((String) nameAndSig);
if (covered != LineCoverage.NONE) {
touchedClass = true;
}
if (isGeneratedDefaultConstructor(psiClass, (String) nameAndSig)) {
continue;
}
if (covered != LineCoverage.NONE) {
toplevelClassCoverageInfo.coveredMethodCount++;
}
toplevelClassCoverageInfo.totalMethodCount++;
}
if (!methodSigs.isEmpty()) {
if (touchedClass) {
packageCoverageInfo.coveredClassCount++;
}
packageCoverageInfo.totalClassCount++;
packageCoverageInfo.coveredLineCount += toplevelClassCoverageInfo.fullyCoveredLineCount;
packageCoverageInfo.coveredLineCount += toplevelClassCoverageInfo.partiallyCoveredLineCount;
packageCoverageInfo.coveredMethodCount += toplevelClassCoverageInfo.coveredMethodCount;
packageCoverageInfo.totalMethodCount += toplevelClassCoverageInfo.totalMethodCount;
} else {
LOG.debug("Did not find any method signatures in " + classFile.getName());
return;
}
} else {
if (!collectNonCoveredClassInfo(classFile, psiClass, toplevelClassCoverageInfo, packageCoverageInfo)) {
LOG.debug("Did not collect non-covered class info for " + classFile.getName());
return;
}
}
ClassCoverageInfo classCoverageInfo = getOrCreateClassCoverageInfo(toplevelClassCoverage, toplevelClassSrcFQName);
LOG.debug("Adding coverage of " + classFile.getName() + " to top-level class " + toplevelClassSrcFQName);
classCoverageInfo.totalLineCount += toplevelClassCoverageInfo.totalLineCount;
classCoverageInfo.fullyCoveredLineCount += toplevelClassCoverageInfo.fullyCoveredLineCount;
classCoverageInfo.partiallyCoveredLineCount += toplevelClassCoverageInfo.partiallyCoveredLineCount;
classCoverageInfo.totalMethodCount += toplevelClassCoverageInfo.totalMethodCount;
classCoverageInfo.coveredMethodCount += toplevelClassCoverageInfo.coveredMethodCount;
if (toplevelClassCoverageInfo.getCoveredLineCount() > 0) {
classCoverageInfo.coveredClassCount++;
}
}
use of com.intellij.rt.coverage.data.LineData in project intellij-community by JetBrains.
the class CoverageLineMarkerRenderer method createActionsToolbar.
protected JComponent createActionsToolbar(final Editor editor, final int lineNumber) {
final JComponent editorComponent = editor.getComponent();
final DefaultActionGroup group = new DefaultActionGroup();
final GotoPreviousCoveredLineAction prevAction = new GotoPreviousCoveredLineAction(editor, lineNumber);
final GotoNextCoveredLineAction nextAction = new GotoNextCoveredLineAction(editor, lineNumber);
group.add(prevAction);
group.add(nextAction);
prevAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.ALT_MASK | InputEvent.SHIFT_MASK)), editorComponent);
nextAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.ALT_MASK | InputEvent.SHIFT_MASK)), editorComponent);
final LineData lineData = getLineData(lineNumber);
if (myCoverageByTestApplicable) {
group.add(new ShowCoveringTestsAction(myClassName, lineData));
}
final AnAction byteCodeViewAction = ActionManager.getInstance().getAction("ByteCodeViewer");
if (byteCodeViewAction != null) {
group.add(byteCodeViewAction);
}
group.add(new EditCoverageColorsAction(editor, lineNumber));
group.add(new HideCoverageInfoAction());
final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.FILEHISTORY_VIEW_TOOLBAR, group, true);
final JComponent toolbarComponent = toolbar.getComponent();
final Color background = ((EditorEx) editor).getBackgroundColor();
final Color foreground = editor.getColorsScheme().getColor(EditorColors.CARET_COLOR);
toolbarComponent.setBackground(background);
toolbarComponent.setBorder(new ColoredSideBorder(foreground, foreground, lineData == null || lineData.getStatus() == LineCoverage.NONE || mySubCoverageActive ? foreground : null, foreground, 1));
toolbar.updateActionsImmediately();
return toolbarComponent;
}
Aggregations