EclipseJDT Source Viewer

Home|eclipse_jdt/src/org/eclipse/jdt/core/dom/LineComment.java
1/*******************************************************************************
2 * Copyright (c) 2004, 2013 IBM Corporation and others.
3 *
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
8 *
9 * SPDX-License-Identifier: EPL-2.0
10 *
11 * Contributors:
12 *     IBM Corporation - initial API and implementation
13 *******************************************************************************/
14package org.eclipse.jdt.core.dom;
15
16import java.util.ArrayList;
17import java.util.List;
18
19/**
20 * End-of-line comment AST node type.
21 * <p>
22 * End-of-line comments begin with "//",
23 * must end with a line delimiter (as per JLS 3.7),
24 * and must not contain line breaks.
25 * </p>
26 * <p>
27 * Note that this node type is a comment placeholder, and is
28 * only useful for recording the source range where a comment
29 * was found in a source string. It is not useful for creating
30 * comments.
31 * </p>
32 *
33 * @since 3.0
34 * @noinstantiate This class is not intended to be instantiated by clients.
35 */
36@SuppressWarnings("rawtypes")
37public final class LineComment extends Comment {
38
39    /**
40     * A list of property descriptors (element type:
41     * {@link StructuralPropertyDescriptor}),
42     * or null if uninitialized.
43     */
44    private static final List PROPERTY_DESCRIPTORS;
45
46    static {
47        List propertyList = new ArrayList(1);
48        createPropertyList(LineComment.classpropertyList);
49        PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
50    }
51
52    /**
53     * Returns a list of structural property descriptors for this node type.
54     * Clients must not modify the result.
55     *
56     * @param apiLevel the API level; one of the
57     * <code>AST.JLS*</code> constants
58
59     * @return a list of property descriptors (element type:
60     * {@link StructuralPropertyDescriptor})
61     * @since 3.0
62     */
63    public static List propertyDescriptors(int apiLevel) {
64        return PROPERTY_DESCRIPTORS;
65    }
66
67    /**
68     * Creates a new line comment node owned by the given AST.
69     * <p>
70     * N.B. This constructor is package-private.
71     * </p>
72     *
73     * @param ast the AST that is to own this node
74     */
75    LineComment(AST ast) {
76        super(ast);
77    }
78
79    @Override
80    final List internalStructuralPropertiesForType(int apiLevel) {
81        return propertyDescriptors(apiLevel);
82    }
83
84    @Override
85    final int getNodeType0() {
86        return LINE_COMMENT;
87    }
88
89    @Override
90    ASTNode clone0(AST target) {
91        LineComment result = new LineComment(target);
92        result.setSourceRange(getStartPosition(), getLength());
93        return result;
94    }
95
96    @Override
97    final boolean subtreeMatch0(ASTMatcher matcherObject other) {
98        // dispatch to correct overloaded match method
99        return matcher.match(this, other);
100    }
101
102    @Override
103    void accept0(ASTVisitor visitor) {
104        visitor.visit(this);
105        visitor.endVisit(this);
106    }
107
108    @Override
109    int memSize() {
110        return super.memSize();
111    }
112
113    @Override
114    int treeSize() {
115        return memSize();
116    }
117}
118
MembersX
LineComment:treeSize
LineComment:accept0
LineComment:propertyDescriptors
LineComment:clone0
LineComment:clone0:Block:result
LineComment:LineComment
LineComment:subtreeMatch0
LineComment:PROPERTY_DESCRIPTORS
LineComment:getNodeType0
LineComment:memSize
LineComment:Block:propertyList
LineComment:internalStructuralPropertiesForType
Members
X