EclipseJDT Source Viewer

Home|eclipse_jdt/src/org/eclipse/jdt/core/dom/ContinueStatement.java
1/*******************************************************************************
2 * Copyright (c) 2000, 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 *******************************************************************************/
14
15package org.eclipse.jdt.core.dom;
16
17import java.util.ArrayList;
18import java.util.List;
19
20/**
21 * Continue statement AST node type.
22 *
23 * <pre>
24 * ContinueStatement:
25 *    <b>continue</b> [ Identifier ] <b>;</b>
26 * </pre>
27 *
28 * @since 2.0
29 * @noinstantiate This class is not intended to be instantiated by clients.
30 */
31@SuppressWarnings("rawtypes")
32public class ContinueStatement extends Statement {
33
34    /**
35     * The "label" structural property of this node type (child type: {@link SimpleName}).
36     * @since 3.0
37     */
38    public static final ChildPropertyDescriptor LABEL_PROPERTY =
39        new ChildPropertyDescriptor(ContinueStatement.class"label"SimpleName.classOPTIONALNO_CYCLE_RISK); //$NON-NLS-1$
40
41    /**
42     * A list of property descriptors (element type:
43     * {@link StructuralPropertyDescriptor}),
44     * or null if uninitialized.
45     */
46    private static final List PROPERTY_DESCRIPTORS;
47
48    static {
49        List properyList = new ArrayList(2);
50        createPropertyList(ContinueStatement.classproperyList);
51        addProperty(LABEL_PROPERTYproperyList);
52        PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
53    }
54
55    /**
56     * Returns a list of structural property descriptors for this node type.
57     * Clients must not modify the result.
58     *
59     * @param apiLevel the API level; one of the
60     * <code>AST.JLS*</code> constants
61
62     * @return a list of property descriptors (element type:
63     * {@link StructuralPropertyDescriptor})
64     * @since 3.0
65     */
66    public static List propertyDescriptors(int apiLevel) {
67        return PROPERTY_DESCRIPTORS;
68    }
69
70    /**
71     * The label, or <code>null</code> if none; none by default.
72     */
73    private SimpleName optionalLabel = null;
74
75    /**
76     * Creates a new unparented continue statement node owned by the given
77     * AST. By default, the continue statement has no label.
78     * <p>
79     * N.B. This constructor is package-private.
80     * </p>
81     *
82     * @param ast the AST that is to own this node
83     */
84    ContinueStatement(AST ast) {
85        super(ast);
86    }
87
88    @Override
89    final List internalStructuralPropertiesForType(int apiLevel) {
90        return propertyDescriptors(apiLevel);
91    }
92
93    @Override
94    final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor propertyboolean getASTNode child) {
95        if (property == LABEL_PROPERTY) {
96            if (get) {
97                return getLabel();
98            } else {
99                setLabel((SimpleNamechild);
100                return null;
101            }
102        }
103        // allow default implementation to flag the error
104        return super.internalGetSetChildProperty(propertygetchild);
105    }
106
107    @Override
108    final int getNodeType0() {
109        return CONTINUE_STATEMENT;
110    }
111
112    @Override
113    ASTNode clone0(AST target) {
114        ContinueStatement result = new ContinueStatement(target);
115        result.setSourceRange(getStartPosition(), getLength());
116        result.copyLeadingComment(this);
117        result.setLabel((SimpleNameASTNode.copySubtree(targetgetLabel()));
118        return result;
119    }
120
121    @Override
122    final boolean subtreeMatch0(ASTMatcher matcherObject other) {
123        // dispatch to correct overloaded match method
124        return matcher.match(this, other);
125    }
126
127    @Override
128    void accept0(ASTVisitor visitor) {
129        boolean visitChildren = visitor.visit(this);
130        if (visitChildren) {
131            acceptChild(visitorgetLabel());
132        }
133        visitor.endVisit(this);
134    }
135
136    /**
137     * Returns the label of this continue statement, or <code>null</code> if
138     * there is none.
139     *
140     * @return the label, or <code>null</code> if there is none
141     */
142    public SimpleName getLabel() {
143        return this.optionalLabel;
144    }
145
146    /**
147     * Sets or clears the label of this continue statement.
148     *
149     * @param label the label, or <code>null</code> if
150     *    there is none
151     * @exception IllegalArgumentException if:
152     * <ul>
153     * <li>the node belongs to a different AST</li>
154     * <li>the node already has a parent</li>
155     * </ul>
156     */
157    public void setLabel(SimpleName label) {
158        ASTNode oldChild = this.optionalLabel;
159        preReplaceChild(oldChildlabelLABEL_PROPERTY);
160        this.optionalLabel = label;
161        postReplaceChild(oldChildlabelLABEL_PROPERTY);
162    }
163
164    @Override
165    int memSize() {
166        return super.memSize() + 1 * 4;
167    }
168
169    @Override
170    int treeSize() {
171        return
172            memSize()
173            + (this.optionalLabel == null ? 0 : getLabel().treeSize());
174    }
175}
176
177
MembersX
ContinueStatement:getLabel
ContinueStatement:setLabel:Block:oldChild
ContinueStatement:optionalLabel
ContinueStatement:internalGetSetChildProperty
ContinueStatement:treeSize
ContinueStatement:Block:properyList
ContinueStatement:setLabel
ContinueStatement:accept0:Block:visitChildren
ContinueStatement:clone0:Block:result
ContinueStatement:ContinueStatement
ContinueStatement:getNodeType0
ContinueStatement:PROPERTY_DESCRIPTORS
ContinueStatement:clone0
ContinueStatement:accept0
ContinueStatement:memSize
ContinueStatement:LABEL_PROPERTY
ContinueStatement:subtreeMatch0
ContinueStatement:propertyDescriptors
ContinueStatement:internalStructuralPropertiesForType
Members
X