public void add(Diagnostic diagnostic) { if (diagnostic == null) return; List<Diagnostic> kids = diagnostic.getChildren(); if (!kids.isEmpty()) { for (Diagnostic kid : kids) add(kid); } else { List<?> objects = diagnostic.getData(); CSTNode cstNode = null; if (!objects.isEmpty()) { Object object = objects.get(0); if (object != null) { if (environment != null) cstNode = environment.getASTMapping(object); else if (object instanceof CSTNode) cstNode = (CSTNode) object; } } int startOffset = cstNode != null ? cstNode.getStartOffset() : 0; int endOffset = cstNode != null ? cstNode.getEndOffset() : 0; Severity problemSeverity = Severity.INFO; if (diagnostic.getSeverity() >= Diagnostic.ERROR) problemSeverity = Severity.ERROR; else if (diagnostic.getSeverity() >= Diagnostic.WARNING) problemSeverity = Severity.WARNING; String problemMessage = diagnostic.getMessage(); String problemContext = diagnostic.getSource(); handleProblem(problemSeverity, problemMessage, problemContext, startOffset, endOffset); } }
protected Diagnostic findProblem(Diagnostic diagnostic, EObject target) { if (ExpressionsValidator.DIAGNOSTIC_SOURCE.equals(diagnostic.getSource()) && (diagnostic.getSeverity() != Diagnostic.OK) && diagnostic.getData().contains(target)) { return diagnostic; } for (Diagnostic child : diagnostic.getChildren()) { Diagnostic result = findProblem(child, target); if (result != null) { return result; } } return null; }