public List<Issue> exec(XtextResource resource) throws Exception { if (resource == null || resource.isValidationDisabled()) return Collections.emptyList(); return resourceValidator.validate(resource, getCheckMode(), new CancelIndicator() { public boolean isCanceled() { return monitor.isCanceled(); } }); } });
@Override public void provideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor, CancelIndicator cancelIndicator) { if (resource == null) return; IParseResult parseResult = resource.getParseResult(); if (parseResult == null || parseResult.getRootASTElement() == null) return; if (highlightedIdentifiers == null) { highlightedIdentifiers = initializeHighlightedIdentifiers(); idLengthsToHighlight = new BitSet(); for (String s : highlightedIdentifiers.keySet()) { idLengthsToHighlight.set(s.length()); } } //TODO remove this check when the typesystem works without a java project if (resource.isValidationDisabled()) { highlightSpecialIdentifiers(acceptor, parseResult.getRootNode()); return; } doProvideHighlightingFor(resource, acceptor, cancelIndicator); }
public void addDiagnostics(final Resource resource) { if (resource instanceof XtextResource) { if (((XtextResource) resource).isValidationDisabled()) return; } class DiagnosticAcceptor implements IAcceptor<AbstractDiagnostic> { @Override public void accept(/* @Nullable */ AbstractDiagnostic diagnostic) { if (diagnostic instanceof EObjectDiagnosticImpl) { Severity severity = ((EObjectDiagnosticImpl) diagnostic).getSeverity(); if (severity == Severity.ERROR) { resource.getErrors().add(diagnostic); } else if (severity == Severity.WARNING) { resource.getWarnings().add(diagnostic); } } else { resource.getErrors().add(diagnostic); } } } DiagnosticAcceptor acceptor = new DiagnosticAcceptor(); addQueuedDiagnostics(acceptor); addLinkingDiagnostics(acceptor); addTypeDiagnostics(acceptor); }