Ejemplo n.º 1
0
 public FlattenedGrammarAccess(final RuleNames names, final RuleFilter filter) {
   final Grammar grammar = names.getContextGrammar();
   Grammar flattenedGrammar = this.<Grammar>copy(grammar);
   String _name = grammar.getName();
   flattenedGrammar.setName(_name);
   LinkedHashMap<RuleWithParameterValues, AbstractRule> origToCopy =
       Maps.<RuleWithParameterValues, AbstractRule>newLinkedHashMap();
   List<AbstractRule> _rules = filter.getRules(grammar);
   boolean _isDiscardRuleTypeRef = filter.isDiscardRuleTypeRef();
   final ArrayList<AbstractRule> copies =
       this.copyRuleStubs(names, origToCopy, _rules, _isDiscardRuleTypeRef);
   EList<AbstractRule> _rules_1 = flattenedGrammar.getRules();
   Iterables.<AbstractRule>addAll(_rules_1, copies);
   Multimap<TerminalRule, AbstractRule> calledFrom = this.copyRuleBodies(copies, origToCopy);
   this.setHiddenTokens(flattenedGrammar, grammar, origToCopy);
   this.markAsFragment(calledFrom);
   boolean _isDiscardUnreachableRules = filter.isDiscardUnreachableRules();
   if (_isDiscardUnreachableRules) {
     Set<AbstractRule> usedRules = CollectionLiterals.<AbstractRule>newHashSet();
     boolean _isDiscardTerminalRules = filter.isDiscardTerminalRules();
     boolean _not = (!_isDiscardTerminalRules);
     if (_not) {
       List<TerminalRule> _allTerminalRules = GrammarUtil.allTerminalRules(flattenedGrammar);
       usedRules.addAll(_allTerminalRules);
     }
     UsedRulesFinder finder = new UsedRulesFinder(usedRules);
     finder.compute(flattenedGrammar);
     EList<AbstractRule> _rules_2 = flattenedGrammar.getRules();
     _rules_2.retainAll(usedRules);
   }
   this.flattenedGrammar = flattenedGrammar;
   OriginalGrammar _originalGrammar = new OriginalGrammar(grammar);
   _originalGrammar.attachToEmfObject(flattenedGrammar);
 }
Ejemplo n.º 2
0
 @Override
 public void generate(Grammar grammar, XpandExecutionContext ctx) {
   if (LOG.isInfoEnabled()) {
     LOG.info(
         "generating infrastructure for "
             + grammar.getName()
             + " with fragments : "
             + Strings.toString(this.fragments, new ToStringFunction(", "), ", "));
   }
   super.generate(grammar, ctx);
 }
 protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
   Grammar grammar = grammarProvider.getGrammar(this);
   while (grammar != null) {
     if ("org.xtext.scripting.Scripting".equals(grammar.getName())) {
       return grammar;
     }
     List<Grammar> grammars = grammar.getUsedGrammars();
     if (!grammars.isEmpty()) {
       grammar = grammars.iterator().next();
     } else {
       return null;
     }
   }
   return grammar;
 }
Ejemplo n.º 4
0
 protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
   Grammar grammar = grammarProvider.getGrammar(this);
   while (grammar != null) {
     if ("fr.inria.diverse.puzzle.language.Binding".equals(grammar.getName())) {
       return grammar;
     }
     List<Grammar> grammars = grammar.getUsedGrammars();
     if (!grammars.isEmpty()) {
       grammar = grammars.iterator().next();
     } else {
       return null;
     }
   }
   return grammar;
 }
 protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
   Grammar grammar = grammarProvider.getGrammar(this);
   while (grammar != null) {
     if ("org.eclipse.xtext.parser.encoding.EncodingTestLanguage".equals(grammar.getName())) {
       return grammar;
     }
     List<Grammar> grammars = grammar.getUsedGrammars();
     if (!grammars.isEmpty()) {
       grammar = grammars.iterator().next();
     } else {
       return null;
     }
   }
   return grammar;
 }
 protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
   Grammar grammar = grammarProvider.getGrammar(this);
   while (grammar != null) {
     if ("com.parallels.aps.ide.rqleditor.xtext.rql.RQL".equals(grammar.getName())) {
       return grammar;
     }
     List<Grammar> grammars = grammar.getUsedGrammars();
     if (!grammars.isEmpty()) {
       grammar = grammars.iterator().next();
     } else {
       return null;
     }
   }
   return grammar;
 }
Ejemplo n.º 7
0
 protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
   Grammar grammar = grammarProvider.getGrammar(this);
   while (grammar != null) {
     if ("org.eclipse.ocl.examples.xtext.markup.Markup".equals(grammar.getName())) {
       return grammar;
     }
     List<Grammar> grammars = grammar.getUsedGrammars();
     if (!grammars.isEmpty()) {
       grammar = grammars.iterator().next();
     } else {
       return null;
     }
   }
   return grammar;
 }
 protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
   Grammar grammar = grammarProvider.getGrammar(this);
   while (grammar != null) {
     if ("org.eclipse.xtext.ui.tests.editor.contentassist.DatatypeRuleTestLanguage"
         .equals(grammar.getName())) {
       return grammar;
     }
     List<Grammar> grammars = grammar.getUsedGrammars();
     if (!grammars.isEmpty()) {
       grammar = grammars.iterator().next();
     } else {
       return null;
     }
   }
   return grammar;
 }
 protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
   Grammar grammar = grammarProvider.getGrammar(this);
   while (grammar != null) {
     if ("org.eclipse.xtext.formatting2.regionaccess.internal.RegionAccessTestLanguage"
         .equals(grammar.getName())) {
       return grammar;
     }
     List<Grammar> grammars = grammar.getUsedGrammars();
     if (!grammars.isEmpty()) {
       grammar = grammars.iterator().next();
     } else {
       return null;
     }
   }
   return grammar;
 }
Ejemplo n.º 10
0
 public static String getClasspathURI(Grammar grammar, EObject object) {
   String fragment = EcoreUtil.getURI(object).fragment();
   return "classpath:/" + grammar.getName().replace('.', '/') + ".xmi#" + fragment;
 }