01: /*
02: * Author: Chris Seguin
03: *
04: * This software has been developed under the copyleft
05: * rules of the GNU General Public License. Please
06: * consult the GNU General Public License for more
07: * details about use and distribution of this software.
08: */
09: package org.acm.seguin.pretty;
10:
11: import net.sourceforge.jrefactory.ast.Node;
12: import net.sourceforge.jrefactory.parser.JavaParserConstants;
13: import net.sourceforge.jrefactory.parser.Token;
14:
15: /**
16: * Consume a category comment
17: *
18: *@author Chris Seguin
19: *@created July 23, 1999
20: */
21: public class PrintSpecialCategoryComment extends PrintSpecial {
22: /**
23: * Determines if this print special can handle the current object
24: *
25: *@FIXME this tries to handle Category comments, but convert non-Category comments
26: * to multiline comments. This convertion should really take place as part of
27: * the parser but I can't work out how to do it.
28: *
29: *@param spec Description of Parameter
30: *@return true if this one should process the input
31: */
32: public boolean isAcceptable(SpecialTokenData spec) {
33: if (spec.getTokenType() == JavaParserConstants.CATEGORY_COMMENT) {
34: String image = spec.getTokenImage().trim();
35: Token special = spec.getSpecialToken();
36: if (image.endsWith(">*/")) {
37: special.kind = JavaParserConstants.CATEGORY_COMMENT;
38: return true;
39: } else {
40: special.kind = JavaParserConstants.MULTI_LINE_COMMENT;
41: return false;
42: }
43: }
44: return false;
45: }
46:
47: /**
48: * Processes the special token
49: *
50: *@param node the type of node this special is being processed for
51: *@param spec the special token data
52: *@return Description of the Returned Value
53: */
54: public boolean process(Node node, SpecialTokenData spec) {
55: // Get the print data
56: PrintData printData = spec.getPrintData();
57:
58: // Make sure we are indented
59: if (!printData.isLineIndented()) {
60: printData.indent();
61: }
62:
63: // Print the comment
64: String image = spec.getTokenImage().trim();
65: printData.appendComment(image, PrintData.CATEGORY_COMMENT);
66:
67: return true;
68: }
69: }
|