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.parser.JavaParserConstants;
12: import net.sourceforge.jrefactory.ast.Node;
13:
14: /**
15: * Consume a single line comment
16: *
17: *@author Chris Seguin
18: *@created October 14, 1999
19: *@date April 10, 1999
20: */
21: public class PrintSpecialSingleLineComment extends PrintSpecial {
22: /**
23: * Determines if this print special can handle the current object
24: *
25: *@param spec Description of Parameter
26: *@return true if this one should process the input
27: */
28: public boolean isAcceptable(SpecialTokenData spec) {
29: return (spec.getTokenType() == JavaParserConstants.SINGLE_LINE_COMMENT);
30: }
31:
32: /**
33: * Processes the special token
34: *
35: *@param node the type of node this special is being processed for
36: *@param spec the special token data
37: *@return Description of the Returned Value
38: */
39: public boolean process(Node node, SpecialTokenData spec) {
40: // Get the print data
41: PrintData printData = spec.getPrintData();
42: // Make sure we are indented
43: if (!printData.isLineIndented()
44: && (spec.getSpecialToken().beginColumn > 2)) {
45: printData.indent();
46: if (spec.isAcceptingReturns()) {
47: spec.setReturnExpected(false);
48: }
49: }
50:
51: if (spec.getSpecialToken().beginColumn < 2) {
52: printData.reset();
53: }
54:
55: // Print the comment
56: printData.appendComment(spec.getTokenImage().trim(),
57: PrintData.SINGLE_LINE_COMMENT);
58:
59: return true;
60: }
61: }
|