forked from phoedos/pmd
Merge pull request #1582 from oowekyala/designer-exception-noise
[ui] Reduce event log noise in designer
This commit is contained in:
@ -4,11 +4,17 @@
|
||||
|
||||
package net.sourceforge.pmd.util.fxdesigner;
|
||||
|
||||
import static net.sourceforge.pmd.util.fxdesigner.model.LogEntry.Category.PARSE_EXCEPTION;
|
||||
import static net.sourceforge.pmd.util.fxdesigner.model.LogEntry.Category.PARSE_OK;
|
||||
import static net.sourceforge.pmd.util.fxdesigner.model.LogEntry.Category.XPATH_EVALUATION_EXCEPTION;
|
||||
import static net.sourceforge.pmd.util.fxdesigner.model.LogEntry.Category.XPATH_OK;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -88,16 +94,21 @@ public class EventLogController extends AbstractController {
|
||||
});
|
||||
|
||||
EventStream<LogEntry> onlyParseException = designerRoot.getLogger().getLog()
|
||||
.filter(x -> x.getCategory() == Category.PARSE_EXCEPTION)
|
||||
.successionEnds(PARSE_EXCEPTION_DELAY);
|
||||
.filter(x -> x.getCategory() == PARSE_EXCEPTION || x.getCategory() == PARSE_OK)
|
||||
.successionEnds(PARSE_EXCEPTION_DELAY)
|
||||
// don't output anything when the last state recorded was OK
|
||||
.filter(x -> x.getCategory() != PARSE_OK);
|
||||
|
||||
EventStream<LogEntry> onlyXPathException = designerRoot.getLogger().getLog()
|
||||
.filter(x -> x.getCategory() == Category.XPATH_EVALUATION_EXCEPTION)
|
||||
.successionEnds(PARSE_EXCEPTION_DELAY);
|
||||
.filter(x -> x.getCategory() == XPATH_EVALUATION_EXCEPTION || x.getCategory() == XPATH_OK)
|
||||
.successionEnds(PARSE_EXCEPTION_DELAY)
|
||||
// don't output anything when the last state recorded was OK
|
||||
.filter(x -> x.getCategory() != XPATH_OK);
|
||||
|
||||
EnumSet<Category> otherExceptionSet = EnumSet.complementOf(EnumSet.of(PARSE_EXCEPTION, XPATH_EVALUATION_EXCEPTION, PARSE_OK, XPATH_OK));
|
||||
|
||||
EventStream<LogEntry> otherExceptions = designerRoot.getLogger().getLog()
|
||||
.filter(x -> x.getCategory() != Category.PARSE_EXCEPTION)
|
||||
.filter(y -> y.getCategory() != Category.XPATH_EVALUATION_EXCEPTION);
|
||||
.filter(x -> otherExceptionSet.contains(x.getCategory()));
|
||||
|
||||
EventStreams.merge(onlyParseException, otherExceptions, onlyXPathException)
|
||||
.subscribe(t -> eventLogTableView.getItems().add(t));
|
||||
|
@ -256,6 +256,8 @@ public class XPathPanelController extends AbstractController {
|
||||
xpathResultListView.setItems(results.stream().map(parent::wrapNode).collect(Collectors.toCollection(LiveArrayList::new)));
|
||||
parent.highlightXPathResults(results);
|
||||
violationsTitledPane.setText("Matched nodes\t(" + results.size() + ")");
|
||||
// Notify that everything went OK so we can avoid logging very recent exceptions
|
||||
designerRoot.getLogger().logEvent(new LogEntry(null, Category.XPATH_OK));
|
||||
} catch (XPathEvaluationException e) {
|
||||
invalidateResults(true);
|
||||
designerRoot.getLogger().logEvent(new LogEntry(e, Category.XPATH_EVALUATION_EXCEPTION));
|
||||
|
@ -104,7 +104,7 @@ public class ASTManager {
|
||||
try {
|
||||
languageVersionHandler.getQualifiedNameResolutionFacade(classLoader).start(node);
|
||||
} catch (Exception e) {
|
||||
designerRoot.getLogger().logEvent(new LogEntry(e, Category.QUALIFIED_NAME_RESOLUTION_EXCEPTION));
|
||||
designerRoot.getLogger().logEvent(new LogEntry(e, Category.QNAME_RESOLUTION_EXCEPTION));
|
||||
}
|
||||
|
||||
try {
|
||||
@ -116,6 +116,10 @@ public class ASTManager {
|
||||
compilationUnit.setValue(node);
|
||||
lastValidSource = source;
|
||||
lastLanguageVersion = getLanguageVersion();
|
||||
|
||||
// Notify that the parse went OK so we can avoid logging very recent exceptions
|
||||
designerRoot.getLogger().logEvent(new LogEntry(null, Category.PARSE_OK));
|
||||
|
||||
return getCompilationUnit();
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class LogEntry {
|
||||
|
||||
|
||||
public String getStackTrace() {
|
||||
return ExceptionUtils.getStackTrace(throwable);
|
||||
return throwable == null ? "" : ExceptionUtils.getStackTrace(throwable);
|
||||
}
|
||||
|
||||
|
||||
@ -56,10 +56,15 @@ public class LogEntry {
|
||||
public enum Category {
|
||||
PARSE_EXCEPTION("Parse exception"),
|
||||
TYPERESOLUTION_EXCEPTION("Type resolution exception"),
|
||||
QUALIFIED_NAME_RESOLUTION_EXCEPTION("Qualified name resolution exception"),
|
||||
QNAME_RESOLUTION_EXCEPTION("Qualified name resolution exception"),
|
||||
SYMBOL_FACADE_EXCEPTION("Symbol façade exception"),
|
||||
XPATH_EVALUATION_EXCEPTION("XPath evaluation exception"),
|
||||
OTHER("Other");
|
||||
OTHER("Other"),
|
||||
|
||||
// These are "flag" categories that signal that previous exceptions
|
||||
// thrown during code or XPath edition may be discarded as uninteresting
|
||||
PARSE_OK("Parsing success"),
|
||||
XPATH_OK("XPath evaluation success");
|
||||
|
||||
public final String name;
|
||||
|
||||
|
Reference in New Issue
Block a user