Java Code Examples for org.eclipse.xtext.validation.Issue#getCode()

The following examples show how to use org.eclipse.xtext.validation.Issue#getCode() . 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: LSPIssue.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Copy constructor
 */
public LSPIssue(Issue copyFrom) {
	this();
	if (copyFrom.getOffset() != null)
		this.setOffset(copyFrom.getOffset());
	if (copyFrom.getLength() != null)
		this.setLength(copyFrom.getLength());
	if (copyFrom.getColumn() != null)
		this.setColumn(copyFrom.getColumn());
	if (copyFrom.getLineNumber() != null)
		this.setLineNumber(copyFrom.getLineNumber());
	if (copyFrom.getCode() != null)
		this.setCode(copyFrom.getCode());
	if (copyFrom.getMessage() != null)
		this.setMessage(copyFrom.getMessage());
	if (copyFrom.getUriToProblem() != null)
		this.setUriToProblem(copyFrom.getUriToProblem());
	if (copyFrom.getSeverity() != null)
		this.setSeverity(copyFrom.getSeverity());
	if (copyFrom.getType() != null)
		this.setType(copyFrom.getType());
	if (copyFrom.getData() != null)
		this.setData(copyFrom.getData());
}
 
Example 2
Source File: QuickfixTestBuilder.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public QuickfixTestBuilder assertIssueCodes(final String... issueCodes) {
  QuickfixTestBuilder _xblockexpression = null;
  {
    final Function1<Issue, String> _function = (Issue it) -> {
      return it.getCode();
    };
    this.assertEqual(((List<String>)Conversions.doWrapArray(issueCodes)), IterableExtensions.<Issue, String>map(this.getIssuesAtCaret(), _function));
    _xblockexpression = this;
  }
  return _xblockexpression;
}
 
Example 3
Source File: AbstractIssueCodeFilter.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean includeIssue(final Issue issue) {
  if (issue == null) {
    return false;
  }
  Collection<String> currentSet = getIgnoredCodes();
  if (currentSet == null) {
    return true;
  }
  String issueCode = issue.getCode();
  return issueCode != null && !currentSet.contains(issueCode);
}
 
Example 4
Source File: SuppressWarningsAddModification.java    From sarl with Apache License 2.0 4 votes vote down vote up
/** Create the quick fix if needed.
 *
 * @param provider the quick fix provider.
 * @param issue the issue to fix.
 * @param acceptor the quick fix acceptor.
 */
public static void accept(SARLQuickfixProvider provider, Issue issue, IssueResolutionAcceptor acceptor) {
	final IFile file = provider.getProjectUtil().findFileStorage(issue.getUriToProblem(), false);
	final ResourceSet resourceSet = provider.getResourceSetProvider().get(file.getProject());
	final EObject failingObject;
	try {
		failingObject = resourceSet.getEObject(issue.getUriToProblem(), true);
	} catch (Exception exception) {
		// Something is going really wrong. Must of the time the cause is a major syntax error.
		return;
	}
	XtendAnnotationTarget eObject = EcoreUtil2.getContainerOfType(failingObject, XtendAnnotationTarget.class);
	boolean first = true;
	int relevance = IProposalRelevance.ADD_SUPPRESSWARNINGS;
	while (eObject != null) {
		final URI uri = EcoreUtil2.getNormalizedURI(eObject);
		final SuppressWarningsAddModification modification = new SuppressWarningsAddModification(uri, issue.getCode());
		modification.setIssue(issue);
		modification.setTools(provider);
		final String elementName;
		final QualifiedName name = provider.getQualifiedNameProvider().getFullyQualifiedName(eObject);
		if (name != null) {
			elementName = name.getLastSegment();
		} else if (first) {
			elementName = Messages.AddSuppressWarnings_0;
		} else {
			elementName = null;
		}
		if (elementName != null) {
			acceptor.accept(issue,
					MessageFormat.format(Messages.AddSuppressWarnings_1, elementName),
					MessageFormat.format(Messages.AddSuppressWarnings_2, elementName),
					JavaPluginImages.IMG_OBJS_ANNOTATION_ALT,
					modification,
					relevance);
			--relevance;
		}
		first = false;
		eObject = EcoreUtil2.getContainerOfType(eObject.eContainer(), XtendAnnotationTarget.class);
	}
}
 
Example 5
Source File: IssueMatcher.java    From n4js with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Creates a builder for an issue's code.
 *
 * @see Issue#getCode()
 *
 * @return an instance of {@link StringPropertyMatcher} that can be used to specify the actual expectation
 */
public StringPropertyMatcherBuilder code() {
	return new StringPropertyMatcherBuilder(this, "code", (Issue issue) -> issue.getCode());
}