本文整理匯總了Java中org.eclipse.xtext.IGrammarAccess.getGrammar方法的典型用法代碼示例。如果您正苦於以下問題:Java IGrammarAccess.getGrammar方法的具體用法?Java IGrammarAccess.getGrammar怎麽用?Java IGrammarAccess.getGrammar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.xtext.IGrammarAccess
的用法示例。
在下文中一共展示了IGrammarAccess.getGrammar方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: Collector
import org.eclipse.xtext.IGrammarAccess; //導入方法依賴的package包/類
@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);
}
示例2: getAllLanguages
import org.eclipse.xtext.IGrammarAccess; //導入方法依賴的package包/類
/**
* 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;
}
示例3: setGrammar
import org.eclipse.xtext.IGrammarAccess; //導入方法依賴的package包/類
@Inject
protected void setGrammar(IGrammarAccess grammar) {
this.grammar = grammar.getGrammar();
}
示例4: RuleNames
import org.eclipse.xtext.IGrammarAccess; //導入方法依賴的package包/類
@Inject
public RuleNames(IGrammarAccess grammarAccess) {
this(grammarAccess.getGrammar(), false);
}
示例5: setGrammar
import org.eclipse.xtext.IGrammarAccess; //導入方法依賴的package包/類
@Inject
public void setGrammar(IGrammarAccess grammarAccess) {
this.grammar = grammarAccess.getGrammar();
}
示例6: GrammarAccessHelper
import org.eclipse.xtext.IGrammarAccess; //導入方法依賴的package包/類
public GrammarAccessHelper(final IGrammarAccess grammarAccess) {
super(grammarAccess.getGrammar());
this.grammarAccess = grammarAccess;
}