📄 compositevisitor.java
字号:
/** * * Copyright 2005 Jeremy Rayner * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * **/package org.codehaus.groovy.antlr.treewalker;import java.util.*;import org.codehaus.groovy.antlr.GroovySourceAST;/** * A composite of many visitors. Any call to a method from Visitor * will invoke each visitor in turn, and reverse the invocation * order on a closing visit. * i.e. * with the list of visitors = [a,b,c] * composite.visitDefault() would... * call on the opening visit - a.visitDefault() then b.visitDefault() then c.visitDefault() * call on the closing visit - c.visitDefault() then b.visitDefault() then a.visitDefault() * * @author <a href="mailto:groovy@ross-rayner.com">Jeremy Rayner</a> * @version $Revision: 1.2 $ */public class CompositeVisitor implements Visitor{ List visitors; List backToFrontVisitors; private Stack stack; /** * A composite of the supplied list of antlr AST visitors. * @param visitors a List of implementations of the Visitor interface */ public CompositeVisitor(List visitors) { this.visitors = visitors; this.stack = new Stack(); backToFrontVisitors = new ArrayList(); backToFrontVisitors.addAll(visitors); Collections.reverse(backToFrontVisitors); } private Iterator itr(int visit) { Iterator itr=visitors.iterator(); if (visit == CLOSING_VISIT) { itr = backToFrontVisitors.iterator(); } return itr; } public void setUp() { Iterator itr = visitors.iterator(); while (itr.hasNext()) {((Visitor)itr.next()).setUp();} } public void visitAbstract(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitAbstract(t,visit);} } public void visitAnnotation(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitAnnotation(t,visit);} } public void visitAnnotations(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitAnnotations(t,visit);} } public void visitAnnotationArrayInit(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitAnnotationArrayInit(t,visit);} } public void visitAnnotationDef(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitAnnotationDef(t,visit);} } public void visitAnnotationFieldDef(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitAnnotationFieldDef(t,visit);} } public void visitAnnotationMemberValuePair(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitAnnotationMemberValuePair(t,visit);} } public void visitArrayDeclarator(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitArrayDeclarator(t,visit);} } public void visitAssign(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitAssign(t,visit);} } public void visitAt(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitAt(t,visit);} } public void visitBand(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitBand(t,visit);} } public void visitBandAssign(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitBandAssign(t,visit);} } public void visitBigSuffix(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitBigSuffix(t,visit);} } public void visitBlock(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitBlock(t,visit);} } public void visitBnot(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitBnot(t,visit);} } public void visitBor(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitBor(t,visit);} } public void visitBorAssign(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitBorAssign(t,visit);} } public void visitBsr(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitBsr(t,visit);} } public void visitBsrAssign(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitBsrAssign(t,visit);} } public void visitBxor(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitBxor(t,visit);} } public void visitBxorAssign(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitBxorAssign(t,visit);} } public void visitCaseGroup(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitCaseGroup(t,visit);} } public void visitClassDef(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitClassDef(t,visit);} } public void visitClosedBlock(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitClosedBlock(t,visit);} } public void visitClosureOp(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitClosureOp(t,visit);} } public void visitColon(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitColon(t,visit);} } public void visitComma(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitComma(t,visit);} } public void visitCompareTo(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitCompareTo(t,visit);} } public void visitCtorCall(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitCtorCall(t,visit);} } public void visitCtorIdent(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitCtorIdent(t,visit);} } public void visitDec(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitDec(t,visit);} } public void visitDigit(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitDigit(t,visit);} } public void visitDiv(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitDiv(t,visit);} } public void visitDivAssign(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitDivAssign(t,visit);} } public void visitDollar(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitDollar(t,visit);} } public void visitDot(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitDot(t,visit);} } public void visitDynamicMember(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitDynamicMember(t,visit);} } public void visitElist(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitElist(t,visit);} } public void visitEmptyStat(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitEmptyStat(t,visit);} } public void visitEnumConstantDef(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitEnumConstantDef(t,visit);} } public void visitEnumDef(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitEnumDef(t,visit);} } public void visitEof(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitEof(t,visit);} } public void visitEqual(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitEqual(t,visit);} } public void visitEsc(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitEsc(t,visit);} } public void visitExponent(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitExponent(t,visit);} } public void visitExpr(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitExpr(t,visit);} } public void visitExtendsClause(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitExtendsClause(t,visit);} } public void visitFinal(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitFinal(t,visit);} } public void visitFloatSuffix(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitFloatSuffix(t,visit);} } public void visitForCondition(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitForCondition(t,visit);} } public void visitForEachClause(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitForEachClause(t,visit);} } public void visitForInit(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitForInit(t,visit);} } public void visitForInIterable(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitForInIterable(t,visit);} } public void visitForIterator(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitForIterator(t,visit);} } public void visitGe(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitGe(t,visit);} } public void visitGt(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitGt(t,visit);} } public void visitHexDigit(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitHexDigit(t,visit);} } public void visitIdent(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitIdent(t,visit);} } public void visitImplementsClause(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitImplementsClause(t,visit);} } public void visitImplicitParameters(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitImplicitParameters(t,visit);} } public void visitImport(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitImport(t,visit);} } public void visitInc(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitInc(t,visit);} } public void visitIndexOp(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitIndexOp(t,visit);} } public void visitInstanceInit(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitInstanceInit(t,visit);} } public void visitInterfaceDef(GroovySourceAST t, int visit) { Iterator itr = itr(visit); while (itr.hasNext()) {((Visitor)itr.next()).visitInterfaceDef(t,visit);} } public void visitLabeledArg(GroovySourceAST t, int visit) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -