Search in sources :

Example 6 with DiagnosticMessage

use of org.eclipse.xtext.diagnostics.DiagnosticMessage in project xtext-xtend by eclipse.

the class Linker method afterCreateAndSetProxy.

@Override
protected void afterCreateAndSetProxy(EObject obj, INode node, EReference eRef, CrossReference xref, IDiagnosticProducer diagnosticProducer) {
    AbstractElement terminal = xref.getTerminal();
    if (!(terminal instanceof RuleCall)) {
        throw new IllegalArgumentException(String.valueOf(xref));
    }
    AbstractRule rule = ((RuleCall) terminal).getRule();
    try {
        String tokenText = NodeModelUtils.getTokenText(node);
        valueConverterService.toValue(tokenText, rule.getName(), node);
    } catch (ValueConverterException e) {
        diagnosticProducer.addDiagnostic(new DiagnosticMessage(e.getMessage(), Severity.ERROR, Diagnostic.SYNTAX_DIAGNOSTIC, Strings.EMPTY_ARRAY));
    }
}
Also used : DiagnosticMessage(org.eclipse.xtext.diagnostics.DiagnosticMessage) AbstractElement(org.eclipse.xtext.AbstractElement) ValueConverterException(org.eclipse.xtext.conversion.ValueConverterException) AbstractRule(org.eclipse.xtext.AbstractRule) RuleCall(org.eclipse.xtext.RuleCall)

Example 7 with DiagnosticMessage

use of org.eclipse.xtext.diagnostics.DiagnosticMessage in project xtext-core by eclipse.

the class LinkingDiagnosticMessageProvider method getUnresolvedProxyMessage.

@Override
public DiagnosticMessage getUnresolvedProxyMessage(ILinkingDiagnosticContext context) {
    EClass referenceType = context.getReference().getEReferenceType();
    String linkText = "";
    try {
        linkText = context.getLinkText();
    } catch (IllegalNodeException e) {
        linkText = e.getNode().getText();
    }
    String msg = "Couldn't resolve reference to " + referenceType.getName() + " '" + linkText + "'.";
    return new DiagnosticMessage(msg, Severity.ERROR, Diagnostic.LINKING_DIAGNOSTIC);
}
Also used : EClass(org.eclipse.emf.ecore.EClass) DiagnosticMessage(org.eclipse.xtext.diagnostics.DiagnosticMessage)

Example 8 with DiagnosticMessage

use of org.eclipse.xtext.diagnostics.DiagnosticMessage in project xtext-core by eclipse.

the class LazyLinkingResource method createDiagnosticMessage.

protected DiagnosticMessage createDiagnosticMessage(Triple<EObject, EReference, INode> triple) {
    ILinkingDiagnosticMessageProvider.ILinkingDiagnosticContext context = createDiagnosticMessageContext(triple);
    DiagnosticMessage message = diagnosticMessageProvider.getUnresolvedProxyMessage(context);
    return message;
}
Also used : DiagnosticMessage(org.eclipse.xtext.diagnostics.DiagnosticMessage) ILinkingDiagnosticMessageProvider(org.eclipse.xtext.linking.ILinkingDiagnosticMessageProvider) ILinkingDiagnosticContext(org.eclipse.xtext.linking.ILinkingDiagnosticMessageProvider.ILinkingDiagnosticContext)

Example 9 with DiagnosticMessage

use of org.eclipse.xtext.diagnostics.DiagnosticMessage in project xtext-core by eclipse.

the class LazyLinkingResource method createAndAddDiagnostic.

/**
 * @since 2.3
 */
protected void createAndAddDiagnostic(Triple<EObject, EReference, INode> triple, IllegalNodeException ex) {
    if (isValidationDisabled())
        return;
    ILinkingDiagnosticMessageProvider.ILinkingDiagnosticContext context = createDiagnosticMessageContext(triple);
    DiagnosticMessage message = linkingDiagnosticMessageProvider.getIllegalNodeMessage(context, ex);
    if (message != null) {
        List<Diagnostic> list = getDiagnosticList(message);
        Diagnostic diagnostic = createDiagnostic(triple, message);
        if (!list.contains(diagnostic))
            list.add(diagnostic);
    }
}
Also used : DiagnosticMessage(org.eclipse.xtext.diagnostics.DiagnosticMessage) ILinkingDiagnosticMessageProvider(org.eclipse.xtext.linking.ILinkingDiagnosticMessageProvider) XtextLinkingDiagnostic(org.eclipse.xtext.linking.impl.XtextLinkingDiagnostic) ExceptionDiagnostic(org.eclipse.xtext.diagnostics.ExceptionDiagnostic) ILinkingDiagnosticContext(org.eclipse.xtext.linking.ILinkingDiagnosticMessageProvider.ILinkingDiagnosticContext)

Example 10 with DiagnosticMessage

use of org.eclipse.xtext.diagnostics.DiagnosticMessage in project xtext-core by eclipse.

the class LazyLinkingResource method createAndAddDiagnostic.

protected void createAndAddDiagnostic(Triple<EObject, EReference, INode> triple) {
    if (isValidationDisabled())
        return;
    DiagnosticMessage message = createDiagnosticMessage(triple);
    if (message != null) {
        List<Diagnostic> list = getDiagnosticList(message);
        Diagnostic diagnostic = createDiagnostic(triple, message);
        if (!list.contains(diagnostic))
            list.add(diagnostic);
    }
}
Also used : DiagnosticMessage(org.eclipse.xtext.diagnostics.DiagnosticMessage) XtextLinkingDiagnostic(org.eclipse.xtext.linking.impl.XtextLinkingDiagnostic) ExceptionDiagnostic(org.eclipse.xtext.diagnostics.ExceptionDiagnostic)

Aggregations

DiagnosticMessage (org.eclipse.xtext.diagnostics.DiagnosticMessage)12 EObject (org.eclipse.emf.ecore.EObject)4 ExceptionDiagnostic (org.eclipse.xtext.diagnostics.ExceptionDiagnostic)3 ILinkingDiagnosticMessageProvider (org.eclipse.xtext.linking.ILinkingDiagnosticMessageProvider)3 ILinkingDiagnosticContext (org.eclipse.xtext.linking.ILinkingDiagnosticMessageProvider.ILinkingDiagnosticContext)3 XtextLinkingDiagnostic (org.eclipse.xtext.linking.impl.XtextLinkingDiagnostic)3 List (java.util.List)2 EReference (org.eclipse.emf.ecore.EReference)2 InternalEList (org.eclipse.emf.ecore.util.InternalEList)2 AbstractRule (org.eclipse.xtext.AbstractRule)2 RuleCall (org.eclipse.xtext.RuleCall)2 LinkedHashSet (java.util.LinkedHashSet)1 EAnnotation (org.eclipse.emf.ecore.EAnnotation)1 EClass (org.eclipse.emf.ecore.EClass)1 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)1 InternalEObject (org.eclipse.emf.ecore.InternalEObject)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 AbstractElement (org.eclipse.xtext.AbstractElement)1 AbstractMetamodelDeclaration (org.eclipse.xtext.AbstractMetamodelDeclaration)1 EnumRule (org.eclipse.xtext.EnumRule)1