< prev index next >

src/jdk.jshell/share/classes/jdk/jshell/ExpressionSnippet.java

Print this page




  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.jshell;
  27 
  28 import jdk.jshell.Key.ExpressionKey;
  29 
  30 /**
  31  * Snippet for an assignment or variable-value expression.
  32  * The Kind is {@link jdk.jshell.Snippet.Kind#EXPRESSION}.
  33  * <p>
  34  * <code>ExpressionSnippet</code> is immutable: an access to
  35  * any of its methods will always return the same result.
  36  * and thus is thread-safe.
  37  *
  38  * @since 9
  39  * @jls 15: Expression.
  40  */
  41 public class ExpressionSnippet extends Snippet {
  42 
  43     ExpressionSnippet(ExpressionKey key, String userSource, Wrap guts, String name, SubKind subkind) {
  44         super(key, userSource, guts, name, subkind, null);
  45     }
  46 
  47     /**
  48      * Variable name which is the value of the expression. Since the expression
  49      * is either just a variable identifier or it is an assignment
  50      * to a variable, there is always a variable which is the subject of the
  51      * expression. All other forms of expression become temporary variables
  52      * which are instead referenced by a {@link VarSnippet}.
  53      * @return the name of the variable which is the subject of the expression.
  54      */
  55     @Override
  56     public String name() {
  57         return key().name();
  58     }
  59 


  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.jshell;
  27 
  28 import jdk.jshell.Key.ExpressionKey;
  29 
  30 /**
  31  * Snippet for an assignment or variable-value expression.
  32  * The Kind is {@link jdk.jshell.Snippet.Kind#EXPRESSION}.
  33  * <p>
  34  * <code>ExpressionSnippet</code> is immutable: an access to
  35  * any of its methods will always return the same result.
  36  * and thus is thread-safe.
  37  *
  38  * @since 9
  39  * @jls 15 Expressions
  40  */
  41 public class ExpressionSnippet extends Snippet {
  42 
  43     ExpressionSnippet(ExpressionKey key, String userSource, Wrap guts, String name, SubKind subkind) {
  44         super(key, userSource, guts, name, subkind, null);
  45     }
  46 
  47     /**
  48      * Variable name which is the value of the expression. Since the expression
  49      * is either just a variable identifier or it is an assignment
  50      * to a variable, there is always a variable which is the subject of the
  51      * expression. All other forms of expression become temporary variables
  52      * which are instead referenced by a {@link VarSnippet}.
  53      * @return the name of the variable which is the subject of the expression.
  54      */
  55     @Override
  56     public String name() {
  57         return key().name();
  58     }
  59 
< prev index next >