Java 类org.eclipse.xtext.Grammar 实例源码

项目:n4js    文件:StableOrderSyntacticSequencerPDAProvider.java   
/**
 * Specialized to yield an {@link AbstractElementAlias} that has sorted alternatives where the occurrence in the
 * grammar defines the order of the output.
 */
@Override
public AbstractElementAlias getAmbiguousSyntax() {
    if (ambiguousSyntax != null)
        return ambiguousSyntax;
    Nfa<ISynState> nfa = getAmbiguousNfa();
    NfaToProduction prod = new NfaToProduction();

    // TODO remove with Xtext 2.13 if the patch makes it into the framework
    // FIX is here: We want to use a stable order
    Grammar grammar = getGrammar(nfa);
    GrammarElementDeclarationOrder order = GrammarElementDeclarationOrder.get(grammar);
    ambiguousSyntax = prod.nfaToGrammar(nfa, new GetGrammarElement(), order, new GrammarAliasFactory());
    // end fix
    return ambiguousSyntax;
}
项目:n4js    文件:StableOrderSyntacticSequencerPDAProvider.java   
/**
 * Extracts the grammar from this transition or the NFA if this transition does not point to an
 * {@link AbstractElement}.
 */
private Grammar getGrammar(Nfa<ISynState> nfa) {
    AbstractElement grammarElement = getGrammarElement();
    if (grammarElement == null) {
        grammarElement = nfa.getStart().getGrammarElement();
        if (grammarElement == null) {
            grammarElement = nfa.getStop().getGrammarElement();
            if (grammarElement == null) {
                Iterator<ISynState> iter = nfa.getStart().getFollowers().iterator();
                while (grammarElement == null && iter.hasNext()) {
                    grammarElement = iter.next().getGrammarElement();
                }
            }
        }
    }
    Grammar grammar = GrammarUtil.getGrammar(grammarElement);
    return grammar;
}
项目:n4js    文件:PatchedFollowElementComputer.java   
@Override
public void collectAbstractElements(Grammar grammar, EStructuralFeature feature,
        IFollowElementAcceptor followElementAcceptor) {
    for (Grammar superGrammar : grammar.getUsedGrammars()) {
        collectAbstractElements(superGrammar, feature, followElementAcceptor);
    }
    EClass declarator = feature.getEContainingClass();
    for (ParserRule rule : GrammarUtil.allParserRules(grammar)) {
        for (Assignment assignment : GrammarUtil.containedAssignments(rule)) {
            if (assignment.getFeature().equals(feature.getName())) {
                EClassifier classifier = GrammarUtil.findCurrentType(assignment);
                EClassifier compType = EcoreUtil2.getCompatibleType(declarator, classifier);
                if (compType == declarator) {
                    followElementAcceptor.accept(assignment);
                }
            }
        }
    }
}
项目:n4js    文件:InternalSemicolonInjectingParser.java   
@SuppressWarnings("unchecked")
@Override
protected void registerRules(Grammar grammar) {
    if (ALL_RULES_FIELD != null) {
        try {
            Map<String, AbstractRule> localAllRules = (Map<String, AbstractRule>) ALL_RULES_FIELD.get(this);
            if (allRules == null) {
                super.registerRules(grammar);
                allRules = localAllRules;
            } else {
                localAllRules.putAll(allRules);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    } else {
        super.registerRules(grammar);
    }
}
项目:OCCI-Studio    文件:OCCIGrammarAccess.java   
protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
    Grammar grammar = grammarProvider.getGrammar(this);
    while (grammar != null) {
        if ("org.eclipse.cmf.occi.core.xtext.OCCI".equals(grammar.getName())) {
            return grammar;
        }
        List<Grammar> grammars = grammar.getUsedGrammars();
        if (!grammars.isEmpty()) {
            grammar = grammars.iterator().next();
        } else {
            return null;
        }
    }
    return grammar;
}
项目:xtext-core    文件:GrammarUtilTest.java   
@Test
public void testFindCurrentType_02() throws Exception {
  this.with(XtextStandaloneSetup.class);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("grammar myLang with org.eclipse.xtext.common.Terminals");
  _builder.newLine();
  _builder.append("generate g \'http://1\'");
  _builder.newLine();
  _builder.append("Rule:");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("Fragment;");
  _builder.newLine();
  _builder.append("fragment Fragment: name=ID {SubRule.named=current};");
  _builder.newLine();
  String model = _builder.toString();
  final XtextResource r = this.getResourceFromString(model);
  EObject _get = r.getContents().get(0);
  final Grammar grammar = ((Grammar) _get);
  final AbstractRule rule = IterableExtensions.<AbstractRule>head(grammar.getRules());
  final AbstractElement fragmentCall = rule.getAlternatives();
  final EClassifier currentType = GrammarUtil.findCurrentType(fragmentCall);
  Assert.assertEquals("SubRule", currentType.getName());
}
项目:dsl-devkit    文件:AbstractSelectorFragmentProviderTest.java   
@Override
public CharSequence getFragmentSegment(final EObject object) {
  EClass eClass = object.eClass();
  EPackage ePackage = eClass.getEPackage();
  if (ePackage == XtextPackage.eINSTANCE) {
    int classifierID = eClass.getClassifierID();
    switch (classifierID) {
    case XtextPackage.GRAMMAR:
      return getFragmentSegment((Grammar) object);
    case XtextPackage.ENUM_RULE:
    case XtextPackage.PARSER_RULE:
    case XtextPackage.TERMINAL_RULE:
      return getFragmentSegment((AbstractRule) object);
    case XtextPackage.KEYWORD:
      if (((Keyword) object).getValue().equals("selectCardinality")) {
        return getFragmentSegment((AbstractElement) object);
      } else {
        return getFragmentSegment((Keyword) object);
      }
    default:
      return super.getFragmentSegment(object);
    }
  }
  return super.getFragmentSegment(object);
}
项目:xtext-core    文件:OverriddenValueInspectorTest.java   
@Test
public void testRuleCall_01() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("grammar org.foo with org.eclipse.xtext.common.Terminals");
  _builder.newLine();
  _builder.append("generate metamodel \'foo.sample\'");
  _builder.newLine();
  _builder.append("First returns Object: (Third|Second) cardinality=(\'+\'|\'*\')?;");
  _builder.newLine();
  _builder.append("Second returns Object: \'(\' First \')\';");
  _builder.newLine();
  _builder.append("Third returns Object: name=ID;");
  _builder.newLine();
  String grammarAsString = _builder.toString();
  final Grammar grammar = this.getGrammar(grammarAsString);
  AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "First");
  final ParserRule rule = ((ParserRule) _findRuleForName);
  this.validateRule(rule);
  Assert.assertEquals(this.warnings.toString(), 2, this.warnings.size());
}
项目:xtext-extras    文件:TestsEMFGeneratorFragment.java   
@Override
protected String getGenModelPath(final Grammar grammar) {
  String _xifexpression = null;
  boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(this.genModel);
  boolean _not = (!_isNullOrEmpty);
  if (_not) {
    _xifexpression = this.genModel;
  } else {
    String _javaModelDirectory = this.getJavaModelDirectory();
    String _plus = (_javaModelDirectory + "/");
    String _replace = grammar.getName().substring(0, grammar.getName().lastIndexOf(".")).replace(".", "/");
    String _plus_1 = (_plus + _replace);
    String _plus_2 = (_plus_1 + "/");
    String _modelName = this.getModelName(grammar);
    String _plus_3 = (_plus_2 + _modelName);
    _xifexpression = (_plus_3 + ".genmodel");
  }
  return _xifexpression;
}
项目:xtext-core    文件:XtextLinkerTest.java   
@Test
public void testQualifiedRuleCall_02() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("grammar test 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 STRING: super;");
  _builder.newLine();
  final String grammarAsString = _builder.toString();
  final XtextResource resource = this.getResourceFromString(grammarAsString);
  EObject _get = resource.getContents().get(0);
  Grammar grammar = ((Grammar) _get);
  AbstractRule _get_1 = grammar.getRules().get(1);
  final TerminalRule string = ((TerminalRule) _get_1);
  AbstractElement _alternatives = string.getAlternatives();
  final RuleCall callToSuper = ((RuleCall) _alternatives);
  Assert.assertEquals(GrammarUtil.findRuleForName(IterableExtensions.<Grammar>head(grammar.getUsedGrammars()), "STRING"), callToSuper.getRule());
}
项目:xtext-core    文件:GrammarPDAProviderTest.java   
private void assertNoLeakedGrammarElements(final Grammar grammar, final Pda<ISerState, RuleCall> pda) {
  final Function1<ISerState, AbstractElement> _function = (ISerState it) -> {
    return it.getGrammarElement();
  };
  Iterable<AbstractElement> _filterNull = IterableExtensions.<AbstractElement>filterNull(IterableExtensions.<ISerState, AbstractElement>map(new NfaUtil().<ISerState>collect(pda), _function));
  for (final AbstractElement ele : _filterNull) {
    {
      final Grammar actual = GrammarUtil.getGrammar(ele);
      if ((actual != grammar)) {
        String _objPath = EmfFormatter.objPath(ele);
        String _plus = ("Element " + _objPath);
        String _plus_1 = (_plus + " leaked!");
        Assert.fail(_plus_1);
      }
    }
  }
}
项目:xtext-extras    文件:PackratParserGenUtil.java   
public static AbstractElement findFirstWithSameConflicts(final AbstractElement element, final Grammar grammar) {
    final List<String> conflicting = getConflictingKeywords(element, grammar);
    AbstractElement result = element;
    Iterator<AbstractElement> iterator = Iterators.filter(
            Iterators.filter(EcoreUtil.getAllContents(grammar, true), AbstractElement.class),
            new Predicate<AbstractElement>() {
                @Override
                public boolean apply(AbstractElement param) {
                    final List<String> otherConflicting = getConflictingKeywords(param, grammar);
                    return otherConflicting != null && otherConflicting.equals(conflicting);
                }
            });
    if (iterator.hasNext())
        result = iterator.next();

    return result;
}
项目:xtext-core    文件:EMFGeneratorFragment2.java   
protected GenModel getSaveAndReconcileGenModel(final Grammar grammar, final List<EPackage> packs, final ResourceSet rs) {
  final GenModel genModel = this.getGenModel(rs, grammar);
  genModel.initialize(packs);
  EList<GenPackage> _genPackages = genModel.getGenPackages();
  for (final GenPackage genPackage : _genPackages) {
    {
      genPackage.setBasePackage(this.getBasePackage(grammar));
      if (this.suppressLoadInitialization) {
        genPackage.setLoadInitialization(false);
      }
      if (((!this.getLanguage().getFileExtensions().isEmpty()) && packs.contains(genPackage.getEcorePackage()))) {
        genPackage.setFileExtensions(IterableExtensions.join(this.getLanguage().getFileExtensions(), ","));
      }
    }
  }
  final Set<EPackage> referencedEPackages = this.getReferencedEPackages(packs);
  final List<GenPackage> usedGenPackages = this.getGenPackagesForPackages(genModel, referencedEPackages);
  this.reconcileMissingGenPackagesInUsedModels(usedGenPackages);
  genModel.getUsedGenPackages().addAll(usedGenPackages);
  this.saveResource(genModel.eResource());
  new GenModelHelper().registerGenModel(genModel);
  return genModel;
}
项目:xtext-core    文件:ParsetreeUtilTest.java   
@Override
public void setUp() throws Exception {
    super.setUp();
    with(XtextStandaloneSetup.class);
    modelAsString = "\n" +
            "grammar org.eclipse.xtext.parsetree.impl.LineTestLanguage with org.eclipse.xtext.common.Terminals\n" +
            "\n" +
            "generate testLanguage \"http://www.eclipse.org/2009/tmf/xtext/ParsetreeUtilTest\"\n" +
            " \n" +
            "Model:\n" +
            "  name=ID\n" +
            ";\n" +
            "\n" +
            "\n";
    grammar = (Grammar) getModel(modelAsString);
    grammarNode = NodeModelUtils.getNode(grammar);
    metamodelNode = NodeModelUtils.getNode(grammar.getMetamodelDeclarations().get(0));
    parentMetamodelNode = metamodelNode.getParent();
}
项目:xtext-extras    文件:Generator.java   
private void generatePluginXmlRt(List<LanguageConfig> configs, XpandExecutionContext ctx) {
    String filePath = fileExists(ctx, "plugin.xml", PLUGIN_RT) ? "plugin.xml_gen" : "plugin.xml";
    deleteFile(ctx, filePath, PLUGIN_RT);
    ctx.getOutput().openFile(filePath, PLUGIN_RT);
    ctx.getOutput().getOutlet(PLUGIN_RT).addVetoStrategy(new EmptyPluginXmlVeto());
    try {
        XpandFacade facade = XpandFacade.create(ctx);
        List<Grammar> grammars = getGrammars(configs);
        facade.evaluate("org::eclipse::xtext::generator::Plugin::pre", grammars);
        for (LanguageConfig conf : languageConfigs) {
            conf.addToPluginXmlRt(conf, ctx);
            if (isUiMergedIntoRt()) {
                conf.addToPluginXmlUi(conf, ctx);
            }
        }
        facade.evaluate("org::eclipse::xtext::generator::Plugin::post", grammars);
    } finally {
        ctx.getOutput().closeFile();
    }
}
项目:xtext-core    文件:XtextValidationTest.java   
@Test public void testActionAllowed_01() throws Exception {
    String grammarAsText =
        "grammar test with org.eclipse.xtext.common.Terminals\n" +
        "generate test 'http://test'\n" +
        "Model: name=ID Fragment;\n" +
        "fragment Fragment: {Model};\n";

    Grammar grammar = (Grammar) getModel(grammarAsText);
    ParserRule rule = (ParserRule) grammar.getRules().get(1);
    Action action = (Action) rule.getAlternatives();
    XtextValidator validator = get(XtextValidator.class);
    ValidatingMessageAcceptor messageAcceptor = new ValidatingMessageAcceptor(action, true, false);
    validator.setMessageAcceptor(messageAcceptor);
    try {
        validator.checkUnassignedActionAfterAssignment(action);
        fail();
    } catch(RuntimeException e) {
        assertEquals("org.eclipse.xtext.validation.GuardException", e.getClass().getName());
    }
    messageAcceptor.validate();
}
项目:xtext-core    文件:SyntacticSequencerPDAProvider.java   
/**
 * Extracts the grammar from this transition or the NFA if this transition does not point to an
 * {@link AbstractElement}.
 */
private Grammar getGrammar(Nfa<ISynState> nfa) {
    AbstractElement grammarElement = getGrammarElement();
    if (grammarElement == null) {
        grammarElement = nfa.getStart().getGrammarElement();
        if (grammarElement == null) {
            grammarElement = nfa.getStop().getGrammarElement();
            if (grammarElement == null) {
                Iterator<ISynState> iter = nfa.getStart().getFollowers().iterator();
                while (grammarElement == null && iter.hasNext()) {
                    grammarElement = iter.next().getGrammarElement();
                }
            }
        }
    }
    Grammar grammar = GrammarUtil.getGrammar(grammarElement);
    return grammar;
}
项目:xtext-core    文件:XtextValidationTest.java   
@Test public void testBug_282852_08() throws Exception {
    Grammar base = XtextFactory.eINSTANCE.createGrammar();
    AbstractRule ruleFoo = XtextFactory.eINSTANCE.createParserRule();
    ruleFoo.setName("Foo");
    base.getRules().add(ruleFoo);
    AbstractRule subRuleFoo = XtextFactory.eINSTANCE.createParserRule();
    subRuleFoo.setName("foo");
    AbstractRule subRuleFoo2 = XtextFactory.eINSTANCE.createParserRule();
    subRuleFoo2.setName("fOO");
    AbstractRule subRuleFoo3 = XtextFactory.eINSTANCE.createParserRule();
    subRuleFoo3.setName("FOO");
    base.getRules().add(subRuleFoo);
    base.getRules().add(subRuleFoo2);
    base.getRules().add(subRuleFoo3);

    XtextValidator validator = get(XtextValidator.class);
    configureValidator(validator, this, subRuleFoo);
    validator.checkRuleName(subRuleFoo);
    assertEquals("A rule's name has to be unique even case insensitive. The conflicting rules are 'FOO', 'Foo' and 'fOO'.", lastMessage);
}
项目:xtext-core    文件:GrammarAccessExtensions.java   
public List<String> initialHiddenTokens(final Grammar it) {
  List<String> _xblockexpression = null;
  {
    boolean _isDefinesHiddenTokens = it.isDefinesHiddenTokens();
    if (_isDefinesHiddenTokens) {
      final Function1<AbstractRule, String> _function = (AbstractRule it_1) -> {
        return this.ruleName(it_1);
      };
      return IterableExtensions.<String>toList(ListExtensions.<AbstractRule, String>map(it.getHiddenTokens(), _function));
    }
    int _size = it.getUsedGrammars().size();
    boolean _equals = (_size == 1);
    if (_equals) {
      return this.initialHiddenTokens(IterableExtensions.<Grammar>head(it.getUsedGrammars()));
    }
    _xblockexpression = CollectionLiterals.<String>emptyList();
  }
  return _xblockexpression;
}
项目:xtext-core    文件:OverriddenValueInspectorTest.java   
@Test
public void testBug306281_02() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("grammar org.foo with org.eclipse.xtext.common.Terminals");
  _builder.newLine();
  _builder.append("generate metamodel \'foo.sample\'");
  _builder.newLine();
  _builder.append("Model : name=ID (({Binary.left=current} operator = \'-\' | {Binary.left=current} operator = \'+\') right=ID)* name=ID;");
  _builder.newLine();
  String grammarAsString = _builder.toString();
  final Grammar grammar = this.getGrammar(grammarAsString);
  AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "Model");
  final ParserRule rule = ((ParserRule) _findRuleForName);
  this.validateRule(rule);
  Assert.assertEquals(this.warnings.toString(), 2, this.warnings.size());
}
项目:pokemon-tcgo-deck-generator    文件:PkmntcgoGrammarAccess.java   
protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
    Grammar grammar = grammarProvider.getGrammar(this);
    while (grammar != null) {
        if ("de.baernreuther.dsls.Pkmntcgo".equals(grammar.getName())) {
            return grammar;
        }
        List<Grammar> grammars = grammar.getUsedGrammars();
        if (!grammars.isEmpty()) {
            grammar = grammars.iterator().next();
        } else {
            return null;
        }
    }
    return grammar;
}
项目:n4js    文件:GrammarLinter.java   
private void printKeywordsInTypesButNotInN4JS() {
    Grammar n4js = grammarAccess.getGrammar();
    Grammar types = typesGrammarAccess.getGrammar();
    ListMultimap<String, Keyword> n4jsKeywords = getAllKeywords(n4js);
    ListMultimap<String, Keyword> typesKeywords = getAllKeywords(types);

    typesKeywords.keySet().removeAll(n4jsKeywords.keySet());

    System.out.println("Keywords which do not occur in n4js rules: ");
    for (String keyword : typesKeywords.keySet()) {
        System.out.println("  " + keyword);
    }
    System.out.println();
}
项目:n4js    文件:GrammarLinter.java   
private void printKeywordsOnlyInDatatypeRules() {
    Grammar grammar = grammarAccess.getGrammar();
    ListMultimap<String, Keyword> allKeywords = getAllKeywords(grammar);
    System.out.println("Keywords which do not occur in production rules: ");
    outer: for (Collection<Keyword> chunk : allKeywords.asMap().values()) {
        for (Keyword keyword : chunk) {
            AbstractRule rule = EcoreUtil2.getContainerOfType(keyword, AbstractRule.class);
            if (!GrammarUtil.isDatatypeRule(rule)) {
                continue outer;
            }
        }
        System.out.println("  " + ((List<Keyword>) chunk).get(0).getValue());
    }
    System.out.println();
}
项目:n4js    文件:TypesGrammarAccess.java   
protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
    Grammar grammar = grammarProvider.getGrammar(this);
    while (grammar != null) {
        if ("org.eclipse.n4js.ts.Types".equals(grammar.getName())) {
            return grammar;
        }
        List<Grammar> grammars = grammar.getUsedGrammars();
        if (!grammars.isEmpty()) {
            grammar = grammars.iterator().next();
        } else {
            return null;
        }
    }
    return grammar;
}
项目:n4js    文件:TypeExpressionsGrammarAccess.java   
protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
    Grammar grammar = grammarProvider.getGrammar(this);
    while (grammar != null) {
        if ("org.eclipse.n4js.ts.TypeExpressions".equals(grammar.getName())) {
            return grammar;
        }
        List<Grammar> grammars = grammar.getUsedGrammars();
        if (!grammars.isEmpty()) {
            grammar = grammars.iterator().next();
        } else {
            return null;
        }
    }
    return grammar;
}
项目:n4js    文件:UnicodeGrammarAccess.java   
protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
    Grammar grammar = grammarProvider.getGrammar(this);
    while (grammar != null) {
        if ("org.eclipse.n4js.common.unicode.Unicode".equals(grammar.getName())) {
            return grammar;
        }
        List<Grammar> grammars = grammar.getUsedGrammars();
        if (!grammars.isEmpty()) {
            grammar = grammars.iterator().next();
        } else {
            return null;
        }
    }
    return grammar;
}
项目:n4js    文件:RegularExpressionGrammarAccess.java   
protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
    Grammar grammar = grammarProvider.getGrammar(this);
    while (grammar != null) {
        if ("org.eclipse.n4js.regex.RegularExpression".equals(grammar.getName())) {
            return grammar;
        }
        List<Grammar> grammars = grammar.getUsedGrammars();
        if (!grammars.isEmpty()) {
            grammar = grammars.iterator().next();
        } else {
            return null;
        }
    }
    return grammar;
}
项目:n4js    文件:N4JSGrammarAccess.java   
protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
    Grammar grammar = grammarProvider.getGrammar(this);
    while (grammar != null) {
        if ("org.eclipse.n4js.N4JS".equals(grammar.getName())) {
            return grammar;
        }
        List<Grammar> grammars = grammar.getUsedGrammars();
        if (!grammars.isEmpty()) {
            grammar = grammars.iterator().next();
        } else {
            return null;
        }
    }
    return grammar;
}
项目:n4js    文件:N4MFGrammarAccess.java   
protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
    Grammar grammar = grammarProvider.getGrammar(this);
    while (grammar != null) {
        if ("org.eclipse.n4js.n4mf.N4MF".equals(grammar.getName())) {
            return grammar;
        }
        List<Grammar> grammars = grammar.getUsedGrammars();
        if (!grammars.isEmpty()) {
            grammar = grammars.iterator().next();
        } else {
            return null;
        }
    }
    return grammar;
}
项目:Xtext_Xtend_HTML_Generator    文件:MyDslGrammarAccess.java   
protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
    Grammar grammar = grammarProvider.getGrammar(this);
    while (grammar != null) {
        if ("org.xtext.example.mydsl.MyDsl".equals(grammar.getName())) {
            return grammar;
        }
        List<Grammar> grammars = grammar.getUsedGrammars();
        if (!grammars.isEmpty()) {
            grammar = grammars.iterator().next();
        } else {
            return null;
        }
    }
    return grammar;
}
项目:bromium    文件:BromiumGrammarAccess.java   
protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
    Grammar grammar = grammarProvider.getGrammar(this);
    while (grammar != null) {
        if ("com.hribol.bromium.dsl.Bromium".equals(grammar.getName())) {
            return grammar;
        }
        List<Grammar> grammars = grammar.getUsedGrammars();
        if (!grammars.isEmpty()) {
            grammar = grammars.iterator().next();
        } else {
            return null;
        }
    }
    return grammar;
}
项目:gw4e.project    文件:DSLPoliciesGrammarAccess.java   
protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
    Grammar grammar = grammarProvider.getGrammar(this);
    while (grammar != null) {
        if ("gw4e.eclipse.dsl.DSLPolicies".equals(grammar.getName())) {
            return grammar;
        }
        List<Grammar> grammars = grammar.getUsedGrammars();
        if (!grammars.isEmpty()) {
            grammar = grammars.iterator().next();
        } else {
            return null;
        }
    }
    return grammar;
}
项目:lcdsl    文件:LcDslGrammarAccess.java   
protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
    Grammar grammar = grammarProvider.getGrammar(this);
    while (grammar != null) {
        if ("com.wamas.ide.launching.LcDsl".equals(grammar.getName())) {
            return grammar;
        }
        List<Grammar> grammars = grammar.getUsedGrammars();
        if (!grammars.isEmpty()) {
            grammar = grammars.iterator().next();
        } else {
            return null;
        }
    }
    return grammar;
}
项目:gemoc-studio    文件:DslGrammarAccess.java   
protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
    Grammar grammar = grammarProvider.getGrammar(this);
    while (grammar != null) {
        if ("org.eclipse.gemoc.Dsl".equals(grammar.getName())) {
            return grammar;
        }
        List<Grammar> grammars = grammar.getUsedGrammars();
        if (!grammars.isEmpty()) {
            grammar = grammars.iterator().next();
        } else {
            return null;
        }
    }
    return grammar;
}
项目:org.xtext.dsl.restaurante    文件:RestauranteGrammarAccess.java   
protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
    Grammar grammar = grammarProvider.getGrammar(this);
    while (grammar != null) {
        if ("org.xtext.dsl.restaurante.Restaurante".equals(grammar.getName())) {
            return grammar;
        }
        List<Grammar> grammars = grammar.getUsedGrammars();
        if (!grammars.isEmpty()) {
            grammar = grammars.iterator().next();
        } else {
            return null;
        }
    }
    return grammar;
}
项目:xtext-core    文件:Bug313089TestLanguageGrammarAccess.java   
protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
    Grammar grammar = grammarProvider.getGrammar(this);
    while (grammar != null) {
        if ("org.eclipse.xtext.linking.Bug313089TestLanguage".equals(grammar.getName())) {
            return grammar;
        }
        List<Grammar> grammars = grammar.getUsedGrammars();
        if (!grammars.isEmpty()) {
            grammar = grammars.iterator().next();
        } else {
            return null;
        }
    }
    return grammar;
}
项目:xtext-core    文件:AbstractAntlrGeneratorFragment2.java   
protected boolean hasParameterizedRules(final Grammar grammar) {
  List<ParserRule> _allParserRules = GrammarUtil.allParserRules(grammar);
  for (final ParserRule rule : _allParserRules) {
    boolean _isEmpty = rule.getParameters().isEmpty();
    boolean _not = (!_isEmpty);
    if (_not) {
      return true;
    }
  }
  return false;
}
项目:xtext-core    文件:NoJdtTestLanguageGrammarAccess.java   
protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
    Grammar grammar = grammarProvider.getGrammar(this);
    while (grammar != null) {
        if ("org.eclipse.xtext.testlanguages.noJdt.NoJdtTestLanguage".equals(grammar.getName())) {
            return grammar;
        }
        List<Grammar> grammars = grammar.getUsedGrammars();
        if (!grammars.isEmpty()) {
            grammar = grammars.iterator().next();
        } else {
            return null;
        }
    }
    return grammar;
}
项目:xtext-core    文件:KeywordInspectorTest.java   
@Test public void testIgnoreTerminalRules() throws Exception {
    String grammarAsString = "grammar org.xtext.example.MyDsl7 with org.eclipse.xtext.common.Terminals\n" + 
            "generate myDsl \"http://www.xtext.org/example/MyDsl\"\n" + 
            "Type : 'type' '#' name=ID;\n" + 
            "terminal POUND: '#';";
    Grammar grammar = getGrammar(grammarAsString);
    AbstractRule rule = GrammarUtil.findRuleForName(grammar, "POUND");
    validateRule(rule);
    assertEquals(errors.toString(), 0, errors.size());
}
项目:xtext-core    文件:NodeModelUtilsTest.java   
@Test public void testFindActualSemanticObjectFor_08() throws Exception {
    String grammarString = "grammar foo.Bar with org.eclipse.xtext.common.Terminals generate foo 'bar' Model:/**/name=ID;";
    Grammar grammar = (Grammar) getModel(grammarString);
    ILeafNode leadingComment = NodeModelUtils.findLeafNodeAtOffset(NodeModelUtils.getNode(grammar), grammarString.indexOf('*'));
    EObject object = NodeModelUtils.findActualSemanticObjectFor(leadingComment);
    assertTrue(object instanceof Assignment);
}