0001: /*
0002: * Author: Chris Seguin
0003: *
0004: * This software has been developed under the copyleft
0005: * rules of the GNU General Public License. Please
0006: * consult the GNU General Public License for more
0007: * details about use and distribution of this software.
0008: */
0009: package org.acm.seguin.pretty;
0010:
0011: import java.util.Vector;
0012: import net.sourceforge.jrefactory.parser.JavaParserVisitor;
0013: import net.sourceforge.jrefactory.parser.Token;
0014: import net.sourceforge.jrefactory.ast.Node;
0015: import net.sourceforge.jrefactory.ast.ASTAdditiveExpression;
0016: import net.sourceforge.jrefactory.ast.ASTAllocationExpression;
0017: import net.sourceforge.jrefactory.ast.ASTAndExpression;
0018: import net.sourceforge.jrefactory.ast.ASTArgumentList;
0019: import net.sourceforge.jrefactory.ast.ASTArguments;
0020: import net.sourceforge.jrefactory.ast.ASTArrayDimsAndInits;
0021: import net.sourceforge.jrefactory.ast.ASTArrayInitializer;
0022: import net.sourceforge.jrefactory.ast.ASTAssignmentOperator;
0023: import net.sourceforge.jrefactory.ast.ASTBlock;
0024: import net.sourceforge.jrefactory.ast.ASTBlockStatement;
0025: import net.sourceforge.jrefactory.ast.ASTBooleanLiteral;
0026: import net.sourceforge.jrefactory.ast.ASTBreakStatement;
0027: import net.sourceforge.jrefactory.ast.ASTCastExpression;
0028: import net.sourceforge.jrefactory.ast.ASTClassBody;
0029: import net.sourceforge.jrefactory.ast.ASTClassBodyDeclaration;
0030: import net.sourceforge.jrefactory.ast.ASTClassDeclaration;
0031: import net.sourceforge.jrefactory.ast.ASTCompilationUnit;
0032: import net.sourceforge.jrefactory.ast.ASTConditionalAndExpression;
0033: import net.sourceforge.jrefactory.ast.ASTConditionalExpression;
0034: import net.sourceforge.jrefactory.ast.ASTConditionalOrExpression;
0035: import net.sourceforge.jrefactory.ast.ASTConstructorDeclaration;
0036: import net.sourceforge.jrefactory.ast.ASTContinueStatement;
0037: import net.sourceforge.jrefactory.ast.ASTDoStatement;
0038: import net.sourceforge.jrefactory.ast.ASTEmptyStatement;
0039: import net.sourceforge.jrefactory.ast.ASTEqualityExpression;
0040: import net.sourceforge.jrefactory.ast.ASTExclusiveOrExpression;
0041: import net.sourceforge.jrefactory.ast.ASTExplicitConstructorInvocation;
0042: import net.sourceforge.jrefactory.ast.ASTExpression;
0043: import net.sourceforge.jrefactory.ast.ASTFieldDeclaration;
0044: import net.sourceforge.jrefactory.ast.ASTForInit;
0045: import net.sourceforge.jrefactory.ast.ASTForStatement;
0046: import net.sourceforge.jrefactory.ast.ASTForUpdate;
0047: import net.sourceforge.jrefactory.ast.ASTFormalParameter;
0048: import net.sourceforge.jrefactory.ast.ASTFormalParameters;
0049: import net.sourceforge.jrefactory.ast.ASTIfStatement;
0050: import net.sourceforge.jrefactory.ast.ASTImportDeclaration;
0051: import net.sourceforge.jrefactory.ast.ASTInclusiveOrExpression;
0052: import net.sourceforge.jrefactory.ast.ASTInitializer;
0053: import net.sourceforge.jrefactory.ast.ASTInstanceOfExpression;
0054: import net.sourceforge.jrefactory.ast.ASTInterfaceBody;
0055: import net.sourceforge.jrefactory.ast.ASTInterfaceDeclaration;
0056: import net.sourceforge.jrefactory.ast.ASTInterfaceMemberDeclaration;
0057: import net.sourceforge.jrefactory.ast.ASTLabeledStatement;
0058: import net.sourceforge.jrefactory.ast.ASTLiteral;
0059: import net.sourceforge.jrefactory.ast.ASTLocalVariableDeclaration;
0060: import net.sourceforge.jrefactory.ast.ASTMethodDeclaration;
0061: import net.sourceforge.jrefactory.ast.ASTMethodDeclarator;
0062: import net.sourceforge.jrefactory.ast.ASTMultiplicativeExpression;
0063: import net.sourceforge.jrefactory.ast.ASTName;
0064: import net.sourceforge.jrefactory.ast.ASTNameList;
0065: import net.sourceforge.jrefactory.ast.ASTNestedClassDeclaration;
0066: import net.sourceforge.jrefactory.ast.ASTNestedInterfaceDeclaration;
0067: import net.sourceforge.jrefactory.ast.ASTNullLiteral;
0068: import net.sourceforge.jrefactory.ast.ASTPackageDeclaration;
0069: import net.sourceforge.jrefactory.ast.ASTPostfixExpression;
0070: import net.sourceforge.jrefactory.ast.ASTPreDecrementExpression;
0071: import net.sourceforge.jrefactory.ast.ASTPreIncrementExpression;
0072: import net.sourceforge.jrefactory.ast.ASTPrimaryExpression;
0073: import net.sourceforge.jrefactory.ast.ASTPrimaryPrefix;
0074: import net.sourceforge.jrefactory.ast.ASTPrimarySuffix;
0075: import net.sourceforge.jrefactory.ast.ASTPrimitiveType;
0076: import net.sourceforge.jrefactory.ast.ASTRelationalExpression;
0077: import net.sourceforge.jrefactory.ast.ASTResultType;
0078: import net.sourceforge.jrefactory.ast.ASTReturnStatement;
0079: import net.sourceforge.jrefactory.ast.ASTShiftExpression;
0080: import net.sourceforge.jrefactory.ast.ASTStatement;
0081: import net.sourceforge.jrefactory.ast.ASTStatementExpression;
0082: import net.sourceforge.jrefactory.ast.ASTStatementExpressionList;
0083: import net.sourceforge.jrefactory.ast.ASTSwitchLabel;
0084: import net.sourceforge.jrefactory.ast.ASTSwitchStatement;
0085: import net.sourceforge.jrefactory.ast.ASTSynchronizedStatement;
0086: import net.sourceforge.jrefactory.ast.ASTThrowStatement;
0087: import net.sourceforge.jrefactory.ast.ASTTryStatement;
0088: import net.sourceforge.jrefactory.ast.ASTType;
0089: import net.sourceforge.jrefactory.ast.ASTTypeDeclaration;
0090: import net.sourceforge.jrefactory.ast.ASTUnaryExpression;
0091: import net.sourceforge.jrefactory.ast.ASTUnaryExpressionNotPlusMinus;
0092: import net.sourceforge.jrefactory.ast.ASTUnmodifiedClassDeclaration;
0093: import net.sourceforge.jrefactory.ast.ASTUnmodifiedInterfaceDeclaration;
0094: import net.sourceforge.jrefactory.ast.ASTVariableDeclarator;
0095: import net.sourceforge.jrefactory.ast.ASTVariableDeclaratorId;
0096: import net.sourceforge.jrefactory.ast.ASTVariableInitializer;
0097: import net.sourceforge.jrefactory.ast.ASTWhileStatement;
0098: import net.sourceforge.jrefactory.ast.ASTAssertionStatement;
0099: import net.sourceforge.jrefactory.ast.SimpleNode;
0100:
0101: import net.sourceforge.jrefactory.ast.ASTTypeParameterList;
0102: import net.sourceforge.jrefactory.ast.ASTTypeParameter;
0103: import net.sourceforge.jrefactory.ast.ASTTypeArguments;
0104: import net.sourceforge.jrefactory.ast.ASTReferenceTypeList;
0105: import net.sourceforge.jrefactory.ast.ASTReferenceType;
0106: import net.sourceforge.jrefactory.ast.ASTClassOrInterfaceType;
0107: import net.sourceforge.jrefactory.ast.ASTActualTypeArgument;
0108: import net.sourceforge.jrefactory.ast.ASTTypeParameters;
0109: import net.sourceforge.jrefactory.ast.ASTGenericNameList;
0110: import net.sourceforge.jrefactory.ast.ASTEnumDeclaration;
0111: import net.sourceforge.jrefactory.ast.ASTEnumElement;
0112: import net.sourceforge.jrefactory.ast.ASTIdentifier;
0113: import net.sourceforge.jrefactory.ast.ASTAnnotation;
0114: import net.sourceforge.jrefactory.ast.ASTMemberValuePairs;
0115: import net.sourceforge.jrefactory.ast.ASTMemberValuePair;
0116: import net.sourceforge.jrefactory.ast.ASTMemberValue;
0117: import net.sourceforge.jrefactory.ast.ASTMemberValueArrayInitializer;
0118: import net.sourceforge.jrefactory.ast.ASTAnnotationTypeDeclaration;
0119: import net.sourceforge.jrefactory.ast.ASTAnnotationTypeMemberDeclaration;
0120: import net.sourceforge.jrefactory.ast.ASTAnnotationMethodDeclaration;
0121: import net.sourceforge.jrefactory.ast.ASTConstantDeclaration;
0122: import net.sourceforge.jrefactory.ast.ASTJSPBody;
0123:
0124: /**
0125: * Processes special tokens
0126: *
0127: *@author Chris Seguin
0128: *@author Mike Atkinson
0129: *@created October 13, 1999
0130: *@date March 10, 1999
0131: */
0132: public class SpecialTokenVisitor implements JavaParserVisitor {
0133: // Instance Variables
0134: private Vector chain;
0135:
0136: /**
0137: * Constructor for the SpecialTokenVisitor object
0138: */
0139: public SpecialTokenVisitor() {
0140: // Create the chain of responsibility
0141: chain = new Vector();
0142:
0143: // Populate it
0144: chain.addElement(new PrintSpecialDefault());
0145: chain.addElement(new PrintSpecialNewline());
0146: chain.addElement(new PrintSpecialSingleLineComment());
0147: chain.addElement(new PrintSpecialMultiLineComment());
0148: chain.addElement(new PrintSpecialJavadocComment());
0149: chain.addElement(new PrintSpecialCategoryComment());
0150: }
0151:
0152: /**
0153: * process the special tokens (Javadoc, newlines, etc.) for this node.
0154: *
0155: * It uses processSpecialToken() to do all the work.
0156: *
0157: *@param node process this node.
0158: *@param data of class PrintData
0159: *@return Updated PrintData
0160: *@since JRefactory 2.9.10
0161: */
0162: public Object visit(ASTJSPBody node, Object data) {
0163: return processSpecialToken(node, data);
0164: }
0165:
0166: /**
0167: * process the special tokens (Javadoc, newlines, etc.) for this node.
0168: *
0169: * It uses processSpecialToken() to do all the work.
0170: *
0171: *@param node process this node.
0172: *@param data of class PrintData
0173: *@return Updated PrintData
0174: *@since JRefactory 2.7.00
0175: */
0176: public Object visit(ASTTypeParameterList node, Object data) {
0177: return processSpecialToken(node, data);
0178: }
0179:
0180: /**
0181: * process the special tokens (Javadoc, newlines, etc.) for this node.
0182: *
0183: * It uses processSpecialToken() to do all the work.
0184: *
0185: *@param node process this node.
0186: *@param data of class PrintData
0187: *@return Updated PrintData
0188: *@since JRefactory 2.7.00
0189: */
0190: public Object visit(ASTTypeParameter node, Object data) {
0191: return processSpecialToken(node, data);
0192: }
0193:
0194: /**
0195: * process the special tokens (Javadoc, newlines, etc.) for this node.
0196: *
0197: * It uses processSpecialToken() to do all the work.
0198: *
0199: *@param node process this node.
0200: *@param data of class PrintData
0201: *@return Updated PrintData
0202: *@since JRefactory 2.7.00
0203: */
0204: public Object visit(ASTTypeArguments node, Object data) {
0205: return processSpecialToken(node, data);
0206: }
0207:
0208: /**
0209: * process the special tokens (Javadoc, newlines, etc.) for this node.
0210: *
0211: * It uses processSpecialToken() to do all the work.
0212: *
0213: *@param node process this node.
0214: *@param data of class PrintData
0215: *@return Updated PrintData
0216: *@since JRefactory 2.7.00
0217: */
0218: public Object visit(ASTReferenceTypeList node, Object data) {
0219: return processSpecialToken(node, data);
0220: }
0221:
0222: /**
0223: * process the special tokens (Javadoc, newlines, etc.) for this node.
0224: *
0225: * It uses processSpecialToken() to do all the work.
0226: *
0227: *@param node process this node.
0228: *@param data of class PrintData
0229: *@return Updated PrintData
0230: *@since JRefactory 2.7.00
0231: */
0232: public Object visit(ASTReferenceType node, Object data) {
0233: return processSpecialToken(node, data);
0234: }
0235:
0236: /**
0237: * process the special tokens (Javadoc, newlines, etc.) for this node.
0238: *
0239: * It uses processSpecialToken() to do all the work.
0240: *
0241: *@param node process this node.
0242: *@param data of class PrintData
0243: *@return Updated PrintData
0244: *@since JRefactory 2.7.00
0245: */
0246: public Object visit(ASTClassOrInterfaceType node, Object data) {
0247: return processSpecialToken(node, data);
0248: }
0249:
0250: /**
0251: * process the special tokens (Javadoc, newlines, etc.) for this node.
0252: *
0253: * It uses processSpecialToken() to do all the work.
0254: *
0255: *@param node process this node.
0256: *@param data of class PrintData
0257: *@return Updated PrintData
0258: *@since JRefactory 2.7.00
0259: */
0260: public Object visit(ASTActualTypeArgument node, Object data) {
0261: return processSpecialToken(node, data);
0262: }
0263:
0264: /**
0265: * process the special tokens (Javadoc, newlines, etc.) for this node.
0266: *
0267: * It uses processSpecialToken() to do all the work.
0268: *
0269: *@param node process this node.
0270: *@param data of class PrintData
0271: *@return Updated PrintData
0272: *@since JRefactory 2.7.00
0273: */
0274: public Object visit(ASTTypeParameters node, Object data) {
0275: return processSpecialToken(node, data);
0276: }
0277:
0278: /**
0279: * process the special tokens (Javadoc, newlines, etc.) for this node.
0280: *
0281: * It uses processSpecialToken() to do all the work.
0282: *
0283: *@param node process this node.
0284: *@param data of class PrintData
0285: *@return Updated PrintData
0286: *@since JRefactory 2.7.00
0287: */
0288: public Object visit(ASTGenericNameList node, Object data) {
0289: return processSpecialToken(node, data);
0290: }
0291:
0292: /**
0293: * process the special tokens (Javadoc, newlines, etc.) for this node.
0294: *
0295: * It uses processSpecialToken() to do all the work.
0296: *
0297: *@param node process this node.
0298: *@param data of class PrintData
0299: *@return Updated PrintData
0300: *@since JRefactory 2.7.00
0301: */
0302: public Object visit(ASTEnumDeclaration node, Object data) {
0303: return processSpecialToken(node, data);
0304: }
0305:
0306: /**
0307: * process the special tokens (Javadoc, newlines, etc.) for this node.
0308: *
0309: * It uses processSpecialToken() to do all the work.
0310: *
0311: *@param node process this node.
0312: *@param data of class PrintData
0313: *@return Updated PrintData
0314: *@since JRefactory 2.7.00
0315: */
0316: public Object visit(ASTEnumElement node, Object data) {
0317: return processSpecialToken(node, data);
0318: }
0319:
0320: /**
0321: * process the special tokens (Javadoc, newlines, etc.) for this node.
0322: *
0323: * It uses processSpecialToken() to do all the work.
0324: *
0325: *@param node process this node.
0326: *@param data of class PrintData
0327: *@return Updated PrintData
0328: *@since JRefactory 2.7.00
0329: */
0330: public Object visit(ASTIdentifier node, Object data) {
0331: return processSpecialToken(node, data);
0332: }
0333:
0334: /**
0335: * process the special tokens (Javadoc, newlines, etc.) for this node.
0336: *
0337: * It uses processSpecialToken() to do all the work.
0338: *
0339: *@param node process this node.
0340: *@param data of class PrintData
0341: *@return Updated PrintData
0342: *@since JRefactory 2.7.00
0343: */
0344: public Object visit(ASTAnnotationTypeDeclaration node, Object data) {
0345: return processSpecialToken(node, data);
0346: }
0347:
0348: /**
0349: * process the special tokens (Javadoc, newlines, etc.) for this node.
0350: *
0351: * It uses processSpecialToken() to do all the work.
0352: *
0353: *@param node process this node.
0354: *@param data of class PrintData
0355: *@return Updated PrintData
0356: *@since JRefactory 2.7.00
0357: */
0358: public Object visit(ASTAnnotationTypeMemberDeclaration node,
0359: Object data) {
0360: return processSpecialToken(node, data);
0361: }
0362:
0363: /**
0364: * process the special tokens (Javadoc, newlines, etc.) for this node.
0365: *
0366: * It uses processSpecialToken() to do all the work.
0367: *
0368: *@param node process this node.
0369: *@param data of class PrintData
0370: *@return Updated PrintData
0371: *@since JRefactory 2.7.00
0372: */
0373: public Object visit(ASTAnnotationMethodDeclaration node, Object data) {
0374: return processSpecialToken(node, data);
0375: }
0376:
0377: /**
0378: * process the special tokens (Javadoc, newlines, etc.) for this node.
0379: *
0380: * It uses processSpecialToken() to do all the work.
0381: *
0382: *@param node process this node.
0383: *@param data of class PrintData
0384: *@return Updated PrintData
0385: *@since JRefactory 2.7.00
0386: */
0387: public Object visit(ASTConstantDeclaration node, Object data) {
0388: return processSpecialToken(node, data);
0389: }
0390:
0391: /**
0392: * process the special tokens (Javadoc, newlines, etc.) for this node.
0393: *
0394: * It uses processSpecialToken() to do all the work.
0395: *
0396: *@param node process this node.
0397: *@param data of class PrintData
0398: *@return Updated PrintData
0399: *@since JRefactory 2.7.00
0400: */
0401: public Object visit(ASTAnnotation node, Object data) {
0402: return processSpecialToken(node, data);
0403: }
0404:
0405: /**
0406: * process the special tokens (Javadoc, newlines, etc.) for this node.
0407: *
0408: * It uses processSpecialToken() to do all the work.
0409: *
0410: *@param node process this node.
0411: *@param data of class PrintData
0412: *@return Updated PrintData
0413: *@since JRefactory 2.7.00
0414: */
0415: public Object visit(ASTMemberValuePairs node, Object data) {
0416: return processSpecialToken(node, data);
0417: }
0418:
0419: /**
0420: * process the special tokens (Javadoc, newlines, etc.) for this node.
0421: *
0422: * It uses processSpecialToken() to do all the work.
0423: *
0424: *@param node process this node.
0425: *@param data of class PrintData
0426: *@return Updated PrintData
0427: *@since JRefactory 2.7.00
0428: */
0429: public Object visit(ASTMemberValuePair node, Object data) {
0430: return processSpecialToken(node, data);
0431: }
0432:
0433: /**
0434: * process the special tokens (Javadoc, newlines, etc.) for this node.
0435: *
0436: * It uses processSpecialToken() to do all the work.
0437: *
0438: *@param node process this node.
0439: *@param data of class PrintData
0440: *@return Updated PrintData
0441: *@since JRefactory 2.7.00
0442: */
0443: public Object visit(ASTMemberValue node, Object data) {
0444: return processSpecialToken(node, data);
0445: }
0446:
0447: /**
0448: * process the special tokens (Javadoc, newlines, etc.) for this node.
0449: *
0450: * It uses processSpecialToken() to do all the work.
0451: *
0452: *@param node process this node.
0453: *@param data of class PrintData
0454: *@return Updated PrintData
0455: *@since JRefactory 2.7.00
0456: */
0457: public Object visit(ASTMemberValueArrayInitializer node, Object data) {
0458: return processSpecialToken(node, data);
0459: }
0460:
0461: /**
0462: * Description of the Method
0463: *
0464: *@param node Description of Parameter
0465: *@param data Description of Parameter
0466: *@return Description of the Returned Value
0467: */
0468: public Object visit(SimpleNode node, Object data) {
0469: return processSpecialToken(node, data);
0470: }
0471:
0472: /**
0473: * Description of the Method
0474: *
0475: *@param node Description of Parameter
0476: *@param data Description of Parameter
0477: *@return Description of the Returned Value
0478: */
0479: public Object visit(ASTCompilationUnit node, Object data) {
0480: return processSpecialToken(node, data);
0481: }
0482:
0483: /**
0484: * Description of the Method
0485: *
0486: *@param node Description of Parameter
0487: *@param data Description of Parameter
0488: *@return Description of the Returned Value
0489: */
0490: public Object visit(ASTPackageDeclaration node, Object data) {
0491: return processSpecialToken(node, data);
0492: }
0493:
0494: /**
0495: * Description of the Method
0496: *
0497: *@param node Description of Parameter
0498: *@param data Description of Parameter
0499: *@return Description of the Returned Value
0500: */
0501: public Object visit(ASTImportDeclaration node, Object data) {
0502: return processSpecialToken(node, data);
0503: }
0504:
0505: /**
0506: * Description of the Method
0507: *
0508: *@param node Description of Parameter
0509: *@param data Description of Parameter
0510: *@return Description of the Returned Value
0511: */
0512: public Object visit(ASTTypeDeclaration node, Object data) {
0513: return processSpecialToken(node, data);
0514: }
0515:
0516: /**
0517: * Description of the Method
0518: *
0519: *@param node Description of Parameter
0520: *@param data Description of Parameter
0521: *@return Description of the Returned Value
0522: */
0523: public Object visit(ASTClassDeclaration node, Object data) {
0524: return processSpecialToken(node, data);
0525: }
0526:
0527: /**
0528: * Description of the Method
0529: *
0530: *@param node Description of Parameter
0531: *@param data Description of Parameter
0532: *@return Description of the Returned Value
0533: */
0534: public Object visit(ASTUnmodifiedClassDeclaration node, Object data) {
0535: return processSpecialToken(node, data);
0536: }
0537:
0538: /**
0539: * Description of the Method
0540: *
0541: *@param node Description of Parameter
0542: *@param data Description of Parameter
0543: *@return Description of the Returned Value
0544: */
0545: public Object visit(ASTClassBody node, Object data) {
0546: return processSpecialToken(node, data);
0547: }
0548:
0549: /**
0550: * Description of the Method
0551: *
0552: *@param node Description of Parameter
0553: *@param data Description of Parameter
0554: *@return Description of the Returned Value
0555: */
0556: public Object visit(ASTNestedClassDeclaration node, Object data) {
0557: return processSpecialToken(node, data);
0558: }
0559:
0560: /**
0561: * Description of the Method
0562: *
0563: *@param node Description of Parameter
0564: *@param data Description of Parameter
0565: *@return Description of the Returned Value
0566: */
0567: public Object visit(ASTClassBodyDeclaration node, Object data) {
0568: return processSpecialToken(node, data);
0569: }
0570:
0571: /**
0572: * Description of the Method
0573: *
0574: *@param node Description of Parameter
0575: *@param data Description of Parameter
0576: *@return Description of the Returned Value
0577: */
0578: public Object visit(ASTInterfaceDeclaration node, Object data) {
0579: return processSpecialToken(node, data);
0580: }
0581:
0582: /**
0583: * Description of the Method
0584: *
0585: *@param node Description of Parameter
0586: *@param data Description of Parameter
0587: *@return Description of the Returned Value
0588: */
0589: public Object visit(ASTNestedInterfaceDeclaration node, Object data) {
0590: return processSpecialToken(node, data);
0591: }
0592:
0593: /**
0594: * Description of the Method
0595: *
0596: *@param node Description of Parameter
0597: *@param data Description of Parameter
0598: *@return Description of the Returned Value
0599: */
0600: public Object visit(ASTUnmodifiedInterfaceDeclaration node,
0601: Object data) {
0602: return processSpecialToken(node, data);
0603: }
0604:
0605: /**
0606: * Description of the Method
0607: *
0608: *@param node Description of Parameter
0609: *@param data Description of Parameter
0610: *@return Description of the Returned Value
0611: */
0612: public Object visit(ASTInterfaceBody node, Object data) {
0613: return processSpecialToken(node, data);
0614: }
0615:
0616: /**
0617: * Description of the Method
0618: *
0619: *@param node Description of Parameter
0620: *@param data Description of Parameter
0621: *@return Description of the Returned Value
0622: */
0623: public Object visit(ASTInterfaceMemberDeclaration node, Object data) {
0624: return processSpecialToken(node, data);
0625: }
0626:
0627: /**
0628: * Description of the Method
0629: *
0630: *@param node Description of Parameter
0631: *@param data Description of Parameter
0632: *@return Description of the Returned Value
0633: */
0634: public Object visit(ASTFieldDeclaration node, Object data) {
0635: return processSpecialToken(node, data);
0636: }
0637:
0638: /**
0639: * Description of the Method
0640: *
0641: *@param node Description of Parameter
0642: *@param data Description of Parameter
0643: *@return Description of the Returned Value
0644: */
0645: public Object visit(ASTVariableDeclarator node, Object data) {
0646: return processSpecialToken(node, data);
0647: }
0648:
0649: /**
0650: * Description of the Method
0651: *
0652: *@param node Description of Parameter
0653: *@param data Description of Parameter
0654: *@return Description of the Returned Value
0655: */
0656: public Object visit(ASTVariableDeclaratorId node, Object data) {
0657: return processSpecialToken(node, data);
0658: }
0659:
0660: /**
0661: * Description of the Method
0662: *
0663: *@param node Description of Parameter
0664: *@param data Description of Parameter
0665: *@return Description of the Returned Value
0666: */
0667: public Object visit(ASTVariableInitializer node, Object data) {
0668: return processSpecialToken(node, data);
0669: }
0670:
0671: /**
0672: * Description of the Method
0673: *
0674: *@param node Description of Parameter
0675: *@param data Description of Parameter
0676: *@return Description of the Returned Value
0677: */
0678: public Object visit(ASTArrayInitializer node, Object data) {
0679: return processSpecialToken(node, data);
0680: }
0681:
0682: /**
0683: * Description of the Method
0684: *
0685: *@param node Description of Parameter
0686: *@param data Description of Parameter
0687: *@return Description of the Returned Value
0688: */
0689: public Object visit(ASTMethodDeclaration node, Object data) {
0690: return processSpecialToken(node, data);
0691: }
0692:
0693: /**
0694: * Description of the Method
0695: *
0696: *@param node Description of Parameter
0697: *@param data Description of Parameter
0698: *@return Description of the Returned Value
0699: */
0700: public Object visit(ASTMethodDeclarator node, Object data) {
0701: return processSpecialToken(node, data);
0702: }
0703:
0704: /**
0705: * Description of the Method
0706: *
0707: *@param node Description of Parameter
0708: *@param data Description of Parameter
0709: *@return Description of the Returned Value
0710: */
0711: public Object visit(ASTFormalParameters node, Object data) {
0712: return processSpecialToken(node, data);
0713: }
0714:
0715: /**
0716: * Description of the Method
0717: *
0718: *@param node Description of Parameter
0719: *@param data Description of Parameter
0720: *@return Description of the Returned Value
0721: */
0722: public Object visit(ASTFormalParameter node, Object data) {
0723: return processSpecialToken(node, data);
0724: }
0725:
0726: /**
0727: * Description of the Method
0728: *
0729: *@param node Description of Parameter
0730: *@param data Description of Parameter
0731: *@return Description of the Returned Value
0732: */
0733: public Object visit(ASTConstructorDeclaration node, Object data) {
0734: return processSpecialToken(node, data);
0735: }
0736:
0737: /**
0738: * Description of the Method
0739: *
0740: *@param node Description of Parameter
0741: *@param data Description of Parameter
0742: *@return Description of the Returned Value
0743: */
0744: public Object visit(ASTExplicitConstructorInvocation node,
0745: Object data) {
0746: return processSpecialToken(node, data);
0747: }
0748:
0749: /**
0750: * Description of the Method
0751: *
0752: *@param node Description of Parameter
0753: *@param data Description of Parameter
0754: *@return Description of the Returned Value
0755: */
0756: public Object visit(ASTInitializer node, Object data) {
0757: return processSpecialToken(node, data);
0758: }
0759:
0760: /**
0761: * Description of the Method
0762: *
0763: *@param node Description of Parameter
0764: *@param data Description of Parameter
0765: *@return Description of the Returned Value
0766: */
0767: public Object visit(ASTType node, Object data) {
0768: return processSpecialToken(node, data);
0769: }
0770:
0771: /**
0772: * Description of the Method
0773: *
0774: *@param node Description of Parameter
0775: *@param data Description of Parameter
0776: *@return Description of the Returned Value
0777: */
0778: public Object visit(ASTPrimitiveType node, Object data) {
0779: return processSpecialToken(node, data);
0780: }
0781:
0782: /**
0783: * Description of the Method
0784: *
0785: *@param node Description of Parameter
0786: *@param data Description of Parameter
0787: *@return Description of the Returned Value
0788: */
0789: public Object visit(ASTResultType node, Object data) {
0790: return processSpecialToken(node, data);
0791: }
0792:
0793: /**
0794: * Description of the Method
0795: *
0796: *@param node Description of Parameter
0797: *@param data Description of Parameter
0798: *@return Description of the Returned Value
0799: */
0800: public Object visit(ASTName node, Object data) {
0801: return processSpecialToken(node, data);
0802: }
0803:
0804: /**
0805: * Description of the Method
0806: *
0807: *@param node Description of Parameter
0808: *@param data Description of Parameter
0809: *@return Description of the Returned Value
0810: */
0811: public Object visit(ASTNameList node, Object data) {
0812: return processSpecialToken(node, data);
0813: }
0814:
0815: /**
0816: * Description of the Method
0817: *
0818: *@param node Description of Parameter
0819: *@param data Description of Parameter
0820: *@return Description of the Returned Value
0821: */
0822: public Object visit(ASTExpression node, Object data) {
0823: return processSpecialToken(node, data);
0824: }
0825:
0826: /**
0827: * Description of the Method
0828: *
0829: *@param node Description of Parameter
0830: *@param data Description of Parameter
0831: *@return Description of the Returned Value
0832: */
0833: public Object visit(ASTAssignmentOperator node, Object data) {
0834: return processSpecialToken(node, data);
0835: }
0836:
0837: /**
0838: * Description of the Method
0839: *
0840: *@param node Description of Parameter
0841: *@param data Description of Parameter
0842: *@return Description of the Returned Value
0843: */
0844: public Object visit(ASTConditionalExpression node, Object data) {
0845: return processSpecialToken(node, data);
0846: }
0847:
0848: /**
0849: * Description of the Method
0850: *
0851: *@param node Description of Parameter
0852: *@param data Description of Parameter
0853: *@return Description of the Returned Value
0854: */
0855: public Object visit(ASTConditionalOrExpression node, Object data) {
0856: return processSpecialToken(node, data);
0857: }
0858:
0859: /**
0860: * Description of the Method
0861: *
0862: *@param node Description of Parameter
0863: *@param data Description of Parameter
0864: *@return Description of the Returned Value
0865: */
0866: public Object visit(ASTConditionalAndExpression node, Object data) {
0867: return processSpecialToken(node, data);
0868: }
0869:
0870: /**
0871: * Description of the Method
0872: *
0873: *@param node Description of Parameter
0874: *@param data Description of Parameter
0875: *@return Description of the Returned Value
0876: */
0877: public Object visit(ASTInclusiveOrExpression node, Object data) {
0878: return processSpecialToken(node, data);
0879: }
0880:
0881: /**
0882: * Description of the Method
0883: *
0884: *@param node Description of Parameter
0885: *@param data Description of Parameter
0886: *@return Description of the Returned Value
0887: */
0888: public Object visit(ASTExclusiveOrExpression node, Object data) {
0889: return processSpecialToken(node, data);
0890: }
0891:
0892: /**
0893: * Description of the Method
0894: *
0895: *@param node Description of Parameter
0896: *@param data Description of Parameter
0897: *@return Description of the Returned Value
0898: */
0899: public Object visit(ASTAndExpression node, Object data) {
0900: return processSpecialToken(node, data);
0901: }
0902:
0903: /**
0904: * Description of the Method
0905: *
0906: *@param node Description of Parameter
0907: *@param data Description of Parameter
0908: *@return Description of the Returned Value
0909: */
0910: public Object visit(ASTEqualityExpression node, Object data) {
0911: return processSpecialToken(node, data);
0912: }
0913:
0914: /**
0915: * Description of the Method
0916: *
0917: *@param node Description of Parameter
0918: *@param data Description of Parameter
0919: *@return Description of the Returned Value
0920: */
0921: public Object visit(ASTInstanceOfExpression node, Object data) {
0922: return processSpecialToken(node, data);
0923: }
0924:
0925: /**
0926: * Description of the Method
0927: *
0928: *@param node Description of Parameter
0929: *@param data Description of Parameter
0930: *@return Description of the Returned Value
0931: */
0932: public Object visit(ASTRelationalExpression node, Object data) {
0933: return processSpecialToken(node, data);
0934: }
0935:
0936: /**
0937: * Description of the Method
0938: *
0939: *@param node Description of Parameter
0940: *@param data Description of Parameter
0941: *@return Description of the Returned Value
0942: */
0943: public Object visit(ASTShiftExpression node, Object data) {
0944: return processSpecialToken(node, data);
0945: }
0946:
0947: /**
0948: * Description of the Method
0949: *
0950: *@param node Description of Parameter
0951: *@param data Description of Parameter
0952: *@return Description of the Returned Value
0953: */
0954: public Object visit(ASTAdditiveExpression node, Object data) {
0955: return processSpecialToken(node, data);
0956: }
0957:
0958: /**
0959: * Description of the Method
0960: *
0961: *@param node Description of Parameter
0962: *@param data Description of Parameter
0963: *@return Description of the Returned Value
0964: */
0965: public Object visit(ASTMultiplicativeExpression node, Object data) {
0966: return processSpecialToken(node, data);
0967: }
0968:
0969: /**
0970: * Description of the Method
0971: *
0972: *@param node Description of Parameter
0973: *@param data Description of Parameter
0974: *@return Description of the Returned Value
0975: */
0976: public Object visit(ASTUnaryExpression node, Object data) {
0977: return processSpecialToken(node, data);
0978: }
0979:
0980: /**
0981: * Description of the Method
0982: *
0983: *@param node Description of Parameter
0984: *@param data Description of Parameter
0985: *@return Description of the Returned Value
0986: */
0987: public Object visit(ASTPreIncrementExpression node, Object data) {
0988: return processSpecialToken(node, data);
0989: }
0990:
0991: /**
0992: * Description of the Method
0993: *
0994: *@param node Description of Parameter
0995: *@param data Description of Parameter
0996: *@return Description of the Returned Value
0997: */
0998: public Object visit(ASTPreDecrementExpression node, Object data) {
0999: return processSpecialToken(node, data);
1000: }
1001:
1002: /**
1003: * Description of the Method
1004: *
1005: *@param node Description of Parameter
1006: *@param data Description of Parameter
1007: *@return Description of the Returned Value
1008: */
1009: public Object visit(ASTUnaryExpressionNotPlusMinus node, Object data) {
1010: return processSpecialToken(node, data);
1011: }
1012:
1013: /**
1014: * Description of the Method
1015: *
1016: *@param node Description of Parameter
1017: *@param data Description of Parameter
1018: *@return Description of the Returned Value
1019: */
1020: public Object visit(ASTPostfixExpression node, Object data) {
1021: return processSpecialToken(node, data);
1022: }
1023:
1024: /**
1025: * Description of the Method
1026: *
1027: *@param node Description of Parameter
1028: *@param data Description of Parameter
1029: *@return Description of the Returned Value
1030: */
1031: public Object visit(ASTCastExpression node, Object data) {
1032: return processSpecialToken(node, data);
1033: }
1034:
1035: /**
1036: * Description of the Method
1037: *
1038: *@param node Description of Parameter
1039: *@param data Description of Parameter
1040: *@return Description of the Returned Value
1041: */
1042: public Object visit(ASTPrimaryExpression node, Object data) {
1043: return processSpecialToken(node, data);
1044: }
1045:
1046: /**
1047: * Description of the Method
1048: *
1049: *@param node Description of Parameter
1050: *@param data Description of Parameter
1051: *@return Description of the Returned Value
1052: */
1053: public Object visit(ASTPrimaryPrefix node, Object data) {
1054: return processSpecialToken(node, data);
1055: }
1056:
1057: /**
1058: * Description of the Method
1059: *
1060: *@param node Description of Parameter
1061: *@param data Description of Parameter
1062: *@return Description of the Returned Value
1063: */
1064: public Object visit(ASTPrimarySuffix node, Object data) {
1065: return processSpecialToken(node, data);
1066: }
1067:
1068: /**
1069: * Description of the Method
1070: *
1071: *@param node Description of Parameter
1072: *@param data Description of Parameter
1073: *@return Description of the Returned Value
1074: */
1075: public Object visit(ASTLiteral node, Object data) {
1076: return processSpecialToken(node, data);
1077: }
1078:
1079: /**
1080: * Description of the Method
1081: *
1082: *@param node Description of Parameter
1083: *@param data Description of Parameter
1084: *@return Description of the Returned Value
1085: */
1086: public Object visit(ASTBooleanLiteral node, Object data) {
1087: return processSpecialToken(node, data);
1088: }
1089:
1090: /**
1091: * Description of the Method
1092: *
1093: *@param node Description of Parameter
1094: *@param data Description of Parameter
1095: *@return Description of the Returned Value
1096: */
1097: public Object visit(ASTNullLiteral node, Object data) {
1098: return processSpecialToken(node, data);
1099: }
1100:
1101: /**
1102: * Description of the Method
1103: *
1104: *@param node Description of Parameter
1105: *@param data Description of Parameter
1106: *@return Description of the Returned Value
1107: */
1108: public Object visit(ASTArguments node, Object data) {
1109: return processSpecialToken(node, data);
1110: }
1111:
1112: /**
1113: * Description of the Method
1114: *
1115: *@param node Description of Parameter
1116: *@param data Description of Parameter
1117: *@return Description of the Returned Value
1118: */
1119: public Object visit(ASTArgumentList node, Object data) {
1120: return processSpecialToken(node, data);
1121: }
1122:
1123: /**
1124: * Description of the Method
1125: *
1126: *@param node Description of Parameter
1127: *@param data Description of Parameter
1128: *@return Description of the Returned Value
1129: */
1130: public Object visit(ASTAllocationExpression node, Object data) {
1131: return processSpecialToken(node, data);
1132: }
1133:
1134: /**
1135: * Description of the Method
1136: *
1137: *@param node Description of Parameter
1138: *@param data Description of Parameter
1139: *@return Description of the Returned Value
1140: */
1141: public Object visit(ASTArrayDimsAndInits node, Object data) {
1142: return processSpecialToken(node, data);
1143: }
1144:
1145: /**
1146: * Description of the Method
1147: *
1148: *@param node Description of Parameter
1149: *@param data Description of Parameter
1150: *@return Description of the Returned Value
1151: */
1152: public Object visit(ASTStatement node, Object data) {
1153: return processSpecialToken(node, data);
1154: }
1155:
1156: /**
1157: * Description of the Method
1158: *
1159: *@param node Description of Parameter
1160: *@param data Description of Parameter
1161: *@return Description of the Returned Value
1162: */
1163: public Object visit(ASTLabeledStatement node, Object data) {
1164: return processSpecialToken(node, data);
1165: }
1166:
1167: /**
1168: * Description of the Method
1169: *
1170: *@param node Description of Parameter
1171: *@param data Description of Parameter
1172: *@return Description of the Returned Value
1173: */
1174: public Object visit(ASTBlock node, Object data) {
1175: return processSpecialToken(node, data);
1176: }
1177:
1178: /**
1179: * Description of the Method
1180: *
1181: *@param node Description of Parameter
1182: *@param data Description of Parameter
1183: *@return Description of the Returned Value
1184: */
1185: public Object visit(ASTBlockStatement node, Object data) {
1186: return processSpecialToken(node, data);
1187: }
1188:
1189: /**
1190: * Description of the Method
1191: *
1192: *@param node Description of Parameter
1193: *@param data Description of Parameter
1194: *@return Description of the Returned Value
1195: */
1196: public Object visit(ASTLocalVariableDeclaration node, Object data) {
1197: return processSpecialToken(node, data);
1198: }
1199:
1200: /**
1201: * Description of the Method
1202: *
1203: *@param node Description of Parameter
1204: *@param data Description of Parameter
1205: *@return Description of the Returned Value
1206: */
1207: public Object visit(ASTEmptyStatement node, Object data) {
1208: return processSpecialToken(node, data);
1209: }
1210:
1211: /**
1212: * Description of the Method
1213: *
1214: *@param node Description of Parameter
1215: *@param data Description of Parameter
1216: *@return Description of the Returned Value
1217: */
1218: public Object visit(ASTStatementExpression node, Object data) {
1219: return processSpecialToken(node, data);
1220: }
1221:
1222: /**
1223: * Description of the Method
1224: *
1225: *@param node Description of Parameter
1226: *@param data Description of Parameter
1227: *@return Description of the Returned Value
1228: */
1229: public Object visit(ASTSwitchStatement node, Object data) {
1230: return processSpecialToken(node, data);
1231: }
1232:
1233: /**
1234: * Description of the Method
1235: *
1236: *@param node Description of Parameter
1237: *@param data Description of Parameter
1238: *@return Description of the Returned Value
1239: */
1240: public Object visit(ASTSwitchLabel node, Object data) {
1241: return processSpecialToken(node, data);
1242: }
1243:
1244: /**
1245: * Description of the Method
1246: *
1247: *@param node Description of Parameter
1248: *@param data Description of Parameter
1249: *@return Description of the Returned Value
1250: */
1251: public Object visit(ASTIfStatement node, Object data) {
1252: return processSpecialToken(node, data);
1253: }
1254:
1255: /**
1256: * Description of the Method
1257: *
1258: *@param node Description of Parameter
1259: *@param data Description of Parameter
1260: *@return Description of the Returned Value
1261: */
1262: public Object visit(ASTWhileStatement node, Object data) {
1263: return processSpecialToken(node, data);
1264: }
1265:
1266: /**
1267: * Description of the Method
1268: *
1269: *@param node Description of Parameter
1270: *@param data Description of Parameter
1271: *@return Description of the Returned Value
1272: */
1273: public Object visit(ASTDoStatement node, Object data) {
1274: return processSpecialToken(node, data);
1275: }
1276:
1277: /**
1278: * Description of the Method
1279: *
1280: *@param node Description of Parameter
1281: *@param data Description of Parameter
1282: *@return Description of the Returned Value
1283: */
1284: public Object visit(ASTForStatement node, Object data) {
1285: return processSpecialToken(node, data);
1286: }
1287:
1288: /**
1289: * Description of the Method
1290: *
1291: *@param node Description of Parameter
1292: *@param data Description of Parameter
1293: *@return Description of the Returned Value
1294: */
1295: public Object visit(ASTForInit node, Object data) {
1296: return processSpecialToken(node, data);
1297: }
1298:
1299: /**
1300: * Description of the Method
1301: *
1302: *@param node Description of Parameter
1303: *@param data Description of Parameter
1304: *@return Description of the Returned Value
1305: */
1306: public Object visit(ASTStatementExpressionList node, Object data) {
1307: return processSpecialToken(node, data);
1308: }
1309:
1310: /**
1311: * Description of the Method
1312: *
1313: *@param node Description of Parameter
1314: *@param data Description of Parameter
1315: *@return Description of the Returned Value
1316: */
1317: public Object visit(ASTForUpdate node, Object data) {
1318: return processSpecialToken(node, data);
1319: }
1320:
1321: /**
1322: * Description of the Method
1323: *
1324: *@param node Description of Parameter
1325: *@param data Description of Parameter
1326: *@return Description of the Returned Value
1327: */
1328: public Object visit(ASTBreakStatement node, Object data) {
1329: return processSpecialToken(node, data);
1330: }
1331:
1332: /**
1333: * Description of the Method
1334: *
1335: *@param node Description of Parameter
1336: *@param data Description of Parameter
1337: *@return Description of the Returned Value
1338: */
1339: public Object visit(ASTContinueStatement node, Object data) {
1340: return processSpecialToken(node, data);
1341: }
1342:
1343: /**
1344: * Description of the Method
1345: *
1346: *@param node Description of Parameter
1347: *@param data Description of Parameter
1348: *@return Description of the Returned Value
1349: */
1350: public Object visit(ASTReturnStatement node, Object data) {
1351: return processSpecialToken(node, data);
1352: }
1353:
1354: /**
1355: * Description of the Method
1356: *
1357: *@param node Description of Parameter
1358: *@param data Description of Parameter
1359: *@return Description of the Returned Value
1360: */
1361: public Object visit(ASTThrowStatement node, Object data) {
1362: return processSpecialToken(node, data);
1363: }
1364:
1365: /**
1366: * Description of the Method
1367: *
1368: *@param node Description of Parameter
1369: *@param data Description of Parameter
1370: *@return Description of the Returned Value
1371: */
1372: public Object visit(ASTSynchronizedStatement node, Object data) {
1373: return processSpecialToken(node, data);
1374: }
1375:
1376: /**
1377: * Description of the Method
1378: *
1379: *@param node Description of Parameter
1380: *@param data Description of Parameter
1381: *@return Description of the Returned Value
1382: */
1383: public Object visit(ASTTryStatement node, Object data) {
1384: return processSpecialToken(node, data);
1385: }
1386:
1387: /**
1388: * Visit the assertion node
1389: *
1390: *@param node the node
1391: *@param data the data needed to perform the visit
1392: *@return the result of visiting the node
1393: */
1394: public Object visit(ASTAssertionStatement node, Object data) {
1395: return processSpecialToken(node, data);
1396: }
1397:
1398: /**
1399: * Process the special token data
1400: *
1401: *@param node the node that the special token data is associated with
1402: *@param data the special token data
1403: *@return the special token data
1404: */
1405: protected Object processSpecialToken(Node node, Object data) {
1406: // Local Variables
1407: SpecialTokenData tokenData = (SpecialTokenData) data;
1408: boolean changed = false;
1409: PrintData printData = tokenData.getPrintData();
1410: boolean wasIndented = printData.isLineIndented();
1411: int endOfChain = chain.size() - 1;
1412:
1413: // This partly fixes bug 761890 by pretending that a program line ending
1414: // with a C Style comment is a single line comment.
1415: if (tokenData.getSpecialToken() != null
1416: && !printData.getCStyleOwnline()) {
1417: tokenData.convertFirstCStyleCommentToSingleLine();
1418: }
1419: while (tokenData.getSpecialToken() != null) {
1420: checkLocation(tokenData.getSpecialToken(), printData);
1421:
1422: // Process the chain of responsibility
1423: for (int ndx = endOfChain; ndx >= 0; ndx--) {
1424: PrintSpecial link = (PrintSpecial) chain.elementAt(ndx);
1425: if (link.isAcceptable(tokenData)) {
1426: changed = link.process(node, tokenData) || changed;
1427: break;
1428: }
1429: }
1430: tokenData.next(); // Next item
1431: }
1432:
1433: // Return to previous indent state
1434: if (changed) {
1435: if (wasIndented && !printData.isLineIndented()) {
1436: printData.indent();
1437: } else if (!wasIndented && !tokenData.isReturnExpected()) {
1438: printData.surpriseIndent();
1439: }
1440: }
1441:
1442: return data; // Return the special token data
1443: }
1444:
1445: /**
1446: * Checks to see if the current location matches the editor's original
1447: * location
1448: *
1449: *@param token Description of Parameter
1450: *@param data Description of Parameter
1451: */
1452: private void checkLocation(Token token, PrintData data) {
1453: if ((token == null) || (data == null)) {
1454: return;
1455: }
1456:
1457: int orig = data.getOriginalLine();
1458: if ((token.beginLine <= orig) && (token.endLine >= orig)) {
1459: data.saveCurrentLine();
1460: }
1461: }
1462:
1463: }
|