本文整理汇总了Java中org.spoofax.interpreter.terms.IStrategoTerm.getAllSubterms方法的典型用法代码示例。如果您正苦于以下问题:Java IStrategoTerm.getAllSubterms方法的具体用法?Java IStrategoTerm.getAllSubterms怎么用?Java IStrategoTerm.getAllSubterms使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spoofax.interpreter.terms.IStrategoTerm
的用法示例。
在下文中一共展示了IStrategoTerm.getAllSubterms方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildTermIterative
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
/**
* Builds the AST for the specified term, iteratively.
*
* @param root
* The root term.
*/
private void buildTermIterative(final PsiBuilder builder, final IStrategoTerm root,
final ATermAstElementTypeProvider elementTypeProvider) {
final Stack<TermTask> tasks = new Stack<>();
tasks.push(new TermTask(root));
while(!tasks.empty()) {
final TermTask task = tasks.pop();
final IStrategoTerm term = task.term();
@Nullable PsiBuilder.Marker marker = task.marker();
if(marker == null) {
// Start
marker = buildTermStart(builder, term);
tasks.push(new TermTask(term, marker));
final IStrategoTerm[] subterms = term.getAllSubterms();
for(int i = subterms.length - 1; i >= 0; i--) {
tasks.push(new TermTask(subterms[i]));
}
} else {
// End
buildTermEnd(builder, term, marker, elementTypeProvider);
}
}
}
示例2: buildTermRecursive
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
/**
* Builds the AST for the specified term, recursively.
*
* @param term
* The term.
*/
@SuppressWarnings("unused") private void buildTermRecursive(final PsiBuilder builder, final IStrategoTerm term,
final ATermAstElementTypeProvider elementTypeProvider) {
final PsiBuilder.Marker marker = buildTermStart(builder, term);
final IStrategoTerm[] subterms = term.getAllSubterms();
for(final IStrategoTerm subterm : subterms) {
// Recurse
buildTermRecursive(builder, subterm, elementTypeProvider);
}
buildTermEnd(builder, term, marker, elementTypeProvider);
}
示例3: simpleAll
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
public IStrategoTerm simpleAll(IStrategoTerm current) {
int termType = current.getTermType();
IStrategoTerm result;
if (termType == LIST) {
result = simpleMapIgnoreAnnos((IStrategoList) current);
} else {
IStrategoTerm[] inputs = current.getAllSubterms();
IStrategoTerm[] results = null;
for (int i = 0; i < inputs.length; i++) {
IStrategoTerm arg = inputs[i];
IStrategoTerm arg2 = transform(arg);
if (arg2 != arg) {
if (arg2 == null)
return null;
if (results == null)
results = inputs.clone();
results[i] = keepAttachments ? factory.copyAttachments(arg, arg2) : arg2;
}
}
if (results == null)
return current;
switch (termType) {
case APPL:
result = factory.makeAppl(((IStrategoAppl) current).getConstructor(),
results, current.getAnnotations());
break;
case TUPLE:
result = factory.makeTuple(results, current.getAnnotations());
break;
default:
throw new IllegalStateException("unexpected term type: " + termType + " - " + current);
}
}
return keepAttachments ? factory.copyAttachments(current, result) : result;
}
示例4: strip
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
public IStrategoTerm strip(IStrategoTerm term) {
if (term == null)
return null;
// Kids
boolean isRebuildNeeded = false;
IStrategoTerm[] kids = TermFactory.EMPTY;
if (term.getSubtermCount() > 0) {
kids = term.getAllSubterms();
IStrategoTerm[] newKids = tryStripKids(kids);
if (newKids != null) {
isRebuildNeeded = true;
kids = newKids;
}
}
// Annotations
IStrategoList annos = term.getAnnotations();
IStrategoTerm[] newAnnos = tryStripAnnos(annos);
if (newAnnos != null) {
isRebuildNeeded = true;
annos = factory.makeList(newAnnos);
}
// Self
if (!isRebuildNeeded)
isRebuildNeeded = term.getAttachment(null) != null;
return isRebuildNeeded
? converter.convertShallow(term, kids, annos)
: term;
}
示例5: isTagElementList
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private boolean isTagElementList(IStrategoTerm term) {
if(term instanceof IStrategoList) {
IStrategoTerm[] kids = term.getAllSubterms();
for(int i = 0; i < kids.length; i++)
if(!isTagElement(kids[i]))
return false;
}
return true;
}
示例6: getChildren
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
public static List<STermCursor> getChildren(STermCursor c) {
IStrategoTerm term = c.getData();
ArrayList<STermCursor> list = new ArrayList<STermCursor>();
for(IStrategoTerm subterm : term.getAllSubterms()) {
list.add(StrategoAdapter.termToTree(subterm));
}
return list;
}
示例7: expandSubterms
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private List<List<IStrategoTerm>> expandSubterms(IStrategoTerm astWithSubAsts) {
List<List<IStrategoTerm>> expandedSubAsts =
new ArrayList<List<IStrategoTerm>>(astWithSubAsts.getSubtermCount());
for(IStrategoTerm subAst : astWithSubAsts.getAllSubterms()) {
expandedSubAsts.add(expand(subAst));
}
return expand(expandedSubAsts);
}
示例8: getSyntaxName
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private static String getSyntaxName(IStrategoTerm entries) {
for(IStrategoTerm entry : entries.getAllSubterms()) {
final String cons = ((IStrategoAppl) entry).getConstructor().getName();
if(cons.equals("Syntax")) {
return Tools.asJavaString(entry.getSubterm(0));
}
}
return null;
}
示例9: asExtendedModifierList
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Collection asExtendedModifierList(IStrategoTerm term) {
IStrategoTerm[] kids = term.getAllSubterms();
List r = new ArrayList(kids.length);
for(IStrategoTerm k : kids) {
r.add(asExtendedModifier(k));
}
return r;
}
示例10: asTypeParameterList
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Collection asTypeParameterList(IStrategoTerm term) {
IStrategoTerm[] kids = term.getAllSubterms();
List r = new ArrayList(kids.length);
for(IStrategoTerm k : kids) {
r.add(asTypeParameter(k));
}
return r;
}
示例11: asTagElementList
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Collection asTagElementList(IStrategoTerm term) {
IStrategoTerm[] kids = term.getAllSubterms();
List r = new ArrayList(kids.length);
for(IStrategoTerm k : kids) {
r.add(asTagElement(k));
}
return r;
}
示例12: collectLeafnodes
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
/**
* Collects the leaf nodes
* @param trm
* @return
*/
public static ArrayList<IStrategoTerm> collectLeafnodes(IStrategoTerm trm){
ArrayList<IStrategoTerm> leafnodes = new ArrayList<IStrategoTerm>();
IStrategoTerm[] subterms = trm.getAllSubterms();
if(subterms.length == 0){
leafnodes.add(trm);
}
else {
for (int i = 0; i < subterms.length; i++) {
leafnodes.addAll(collectLeafnodes(subterms[i]));
}
}
return leafnodes;
}
示例13: asNameList
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Collection asNameList(IStrategoTerm term) {
IStrategoTerm[] kids = term.getAllSubterms();
List r = new ArrayList(kids.length);
for(IStrategoTerm k : kids) {
r.add(asName(k));
}
return r;
}
示例14: asSingleVariableDeclarationList
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Collection asSingleVariableDeclarationList(IStrategoTerm term) {
IStrategoTerm[] kids = term.getAllSubterms();
List r = new ArrayList(kids.length);
for(IStrategoTerm k : kids) {
r.add(asSingleVariableDeclaration(k));
}
return r;
}
示例15: asExpressionList
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Collection asExpressionList(IStrategoTerm term) {
IStrategoTerm[] kids = term.getAllSubterms();
List r = new ArrayList(kids.length);
for(IStrategoTerm k : kids) {
r.add(asExpression(k));
}
return r;
}