Java 类org.eclipse.xtext.linking.impl.XtextLinkingDiagnostic 实例源码

项目:n4js    文件:ErrorAwareLinkingService.java   
/**
 * Add the error to the resource of the given {@code context} if it does support validation.
 *
 * @param context
 *            the context object that caused the error.
 * @param node
 *            the error location.
 * @param error
 *            the actual error description.
 */
protected void addError(EObject context, INode node, IEObjectDescriptionWithError error) {
    N4JSResource resource = (N4JSResource) context.eResource();
    if (resource.isValidationDisabled())
        return;

    List<Diagnostic> list = resource.getErrors();

    // Convert key value user data to String array
    String[] userData = null;
    if (error.getUserDataKeys() != null) {
        ArrayList<String> userDataList = new ArrayList<>(error.getUserDataKeys().length * 2);
        for (String userDataKey : error.getUserDataKeys()) {
            final String userDataValue = error.getUserData(userDataKey);
            if (userDataValue != null) {
                userDataList.add(userDataKey);
                userDataList.add(userDataValue);
            }
        }
        userData = userDataList.toArray(new String[userDataList.size()]);
    }

    Diagnostic diagnostic = new XtextLinkingDiagnostic(node, error.getMessage(), error.getIssueCode(), userData);

    if (!list.contains(diagnostic))
        list.add(diagnostic);
}
项目:xtext-extras    文件:AbstractUnresolvableReferenceWithNode.java   
protected Resource.Diagnostic createDiagnostic(DiagnosticMessage message) {
    Diagnostic diagnostic = new XtextLinkingDiagnostic(
            node, 
            message.getMessage(),
            message.getIssueCode(), message.getIssueData());
    return diagnostic;
}
项目:xtext-core    文件:ReducedXtextResourceValidator.java   
@Override
protected void issueFromXtextResourceDiagnostic(Diagnostic diagnostic, Severity severity,
        IAcceptor<Issue> acceptor) {
    if (diagnostic instanceof XtextSyntaxDiagnostic) {
        super.issueFromXtextResourceDiagnostic(diagnostic, severity, acceptor);
    } else if (diagnostic instanceof XtextLinkingDiagnostic) {
        XtextLinkingDiagnostic linkingDiagnostic = (XtextLinkingDiagnostic) diagnostic;
        if (linkingDiagnostic.getCode().equals(XtextLinkingDiagnosticMessageProvider.UNRESOLVED_RULE)) {
            super.issueFromXtextResourceDiagnostic(diagnostic, severity, acceptor);
        } else if (linkingDiagnostic.getMessage().contains("reference to Grammar")) {
            super.issueFromXtextResourceDiagnostic(diagnostic, severity, acceptor);
        }
    }
}
项目:xtext-core    文件:XtextResourceTest.java   
@Test public void testErrorMarkers() throws Exception {
    String model = "spielplatz 1 {kind(B 1) erwachsener(E 1) familie(F E E B, C)}";
    resource.update(0, 0, model);
    EcoreUtil.resolveAll(resource);
    assertEquals(1, resource.getErrors().size());
    XtextLinkingDiagnostic diag = (XtextLinkingDiagnostic) resource.getErrors().get(0);
    assertEquals(model.indexOf("C)"), diag.getOffset());
    assertEquals(1, diag.getLength());
}
项目:xtext-core    文件:Bug362902Test.java   
@Test public void testNoExceptionUncaught() throws Exception {
    String modelAsString = "Hello max ! Hello peter! favourite peter";
    Model model = (Model)getModelAndExpect(modelAsString, 2);
    EList<Diagnostic> errors = model.eResource().getErrors();
    Diagnostic diagnosticSyntax = errors.get(0);
    Diagnostic diagnosticLinking = errors.get(1);
    assertTrue(diagnosticSyntax instanceof XtextSyntaxDiagnostic);
    assertTrue(diagnosticLinking instanceof XtextLinkingDiagnostic);
}
项目:statecharts    文件:AbstractSCTResource.java   
protected void createDiagnostic(Triple<EObject, EReference, INode> triple) {
    SpecificationElement specificationElement = EcoreUtil2.getContainerOfType(triple.getFirst(),
            SpecificationElement.class);
    DiagnosticMessage message = createDiagnosticMessage(triple);
    Diagnostic diagnostic = new XtextLinkingDiagnostic(triple.getThird(), message.getMessage(),
            message.getIssueCode(), message.getIssueData());
    linkingDiagnostics.put(specificationElement, diagnostic);

}
项目:n4js    文件:ASTStructureDiagnosticProducer.java   
@Override
protected Diagnostic createDiagnostic(DiagnosticMessage message) {
    return new XtextLinkingDiagnostic(getNode(), message.getMessage(), message.getIssueCode(),
            message.getIssueData());
}
项目:xtext-extras    文件:AbstractTypeResolverTest.java   
public Iterable<Resource.Diagnostic> getLinkingAndSyntaxErrors(final Resource resource) {
  final Function1<Resource.Diagnostic, Boolean> _function = (Resource.Diagnostic it) -> {
    return Boolean.valueOf(((it instanceof XtextSyntaxDiagnostic) || (it instanceof XtextLinkingDiagnostic)));
  };
  return IterableExtensions.<Resource.Diagnostic>filter(resource.getErrors(), _function);
}
项目:xtext-core    文件:LazyLinkingResource.java   
protected Diagnostic createDiagnostic(Triple<EObject, EReference, INode> triple, DiagnosticMessage message) {
    Diagnostic diagnostic = new XtextLinkingDiagnostic(triple.getThird(), message.getMessage(),
            message.getIssueCode(), message.getIssueData());
    return diagnostic;
}
项目:sadlos2    文件:ErrorAddingLinkingService.java   
protected void createAndAddDiagnostic(Resource resource, INode node, String message, String commaSeparatedAlternatives) {
    resource.getErrors().add(new XtextLinkingDiagnostic(node, message, AMBIGUOUS_NAME_ISSUE_CODE, commaSeparatedAlternatives));
}
项目:cs2as    文件:CS2ASLinker.java   
protected org.eclipse.xtext.diagnostics.Diagnostic createLinkingDiagnostic(CS2ASDiagnostic diagnostic) {

    return new XtextLinkingDiagnostic(NodeModelUtils.getNode(diagnostic.getCSObject()),
            diagnostic.getMessage(),
            diagnostic.getSource());
}
项目:cs2as    文件:CS2ASLinker.java   
protected org.eclipse.xtext.diagnostics.Diagnostic createLinkingDiagnostic(CS2ASDiagnostic diagnostic) {

    return new XtextLinkingDiagnostic(NodeModelUtils.getNode(diagnostic.getCSObject()),
            diagnostic.getMessage(),
            diagnostic.getSource());
}