From 7f10364f08bc0751dbd9ffcd1cf9f0397c6b6b45 Mon Sep 17 00:00:00 2001 From: overflowerror Date: Mon, 17 Jan 2022 17:13:57 +0100 Subject: [PATCH] get debug and token limit from ecore model moved default token limit to ecore model --- .../trace/node/TracingSugarTest.java | 64 +++++++++---------- .../antlr/hoisting/HoistingConfiguration.java | 7 +- .../emf-gen/org/eclipse/xtext/Grammar.java | 3 +- .../org/eclipse/xtext/impl/GrammarImpl.java | 3 +- .../eclipse/xtext/impl/XtextPackageImpl.java | 2 +- .../org/eclipse/xtext/Xtext.ecore | 3 +- .../trace/node/GeneratorNodeProcessor.java | 16 ++--- 7 files changed, 51 insertions(+), 47 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 4821d2bea..793aa18bc 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,6 +61,38 @@ 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); @@ -85,14 +117,6 @@ 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); @@ -101,30 +125,6 @@ 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.xtext.generator/src/org/eclipse/xtext/xtext/generator/parser/antlr/hoisting/HoistingConfiguration.java b/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/parser/antlr/hoisting/HoistingConfiguration.java index 8d345793e..610dd2ea4 100644 --- a/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/parser/antlr/hoisting/HoistingConfiguration.java +++ b/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/parser/antlr/hoisting/HoistingConfiguration.java @@ -14,11 +14,12 @@ import org.eclipse.xtext.Grammar; * @author overflow - Initial contribution and API */ public class HoistingConfiguration { - private final int tokenLimit = 10; - private boolean debug = false; + private int tokenLimit; + private boolean debug; public HoistingConfiguration(Grammar grammar) { - // TODO: get config options from ecore object + this.tokenLimit = grammar.getTokenLimit(); + this.debug = grammar.isDebug(); } public int getTokenLimit() { diff --git a/org.eclipse.xtext/emf-gen/org/eclipse/xtext/Grammar.java b/org.eclipse.xtext/emf-gen/org/eclipse/xtext/Grammar.java index 775459ed9..d4b3adbf1 100644 --- a/org.eclipse.xtext/emf-gen/org/eclipse/xtext/Grammar.java +++ b/org.eclipse.xtext/emf-gen/org/eclipse/xtext/Grammar.java @@ -171,12 +171,13 @@ public interface Grammar extends EObject { /** * Returns the value of the 'Token Limit' attribute. + * The default value is "10". * * * @return the value of the 'Token Limit' attribute. * @see #setTokenLimit(int) * @see org.eclipse.xtext.XtextPackage#getGrammar_TokenLimit() - * @model + * @model default="10" * @generated */ int getTokenLimit(); diff --git a/org.eclipse.xtext/emf-gen/org/eclipse/xtext/impl/GrammarImpl.java b/org.eclipse.xtext/emf-gen/org/eclipse/xtext/impl/GrammarImpl.java index b7b57f5ce..1b4b89a3f 100644 --- a/org.eclipse.xtext/emf-gen/org/eclipse/xtext/impl/GrammarImpl.java +++ b/org.eclipse.xtext/emf-gen/org/eclipse/xtext/impl/GrammarImpl.java @@ -15,6 +15,7 @@ import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; +import org.eclipse.emf.ecore.util.EDataTypeUniqueEList; import org.eclipse.emf.ecore.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.EObjectResolvingEList; import org.eclipse.emf.ecore.util.InternalEList; @@ -146,7 +147,7 @@ public class GrammarImpl extends MinimalEObjectImpl.Container implements Grammar * @generated * @ordered */ - protected static final int TOKEN_LIMIT_EDEFAULT = 0; + protected static final int TOKEN_LIMIT_EDEFAULT = 10; /** * The cached value of the '{@link #getTokenLimit() Token Limit}' attribute. diff --git a/org.eclipse.xtext/emf-gen/org/eclipse/xtext/impl/XtextPackageImpl.java b/org.eclipse.xtext/emf-gen/org/eclipse/xtext/impl/XtextPackageImpl.java index c1b29d309..02e66ed33 100644 --- a/org.eclipse.xtext/emf-gen/org/eclipse/xtext/impl/XtextPackageImpl.java +++ b/org.eclipse.xtext/emf-gen/org/eclipse/xtext/impl/XtextPackageImpl.java @@ -1696,7 +1696,7 @@ public class XtextPackageImpl extends EPackageImpl implements XtextPackage { initEReference(getGrammar_MetamodelDeclarations(), this.getAbstractMetamodelDeclaration(), null, "metamodelDeclarations", null, 0, -1, Grammar.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEReference(getGrammar_Rules(), this.getAbstractRule(), null, "rules", null, 0, -1, Grammar.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEReference(getGrammar_InitBlock(), this.getInitBlock(), null, "initBlock", null, 0, 1, Grammar.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getGrammar_TokenLimit(), ecorePackage.getEInt(), "tokenLimit", null, 0, 1, Grammar.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getGrammar_TokenLimit(), ecorePackage.getEInt(), "tokenLimit", "10", 0, 1, Grammar.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getGrammar_Debug(), ecorePackage.getEBoolean(), "debug", null, 0, 1, Grammar.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEClass(abstractRuleEClass, AbstractRule.class, "AbstractRule", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); diff --git a/org.eclipse.xtext/org/eclipse/xtext/Xtext.ecore b/org.eclipse.xtext/org/eclipse/xtext/Xtext.ecore index 1ab932718..5283ce49c 100644 --- a/org.eclipse.xtext/org/eclipse/xtext/Xtext.ecore +++ b/org.eclipse.xtext/org/eclipse/xtext/Xtext.ecore @@ -14,7 +14,8 @@ eType="#//AbstractRule" containment="true"/> - + 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 b9ad90619..9d7dde604 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 arg0) { - return this.getDelegate().contains(arg0); + public boolean contains(final ITextRegion other) { + return this.getDelegate().contains(other); } - public boolean contains(final int arg0) { - return this.getDelegate().contains(arg0); + public boolean contains(final int offset) { + return this.getDelegate().contains(offset); } public int getEndLineNumber() { @@ -279,12 +279,12 @@ public class GeneratorNodeProcessor { return this.getDelegate().getOffset(); } - public ITextRegion merge(final ITextRegion arg0) { - return this.getDelegate().merge(arg0); + public ITextRegion merge(final ITextRegion region) { + return this.getDelegate().merge(region); } - public ITextRegionWithLineInformation merge(final ITextRegionWithLineInformation arg0) { - return this.getDelegate().merge(arg0); + public ITextRegionWithLineInformation merge(final ITextRegionWithLineInformation other) { + return this.getDelegate().merge(other); } }