get debug and token limit from ecore model

moved default token limit to ecore model
This commit is contained in:
overflowerror 2022-01-17 17:13:57 +01:00
parent 2deeea0bd5
commit 7f10364f08
7 changed files with 51 additions and 47 deletions

View file

@ -61,6 +61,38 @@ public class TracingSugarTest {
return result; 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<String, String> 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<Type, String> 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) { public IGeneratorNode _name(final Type target) {
EStructuralFeature feature = target.eClass().getEStructuralFeature("name"); EStructuralFeature feature = target.eClass().getEStructuralFeature("name");
ILocationData location = this.location(target, feature, -1); ILocationData location = this.location(target, feature, -1);
@ -85,14 +117,6 @@ public class TracingSugarTest {
return trace; return trace;
} }
public IGeneratorNode _extends(final Type target, final Function<Type, String> 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<Property, String> stringProvider) { public IGeneratorNode _parentId(final Type target, final Function<Property, String> stringProvider) {
EStructuralFeature feature = target.eClass().getEStructuralFeature("parentId"); EStructuralFeature feature = target.eClass().getEStructuralFeature("parentId");
ILocationData location = this.location(target, feature, -1); ILocationData location = this.location(target, feature, -1);
@ -101,30 +125,6 @@ public class TracingSugarTest {
return trace; 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<String, String> 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) { public IGeneratorNode _name(final UnresolvedProxyProperty target) {
EStructuralFeature feature = target.eClass().getEStructuralFeature("name"); EStructuralFeature feature = target.eClass().getEStructuralFeature("name");
ILocationData location = this.location(target, feature, -1); ILocationData location = this.location(target, feature, -1);

View file

@ -14,11 +14,12 @@ import org.eclipse.xtext.Grammar;
* @author overflow - Initial contribution and API * @author overflow - Initial contribution and API
*/ */
public class HoistingConfiguration { public class HoistingConfiguration {
private final int tokenLimit = 10; private int tokenLimit;
private boolean debug = false; private boolean debug;
public HoistingConfiguration(Grammar grammar) { public HoistingConfiguration(Grammar grammar) {
// TODO: get config options from ecore object this.tokenLimit = grammar.getTokenLimit();
this.debug = grammar.isDebug();
} }
public int getTokenLimit() { public int getTokenLimit() {

View file

@ -171,12 +171,13 @@ public interface Grammar extends EObject {
/** /**
* Returns the value of the '<em><b>Token Limit</b></em>' attribute. * Returns the value of the '<em><b>Token Limit</b></em>' attribute.
* The default value is <code>"10"</code>.
* <!-- begin-user-doc --> * <!-- begin-user-doc -->
* <!-- end-user-doc --> * <!-- end-user-doc -->
* @return the value of the '<em>Token Limit</em>' attribute. * @return the value of the '<em>Token Limit</em>' attribute.
* @see #setTokenLimit(int) * @see #setTokenLimit(int)
* @see org.eclipse.xtext.XtextPackage#getGrammar_TokenLimit() * @see org.eclipse.xtext.XtextPackage#getGrammar_TokenLimit()
* @model * @model default="10"
* @generated * @generated
*/ */
int getTokenLimit(); int getTokenLimit();

View file

@ -15,6 +15,7 @@ import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; 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.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList; import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList; import org.eclipse.emf.ecore.util.InternalEList;
@ -146,7 +147,7 @@ public class GrammarImpl extends MinimalEObjectImpl.Container implements Grammar
* @generated * @generated
* @ordered * @ordered
*/ */
protected static final int TOKEN_LIMIT_EDEFAULT = 0; protected static final int TOKEN_LIMIT_EDEFAULT = 10;
/** /**
* The cached value of the '{@link #getTokenLimit() <em>Token Limit</em>}' attribute. * The cached value of the '{@link #getTokenLimit() <em>Token Limit</em>}' attribute.

View file

@ -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_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_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); 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); 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); initEClass(abstractRuleEClass, AbstractRule.class, "AbstractRule", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);

View file

@ -14,7 +14,8 @@
eType="#//AbstractRule" containment="true"/> eType="#//AbstractRule" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="initBlock" eType="#//InitBlock" <eStructuralFeatures xsi:type="ecore:EReference" name="initBlock" eType="#//InitBlock"
containment="true"/> containment="true"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="tokenLimit" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="tokenLimit" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"
defaultValueLiteral="10"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="debug" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="debug" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
</eClassifiers> </eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="AbstractRule"> <eClassifiers xsi:type="ecore:EClass" name="AbstractRule">

View file

@ -255,12 +255,12 @@ public class GeneratorNodeProcessor {
return this.delegate; return this.delegate;
} }
public boolean contains(final ITextRegion arg0) { public boolean contains(final ITextRegion other) {
return this.getDelegate().contains(arg0); return this.getDelegate().contains(other);
} }
public boolean contains(final int arg0) { public boolean contains(final int offset) {
return this.getDelegate().contains(arg0); return this.getDelegate().contains(offset);
} }
public int getEndLineNumber() { public int getEndLineNumber() {
@ -279,12 +279,12 @@ public class GeneratorNodeProcessor {
return this.getDelegate().getOffset(); return this.getDelegate().getOffset();
} }
public ITextRegion merge(final ITextRegion arg0) { public ITextRegion merge(final ITextRegion region) {
return this.getDelegate().merge(arg0); return this.getDelegate().merge(region);
} }
public ITextRegionWithLineInformation merge(final ITextRegionWithLineInformation arg0) { public ITextRegionWithLineInformation merge(final ITextRegionWithLineInformation other) {
return this.getDelegate().merge(arg0); return this.getDelegate().merge(other);
} }
} }