KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > core > dom > LineComment


1 /*******************************************************************************
2  * Copyright (c) 2004, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.core.dom;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.List JavaDoc;
15
16 /**
17  * End-of-line comment AST node type.
18  * <p>
19  * End-of-line comments begin with "//",
20  * must end with a line delimiter (as per JLS 3.7),
21  * and must not contain line breaks.
22  * </p>
23  * <p>
24  * Note that this node type is a comment placeholder, and is
25  * only useful for recording the source range where a comment
26  * was found in a source string. It is not useful for creating
27  * comments.
28  * </p>
29  *
30  * @since 3.0
31  */

32 public final class LineComment extends Comment {
33     
34     /**
35      * A list of property descriptors (element type:
36      * {@link StructuralPropertyDescriptor}),
37      * or null if uninitialized.
38      */

39     private static final List JavaDoc PROPERTY_DESCRIPTORS;
40     
41     static {
42         List JavaDoc propertyList = new ArrayList JavaDoc(1);
43         createPropertyList(LineComment.class, propertyList);
44         PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
45     }
46
47     /**
48      * Returns a list of structural property descriptors for this node type.
49      * Clients must not modify the result.
50      *
51      * @param apiLevel the API level; one of the
52      * <code>AST.JLS*</code> constants
53
54      * @return a list of property descriptors (element type:
55      * {@link StructuralPropertyDescriptor})
56      * @since 3.0
57      */

58     public static List JavaDoc propertyDescriptors(int apiLevel) {
59         return PROPERTY_DESCRIPTORS;
60     }
61             
62     /**
63      * Creates a new line comment node owned by the given AST.
64      * <p>
65      * N.B. This constructor is package-private.
66      * </p>
67      *
68      * @param ast the AST that is to own this node
69      */

70     LineComment(AST ast) {
71         super(ast);
72     }
73
74     /* (omit javadoc for this method)
75      * Method declared on ASTNode.
76      */

77     final List JavaDoc internalStructuralPropertiesForType(int apiLevel) {
78         return propertyDescriptors(apiLevel);
79     }
80     
81     /* (omit javadoc for this method)
82      * Method declared on ASTNode.
83      */

84     final int getNodeType0() {
85         return LINE_COMMENT;
86     }
87
88     /* (omit javadoc for this method)
89      * Method declared on ASTNode.
90      */

91     ASTNode clone0(AST target) {
92         LineComment result = new LineComment(target);
93         result.setSourceRange(this.getStartPosition(), this.getLength());
94         return result;
95     }
96
97     /* (omit javadoc for this method)
98      * Method declared on ASTNode.
99      */

100     final boolean subtreeMatch0(ASTMatcher matcher, Object JavaDoc other) {
101         // dispatch to correct overloaded match method
102
return matcher.match(this, other);
103     }
104
105     /* (omit javadoc for this method)
106      * Method declared on ASTNode.
107      */

108     void accept0(ASTVisitor visitor) {
109         visitor.visit(this);
110         visitor.endVisit(this);
111     }
112     
113     /* (omit javadoc for this method)
114      * Method declared on ASTNode.
115      */

116     int memSize() {
117         return super.memSize();
118     }
119     
120     /* (omit javadoc for this method)
121      * Method declared on ASTNode.
122      */

123     int treeSize() {
124         return memSize();
125     }
126 }
127
Popular Tags