From 87d5b57f628126a5b16fe32a35ff84252809de7e Mon Sep 17 00:00:00 2001 From: overflowerror Date: Tue, 18 Jan 2022 14:31:54 +0100 Subject: [PATCH] fixed grammar attributes (debug, token limit) not being set attributes are not set when generating flattened grammar access fix: explicitly copy attributes to flattenedGrammar --- .../trace/node/TracingSugarTest.java | 64 +++++++++---------- .../xtext/xtext/FlattenedGrammarAccess.java | 3 + .../trace/node/GeneratorNodeProcessor.java | 16 ++--- 3 files changed, 43 insertions(+), 40 deletions(-) diff --git a/org.eclipse.xtext.tests/xtend-gen/org/eclipse/xtext/generator/trace/node/TracingSugarTest.java b/org.eclipse.xtext.tests/xtend-gen/org/eclipse/xtext/generator/trace/node/TracingSugarTest.java index 793aa18bc..4821d2bea 100644 --- a/org.eclipse.xtext.tests/xtend-gen/org/eclipse/xtext/generator/trace/node/TracingSugarTest.java +++ b/org.eclipse.xtext.tests/xtend-gen/org/eclipse/xtext/generator/trace/node/TracingSugarTest.java @@ -61,38 +61,6 @@ public class TracingSugarTest { return result; } - public IGeneratorNode _name(final Property target) { - EStructuralFeature feature = target.eClass().getEStructuralFeature("name"); - ILocationData location = this.location(target, feature, -1); - CompositeGeneratorNode trace = this.trace(location); - this.append(trace, target.getName()); - return trace; - } - - public IGeneratorNode _name(final Property target, final boolean useForDebugging) { - EStructuralFeature feature = target.eClass().getEStructuralFeature("name"); - ILocationData location = this.location(target, feature, -1); - CompositeGeneratorNode trace = this.trace(location, useForDebugging); - this.append(trace, target.getName()); - return trace; - } - - public IGeneratorNode _name(final Property target, final Function stringProvider) { - EStructuralFeature feature = target.eClass().getEStructuralFeature("name"); - ILocationData location = this.location(target, feature, -1); - CompositeGeneratorNode trace = this.trace(location); - this.append(trace, stringProvider.apply(target.getName())); - return trace; - } - - public IGeneratorNode _extends(final Type target, final Function stringProvider) { - EStructuralFeature feature = target.eClass().getEStructuralFeature("extends"); - ILocationData location = this.location(target, feature, -1); - CompositeGeneratorNode trace = this.trace(location); - this.append(trace, stringProvider.apply(target.getExtends())); - return trace; - } - public IGeneratorNode _name(final Type target) { EStructuralFeature feature = target.eClass().getEStructuralFeature("name"); ILocationData location = this.location(target, feature, -1); @@ -117,6 +85,14 @@ public class TracingSugarTest { return trace; } + public IGeneratorNode _extends(final Type target, final Function stringProvider) { + EStructuralFeature feature = target.eClass().getEStructuralFeature("extends"); + ILocationData location = this.location(target, feature, -1); + CompositeGeneratorNode trace = this.trace(location); + this.append(trace, stringProvider.apply(target.getExtends())); + return trace; + } + public IGeneratorNode _parentId(final Type target, final Function stringProvider) { EStructuralFeature feature = target.eClass().getEStructuralFeature("parentId"); ILocationData location = this.location(target, feature, -1); @@ -125,6 +101,30 @@ public class TracingSugarTest { return trace; } + public IGeneratorNode _name(final Property target) { + EStructuralFeature feature = target.eClass().getEStructuralFeature("name"); + ILocationData location = this.location(target, feature, -1); + CompositeGeneratorNode trace = this.trace(location); + this.append(trace, target.getName()); + return trace; + } + + public IGeneratorNode _name(final Property target, final boolean useForDebugging) { + EStructuralFeature feature = target.eClass().getEStructuralFeature("name"); + ILocationData location = this.location(target, feature, -1); + CompositeGeneratorNode trace = this.trace(location, useForDebugging); + this.append(trace, target.getName()); + return trace; + } + + public IGeneratorNode _name(final Property target, final Function stringProvider) { + EStructuralFeature feature = target.eClass().getEStructuralFeature("name"); + ILocationData location = this.location(target, feature, -1); + CompositeGeneratorNode trace = this.trace(location); + this.append(trace, stringProvider.apply(target.getName())); + return trace; + } + public IGeneratorNode _name(final UnresolvedProxyProperty target) { EStructuralFeature feature = target.eClass().getEStructuralFeature("name"); ILocationData location = this.location(target, feature, -1); diff --git a/org.eclipse.xtext/src/org/eclipse/xtext/xtext/FlattenedGrammarAccess.java b/org.eclipse.xtext/src/org/eclipse/xtext/xtext/FlattenedGrammarAccess.java index 54333ab7b..75a97cb68 100644 --- a/org.eclipse.xtext/src/org/eclipse/xtext/xtext/FlattenedGrammarAccess.java +++ b/org.eclipse.xtext/src/org/eclipse/xtext/xtext/FlattenedGrammarAccess.java @@ -70,6 +70,9 @@ public class FlattenedGrammarAccess { flattenedGrammar.setInitBlock(copiedBlock); } + flattenedGrammar.setDebug(grammar.isDebug()); + flattenedGrammar.setTokenLimit(grammar.getTokenLimit()); + Map origToCopy = new LinkedHashMap<>(); List copies = copyRuleStubs(names, origToCopy, filter.getRules(grammar), filter.isDiscardRuleTypeRef()); diff --git a/org.eclipse.xtext/xtend-gen/org/eclipse/xtext/generator/trace/node/GeneratorNodeProcessor.java b/org.eclipse.xtext/xtend-gen/org/eclipse/xtext/generator/trace/node/GeneratorNodeProcessor.java index 9d7dde604..b9ad90619 100644 --- a/org.eclipse.xtext/xtend-gen/org/eclipse/xtext/generator/trace/node/GeneratorNodeProcessor.java +++ b/org.eclipse.xtext/xtend-gen/org/eclipse/xtext/generator/trace/node/GeneratorNodeProcessor.java @@ -255,12 +255,12 @@ public class GeneratorNodeProcessor { return this.delegate; } - public boolean contains(final ITextRegion other) { - return this.getDelegate().contains(other); + public boolean contains(final ITextRegion arg0) { + return this.getDelegate().contains(arg0); } - public boolean contains(final int offset) { - return this.getDelegate().contains(offset); + public boolean contains(final int arg0) { + return this.getDelegate().contains(arg0); } public int getEndLineNumber() { @@ -279,12 +279,12 @@ public class GeneratorNodeProcessor { return this.getDelegate().getOffset(); } - public ITextRegion merge(final ITextRegion region) { - return this.getDelegate().merge(region); + public ITextRegion merge(final ITextRegion arg0) { + return this.getDelegate().merge(arg0); } - public ITextRegionWithLineInformation merge(final ITextRegionWithLineInformation other) { - return this.getDelegate().merge(other); + public ITextRegionWithLineInformation merge(final ITextRegionWithLineInformation arg0) { + return this.getDelegate().merge(arg0); } }