org.eclipse.xtext.validation.Issue.IssueImpl Java Examples

The following examples show how to use org.eclipse.xtext.validation.Issue.IssueImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElementIssueProvider.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected void synthesizeIssuesForFollowUpErrors(Resource resource, List<Issue> result) {
	List<EObject> contents = resource.getContents();
	if (!contents.isEmpty()) {
		IResolvedTypes resolvedTypes = typeResolver.resolveTypes(contents.get(0));
		for(ILinkingCandidate linkingCandidate: resolvedTypes.getFollowUpErrors()) {
			XExpression expression = linkingCandidate.getExpression();
			IssueImpl issue = new Issue.IssueImpl();
			issue.setUriToProblem(EcoreUtil.getURI(linkingCandidate.getExpression()));
			if (expression instanceof XAbstractFeatureCall)
				issue.setMessage(((XAbstractFeatureCall) expression).getConcreteSyntaxFeatureName() + " cannot be resolved");
			else {
				List<INode> nodes = NodeModelUtils.findNodesForFeature(expression, XbasePackage.Literals.XCONSTRUCTOR_CALL__CONSTRUCTOR);
				if (nodes.size() >= 1) {
					issue.setMessage(nodes.get(0).getText() + " cannot be resolved");
				}
			}
			result.add(issue);
		}
	}
}
 
Example #2
Source File: DiagnosticConverterImpl.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void convertResourceDiagnostic(Diagnostic diagnostic, Severity severity,	IAcceptor<Issue> acceptor) {
	IssueImpl issue = new Issue.IssueImpl();
	issue.setSyntaxError(diagnostic instanceof XtextSyntaxDiagnostic);
	issue.setSeverity(severity);
	issue.setLineNumber(diagnostic.getLine());
	issue.setColumn(diagnostic.getColumn());
	issue.setMessage(diagnostic.getMessage());

	if (diagnostic instanceof org.eclipse.xtext.diagnostics.Diagnostic) {
		org.eclipse.xtext.diagnostics.Diagnostic xtextDiagnostic = (org.eclipse.xtext.diagnostics.Diagnostic) diagnostic;
		issue.setOffset(xtextDiagnostic.getOffset());
		issue.setLength(xtextDiagnostic.getLength());
	}
	if (diagnostic instanceof AbstractDiagnostic) {
		AbstractDiagnostic castedDiagnostic = (AbstractDiagnostic)diagnostic;
		issue.setUriToProblem(castedDiagnostic.getUriToProblem());
		issue.setCode(castedDiagnostic.getCode());
		issue.setData(castedDiagnostic.getData());
		issue.setLineNumberEnd(castedDiagnostic.getLineEnd());
		issue.setColumnEnd(castedDiagnostic.getColumnEnd());
	}
	issue.setType(CheckType.FAST);
	acceptor.accept(issue);
}
 
Example #3
Source File: DiagnosticIssueConverter.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/** Convert the given diagnostic to an issue. */
public Issue toIssue(URI uri, Diagnostic diagnostic, Optional<Document> document) {
	IssueImpl issue = new Issue.IssueImpl();

	issue.setSeverity(toSeverity(diagnostic.getSeverity()));

	Range range = diagnostic.getRange();
	Position sPos = range.getStart();
	Position ePos = range.getEnd();
	int offSetStart = 0;
	int offSetEnd = 0;
	if (document.isPresent()) {
		offSetStart = document.get().getOffSet(new Position(sPos.getLine() + 1, sPos.getCharacter() + 1));
		offSetEnd = document.get().getOffSet(new Position(ePos.getLine() + 1, ePos.getCharacter() + 1));
	}

	issue.setLineNumber(sPos.getLine() + 1);
	issue.setColumn(sPos.getCharacter() + 1);
	issue.setOffset(offSetStart);
	issue.setLength(offSetEnd - offSetStart);

	issue.setUriToProblem(uri);
	issue.setCode(diagnostic.getCode());
	issue.setType(CheckType.FAST);
	issue.setMessage(diagnostic.getMessage());

	return issue;
}
 
Example #4
Source File: DiagnosticConverterImpl.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void convertValidatorDiagnostic(org.eclipse.emf.common.util.Diagnostic diagnostic,
		IAcceptor<Issue> acceptor) {
	Severity severity = getSeverity(diagnostic);
	if (severity == null)
		return;
	IssueImpl issue = new Issue.IssueImpl();
	issue.setSeverity(severity);
	
	IssueLocation locationData = getLocationData(diagnostic);
	if (locationData != null) {
		issue.setLineNumber(locationData.lineNumber);
		issue.setColumn(locationData.column);
		issue.setOffset(locationData.offset);
		issue.setLength(locationData.length);
		issue.setLineNumberEnd(locationData.lineNumberEnd);
		issue.setColumnEnd(locationData.columnEnd);
	}
	final EObject causer = getCauser(diagnostic);
	if (causer != null)
		issue.setUriToProblem(EcoreUtil.getURI(causer));

	issue.setCode(getIssueCode(diagnostic));
	issue.setType(getIssueType(diagnostic));
	issue.setData(getIssueData(diagnostic));
	
	//		marker.put(IXtextResourceChecker.DIAGNOSTIC_KEY, diagnostic);
	issue.setMessage(diagnostic.getMessage());
	//		marker.put(IMarker.PRIORITY, Integer.valueOf(IMarker.PRIORITY_LOW));
	acceptor.accept(issue);
}
 
Example #5
Source File: StatechartValidationDecorationProvider.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected SCTIssue getSubDiagramIssue(View view) {
	if (SemanticHints.STATE.equals(view.getType())) {
		BooleanValueStyle style = GMFNotationUtil.getBooleanValueStyle(view,
				DiagramPartitioningUtil.INLINE_STYLE);
		if (style == null ? false : !style.isBooleanValue()) {
			EObject element = view.getElement();
			TreeIterator<EObject> eAllContents = element.eAllContents();
			while (eAllContents.hasNext()) {
				EObject next = eAllContents.next();
				if(next instanceof Transition && next.eContainer() == element) {
					eAllContents.prune();
					continue;
				}
				String semanticURI = EcoreUtil.getURI(next).fragment();
				List<SCTIssue> issues = store.getIssues(semanticURI);
				for (final SCTIssue issue : issues) {
					if (Severity.ERROR.equals(issue.getSeverity())) {
						IssueImpl result = new Issue.IssueImpl();
						result.setMessage(SUB_DIAGRAM_ERRORS);
						result.setSeverity(Severity.ERROR);
						return new SCTIssue(result, issue.getSemanticURI());
					}
				}
			}
		}
	}
	return null;
}