001: /*******************************************************************************
002: * Copyright (c) 2004, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.jdt.core.dom;
011:
012: import java.util.ArrayList;
013: import java.util.List;
014:
015: /**
016: * End-of-line comment AST node type.
017: * <p>
018: * End-of-line comments begin with "//",
019: * must end with a line delimiter (as per JLS 3.7),
020: * and must not contain line breaks.
021: * </p>
022: * <p>
023: * Note that this node type is a comment placeholder, and is
024: * only useful for recording the source range where a comment
025: * was found in a source string. It is not useful for creating
026: * comments.
027: * </p>
028: *
029: * @since 3.0
030: */
031: public final class LineComment extends Comment {
032:
033: /**
034: * A list of property descriptors (element type:
035: * {@link StructuralPropertyDescriptor}),
036: * or null if uninitialized.
037: */
038: private static final List PROPERTY_DESCRIPTORS;
039:
040: static {
041: List propertyList = new ArrayList(1);
042: createPropertyList(LineComment.class, propertyList);
043: PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
044: }
045:
046: /**
047: * Returns a list of structural property descriptors for this node type.
048: * Clients must not modify the result.
049: *
050: * @param apiLevel the API level; one of the
051: * <code>AST.JLS*</code> constants
052:
053: * @return a list of property descriptors (element type:
054: * {@link StructuralPropertyDescriptor})
055: * @since 3.0
056: */
057: public static List propertyDescriptors(int apiLevel) {
058: return PROPERTY_DESCRIPTORS;
059: }
060:
061: /**
062: * Creates a new line comment node owned by the given AST.
063: * <p>
064: * N.B. This constructor is package-private.
065: * </p>
066: *
067: * @param ast the AST that is to own this node
068: */
069: LineComment(AST ast) {
070: super (ast);
071: }
072:
073: /* (omit javadoc for this method)
074: * Method declared on ASTNode.
075: */
076: final List internalStructuralPropertiesForType(int apiLevel) {
077: return propertyDescriptors(apiLevel);
078: }
079:
080: /* (omit javadoc for this method)
081: * Method declared on ASTNode.
082: */
083: final int getNodeType0() {
084: return LINE_COMMENT;
085: }
086:
087: /* (omit javadoc for this method)
088: * Method declared on ASTNode.
089: */
090: ASTNode clone0(AST target) {
091: LineComment result = new LineComment(target);
092: result
093: .setSourceRange(this .getStartPosition(), this
094: .getLength());
095: return result;
096: }
097:
098: /* (omit javadoc for this method)
099: * Method declared on ASTNode.
100: */
101: final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
102: // dispatch to correct overloaded match method
103: return matcher.match(this , other);
104: }
105:
106: /* (omit javadoc for this method)
107: * Method declared on ASTNode.
108: */
109: void accept0(ASTVisitor visitor) {
110: visitor.visit(this );
111: visitor.endVisit(this );
112: }
113:
114: /* (omit javadoc for this method)
115: * Method declared on ASTNode.
116: */
117: int memSize() {
118: return super .memSize();
119: }
120:
121: /* (omit javadoc for this method)
122: * Method declared on ASTNode.
123: */
124: int treeSize() {
125: return memSize();
126: }
127: }
|