本文整理匯總了Java中org.eclipse.xtext.AbstractRule.eAllContents方法的典型用法代碼示例。如果您正苦於以下問題:Java AbstractRule.eAllContents方法的具體用法?Java AbstractRule.eAllContents怎麽用?Java AbstractRule.eAllContents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.xtext.AbstractRule
的用法示例。
在下文中一共展示了AbstractRule.eAllContents方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findByNestedRuleCall
import org.eclipse.xtext.AbstractRule; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
protected <T> List<T> findByNestedRuleCall(Class<T> clazz, AbstractRule... rule) {
Set<AbstractRule> rls = new HashSet<AbstractRule>(Arrays.asList(rule));
ArrayList<T> r = new ArrayList<T>();
for (AbstractRule ar : getRules()) {
TreeIterator<EObject> i = ar.eAllContents();
while (i.hasNext()) {
EObject o = i.next();
if (clazz.isInstance(o)) {
TreeIterator<EObject> ct = o.eAllContents();
while (ct.hasNext()) {
EObject cto = ct.next();
if (cto instanceof RuleCall && rls.contains(((RuleCall) cto).getRule())) {
r.add((T) o);
break;
}
}
i.prune();
}
}
}
return r;
}
示例2: findRuleCalls
import org.eclipse.xtext.AbstractRule; //導入方法依賴的package包/類
public List<RuleCall> findRuleCalls(AbstractRule... rules) {
Set<AbstractRule> rls = new HashSet<AbstractRule>(Arrays.asList(rules));
ArrayList<RuleCall> r = new ArrayList<RuleCall>();
for (AbstractRule ar : getRules()) {
TreeIterator<EObject> i = ar.eAllContents();
while (i.hasNext()) {
EObject o = i.next();
if (o instanceof RuleCall) {
RuleCall c = (RuleCall) o;
if (rls.contains(c.getRule()))
r.add(c);
}
}
}
return r;
}
示例3: ruleContainsAssignedAction
import org.eclipse.xtext.AbstractRule; //導入方法依賴的package包/類
protected boolean ruleContainsAssignedAction(AbstractRule rule, Set<AbstractRule> visited) {
if (!visited.add(rule))
return false;
TreeIterator<EObject> i = rule.eAllContents();
while (i.hasNext()) {
EObject o = i.next();
if (o instanceof Action && ((Action) o).getFeature() != null)
return true;
else if (o instanceof Assignment)
i.prune();
else if (o instanceof RuleCall && isParserRule(((RuleCall) o).getRule())) {
if (ruleContainsAssignedAction(((RuleCall) o).getRule(), visited))
return true;
}
}
return false;
}
示例4: findCrossReferences
import org.eclipse.xtext.AbstractRule; //導入方法依賴的package包/類
public List<CrossReference> findCrossReferences(EClassifier... targetEClassifiers) {
Set<EClassifier> classifiers = new HashSet<EClassifier>(Arrays.asList(targetEClassifiers));
Collection<EClass> classes = Lists.newArrayList(Iterables.filter(classifiers, EClass.class));
ArrayList<CrossReference> r = new ArrayList<CrossReference>();
for (AbstractRule ar : getRules()) {
TreeIterator<EObject> i = ar.eAllContents();
while (i.hasNext()) {
EObject o = i.next();
if (o instanceof CrossReference) {
CrossReference c = (CrossReference) o;
if (classifiers.contains(c.getType().getClassifier()))
r.add(c);
else if (c.getType().getClassifier() instanceof EClass)
for (EClass cls : classes)
if (EcoreUtil2.isAssignableFrom(cls,(EClass) c.getType().getClassifier())) {
r.add(c);
break;
}
i.prune();
}
}
}
return r;
}
示例5: findKeywordPairs
import org.eclipse.xtext.AbstractRule; //導入方法依賴的package包/類
public List<Pair<Keyword, Keyword>> findKeywordPairs(String leftKw, String rightKw) {
ArrayList<Pair<Keyword, Keyword>> pairs = new ArrayList<Pair<Keyword, Keyword>>();
for (AbstractRule ar : getRules())
if (ar instanceof ParserRule && !GrammarUtil.isDatatypeRule((ParserRule) ar)) {
Stack<Keyword> openings = new Stack<Keyword>();
TreeIterator<EObject> i = ar.eAllContents();
while (i.hasNext()) {
EObject o = i.next();
if (o instanceof Keyword) {
Keyword k = (Keyword) o;
if (leftKw.equals(k.getValue()))
openings.push(k);
else if (rightKw.equals(k.getValue())) {
if (openings.size() > 0)
pairs.add(Tuples.create(openings.pop(), k));
}
}
}
}
return pairs;
}
示例6: findKeywords
import org.eclipse.xtext.AbstractRule; //導入方法依賴的package包/類
public List<Keyword> findKeywords(String... keywords) {
Set<String> kwds = new HashSet<String>(Arrays.asList(keywords));
ArrayList<Keyword> r = new ArrayList<Keyword>();
for (AbstractRule ar : getRules()) {
TreeIterator<EObject> i = ar.eAllContents();
while (i.hasNext()) {
EObject o = i.next();
if (o instanceof Keyword) {
Keyword k = (Keyword) o;
if (kwds.contains(k.getValue()))
r.add(k);
}
}
}
return r;
}
示例7: GrammarElementDeclarationOrder
import org.eclipse.xtext.AbstractRule; //導入方法依賴的package包/類
protected GrammarElementDeclarationOrder(Grammar grammar) {
elementIDCache = Maps.newHashMap();
List<Grammar> grammars = Lists.newArrayList(grammar);
grammars.addAll(GrammarUtil.allUsedGrammars(grammar));
int counter = 0;
for (Grammar g : grammars) {
elementIDCache.put(g, counter++);
for (AbstractRule rule : g.getRules()) {
elementIDCache.put(rule, counter++);
TreeIterator<EObject> iterator = rule.eAllContents();
while (iterator.hasNext()) {
elementIDCache.put(iterator.next(), counter++);
}
}
}
}
示例8: findRuleCallsTo
import org.eclipse.xtext.AbstractRule; //導入方法依賴的package包/類
protected Set<MatcherState> findRuleCallsTo(AbstractRule rule, Set<AbstractRule> visited) {
if (!visited.add(rule))
return Collections.emptySet();
Set<MatcherState> result = Sets.newHashSet();
Iterator<EObject> i = rule.eAllContents();
while (i.hasNext()) {
EObject obj = i.next();
if (obj instanceof AbstractElement) {
MatcherState state = nfaProvider.getNFA((AbstractElement) obj);
if (state.hasTransitions())
for (MatcherTransition incoming : state.getAllIncoming())
if (incoming.isRuleCall() && result.add(incoming.getSource())
&& incoming.getSource().isEndState())
result.addAll(findRuleCallsTo(
GrammarUtil.containingRule(incoming.getSource().getGrammarElement()), visited));
}
}
return result;
}
示例9: ruleContainsRecursiveUnassignedRuleCall
import org.eclipse.xtext.AbstractRule; //導入方法依賴的package包/類
protected boolean ruleContainsRecursiveUnassignedRuleCall(AbstractRule rule, Set<AbstractRule> visited) {
if (!visited.add(rule))
return true;
TreeIterator<EObject> i = rule.eAllContents();
while (i.hasNext()) {
EObject o = i.next();
if (o instanceof Assignment)
i.prune();
else if (o instanceof RuleCall && isParserRule(((RuleCall) o).getRule())) {
if (ruleContainsRecursiveUnassignedRuleCall(((RuleCall) o).getRule(), visited))
return true;
}
}
return false;
}