use of nl.tudelft.watchdog.core.logic.ui.listeners.staticanalysis.Warning 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.ui.listeners.staticanalysis.Warning in project watchdog by TestRoots.
the class MarkerBackTrackingAlgorithm method traverseMemoizationTable.
/**
* Traverse the memoized matrix and based on the length of the path
* either invoke addCreatedWarning or addRemovedWarning as defined in
* {@link CoreMarkupModelListener}.
*
* @param row The current row in the matrix
* @param column The current column in the matrix
*/
void traverseMemoizationTable(int row, int column) {
// The markers at this position are equal, just continue traversing through the matrix
if (row > 0 && column > 0 && oldMarkers.get(row - 1).equals(currentMarkers.get(column - 1))) {
traverseMemoizationTable(row - 1, column - 1);
// The markers are not the same. In this case, the length to traverse by choosing the column
// is longer, which means that a new marker was added (as the column is larger) in currentMarkers
} else if (column > 0 && (row == 0 || memoization[row][column - 1] >= memoization[row - 1][column])) {
MarkerHolder warning = currentMarkers.get(column - 1);
this.createdWarningTypes.add(new Warning<>(warning.message, warning.lineNumber, DateTime.now().toDate()));
traverseMemoizationTable(row, column - 1);
// In this case, the row length is lower, which means that the oldMarkers was longer at this point
// Therefore it is a removed warning
} else if (row > 0 && (column == 0 || memoization[row][column - 1] < memoization[row - 1][column])) {
MarkerHolder warning = oldMarkers.get(row - 1);
DateTime now = DateTime.now();
this.removedWarningTypes.add(new Warning<>(warning.message, warning.lineNumber, now.toDate(), Seconds.secondsBetween(warning.warningCreationTime, now).getSeconds()));
traverseMemoizationTable(row - 1, column);
}
// In this case we are at the end of the matrix (0th row/column), so nothing happens
}
use of nl.tudelft.watchdog.core.logic.ui.listeners.staticanalysis.Warning 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));
}
use of nl.tudelft.watchdog.core.logic.ui.listeners.staticanalysis.Warning in project watchdog by TestRoots.
the class IntelliJMarkupModelListener method createWarningFromRangeHighlighter.
@NotNull
private Warning<RangeHighlighterEx> createWarningFromRangeHighlighter(@NotNull RangeHighlighterEx rangeHighlighterEx, DateTime creationTime) {
final DateTime now = DateTime.now();
int seconds;
if (creationTime == null) {
seconds = -1;
} else {
seconds = Seconds.secondsBetween(creationTime, now).getSeconds();
}
return new Warning<>(rangeHighlighterEx, getLineNumberForHighlighter(rangeHighlighterEx), now.toDate(), seconds);
}
Aggregations