Search in sources :

Example 6 with SuperCallScope

use of org.eclipse.xtext.xtext.SuperCallScope in project xtext-core by eclipse.

the class SuperCallScopeTest method testGetAllElements_02.

@Test
public void testGetAllElements_02() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("grammar test.Lang with org.eclipse.xtext.common.Terminals");
    _builder.newLine();
    _builder.append("generate test \'http://test\'");
    _builder.newLine();
    _builder.append("Rule: name=ID;");
    _builder.newLine();
    _builder.append("terminal ID: super;");
    _builder.newLine();
    final String grammarAsString = _builder.toString();
    EObject _model = this.getModel(grammarAsString);
    final Grammar grammar = ((Grammar) _model);
    AbstractRule _last = IterableExtensions.<AbstractRule>last(grammar.getRules());
    final SuperCallScope scope = new SuperCallScope(_last);
    this.assertElementNames(scope.getAllElements(), "Lang.Rule", "test.Lang.Rule", "Lang.ID", "test.Lang.ID", "super", "super.ID", "Terminals.ID", "org.eclipse.xtext.common.Terminals.ID", "super.INT", "Terminals.INT", "org.eclipse.xtext.common.Terminals.INT", "super.STRING", "Terminals.STRING", "org.eclipse.xtext.common.Terminals.STRING", "super.ML_COMMENT", "Terminals.ML_COMMENT", "org.eclipse.xtext.common.Terminals.ML_COMMENT", "super.SL_COMMENT", "Terminals.SL_COMMENT", "org.eclipse.xtext.common.Terminals.SL_COMMENT", "super.WS", "Terminals.WS", "org.eclipse.xtext.common.Terminals.WS", "super.ANY_OTHER", "Terminals.ANY_OTHER", "org.eclipse.xtext.common.Terminals.ANY_OTHER");
}
Also used : SuperCallScope(org.eclipse.xtext.xtext.SuperCallScope) EObject(org.eclipse.emf.ecore.EObject) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Grammar(org.eclipse.xtext.Grammar) AbstractRule(org.eclipse.xtext.AbstractRule) Test(org.junit.Test)

Example 7 with SuperCallScope

use of org.eclipse.xtext.xtext.SuperCallScope in project xtext-core by eclipse.

the class SuperCallScopeTest method testGetAllElements_01.

@Test
public void testGetAllElements_01() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("grammar test.Lang with org.eclipse.xtext.common.Terminals");
    _builder.newLine();
    _builder.append("generate test \'http://test\'");
    _builder.newLine();
    _builder.append("Rule: name=ID;");
    _builder.newLine();
    _builder.append("terminal ID: super;");
    _builder.newLine();
    final String grammarAsString = _builder.toString();
    EObject _model = this.getModel(grammarAsString);
    final Grammar grammar = ((Grammar) _model);
    final SuperCallScope scope = new SuperCallScope(grammar);
    this.assertElementNames(scope.getAllElements(), "Lang.Rule", "test.Lang.Rule", "Lang.ID", "test.Lang.ID", "super.ID", "Terminals.ID", "org.eclipse.xtext.common.Terminals.ID", "super.INT", "Terminals.INT", "org.eclipse.xtext.common.Terminals.INT", "super.STRING", "Terminals.STRING", "org.eclipse.xtext.common.Terminals.STRING", "super.ML_COMMENT", "Terminals.ML_COMMENT", "org.eclipse.xtext.common.Terminals.ML_COMMENT", "super.SL_COMMENT", "Terminals.SL_COMMENT", "org.eclipse.xtext.common.Terminals.SL_COMMENT", "super.WS", "Terminals.WS", "org.eclipse.xtext.common.Terminals.WS", "super.ANY_OTHER", "Terminals.ANY_OTHER", "org.eclipse.xtext.common.Terminals.ANY_OTHER");
}
Also used : SuperCallScope(org.eclipse.xtext.xtext.SuperCallScope) EObject(org.eclipse.emf.ecore.EObject) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Grammar(org.eclipse.xtext.Grammar) Test(org.junit.Test)

Example 8 with SuperCallScope

use of org.eclipse.xtext.xtext.SuperCallScope in project xtext-core by eclipse.

the class SuperCallScopeTest method testGetElementsByName_05.

@Test
public void testGetElementsByName_05() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("grammar test.Lang with org.eclipse.xtext.common.Terminals");
    _builder.newLine();
    _builder.append("generate test \'http://test\'");
    _builder.newLine();
    _builder.append("Rule: name=ID;");
    _builder.newLine();
    _builder.append("terminal ID: super;");
    _builder.newLine();
    final String grammarAsString = _builder.toString();
    EObject _model = this.getModel(grammarAsString);
    final Grammar grammar = ((Grammar) _model);
    final SuperCallScope scope = new SuperCallScope(grammar);
    Iterable<IEObjectDescription> _elements = scope.getElements(QualifiedName.create("super", "ID"));
    AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "org.eclipse.xtext.common.Terminals.ID");
    Pair<String, AbstractRule> _mappedTo = Pair.<String, AbstractRule>of("super.ID", _findRuleForName);
    this.assertElements(_elements, _mappedTo);
}
Also used : SuperCallScope(org.eclipse.xtext.xtext.SuperCallScope) EObject(org.eclipse.emf.ecore.EObject) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Grammar(org.eclipse.xtext.Grammar) AbstractRule(org.eclipse.xtext.AbstractRule) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Example 9 with SuperCallScope

use of org.eclipse.xtext.xtext.SuperCallScope in project xtext-core by eclipse.

the class SuperCallScopeTest method testGetElementsByEObject_02.

@Test
public void testGetElementsByEObject_02() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("grammar test.Lang with org.eclipse.xtext.common.Terminals");
    _builder.newLine();
    _builder.append("generate test \'http://test\'");
    _builder.newLine();
    _builder.append("Rule: name=ID;");
    _builder.newLine();
    _builder.append("terminal ID: super;");
    _builder.newLine();
    final String grammarAsString = _builder.toString();
    EObject _model = this.getModel(grammarAsString);
    final Grammar grammar = ((Grammar) _model);
    AbstractRule _head = IterableExtensions.<AbstractRule>head(grammar.getRules());
    final SuperCallScope scope = new SuperCallScope(_head);
    final AbstractRule id = GrammarUtil.findRuleForName(grammar, "org.eclipse.xtext.common.Terminals.ID");
    Iterable<IEObjectDescription> _elements = scope.getElements(id);
    AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "org.eclipse.xtext.common.Terminals.ID");
    Pair<String, AbstractRule> _mappedTo = Pair.<String, AbstractRule>of("super.ID", _findRuleForName);
    AbstractRule _findRuleForName_1 = GrammarUtil.findRuleForName(grammar, "org.eclipse.xtext.common.Terminals.ID");
    Pair<String, AbstractRule> _mappedTo_1 = Pair.<String, AbstractRule>of("Lang.ID", _findRuleForName_1);
    AbstractRule _findRuleForName_2 = GrammarUtil.findRuleForName(grammar, "org.eclipse.xtext.common.Terminals.ID");
    Pair<String, AbstractRule> _mappedTo_2 = Pair.<String, AbstractRule>of("test.Lang.ID", _findRuleForName_2);
    this.assertElements(_elements, _mappedTo, _mappedTo_1, _mappedTo_2);
}
Also used : SuperCallScope(org.eclipse.xtext.xtext.SuperCallScope) EObject(org.eclipse.emf.ecore.EObject) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Grammar(org.eclipse.xtext.Grammar) AbstractRule(org.eclipse.xtext.AbstractRule) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Example 10 with SuperCallScope

use of org.eclipse.xtext.xtext.SuperCallScope in project xtext-core by eclipse.

the class SuperCallScopeTest method testGetElementsByName_07.

@Test
public void testGetElementsByName_07() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("grammar test.Lang with org.eclipse.xtext.common.Terminals");
    _builder.newLine();
    _builder.append("generate test \'http://test\'");
    _builder.newLine();
    _builder.append("Rule: name=ID;");
    _builder.newLine();
    _builder.append("terminal ID: super;");
    _builder.newLine();
    final String grammarAsString = _builder.toString();
    EObject _model = this.getModel(grammarAsString);
    final Grammar grammar = ((Grammar) _model);
    final SuperCallScope scope = new SuperCallScope(grammar);
    Iterable<IEObjectDescription> _elements = scope.getElements(QualifiedName.create("test", "Lang", "ID"));
    AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "test.Lang.ID");
    Pair<String, AbstractRule> _mappedTo = Pair.<String, AbstractRule>of("test.Lang.ID", _findRuleForName);
    this.assertElements(_elements, _mappedTo);
}
Also used : SuperCallScope(org.eclipse.xtext.xtext.SuperCallScope) EObject(org.eclipse.emf.ecore.EObject) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Grammar(org.eclipse.xtext.Grammar) AbstractRule(org.eclipse.xtext.AbstractRule) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)12 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)12 Grammar (org.eclipse.xtext.Grammar)12 SuperCallScope (org.eclipse.xtext.xtext.SuperCallScope)12 Test (org.junit.Test)12 AbstractRule (org.eclipse.xtext.AbstractRule)9 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)7