org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic Java Examples
The following examples show how to use
org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic.
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: AbstractSemanticSequencerTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
private EObject testSequence(String stringModel) throws Exception { DebugSequenceAcceptor genericActual = new DebugSequenceAcceptor(); DebugSequenceAcceptor generatedActual = new DebugSequenceAcceptor(); DebugSequenceAcceptor expected = new DebugSequenceAcceptor(); ISemanticSequencer generatedSequencer = generatedSequencerProvider.get(); ISemanticSequencer genericSequencer = getGenericSemanticSequencer(); assertTrue(generatedSequencer instanceof SequencerTestLanguageSemanticSequencer); generatedSequencer.init(generatedActual, ISerializationDiagnostic.STDERR_ACCEPTOR); genericSequencer.init(genericActual, ISerializationDiagnostic.STDERR_ACCEPTOR); nmSequencer.init(expected, ISerializationDiagnostic.STDERR_ACCEPTOR); EObject model = getModel(stringModel).eContents().get(0); ISerializationContext context = nmSequencer.findContexts(model, true, null).iterator().next(); generatedSequencer.createSequence(context, model); genericSequencer.createSequence(context, model); nmSequencer.createSequence(context, model); assertEquals(expected.toString(), genericActual.toString()); assertEquals(expected.toString(), generatedActual.toString()); return model; }
Example #2
Source File: HiddenTokenSequencerTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
private void testSequence(String stringModel) throws Exception { EObject model = getModel(stringModel); ISerializationContext context = nmSequencer.findContexts(model, true, null).iterator().next(); DebugSequenceAcceptor actual = new NoEnterNodesDebugSequenceAcceptor(false); ISemanticSequencer semanticSequencer = semanticSequencerProvider.get(); ISyntacticSequencer syntacticSequencer = syntacticSequencerProvider.get(); IHiddenTokenSequencer hiddenTokenSequencer = hiddenTokenSequencerProvider.get(); semanticSequencer .init((ISemanticSequenceAcceptor) syntacticSequencer, ISerializationDiagnostic.STDERR_ACCEPTOR); syntacticSequencer.init(context, model, (ISyntacticSequenceAcceptor) hiddenTokenSequencer, ISerializationDiagnostic.STDERR_ACCEPTOR); hiddenTokenSequencer.init(context, model, actual, ISerializationDiagnostic.STDERR_ACCEPTOR); semanticSequencer.createSequence(context, model); // System.out.println(actual); // System.out.println(NodeModelUtils.compactDump(NodeModelUtils.findActualNodeFor(model), true)); assertEquals(Joiner.on("\n").join(getNodeSequence(model)), Joiner.on("\n").join(actual.getColumn(4))); }
Example #3
Source File: SerializerTester.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.3 */ protected String serialize(EObject semanticObject, DelegatingSequenceAcceptor... acceptors) { ISequenceAcceptor debug = null; try { ISerializationDiagnostic.Acceptor errors = ISerializationDiagnostic.EXCEPTION_THROWING_ACCEPTOR; ISemanticSequencer semantic = semanticSequencerProvider.get(); ISyntacticSequencer syntactic = syntacticSequencerProvider.get(); IHiddenTokenSequencer hidden = hiddenTokenSequencerProvider.get(); ISequenceAcceptor result = new StringBufferSequenceAcceptor(); ISequenceAcceptor out = result; for (DelegatingSequenceAcceptor delegate : acceptors) { delegate.setDelegate(out); out = delegate; } out = debug = new DebugSequenceAcceptor(out); semantic.init((ISemanticSequenceAcceptor) syntactic, errors); ISerializationContext context = getContext(semanticObject); syntactic.init(context, semanticObject, (ISyntacticSequenceAcceptor) hidden, errors); hidden.init(context, semanticObject, out, errors); semantic.createSequence(context, semanticObject); return result.toString(); } catch (Exception t) { if (debug != null) { System.out.println("Serializer debug output:"); System.out.println(debug.toString()); } Exceptions.sneakyThrow(t); return ""; } }
Example #4
Source File: SARLEcoreDocumentationSyntacticSequencer.java From sarl with Apache License 2.0 | 5 votes |
public void init(ISerializationContext context, EObject semanticObject, ISyntacticSequenceAcceptor sequenceAcceptor, ISerializationDiagnostic.Acceptor errorAcceptor) { super.init(context, semanticObject, sequenceAcceptor, errorAcceptor); if (sequenceAcceptor instanceof ISequenceAcceptor) { this.trailingSequenceAcceptor = (ISequenceAcceptor) sequenceAcceptor; } this.documentedSemanticObjects.clear(); this.indocumentedSemanticObjects.clear(); this.lastInnerBlock = null; }
Example #5
Source File: SyntacticSequencerTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
private void testSequence(EObject inObj, String outModel) throws Exception { EObject outObj = getModel(outModel); ISerializationContext context = nmSequencer.findContexts(inObj, true, null).iterator().next(); Acceptor actual = new Acceptor(); ISemanticSequencer semanticSeq = semanticSequencerProvider.get(); ISyntacticSequencer syntacticSeq = syntacticSequencerProvider.get(); semanticSeq.init((ISemanticSequenceAcceptor) syntacticSeq, ISerializationDiagnostic.STDERR_ACCEPTOR); syntacticSeq.init(context, inObj, actual, ISerializationDiagnostic.STDERR_ACCEPTOR); semanticSeq.createSequence(context, inObj); assertEquals(Joiner.on("\n").join(getNodeSequence(outObj)), Joiner.on("\n").join(actual.getResult())); }
Example #6
Source File: SyntacticSequencerTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
private void testSequence(String stringModel) throws Exception { EObject model = getModel(stringModel); ISerializationContext context = nmSequencer.findContexts(model, true, null).iterator().next(); Acceptor actual = new Acceptor(); ISemanticSequencer semanticSeq = semanticSequencerProvider.get(); ISyntacticSequencer syntacticSeq = syntacticSequencerProvider.get(); semanticSeq.init((ISemanticSequenceAcceptor) syntacticSeq, ISerializationDiagnostic.STDERR_ACCEPTOR); syntacticSeq.init(context, model, actual, ISerializationDiagnostic.STDERR_ACCEPTOR); semanticSeq.createSequence(context, model); assertEquals(Joiner.on("\n").join(getNodeSequence(model)), Joiner.on("\n").join(actual.getResult())); }
Example #7
Source File: FormatterTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected void serializeToTokenBuffer(String model, ITokenStream out) throws Exception { EObject semanticObject = get(ParseHelper.class).parse(model); ISerializationDiagnostic.Acceptor errors = ISerializationDiagnostic.EXCEPTION_THROWING_ACCEPTOR; ISemanticSequencer semantic = get(ISemanticSequencer.class); ISyntacticSequencer syntactic = get(ISyntacticSequencer.class); IHiddenTokenSequencer hidden = get(IHiddenTokenSequencer.class); TokenStreamSequenceAdapter tokenstream = new TokenStreamSequenceAdapter(out, getGrammarAccess().getGrammar(), errors); semantic.init((ISemanticSequenceAcceptor) syntactic, errors); ISerializationContext context = new SerializationContext.RuleContext(null, (ParserRule) get(IGrammarAccess.class).getGrammar().getRules().get(0)); syntactic.init(context, semanticObject, (ISyntacticSequenceAcceptor) hidden, errors); hidden.init(context, semanticObject, tokenstream, errors); tokenstream.init(context); semantic.createSequence(context, semanticObject); }
Example #8
Source File: SerializerTestHelper.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected String serialize(EObject semanticObject, DelegatingSequenceAcceptor... acceptors) { ISequenceAcceptor debug = null; try { ISerializationDiagnostic.Acceptor errors = ISerializationDiagnostic.EXCEPTION_THROWING_ACCEPTOR; ISemanticSequencer semantic = semanticSequencerProvider.get(); ISyntacticSequencer syntactic = syntacticSequencerProvider.get(); IHiddenTokenSequencer hidden = hiddenTokenSequencerProvider.get(); ISequenceAcceptor result = new StringBufferSequenceAcceptor(); ISequenceAcceptor out = result; for (DelegatingSequenceAcceptor delegate : acceptors) { delegate.setDelegate(out); out = delegate; } out = debug = new DebugSequenceAcceptor(out); semantic.init((ISemanticSequenceAcceptor) syntactic, errors); ISerializationContext context = getContext(semanticObject); syntactic.init(context, semanticObject, (ISyntacticSequenceAcceptor) hidden, errors); hidden.init(context, semanticObject, out, errors); semantic.createSequence(context, semanticObject); return result.toString(); } catch (Exception t) { if (debug != null) { System.out.println("Serializer debug output:"); System.out.println(debug.toString()); } Exceptions.sneakyThrow(t); return ""; } }
Example #9
Source File: Serializer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
public ITextRegionAccess serializeToRegions(EObject obj) { checkNotNull(obj, "obj must not be null."); ISerializationContext context = getIContext(obj); TextRegionAccessBuilder builder = textRegionBuilderProvider.get(); ISerializationDiagnostic.Acceptor errors = ISerializationDiagnostic.EXCEPTION_THROWING_ACCEPTOR; serialize(context, obj, builder.forSequence(context, obj), errors); ITextRegionAccess regionAccess = builder.create(); return regionAccess; }
Example #10
Source File: Serializer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected void serialize(EObject obj, ITokenStream tokenStream, SaveOptions options) throws IOException { ISerializationDiagnostic.Acceptor errors = ISerializationDiagnostic.EXCEPTION_THROWING_ACCEPTOR; ITokenStream formatterTokenStream; if (formatter instanceof IFormatterExtension) formatterTokenStream = ((IFormatterExtension) formatter).createFormatterStream(obj, null, tokenStream, !options.isFormatting()); else formatterTokenStream = formatter.createFormatterStream(null, tokenStream, !options.isFormatting()); ISerializationContext context = getIContext(obj); ISequenceAcceptor acceptor = new TokenStreamSequenceAdapter(formatterTokenStream, grammar.getGrammar(), errors); serialize(context, obj, acceptor, errors); formatterTokenStream.flush(); }
Example #11
Source File: Serializer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected void serialize(ISerializationContext context, EObject semanticObject, ISequenceAcceptor tokens, ISerializationDiagnostic.Acceptor errors) { ISemanticSequencer semantic = semanticSequencerProvider.get(); ISyntacticSequencer syntactic = syntacticSequencerProvider.get(); IHiddenTokenSequencer hidden = hiddenTokenSequencerProvider.get(); semantic.init((ISemanticSequenceAcceptor) syntactic, errors); syntactic.init(context, semanticObject, (ISyntacticSequenceAcceptor) hidden, errors); hidden.init(context, semanticObject, tokens, errors); if (tokens instanceof TokenStreamSequenceAdapter) ((TokenStreamSequenceAdapter) tokens).init(context); semantic.createSequence(context, semanticObject); }
Example #12
Source File: Serializer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
/** * @deprecated use {@link #serialize(ISerializationContext, EObject, ISequenceAcceptor, ISerializationDiagnostic.Acceptor)} */ @Deprecated protected void serialize(EObject semanticObject, EObject context, ISequenceAcceptor tokens, ISerializationDiagnostic.Acceptor errors) { ISemanticSequencer semantic = semanticSequencerProvider.get(); ISyntacticSequencer syntactic = syntacticSequencerProvider.get(); IHiddenTokenSequencer hidden = hiddenTokenSequencerProvider.get(); semantic.init((ISemanticSequenceAcceptor) syntactic, errors); syntactic.init(context, semanticObject, (ISyntacticSequenceAcceptor) hidden, errors); hidden.init(context, semanticObject, tokens, errors); if (tokens instanceof TokenStreamSequenceAdapter) ((TokenStreamSequenceAdapter) tokens).init(context); semantic.createSequence(context, semanticObject); }
Example #13
Source File: SerializerTester.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.3 */ protected String serialize(EObject semanticObject, DelegatingSequenceAcceptor... acceptors) { ISequenceAcceptor debug = null; try { ISerializationDiagnostic.Acceptor errors = ISerializationDiagnostic.EXCEPTION_THROWING_ACCEPTOR; ISemanticSequencer semantic = semanticSequencerProvider.get(); ISyntacticSequencer syntactic = syntacticSequencerProvider.get(); IHiddenTokenSequencer hidden = hiddenTokenSequencerProvider.get(); ISequenceAcceptor result = new StringBufferSequenceAcceptor(); ISequenceAcceptor out = result; for (DelegatingSequenceAcceptor delegate : acceptors) { delegate.setDelegate(out); out = delegate; } out = debug = new DebugSequenceAcceptor(out); semantic.init((ISemanticSequenceAcceptor) syntactic, errors); ISerializationContext context = getContext(semanticObject); syntactic.init(context, semanticObject, (ISyntacticSequenceAcceptor) hidden, errors); hidden.init(context, semanticObject, out, errors); semantic.createSequence(context, semanticObject); return result.toString(); } catch (Exception t) { if (debug != null) { System.out.println("Serializer debug output:"); System.out.println(debug.toString()); } Exceptions.sneakyThrow(t); return ""; } }
Example #14
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 #15
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 #16
Source File: IHiddenTokenSequencer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
/** * @deprecated use {@link #init(ISerializationContext, EObject, ISequenceAcceptor, ISerializationDiagnostic.Acceptor)} */ @Deprecated void init(EObject context, EObject semanticObject, ISequenceAcceptor sequenceAcceptor, ISerializationDiagnostic.Acceptor errorAcceptor);
Example #17
Source File: PartialSerializer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public void setErrorAcceptor(ISerializationDiagnostic.Acceptor errorAcceptor) { this.errorAcceptor = errorAcceptor; }
Example #18
Source File: PartialSerializer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public ISerializationDiagnostic.Acceptor getErrorAcceptor() { return errorAcceptor; }
Example #19
Source File: TokenStreamSequenceAdapter.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public TokenStreamSequenceAdapter(ITokenStream out, Grammar grammar, ISerializationDiagnostic.Acceptor errorAcceptor) { this.out = out; this.grammar = grammar; this.errorAcceptor = errorAcceptor; }
Example #20
Source File: ISyntacticSequencer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
/** * @deprecated use {@link #init(ISerializationContext, EObject, ISyntacticSequenceAcceptor, ISerializationDiagnostic.Acceptor)} */ @Deprecated void init(EObject context, EObject semanticObject, ISyntacticSequenceAcceptor sequenceAcceptor, ISerializationDiagnostic.Acceptor errorAcceptor);
Example #21
Source File: ISyntacticSequencer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
void init(ISerializationContext context, EObject semanticObject, ISyntacticSequenceAcceptor sequenceAcceptor, ISerializationDiagnostic.Acceptor errorAcceptor);
Example #22
Source File: ISemanticSequencer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
void init(ISemanticSequencer sequencer, ISemanticSequenceAcceptor sequenceAcceptor, ISerializationDiagnostic.Acceptor errorAcceptor);
Example #23
Source File: IValueSerializer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
String serializeAssignedValue(EObject context, RuleCall ruleCall, Object value, INode node, ISerializationDiagnostic.Acceptor errorAcceptor);
Example #24
Source File: IHiddenTokenSequencer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
void init(ISerializationContext context, EObject semanticObject, ISequenceAcceptor sequenceAcceptor, ISerializationDiagnostic.Acceptor errorAcceptor);
Example #25
Source File: IEnumLiteralSerializer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
String serializeAssignedEnumLiteral(EObject context, RuleCall ruleCall, Object value, INode node, ISerializationDiagnostic.Acceptor errorAcceptor);
Example #26
Source File: ICrossReferenceSerializer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
String serializeCrossRef(EObject context, CrossReference crossref, EObject target, INode node, ISerializationDiagnostic.Acceptor errorAcceptor);
Example #27
Source File: ICrossReferenceSerializer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
boolean isValid(EObject context, CrossReference crossref, EObject target, INode node, ISerializationDiagnostic.Acceptor errorAcceptor);
Example #28
Source File: IKeywordSerializer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
String serializeAssignedKeyword(EObject context, Keyword keyword, Object value, INode node, ISerializationDiagnostic.Acceptor errorAcceptor);
Example #29
Source File: IndentingSerializer.java From dsl-devkit with Eclipse Public License 1.0 | 3 votes |
/** * Serialize the given object into tokenStream using save options. * The initial indentation is passed on to the formatter. * This implementation is based on {@link Serializer#serialize(EObject, ITokenStream, SaveOptions)}. * * @param obj * the obj * @param tokenStream * the token stream * @param options * the options * @param initialIndentation * the initial indentation * @throws IOException * Signals that an I/O exception has occurred. */ protected void serialize(final EObject obj, final ITokenStream tokenStream, final SaveOptions options, final String initialIndentation) throws IOException { ISerializationDiagnostic.Acceptor errors = ISerializationDiagnostic.EXCEPTION_THROWING_ACCEPTOR; ITokenStream formatterTokenStream; if (formatter instanceof IFormatterExtension) { formatterTokenStream = ((IFormatterExtension) formatter).createFormatterStream(obj, initialIndentation, tokenStream, !options.isFormatting()); } else { formatterTokenStream = formatter.createFormatterStream(initialIndentation, tokenStream, !options.isFormatting()); } ISerializationContext context = getIContext(obj); ISequenceAcceptor acceptor = new TokenStreamSequenceAdapter(formatterTokenStream, grammar.getGrammar(), errors); serialize(context, obj, acceptor, errors); formatterTokenStream.flush(); }
Example #30
Source File: IValueSerializer.java From xtext-core with Eclipse Public License 2.0 | votes |
boolean isValid(EObject context, RuleCall ruleCall, Object value, ISerializationDiagnostic.Acceptor errorAcceptor);