use of nl.tudelft.watchdog.core.logic.event.eventtypes.staticanalysis.FileWarningSnapshotEvent in project watchdog by TestRoots.
the class MarkupModelListenerTest method generates_file_warning_snapshot_with_correct_line_numbers_when_opening_a_file.
@Test
public void generates_file_warning_snapshot_with_correct_line_numbers_when_opening_a_file() throws Exception {
runForActivePage((page) -> {
IEditorPart editor;
try {
editor = IDE.openEditor(page, this.preExistingTestFile);
} catch (PartInitException e) {
throw new RuntimeException(e);
}
ArgumentCaptor<FileWarningSnapshotEvent> captor = ArgumentCaptor.forClass(FileWarningSnapshotEvent.class);
Mockito.verify(this.trackingEventManager).addEvent(captor.capture());
try {
int[] lineNumbers = captor.getValue().warnings.stream().map(warning -> warning.lineNumber).mapToInt(Integer::intValue).toArray();
assertArrayEquals(lineNumbers, new int[] { 2, 5 });
} finally {
page.closeEditor(editor, false);
}
});
}
use of nl.tudelft.watchdog.core.logic.event.eventtypes.staticanalysis.FileWarningSnapshotEvent in project watchdog by TestRoots.
the class MarkupModelListenerTest method generates_file_warning_snapshot_with_correct_classification_when_opening_a_file.
@Test
public void generates_file_warning_snapshot_with_correct_classification_when_opening_a_file() throws Exception {
runForActivePage((page) -> {
IEditorPart editor;
try {
editor = IDE.openEditor(page, this.preExistingTestFile);
} catch (PartInitException e) {
throw new RuntimeException(e);
}
ArgumentCaptor<FileWarningSnapshotEvent> captor = ArgumentCaptor.forClass(FileWarningSnapshotEvent.class);
Mockito.verify(this.trackingEventManager).addEvent(captor.capture());
try {
String[] classifications = captor.getValue().warnings.stream().map(warning -> warning.type).toArray(String[]::new);
assertArrayEquals(classifications, new String[] { PRE_EXISTING_MARKER_CLASSIFICATION_TYPE, "unknown" });
} finally {
page.closeEditor(editor, false);
}
});
}
use of nl.tudelft.watchdog.core.logic.event.eventtypes.staticanalysis.FileWarningSnapshotEvent in project watchdog by TestRoots.
the class ResourceAndResourceDeltaVisitor method createWarningSnapshotForMarkers.
private void createWarningSnapshotForMarkers(List<MarkerHolder> currentMarkers, Document document) {
List<Warning<String>> warnings = currentMarkers.stream().map(holder -> new Warning<>(StaticAnalysisMessageClassifier.classify(holder.message), holder.lineNumber, DateTime.now().toDate())).collect(Collectors.toList());
this.trackingEventManager.addEvent(new FileWarningSnapshotEvent(document, warnings));
}
use of nl.tudelft.watchdog.core.logic.event.eventtypes.staticanalysis.FileWarningSnapshotEvent in project watchdog by TestRoots.
the class IntelliJMarkupModelListener method processWarningSnapshot.
private void processWarningSnapshot(RangeHighlighter[] highlighters) {
if (highlighters.length == 0) {
return;
}
// markupModel.getAllHighlighters returns a list of RangeHighlighter,
// even though we know they are all instances of RangeHighlighterEx.
// Therefore do an instanceof check and then explicitly cast them
// to use them in the other methods
final Stream<RangeHighlighterEx> rangeHighlighters = Arrays.stream(highlighters).filter(RangeHighlighterEx.class::isInstance).map(RangeHighlighterEx.class::cast);
final List<Warning<String>> warnings = rangeHighlighters.filter(IntelliJMarkupModelListener::isWarningRangeHighlighter).map(rangeHighlighter -> createWarningFromRangeHighlighter(rangeHighlighter, null)).map(IntelliJMarkupModelListener::classifyWarning).collect(Collectors.toList());
this.trackingEventManager.addEvent(new FileWarningSnapshotEvent(this.document.prepareDocument(), warnings));
}
Aggregations