当前位置: 首页>>代码示例>>Java>>正文


Java Issue类代码示例

本文整理汇总了Java中org.eclipse.xtext.validation.Issue的典型用法代码示例。如果您正苦于以下问题:Java Issue类的具体用法?Java Issue怎么用?Java Issue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Issue类属于org.eclipse.xtext.validation包,在下文中一共展示了Issue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setOverride

import org.eclipse.xtext.validation.Issue; //导入依赖的package包/类
/**
 * Semantic quickfix setting the override flag for a rule.
 *
 * @param issue
 *          the issue
 * @param acceptor
 *          the acceptor
 */
@Fix(FormatJavaValidator.OVERRIDE_MISSING_CODE)
public void setOverride(final Issue issue, final IssueResolutionAcceptor acceptor) {
  acceptor.accept(issue, "Set override", "Set override flag.", null, new IModification() {
    @Override
    public void apply(final IModificationContext context) throws BadLocationException {
      context.getXtextDocument().modify(new IUnitOfWork<Void, XtextResource>() {
        @Override
        public java.lang.Void exec(final XtextResource state) {
          Rule rule = (Rule) state.getEObject(issue.getUriToProblem().fragment());
          rule.setOverride(true);
          return null;
        }
      });
    }
  });
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:25,代码来源:FormatQuickfixProvider.java

示例2: getLanguage

import org.eclipse.xtext.validation.Issue; //导入依赖的package包/类
/**
 * Gets the language for the given object.
 *
 * @param context
 *          object
 * @return the language the corresponding resource was parsed from, may be {@code null}
 */
private String getLanguage(final Object context) {
  if (context instanceof EObject) {
    Resource resource = ((EObject) context).eResource();
    if (resource instanceof LazyLinkingResource) {
      return ((LazyLinkingResource) resource).getLanguageName();
    }
  } else if (context instanceof Issue) {
    URI uri = ((Issue) context).getUriToProblem();
    if (uri != null) {
      Registry registry = IResourceServiceProvider.Registry.INSTANCE;
      IResourceServiceProvider resourceServiceProvider = registry.getResourceServiceProvider(uri);
      if (resourceServiceProvider != null) {
        return resourceServiceProvider.get(Injector.class).getInstance(Key.get(String.class, Names.named(Constants.LANGUAGE_NAME)));
      } else {
        LOGGER.error("Could not fetch a ResourceServiceProvider for URI: " + uri); //$NON-NLS-1$
      }
    } else {
      LOGGER.warn("Could not fetch eResource from issue: URI to problem is null"); //$NON-NLS-1$
    }
  }

  return null;
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:31,代码来源:CheckConfigurationStoreService.java

示例3: resolutionsFor

import org.eclipse.xtext.validation.Issue; //导入依赖的package包/类
/**
 * Finds all resolutions for issues with a specific issue code.
 *
 * @param issueCode
 *          to find resolutions for, may be {@code null}
 * @param quickfixLabel
 *          to find resolutions for, may be {@code null}
 * @return {@link List} of resolutions for issues with a specific code
 */
private List<IssueResolution> resolutionsFor(final String issueCode, final String quickfixLabel) {
  final List<IssueResolution> resolutions = new ArrayList<IssueResolution>();

  for (final Issue issue : issuesWith(issueCode)) {
    UiThreadDispatcher.dispatchAndWait(new Runnable() {
      @Override
      public void run() {
        if (quickfixLabel == null) {
          resolutions.addAll(getIssueResolutionProvider().getResolutions(issue));
        } else {
          for (IssueResolution r : getIssueResolutionProvider().getResolutions(issue)) {
            if (quickfixLabel.equals(r.getLabel())) {
              resolutions.add(r);
            }
          }
        }
      }
    });
  }

  return resolutions;
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:32,代码来源:AbstractQuickFixTest.java

示例4: matches

import org.eclipse.xtext.validation.Issue; //导入依赖的package包/类
@Override
public boolean matches(Issue issue) {
	URI actualValue = getActualValue.apply(issue);
	if (actualValue == null)
		return false;

	List<String> actualSegments = actualValue.segmentsList();
	List<String> expectedSegments = expectedPattern.segmentsList();

	switch (mode) {
	case StartsWith:
		return Collections.indexOfSubList(actualSegments, expectedSegments) == 0;
	case EndsWith:
		return Collections.lastIndexOfSubList(actualSegments, expectedSegments) == actualSegments.size()
				- expectedSegments.size();
	case Equals:
		return actualSegments.equals(expectedSegments);
	}

	throw new IllegalStateException("Unknown URI property matching mode: " + mode);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:22,代码来源:URIPropertyMatcher.java

示例5: explainMismatch

import org.eclipse.xtext.validation.Issue; //导入依赖的package包/类
@Override
protected String explainMismatch(Issue issue) {
	URI actualValue = getActualValue.apply(issue);
	if (actualValue == null)
		return "Actual value is null";

	switch (mode) {
	case StartsWith:
		return "'" + expectedPattern + "' is not a prefix of value '" + actualValue + "'";
	case EndsWith:
		return "'" + expectedPattern + "' is not a suffix of value '" + actualValue + "'";
	case Equals:
		return "Value '" + actualValue + "' is not equal to expected value'"
				+ expectedPattern + "'";
	}

	throw new IllegalStateException("Unknown URI property matching mode: " + mode);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:19,代码来源:URIPropertyMatcher.java

示例6: matchesExactly

import org.eclipse.xtext.validation.Issue; //导入依赖的package包/类
/**
 * Matches the expectations in the added issues matchers against the given issues.
 *
 * @param issues
 *            the issues to match the expectations against
 * @param messages
 *            if this parameter is not <code>null</code>, this method will add an explanatory message for each
 *            mismatch
 * @return <code>true</code> if and only if every expectation was matched against an issue and every issue in the
 *         given collection was matched by an expectation
 */
public boolean matchesExactly(Collection<Issue> issues, List<String> messages) {
	Collection<Issue> issueCopy = new LinkedList<>(issues);
	Collection<IssueMatcher> matcherCopy = new LinkedList<>(issueMatchers);

	performMatching(issueCopy, matcherCopy, messages);
	if (inverted) {
		if (issueCopy.isEmpty() && matcherCopy.isEmpty()) {
			if (issueMatchers.isEmpty() && messages != null) {
				messages.add("Expected issues, but got nothing");
			} else {
				explainIssues(issues, messages, inverted);
				explainExpectations(issueMatchers, messages, inverted);
			}
			return false;
		}
	} else {
		if (!issueCopy.isEmpty() || !matcherCopy.isEmpty()) {
			explainIssues(issueCopy, messages, inverted);
			explainExpectations(matcherCopy, messages, inverted);
			return false;
		}
	}
	return true;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:36,代码来源:IssueExpectations.java

示例7: matchesAllExpectations

import org.eclipse.xtext.validation.Issue; //导入依赖的package包/类
/**
 * Matches the expectations in the added issues matchers against the given issues.
 *
 * @param issues
 *            the issues to match the expectations against
 * @param messages
 *            if this parameter is not <code>null</code>, this method will add an explanatory message for each
 *            mismatch
 * @return <code>true</code> if and only if every expectation was matched against an issue
 */
public boolean matchesAllExpectations(Collection<Issue> issues, List<String> messages) {
	Collection<Issue> issueCopy = new LinkedList<>(issues);
	Collection<IssueMatcher> matcherCopy = new LinkedList<>(issueMatchers);

	performMatching(issueCopy, matcherCopy, messages);
	if (inverted) {
		if (matcherCopy.isEmpty()) {
			explainExpectations(issueMatchers, messages, inverted);
			return false;
		}
	} else {
		if (!matcherCopy.isEmpty()) {
			explainExpectations(matcherCopy, messages, inverted);
			return false;
		}
	}
	return false;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:29,代码来源:IssueExpectations.java

示例8: matchesAllIssues

import org.eclipse.xtext.validation.Issue; //导入依赖的package包/类
/**
 * Matches the expectations in the added issues matchers against the given issues.
 *
 * @param issues
 *            the issues to match the expectations against
 * @param messages
 *            if this parameter is not <code>null</code>, this method will add an explanatory message for each
 *            mismatch
 * @return <code>true</code> if and only if every issue in the given collection was matched by an expectation
 */
public boolean matchesAllIssues(Collection<Issue> issues, List<String> messages) {
	Collection<Issue> issueCopy = new LinkedList<>(issues);
	Collection<IssueMatcher> matcherCopy = new LinkedList<>(issueMatchers);

	performMatching(issueCopy, matcherCopy, messages);
	if (inverted) {
		if (issueCopy.isEmpty()) {
			explainIssues(issues, messages, inverted);
			return false;
		}
	} else {
		if (!issueCopy.isEmpty()) {
			explainIssues(issueCopy, messages, inverted);
			return false;
		}
	}
	return true;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:29,代码来源:IssueExpectations.java

示例9: performMatching

import org.eclipse.xtext.validation.Issue; //导入依赖的package包/类
private void performMatching(Collection<Issue> issues, Collection<IssueMatcher> matchers, List<String> messages) {
	Iterator<Issue> issueIt = issues.iterator();
	while (issueIt.hasNext() && !matchers.isEmpty()) {
		Issue issue = issueIt.next();

		Iterator<IssueMatcher> matcherIt = matchers.iterator();
		while (matcherIt.hasNext()) {
			IssueMatcher matcher = matcherIt.next();
			if (matcher.matches(issue)) {
				issueIt.remove();
				matcherIt.remove();
				break;
			} else if (messages != null) {
				messages.addAll(matcher.explainMismatch(issue));
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:19,代码来源:IssueExpectations.java

示例10: explainMismatch

import org.eclipse.xtext.validation.Issue; //导入依赖的package包/类
@Override
protected String explainMismatch(Issue issue) {
	String actualValue = safeGetValue(getActualValue.apply(issue));
	switch (mode) {
	case StartsWith:
		return "'" + expectedPattern + "' is not a prefix of value '" + actualValue + "'";
	case EndsWith:
		return "'" + expectedPattern + "' is not a suffix of value '" + actualValue + "'";
	case Equals:
		return "Value '" + actualValue + "' is not equal to expected value'"
				+ expectedPattern + "'";
	}

	// This should never happen lest we extended the enum without adding a case above!
	throw new IllegalStateException("Unknown string property matching mode: " + mode);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:17,代码来源:StringPropertyMatcher.java

示例11: quickFixList

import org.eclipse.xtext.validation.Issue; //导入依赖的package包/类
/**
 * Example: {@code // XPECT quickFixList  at 'a.<|>method' --> 'import A','do other things' }
 *
 * @param expectation
 *            comma separated strings, which are proposed as quick fix
 * @param resource
 *            injected xtext-file
 * @param offset
 *            cursor position at '<|>'
 * @param checkType
 *            'display': verify list of provided proposals comparing their user-displayed strings.
 * @param selected
 *            which proposal to pick
 * @param mode
 *            modus of operation
 * @param offset2issue
 *            mapping of offset(!) to issues.
 * @throws Exception
 *             if failing
 */
@Xpect
@ParameterParser(syntax = "('at' (arg2=STRING (arg3=ID  (arg4=STRING)?  (arg5=ID)? )? )? )?")
@ConsumedIssues({ Severity.INFO, Severity.ERROR, Severity.WARNING })
public void quickFixList(
		@CommaSeparatedValuesExpectation(quoted = true, ordered = true) ICommaSeparatedValuesExpectation expectation, // arg0
		@ThisResource XtextResource resource, // arg1
		RegionWithCursor offset, // arg2
		String checkType, // arg3
		String selected, // arg4
		String mode, // arg5
		@IssuesByLine Multimap<Integer, Issue> offset2issue) throws Exception {

	List<IssueResolution> resolutions = collectAllResolutions(resource, offset, offset2issue);

	List<String> resolutionNames = Lists.newArrayList();
	for (IssueResolution resolution : resolutions) {
		resolutionNames.add(resolution.getLabel());
	}

	expectation.assertEquals(resolutionNames);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:42,代码来源:QuickFixXpectMethod.java

示例12: collectAllResolutions

import org.eclipse.xtext.validation.Issue; //导入依赖的package包/类
/**
 * CollectAll resolutions under the cursor at offset.
 *
 */
List<IssueResolution> collectAllResolutions(XtextResource resource, RegionWithCursor offset,
		Multimap<Integer, Issue> offset2issue) {

	EObject script = resource.getContents().get(0);
	ICompositeNode scriptNode = NodeModelUtils.getNode(script);
	ILeafNode offsetNode = NodeModelUtils.findLeafNodeAtOffset(scriptNode, offset.getGlobalCursorOffset());
	int offStartLine = offsetNode.getTotalStartLine();
	List<Issue> allIssues = QuickFixTestHelper.extractAllIssuesInLine(offStartLine, offset2issue);

	List<IssueResolution> resolutions = Lists.newArrayList();

	for (Issue issue : allIssues) {
		if (issue.getLineNumber() == offsetNode.getStartLine()
				&& issue.getLineNumber() <= offsetNode.getEndLine()) {
			Display.getDefault().syncExec(() -> resolutions.addAll(quickfixProvider.getResolutions(issue)));
		}
	}
	return resolutions;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:24,代码来源:QuickFixXpectMethod.java

示例13: registerErrors

import org.eclipse.xtext.validation.Issue; //导入依赖的package包/类
private boolean registerErrors(Resource dep, StringBuilder errorResult) {
	boolean hasErrors = false;
	List<Issue> issues = resourceValidator.validate(dep, CheckMode.ALL, CancelIndicator.NullImpl);
	List<Issue> errorIssues = new ArrayList<>();
	for (Issue issue : issues) {
		if (Severity.ERROR == issue.getSeverity()) {
			errorIssues.add(issue);
		}
	}
	hasErrors = !errorIssues.isEmpty();
	if (hasErrors) {
		errorResult.append("Couldn't compile resource " + dep.getURI() + " because it contains errors: ");
		for (Issue errorIssue : errorIssues) {
			errorResult
					.append(nl + errorIssue.getMessage() + " at line " + errorIssue.getLineNumber());
		}
	}
	return hasErrors;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:XpectN4JSES5TranspilerHelper.java

示例14: addMarkers

import org.eclipse.xtext.validation.Issue; //导入依赖的package包/类
private void addMarkers(IFile file, Resource resource, CheckMode mode, IProgressMonitor monitor)
		throws OperationCanceledException {
	try {
		List<Issue> list = getValidator(resource).validate(resource, mode, getCancelIndicator(monitor));
		if (monitor.isCanceled()) {
			throw new OperationCanceledException();
		}
		deleteMarkers(file, mode, monitor);
		if (monitor.isCanceled()) {
			throw new OperationCanceledException();
		}
		createMarkers(file, list, getMarkerCreator(resource), getMarkerTypeProvider(resource));
	} catch (OperationCanceledError error) {
		throw error.getWrapped();
	} catch (CoreException e) {
		LOGGER.error(e.getMessage(), e);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:19,代码来源:ResourceUIValidatorExtension.java

示例15: validate

import org.eclipse.xtext.validation.Issue; //导入依赖的package包/类
/**
 * Don't validate the inferred module since all validation information should be available on the AST elements.
 */
@Override
protected void validate(Resource resource, CheckMode mode, CancelIndicator cancelIndicator,
		IAcceptor<Issue> acceptor) {
	operationCanceledManager.checkCanceled(cancelIndicator);
	if (n4jsCore.isNoValidate(resource.getURI())) {
		return;
	}
	List<EObject> contents = resource.getContents();
	if (!contents.isEmpty()) {
		EObject firstElement = contents.get(0);
		// // Mark the scoping as sealed. (No other usage-flags should be set for import-declarations.)
		// if (firstElement instanceof Script) {
		// ((Script) firstElement).setFlaggedBound(true);
		// }
		validate(resource, firstElement, mode, cancelIndicator, acceptor);

		// UtilN4.takeSnapshotInGraphView("post validation", resource);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:23,代码来源:N4JSResourceValidator.java


注:本文中的org.eclipse.xtext.validation.Issue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。