org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic.Acceptor Java Examples
The following examples show how to use
org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic.Acceptor.
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: ValueSerializer.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Override public String serializeAssignedValue(EObject context, RuleCall ruleCall, Object value, INode node, Acceptor errors) { AbstractRule rule = ruleCall.getRule(); String ruleName = ruleNames.getQualifiedName(rule); if (node != null) { AbstractRule nodeRule = linkingHelper.getRuleFrom(node.getGrammarElement()); // TODO: analyze why grammar element identity is broken here during generation of Xtext languages using MWE2 if (nodeRule != null && ruleNames.getQualifiedName(nodeRule).equals(ruleName)) { Object converted = converter.toValue(NodeModelUtils.getTokenText(node), ruleName, node); if (converted != null && converted.equals(value)) return tokenUtil.serializeNode(node); } } try { String str = converter.toString(value, ruleName); if (str != null) return str; if (errors != null) errors.accept(diagnostics.getNullNotAllowedDiagnostic(context, ruleCall)); return null; } catch (Throwable e) { if (errors != null) errors.accept(diagnostics.getValueConversionExceptionDiagnostic(context, ruleCall, value, e)); return null; } }
Example #2
Source File: CrossReferenceSerializer.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Override public boolean isValid(EObject semanticObject, CrossReference crossref, EObject target, INode node, Acceptor errors) { if ((target == null || target.eIsProxy()) && node != null) { CrossReference crossrefFromNode = GrammarUtil.containingCrossReference(node.getGrammarElement()); return crossref == crossrefFromNode; } final EReference ref = GrammarUtil.getReference(crossref, semanticObject.eClass()); final IScope scope = scopeProvider.getScope(semanticObject, ref); if (scope == null) { if (errors != null) errors.accept(diagnostics.getNoScopeFoundDiagnostic(semanticObject, crossref, target)); return false; } if (target != null && target.eIsProxy()) { target = handleProxy(target, semanticObject, ref); } return getCrossReferenceNameFromScope(semanticObject, crossref, target, scope, errors) != null; }
Example #3
Source File: CrossReferenceSerializer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public String serializeCrossRef(EObject semanticObject, CrossReference crossref, EObject target, INode node, Acceptor errors) { if ((target == null || target.eIsProxy()) && node != null) return tokenUtil.serializeNode(node); final EReference ref = GrammarUtil.getReference(crossref, semanticObject.eClass()); final IScope scope = scopeProvider.getScope(semanticObject, ref); if (scope == null) { if (errors != null) errors.accept(diagnostics.getNoScopeFoundDiagnostic(semanticObject, crossref, target)); return null; } if (target != null && target.eIsProxy()) { target = handleProxy(target, semanticObject, ref); } if (target != null && node != null) { String text = linkingHelper.getCrossRefNodeAsString(node, true); QualifiedName qn = qualifiedNameConverter.toQualifiedName(text); URI targetURI = EcoreUtil2.getPlatformResourceOrNormalizedURI(target); for (IEObjectDescription desc : scope.getElements(qn)) { if (targetURI.equals(desc.getEObjectURI())) return tokenUtil.serializeNode(node); } } return getCrossReferenceNameFromScope(semanticObject, crossref, target, scope, errors); }
Example #4
Source File: SGenCrossReferenceSerializer.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override public String serializeCrossRef(EObject semanticObject, CrossReference crossref, EObject target, INode node, Acceptor errors) { // for statechart crossreferences, we do not want to check the scope if (target instanceof Statechart) { return provider.getFullyQualifiedName(target).toString(); } return super.serializeCrossRef(semanticObject, crossref, target, node, errors); }
Example #5
Source File: ReorderingHiddenTokenSequencer.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override public void init(final ISerializationContext context, final EObject semanticObject, final ISequenceAcceptor sequenceAcceptor, final Acceptor errorAcceptor) { this.delegate = sequenceAcceptor; this.lastNode = NodeModelUtils.findActualNodeFor(semanticObject); this.rootNode = lastNode; if (rootNode != null) { this.rootOffset = rootNode.getTotalOffset(); this.rootEndOffset = rootNode.getTotalEndOffset(); } }
Example #6
Source File: ReorderingHiddenTokenSequencer.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override @Deprecated public void init(final EObject context, final EObject semanticObject, final ISequenceAcceptor sequenceAcceptor, final Acceptor errorAcceptor) { this.delegate = sequenceAcceptor; this.lastNode = NodeModelUtils.findActualNodeFor(semanticObject); this.rootNode = lastNode; if (rootNode != null) { this.rootOffset = rootNode.getTotalOffset(); this.rootEndOffset = rootNode.getTotalEndOffset(); } }
Example #7
Source File: KeywordSerializer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public String serializeAssignedKeyword(EObject context, Keyword keyword, Object value, INode node, Acceptor errorAcceptor) { if (node != null && node.getGrammarElement() == keyword) return node.getText(); return keyword.getValue(); }
Example #8
Source File: IgnoreCaseKeywordSerializer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public boolean isValid(EObject context, Keyword keyword, Object value, Acceptor errorAcceptor) { if (value instanceof String) { return keyword.getValue().equalsIgnoreCase((String) value); } return false; }
Example #9
Source File: ValueSerializer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public boolean isValid(EObject context, RuleCall ruleCall, Object value, Acceptor errors) { try { String str = converter.toString(value, ruleNames.getQualifiedName(ruleCall.getRule())); if (str != null) return true; if (errors != null) errors.accept(diagnostics.getNullNotAllowedDiagnostic(context, ruleCall)); return false; } catch (Throwable e) { if (errors != null) errors.accept(diagnostics.getValueConversionExceptionDiagnostic(context, ruleCall, value, e)); return false; } }
Example #10
Source File: EnumLiteralSerializer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public String serializeAssignedEnumLiteral(EObject context, RuleCall ruleCall, Object value, INode node, Acceptor errorAcceptor) { Keyword nodeLit = getLiteral(node); Keyword modelLit = getLiteral(context, ruleCall, value); if (modelLit == null) { if (errorAcceptor != null) errorAcceptor.accept(diagnosticProvider.getInvalidEnumValueDiagnostic(context, ruleCall, value)); return null; } else if (nodeLit != null && nodeLit.equals(modelLit)) return tokenUtil.serializeNode(node); else return modelLit.getValue(); }
Example #11
Source File: CrossReferenceSerializer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected String getCrossReferenceNameFromScope(EObject semanticObject, CrossReference crossref, EObject target, final IScope scope, Acceptor errors) { String ruleName = linkingHelper.getRuleNameFrom(crossref); boolean foundOne = false; List<ISerializationDiagnostic> recordedErrors = null; for (IEObjectDescription desc : scope.getElements(target)) { foundOne = true; String unconverted = qualifiedNameConverter.toString(desc.getName()); try { return valueConverter.toString(unconverted, ruleName); } catch (ValueConverterException e) { if (errors != null) { if (recordedErrors == null) recordedErrors = Lists.newArrayList(); recordedErrors.add(diagnostics.getValueConversionExceptionDiagnostic(semanticObject, crossref, unconverted, e)); } } } if (errors != null) { if (recordedErrors != null) for (ISerializationDiagnostic diag : recordedErrors) errors.accept(diag); if (!foundOne) errors.accept(diagnostics.getNoEObjectDescriptionFoundDiagnostic(semanticObject, crossref, target, scope)); } return null; }
Example #12
Source File: GrammarPrettyPrinter.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override protected String getCrossReferenceNameFromScope(EObject semanticObject, CrossReference crossref, EObject target, IScope scope, Acceptor errors) { if (target instanceof AbstractRule) { return ((AbstractRule) target).getName(); } if (target instanceof ENamedElement) { return ((ENamedElement) target).getName(); } return super.getCrossReferenceNameFromScope(semanticObject, crossref, target, scope, errors); }
Example #13
Source File: HiddenTokenSequencer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public void init(ISerializationContext context, EObject semanticObject, ISequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) { this.delegate = sequenceAcceptor; this.lastNode = NodeModelUtils.findActualNodeFor(semanticObject); this.rootNode = lastNode; if (rootNode != null) { this.rootOffset = rootNode.getTotalOffset(); this.rootEndOffset = rootNode.getTotalEndOffset(); } }
Example #14
Source File: HiddenTokenSequencer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override @Deprecated public void init(EObject context, EObject semanticObject, ISequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) { this.delegate = sequenceAcceptor; this.lastNode = NodeModelUtils.findActualNodeFor(semanticObject); this.rootNode = lastNode; if (rootNode != null) { this.rootOffset = rootNode.getTotalOffset(); this.rootEndOffset = rootNode.getTotalEndOffset(); } }
Example #15
Source File: AbstractSyntacticSequencer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public void init(ISerializationContext context, EObject semanticObject, ISyntacticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) { INode node = NodeModelUtils.findActualNodeFor(semanticObject); syntacticSequencerPDAs = pdaProvider.getSyntacticSequencerPDAs(grammar.getGrammar()); ISynAbsorberState state = syntacticSequencerPDAs.get(context); Preconditions.checkNotNull(state, "Invalid context: " + context); SyntacticalContext acceptor = new SyntacticalContext(context, semanticObject, state, node); contexts.push(acceptor); delegate = sequenceAcceptor; this.errorAcceptor = errorAcceptor; }
Example #16
Source File: AbstractSyntacticSequencer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override @Deprecated public void init(EObject context, EObject semanticObject, ISyntacticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) { ISerializationContext ctx = SerializationContext.fromEObject(context, semanticObject); init(ctx, semanticObject, sequenceAcceptor, errorAcceptor); }
Example #17
Source File: AbstractSemanticSequencer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public void init(ISemanticSequencer sequencer, ISemanticSequenceAcceptor sequenceAcceptor, ISerializationDiagnostic.Acceptor errorAcceptor) { this.masterSequencer = sequencer; this.sequenceAcceptor = sequenceAcceptor; this.errorAcceptor = errorAcceptor; }
Example #18
Source File: SequenceFeeder.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected SequenceFeeder(Provider provider, ISerializationContext context, EObject semanticObject, INodesForEObjectProvider nodes, ISemanticSequencer masterSequencer, ISemanticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) { super(); if (semanticObject == null || nodes == null || sequenceAcceptor == null) throw new NullPointerException(); this.context = context; this.provider = provider; this.semanticObject = semanticObject; this.nodes = nodes; this.masterSequencer = masterSequencer; this.sequenceAcceptor = sequenceAcceptor; this.errorAcceptor = errorAcceptor; }
Example #19
Source File: AbstractDelegatingSemanticSequencer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public void init(ISemanticSequencer sequencer, ISemanticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) { super.init(sequencer, sequenceAcceptor, errorAcceptor); this.genericSequencer = genericSequencerProvider.get(); this.genericSequencer.init(sequencer, sequenceAcceptor, errorAcceptor); }
Example #20
Source File: EnumLiteralSerializer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public boolean isValid(EObject context, RuleCall ruleCall, Object value, Acceptor errorAcceptor) { return getLiteral(context, ruleCall, value) != null; }
Example #21
Source File: AbstractSemanticSequencer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public void init(ISemanticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) { init(this, sequenceAcceptor, errorAcceptor); }
Example #22
Source File: IgnoreCaseKeywordSerializer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public String serializeAssignedKeyword(EObject context, Keyword keyword, Object value, INode node, Acceptor errorAcceptor) { if (node != null && node.getGrammarElement() == keyword) return node.getText(); return keyword.getValue(); }
Example #23
Source File: KeywordSerializer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public boolean isValid(EObject context, Keyword keyword, Object value, Acceptor errorAcceptor) { return keyword.getValue().equals(value); }
Example #24
Source File: SequenceFeeder.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
/** * @deprecated {@link #SequenceFeeder(SequenceFeeder.Provider, ISerializationContext, EObject, ISemanticNodeProvider.INodesForEObjectProvider, ISemanticSequencer, ISemanticSequenceAcceptor, ISerializationDiagnostic.Acceptor)} */ @Deprecated protected SequenceFeeder(Provider provider, EObject semanticObject, INodesForEObjectProvider nodes, ISemanticSequencer masterSequencer, ISemanticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) { this(provider, null, semanticObject, nodes, masterSequencer, sequenceAcceptor, errorAcceptor); }
Example #25
Source File: SequenceFeeder.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public SequenceFeeder create(ISerializationContext context, EObject semanticObject, INodesForEObjectProvider nodes, ISemanticSequencer masterSequencer, ISemanticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) { return new SequenceFeeder(this, context, semanticObject, nodes, masterSequencer, sequenceAcceptor, errorAcceptor); }
Example #26
Source File: SequenceFeeder.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
/** * @deprecated {@link #create(ISerializationContext, EObject, ISemanticNodeProvider.INodesForEObjectProvider, ISemanticSequencer, ISemanticSequenceAcceptor, ISerializationDiagnostic.Acceptor)} */ @Deprecated public SequenceFeeder create(EObject semanticObject, INodesForEObjectProvider nodes, ISemanticSequencer masterSequencer, ISemanticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) { return new SequenceFeeder(this, semanticObject, nodes, masterSequencer, sequenceAcceptor, errorAcceptor); }