private String stringRepresentation(Issue issue) { return String.format("[%s] %s", issue.getSeverity().toString(), issue.getMessage()); }
private String stringRepresentation(Issue issue) { return String.format("[%s] %s", issue.getSeverity().toString(), issue.getMessage()); }
public XtextAnnotation(String type, boolean isPersistent, IXtextDocument document, Issue issue, boolean isQuickfixable) { super(type, isPersistent, issue.getMessage()); AnnotationPreference preference= lookup.getAnnotationPreference(this); if (preference != null) this.layer = preference.getPresentationLayer() + 1; else this.layer = IAnnotationAccessExtension.DEFAULT_LAYER + 1; this.document = document; this.issue = issue; this.isQuickfixable = isQuickfixable; }
public ZenModel loadAndValidateModel(URI modelUri) { Resource resource = getResource(modelUri); if (validator != null) { List<Issue> issues = validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl); if (!issues.isEmpty()) { throw new RuntimeException(String.format(errorMessage, issues.get(0).getMessage())); } } else if (!resource.getErrors().isEmpty()) { throw new RuntimeException(String.format(errorMessage, resource.getErrors().get(0).getMessage())); } return (ZenModel) resource.getContents().get(0); }
public void processIssues(List<Issue> issues, IProgressMonitor monitor) { IStatus result = Status.OK_STATUS; StringBuilder messages = new StringBuilder(); for(Issue issue: issues) { if (issue.getSeverity() == Severity.ERROR) { if (messages.length() != 0) messages.append('\n'); messages.append(issue.getMessage()); } } if (messages.length() != 0) { result = createErrorStatus(messages.toString(), null); } final IStatus toBeUpdated = result; getShell().getDisplay().asyncExec(new Runnable() { public void run() { updateStatus(toBeUpdated); } }); } });
/** * @since 2.4 */ protected StringBuilder getIssuesAsString(final EObject model, final Iterable<Issue> issues, StringBuilder result) { for(Issue issue: issues) { EObject eObject = model.eResource().getResourceSet().getEObject(issue.getUriToProblem(), true); result.append(issue.getSeverity()) .append(" (") .append(issue.getCode()) .append(") '") .append(issue.getMessage()) .append("' on ") .append(eObject.eClass().getName()) .append("\n"); } return result; }
private StringBuilder createIssueMessage(Issue issue) { StringBuilder issueBuilder = new StringBuilder("\n"); issueBuilder.append(issue.getSeverity()).append(": \t"); URI uriToProblem = issue.getUriToProblem(); if (uriToProblem != null) { URI resourceUri = uriToProblem.trimFragment(); issueBuilder.append(resourceUri.lastSegment()).append(" - "); if (resourceUri.isFile()) { issueBuilder.append(resourceUri.toFileString()); } } issueBuilder.append("\n").append(issue.getLineNumber()).append(": ").append(issue.getMessage()); return issueBuilder; }
/** * @since 2.8 */ protected StringBuilder doGetIssuesAsString(Resource resource, final Iterable<Issue> issues, StringBuilder result) { for (Issue issue : issues) { URI uri = issue.getUriToProblem(); result.append(issue.getSeverity()); result.append(" ("); result.append(issue.getCode()); result.append(") '"); result.append(issue.getMessage()); result.append("'"); if (uri != null) { EObject eObject = resource.getResourceSet().getEObject(uri, true); result.append(" on "); result.append(eObject.eClass().getName()); } result.append(", offset " + issue.getOffset() + ", length " + issue.getLength()); result.append("\n"); } return result; }
public static PProblem toPProblem(Issue issue) { return new PProblem(issue.getMessage(), issue.getLineNumber(), issue.getColumn()); } }
public ScriptParsingException addValidationIssues(Iterable<Issue> validationErrors) { for (Issue validationError : validationErrors) { this.getErrors().add( new ScriptError(validationError.getMessage(), validationError.getLineNumber(), validationError .getOffset(), validationError.getLength())); } return this; }
public boolean apply(Issue input) { if (Strings.equal(input.getCode(), code) && input.getSeverity()==severity) { EObject object = model.eResource().getResourceSet().getEObject(input.getUriToProblem(), true); if (objectType.isInstance(object)) { for (String messagePart : messageParts) { if (!input.getMessage().toLowerCase().contains(messagePart.toLowerCase())) { return false; } } return true; } } return false; } });
public boolean apply(Issue input) { if (Strings.equal(input.getCode(), code) && input.getSeverity()==severity) { EObject object = model.eResource().getResourceSet().getEObject(input.getUriToProblem(), true); if (objectType.isInstance(object)) { for (String messagePart : messageParts) { if (!input.getMessage().toLowerCase().contains(messagePart.toLowerCase())) { return false; } } return true; } } return false; } });
private void assertIssue(final DomainModel model, final List<Issue> issues, final Severity severity, final String objName, final String message) { for (final Issue issue : issues) { { final EObject issueObj = model.eResource().getResourceSet().getEObject(issue.getUriToProblem(), true); if (((severity.equals(severity) && objName.equals(DddEObjectExtensions.getName(issueObj))) && message.equals(issue.getMessage()))) { return; } } } StringBuilder _asString = DomainDrivenDesignDslValidatorTest.asString(issues); String _plus = ((((((("[" + objName) + "] No issue with severity \'") + severity) + "\' and \'") + message) + "\' found:\n") + _asString); Assert.fail(_plus); }
@Override public boolean apply(Issue input) { if (Strings.equal(input.getCode(), code) && input.getSeverity()==severity) { if ((offset < 0 || offset == input.getOffset()) && (length < 0 || length == input.getLength())) { EObject object = resource.getResourceSet().getEObject(input.getUriToProblem(), true); if (objectType.isInstance(object)) { for (String messagePart : messageParts) { if (!input.getMessage().toLowerCase().contains(messagePart.toLowerCase())) { return false; } } return true; } } } return false; } });
protected Map<Annotation, Position> getAnnotationsToAdd(Multimap<Position, Annotation> positionToAnnotations, List<Issue> issues, IProgressMonitor monitor) { if (monitor.isCanceled()) { return HashBiMap.create(); } Map<Annotation, Position> annotationToPosition = Maps.newHashMapWithExpectedSize(issues.size()); for (Issue issue : issues) { if (monitor.isCanceled()) { return annotationToPosition; } if (isSet(issue.getOffset()) && isSet(issue.getLength()) && issue.getMessage() != null) { String type = lookup.getAnnotationType(EValidator.MARKER, getMarkerSeverity(issue.getSeverity())); boolean isQuickfixable = false; if (issueResolutionProvider instanceof IssueResolutionProviderExtension) { isQuickfixable = ((IssueResolutionProviderExtension)issueResolutionProvider).hasResolutionFor(issue); } else { isQuickfixable = issueResolutionProvider.hasResolutionFor(issue.getCode()); } Annotation annotation = new XtextAnnotation(type, false, xtextDocument, issue, isQuickfixable); if (issue.getOffset() < 0 || issue.getLength() < 0) { LOG.error("Invalid annotation position offset=" + issue.getOffset() + " length = " + issue.getLength()); } Position position = new Position(Math.max(0, issue.getOffset()), Math.max(0, issue.getLength())); annotationToPosition.put(annotation, position); positionToAnnotations.put(position, annotation); } } return annotationToPosition; }
switch (issue.getSeverity()) { case ERROR: issues.addError(issue.getMessage(), issue); break; case WARNING: issues.addWarning(issue.getMessage(), issue); break; case INFO: issues.addInfo(issue.getMessage(), issue); break;
/** Create a message for the issue. * * @param issue the issue. * @return the message. */ protected String createIssueMessage(Issue issue) { final IssueMessageFormatter formatter = getIssueMessageFormatter(); final org.eclipse.emf.common.util.URI uriToProblem = issue.getUriToProblem(); if (formatter != null) { final String message = formatter.format(issue, uriToProblem); if (message != null) { return message; } } if (uriToProblem != null) { final org.eclipse.emf.common.util.URI resourceUri = uriToProblem.trimFragment(); return MessageFormat.format(Messages.SarlBatchCompiler_4, issue.getSeverity(), resourceUri.lastSegment(), resourceUri.isFile() ? resourceUri.toFileString() : "", //$NON-NLS-1$ issue.getLineNumber(), issue.getColumn(), issue.getCode(), issue.getMessage()); } return MessageFormat.format(Messages.SarlBatchCompiler_5, issue.getSeverity(), issue.getLineNumber(), issue.getColumn(), issue.getCode(), issue.getMessage()); }
/** * Compute the validation result for the given document. This method should not be called * directly from the service dispatcher; use {@link #getResult(XtextWebDocumentAccess)} instead * in order to avoid duplicate computations. */ @Override public ValidationResult compute(final IXtextWebDocument it, final CancelIndicator cancelIndicator) { final List<Issue> issues = this.resourceValidator.validate(it.getResource(), CheckMode.ALL, cancelIndicator); final ValidationResult result = new ValidationResult(); final Function1<Issue, Boolean> _function = (Issue it_1) -> { Severity _severity = it_1.getSeverity(); return Boolean.valueOf((!Objects.equal(_severity, Severity.IGNORE))); }; final Consumer<Issue> _function_1 = (Issue issue) -> { List<ValidationResult.Issue> _issues = result.getIssues(); String _message = issue.getMessage(); String _translate = this.translate(issue.getSeverity()); Integer _lineNumber = issue.getLineNumber(); Integer _column = issue.getColumn(); Integer _offset = issue.getOffset(); Integer _length = issue.getLength(); ValidationResult.Issue _issue = new ValidationResult.Issue(_message, _translate, _lineNumber, _column, _offset, _length); _issues.add(_issue); }; IterableExtensions.<Issue>filter(issues, _function).forEach(_function_1); return result; }
public ITreeAppendable generateBodyWithIssues(final ITreeAppendable appendable, final Iterable<Issue> errors) { ITreeAppendable _xblockexpression = null; { appendable.append("{").increaseIndentation().newLine().append("throw new Error(\"Unresolved compilation problems:\""); appendable.increaseIndentation(); final Consumer<Issue> _function = (Issue it) -> { appendable.newLine().append("+ \"\\n").append(this.doConvertToJavaString(it.getMessage())).append("\""); }; errors.forEach(_function); _xblockexpression = appendable.append(");").decreaseIndentation().decreaseIndentation().newLine().append("}"); } return _xblockexpression; }
/** * @since 2.0 */ protected void setMarkerAttributes(Issue issue, IResource resource, IMarker marker) throws CoreException { String lineNR = ""; if (issue.getLineNumber() != null) { lineNR = "line: " + issue.getLineNumber() + " "; } marker.setAttribute(IMarker.LOCATION, lineNR + resource.getFullPath().toString()); marker.setAttribute(Issue.CODE_KEY, issue.getCode()); marker.setAttribute(IMarker.SEVERITY, getSeverity(issue)); marker.setAttribute(IMarker.CHAR_START, issue.getOffset()); if(issue.getOffset() != null && issue.getLength() != null) marker.setAttribute(IMarker.CHAR_END, issue.getOffset()+issue.getLength()); marker.setAttribute(IMarker.LINE_NUMBER, issue.getLineNumber()); marker.setAttribute(IMarker.MESSAGE, issue.getMessage()); if (issue.getUriToProblem()!=null) marker.setAttribute(Issue.URI_KEY, issue.getUriToProblem().toString()); if(issue.getData() != null && issue.getData().length > 0) { marker.setAttribute(Issue.DATA_KEY, Strings.pack(issue.getData())); } if (resolutionProvider != null && resolutionProvider.hasResolutionFor(issue.getCode())) { marker.setAttribute(FIXABLE_KEY, true); } }