Java Code Examples for org.eclipse.xtext.IGrammarAccess#getGrammar()

The following examples show how to use org.eclipse.xtext.IGrammarAccess#getGrammar() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UnorderedGroupHelper.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Inject
public Collector(IGrammarAccess grammarAccess) {
	Grammar grammar = grammarAccess.getGrammar();
	List<ParserRule> parserRules = GrammarUtil.allParserRules(grammar);
	List<UnorderedGroup> groups = Lists.newArrayList();
	for(ParserRule rule: parserRules) {
		Iterator<EObject> iter = rule.eAllContents();
		while(iter.hasNext()) {
			EObject next = iter.next();
			if (next instanceof UnorderedGroup) {
				groups.add((UnorderedGroup) next);
			}
		}
	}
	this.groups = ImmutableList.copyOf(groups);
}
 
Example 2
Source File: CheckCfgUtil.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Gets the all languages available in the workbench.
 *
 * @return set of all languages
 */
public Set<String> getAllLanguages() {
  Set<String> languages = new HashSet<String>();
  for (String extension : Registry.INSTANCE.getExtensionToFactoryMap().keySet()) {
    final URI dummyUri = URI.createURI("foo:/foo." + extension);
    IResourceServiceProvider resourceServiceProvider = Registry.INSTANCE.getResourceServiceProvider(dummyUri);
    // By checking that description manager is AbstractCachingResourceDescriptionManager we exclude technical languages of the framework
    if (resourceServiceProvider != null && resourceServiceProvider.getResourceDescriptionManager() instanceof AbstractCachingResourceDescriptionManager) {
      try {
        IGrammarAccess grammarAccess = resourceServiceProvider.get(IGrammarAccess.class);
        if (grammarAccess != null && grammarAccess.getGrammar() != null) {
          languages.add(grammarAccess.getGrammar().getName());
        }
      } catch (ConfigurationException e) {
        // Will happen if no binding for IGrammarAccess was present.
      }
    }
  }
  return languages;
}
 
Example 3
Source File: ConcreteSyntaxConstraintProvider.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Inject
protected void setGrammar(IGrammarAccess grammar) {
	this.grammar = grammar.getGrammar();
}
 
Example 4
Source File: RuleNames.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Inject
public RuleNames(IGrammarAccess grammarAccess) {
	this(grammarAccess.getGrammar(), false);
}
 
Example 5
Source File: AbstractDeclarativeValueConverterService.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Inject
public void setGrammar(IGrammarAccess grammarAccess) {
	this.grammar = grammarAccess.getGrammar();
}
 
Example 6
Source File: GrammarAccessHelper.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
public GrammarAccessHelper(final IGrammarAccess grammarAccess) {
  super(grammarAccess.getGrammar());
  this.grammarAccess = grammarAccess;
}