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.ASTMethodDeclaration;
12: import net.sourceforge.jrefactory.ast.ASTAnnotation;
13: import net.sourceforge.jrefactory.ast.ASTTypeParameters;
14: import net.sourceforge.jrefactory.ast.ASTMethodDeclarator;
15: import net.sourceforge.jrefactory.ast.Node;
16: import org.acm.seguin.pretty.ForceJavadocComments;
17: import org.acm.seguin.pretty.PrintData;
18: import org.acm.seguin.pretty.ai.MethodAnalyzer;
19: import org.acm.seguin.pretty.ai.RequiredTags;
20:
21: /**
22: * Holds a method declaration in a class
23: *
24: * @author Mike Atkinson
25: * @since jRefactory 2.9.0, created October 16, 2003
26: */
27: public class MethodDeclaration extends BaseJDI {
28: ASTMethodDeclaration method;
29:
30: /**
31: * Constructor for the MethodDeclaration JavaDoc creator.
32: *
33: * @param method Create JavaDoc for this node.
34: */
35: public MethodDeclaration(ASTMethodDeclaration method) {
36: super ();
37: this .method = method;
38: }
39:
40: /**
41: * Checks to see if it was printed
42: *
43: * @return true if it still needs to be printed
44: */
45: public boolean isRequired() {
46: return jdi.isRequired()
47: && (new ForceJavadocComments()).isJavaDocRequired(
48: "method", method);
49: }
50:
51: /**
52: * Prints all the java doc components
53: *
54: * @param printData the print data
55: */
56: public void printJavaDocComponents(PrintData printData) {
57: jdi.printJavaDocComponents(printData, bundle
58: .getString("method.tags"));
59: }
60:
61: /**
62: * Makes sure all the java doc components are present. For methods and constructors we need to do more work -
63: * checking parameters, return types, and exceptions.
64: */
65: public void finish() {
66: finish("");
67: }
68:
69: /**
70: * Makes sure all the java doc components are present. For methods and constructors we need to do more work -
71: * checking parameters, return types, and exceptions.
72: *
73: * @param className Description of Parameter
74: */
75: public void finish(String className) {
76: MethodAnalyzer mai = new MethodAnalyzer(method, jdi);
77: mai.finish(className);
78:
79: // Require the other tags
80: // skip possible attributes
81: int childNo = method.skipAnnotationsAndTypeParameters();
82: ASTMethodDeclarator mthd = (ASTMethodDeclarator) method
83: .jjtGetChild(childNo + 1);
84: RequiredTags.getTagger().addTags(bundle, "method",
85: mthd.getName(), jdi);
86: }
87:
88: }
|