src/jdk.compiler/share/classes/com/sun/source/tree/CaseTree.java
author jlahoda
Wed, 02 Oct 2019 10:59:40 +0200
branchJDK-8226585-branch
changeset 58440 4c8a6d1d066c
parent 58109 ee07de0d2c16
permissions -rw-r--r--
Improving appearance of javadoc of the APIs associated with preview features.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
57706
7ac414640ad5 8229386: Typo "lables" in doc comment
jjg
parents: 54817
diff changeset
     2
 * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.source.tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import java.util.List;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
/**
51563
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    31
 * A tree node for a {@code case} in a {@code switch} statement or expression.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 * For example:
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 * <pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 *   case <em>expression</em> :
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 *       <em>statements</em>
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 *   default :
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 *       <em>statements</em>
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * </pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 *
54817
ef73702a906e 8223654: Clean up @jls references in com.sun.source
jjg
parents: 51563
diff changeset
    42
 * @jls 14.11 The switch Statement
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * @author Peter von der Ah&eacute;
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * @author Jonathan Gibbons
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 * @since 1.6
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
public interface CaseTree extends Tree {
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
    50
     * Returns the expression for the case, or
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
    51
     * {@code null} if this is the default case.
57706
7ac414640ad5 8229386: Typo "lables" in doc comment
jjg
parents: 54817
diff changeset
    52
     * If this case has multiple labels, returns the first label.
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
    53
     * @return the expression for the case, or null
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
    ExpressionTree getExpression();
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
    56
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
    57
    /**
58440
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
    58
     * {@preview Associated with switch expressions, a preview feature of
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
    59
     *           the Java language.
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
    60
     *
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
    61
     *           This method is associated with <i>switch expressions</i>, a preview
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
    62
     *           feature of the Java language. Preview features
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
    63
     *           may be removed in a future release, or upgraded to permanent
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
    64
     *           features of the Java language.}
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
    65
     *
51563
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    66
     * Returns the labels for this case.
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    67
     * For default case, returns an empty list.
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    68
     *
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    69
     * @return labels for this case
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    70
     * @since 12
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    71
     *
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents: 57706
diff changeset
    72
     * @preview This method is modeling a case with multiple labels,
51563
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    73
     * which is part of a preview feature and may be removed
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    74
     * if the preview feature is removed.
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    75
     */
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents: 57706
diff changeset
    76
    @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
51563
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    77
    List<? extends ExpressionTree> getExpressions();
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    78
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    79
    /**
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    80
     * For case with kind {@linkplain CaseKind#STATEMENT},
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    81
     * returns the statements labeled by the case.
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    82
     * Returns {@code null} for case with kind
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    83
     * {@linkplain CaseKind#RULE}.
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    84
     * @return the statements labeled by the case or null
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
    85
     */
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    List<? extends StatementTree> getStatements();
51563
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    87
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    88
    /**
58440
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
    89
     * {@preview Associated with switch expressions, a preview feature of
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
    90
     *           the Java language.
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
    91
     *
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
    92
     *           This method is associated with <i>switch expressions</i>, a preview
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
    93
     *           feature of the Java language. Preview features
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
    94
     *           may be removed in a future release, or upgraded to permanent
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
    95
     *           features of the Java language.}
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
    96
     *
51563
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    97
     * For case with kind {@linkplain CaseKind#RULE},
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    98
     * returns the statement or expression after the arrow.
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
    99
     * Returns {@code null} for case with kind
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   100
     * {@linkplain CaseKind#STATEMENT}.
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   101
     *
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   102
     * @return case value or null
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   103
     * @since 12
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   104
     */
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents: 57706
diff changeset
   105
    @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
51563
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   106
    public default Tree getBody() {
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   107
        return null;
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   108
    }
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   109
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   110
    /**
58440
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
   111
     * {@preview Associated with switch expressions, a preview feature of
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
   112
     *           the Java language.
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
   113
     *
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
   114
     *           This method is associated with <i>switch expressions</i>, a preview
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
   115
     *           feature of the Java language. Preview features
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
   116
     *           may be removed in a future release, or upgraded to permanent
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
   117
     *           features of the Java language.}
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
   118
     *
51563
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   119
     * Returns the kind of this case.
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   120
     *
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   121
     * @return the kind of this case
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   122
     * @since 12
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   123
     */
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents: 57706
diff changeset
   124
    @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents: 57706
diff changeset
   125
    @SuppressWarnings("preview")
51563
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   126
    public default CaseKind getCaseKind() {
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   127
        return CaseKind.STATEMENT;
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   128
    }
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   129
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   130
    /**
58440
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
   131
     * {@preview Associated with switch expressions, a preview feature of
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
   132
     *           the Java language.
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
   133
     *
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
   134
     *           This enum is associated with <i>switch expressions</i>, a preview
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
   135
     *           feature of the Java language. Preview features
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
   136
     *           may be removed in a future release, or upgraded to permanent
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
   137
     *           features of the Java language.}
4c8a6d1d066c Improving appearance of javadoc of the APIs associated with preview features.
jlahoda
parents: 58109
diff changeset
   138
     *
51563
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   139
     * The syntatic form of this case:
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   140
     * <ul>
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   141
     *     <li>STATEMENT: {@code case <expression>: <statements>}</li>
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   142
     *     <li>RULE: {@code case <expression> -> <expression>/<statement>}</li>
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   143
     * </ul>
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   144
     *
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   145
     * @since 12
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   146
     */
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents: 57706
diff changeset
   147
    @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents: 57706
diff changeset
   148
    @SuppressWarnings("preview")
51563
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   149
    public enum CaseKind {
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   150
        /**
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   151
         * Case is in the form: {@code case <expression>: <statements>}.
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   152
         */
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   153
        STATEMENT,
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   154
        /**
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   155
         * Case is in the form: {@code case <expression> -> <expression>}.
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   156
         */
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   157
        RULE;
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   158
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
}