01: /*
02: * Author: Mike Atkinson
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.jdi;
10:
11: import net.sourceforge.jrefactory.ast.ASTFieldDeclaration;
12: import net.sourceforge.jrefactory.ast.ASTVariableDeclarator;
13: import net.sourceforge.jrefactory.ast.ASTVariableDeclaratorId;
14: import org.acm.seguin.pretty.DescriptionPadder;
15: import org.acm.seguin.pretty.ForceJavadocComments;
16: import org.acm.seguin.pretty.PrintData;
17: import org.acm.seguin.pretty.ai.RequiredTags;
18:
19: /**
20: * Holds a field declaration. The two components that this structure store are the modifiers to the field and any
21: * javadoc comments associated with the field.
22: *
23: * @author Mike Atkinson
24: * @since jRefactory 2.9.0, created October 16, 2003
25: */
26: public class FieldDeclaration extends BaseJDI {
27: private ASTFieldDeclaration field;
28:
29: /**
30: * Constructor for the FieldDeclaration JavaDoc creator.
31: *
32: * @param field Create JavaDoc for this node.
33: */
34: public FieldDeclaration(ASTFieldDeclaration field) {
35: super ();
36: this .field = field;
37: }
38:
39: /**
40: * Checks to see if it was printed
41: *
42: * @return true if it still needs to be printed
43: */
44: public boolean isRequired() {
45: return jdi.isRequired()
46: && (new ForceJavadocComments()).isJavaDocRequired(
47: "field", field);
48: }
49:
50: /**
51: * Return true if the javadoc comments were printed
52: *
53: * @return The javadocPrinted value
54: */
55: public boolean isJavadocPrinted() {
56: return jdi.isPrinted();
57: }
58:
59: /**
60: * Prints all the java doc components
61: *
62: * @param printData the print data
63: */
64: public void printJavaDocComponents(PrintData printData) {
65: jdi.printJavaDocComponents(printData, bundle
66: .getString("field.tags"));
67: }
68:
69: /** Makes sure all the java doc components are present */
70: public void finish() {
71: jdi.require("", DescriptionPadder.find(bundle, "field.descr"));
72:
73: // Require the other tags
74: int childNo = field.skipAnnotations();
75: ASTVariableDeclarator decl = (ASTVariableDeclarator) field
76: .jjtGetChild(childNo + 1);
77: ASTVariableDeclaratorId varID = (ASTVariableDeclaratorId) decl
78: .jjtGetFirstChild();
79: RequiredTags.getTagger().addTags(bundle, "field",
80: varID.getName(), jdi);
81: }
82:
83: }
|