langtools/src/jdk.jshell/share/classes/jdk/jshell/Snippet.java
changeset 45868 6a58a7837e93
parent 43770 a321bed02000
child 46108 528c42d694f1
equal deleted inserted replaced
45867:ca77ebd05a06 45868:6a58a7837e93
     1 /*
     1 /*
     2  * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    70          * an on-demand type import
    70          * an on-demand type import
    71          * ({@link jdk.jshell.Snippet.SubKind#TYPE_IMPORT_ON_DEMAND_SUBKIND}),
    71          * ({@link jdk.jshell.Snippet.SubKind#TYPE_IMPORT_ON_DEMAND_SUBKIND}),
    72          * or a static on-demand type import
    72          * or a static on-demand type import
    73          * ({@link jdk.jshell.Snippet.SubKind#SINGLE_STATIC_IMPORT_SUBKIND}) --
    73          * ({@link jdk.jshell.Snippet.SubKind#SINGLE_STATIC_IMPORT_SUBKIND}) --
    74          * use {@link jdk.jshell.Snippet#subKind()} to distinguish.
    74          * use {@link jdk.jshell.Snippet#subKind()} to distinguish.
    75          * <P>
    75          *
    76          * @jls 8.3: importDeclaration.
    76          * @jls 8.3: importDeclaration.
    77          * <P>
    77          * <P>
    78          * An import declaration is {@linkplain Kind#isPersistent() persistent}.
    78          * An import declaration is {@linkplain Kind#isPersistent() persistent}.
    79          */
    79          */
    80         IMPORT(true),
    80         IMPORT(true),
    88          * A type declaration may be an interface
    88          * A type declaration may be an interface
    89          * {@link jdk.jshell.Snippet.SubKind#INTERFACE_SUBKIND},
    89          * {@link jdk.jshell.Snippet.SubKind#INTERFACE_SUBKIND},
    90          * classes {@link jdk.jshell.Snippet.SubKind#CLASS_SUBKIND}, enums, and
    90          * classes {@link jdk.jshell.Snippet.SubKind#CLASS_SUBKIND}, enums, and
    91          * annotation interfaces -- see {@link jdk.jshell.Snippet.SubKind} to
    91          * annotation interfaces -- see {@link jdk.jshell.Snippet.SubKind} to
    92          * differentiate.
    92          * differentiate.
    93          * <P>
    93          *
    94          * @jls 7.6: TypeDeclaration.
    94          * @jls 7.6: TypeDeclaration.
    95          * <P>
    95          * <P>
    96          * A type declaration is {@linkplain Kind#isPersistent() persistent}.
    96          * A type declaration is {@linkplain Kind#isPersistent() persistent}.
    97          */
    97          */
    98         TYPE_DECL(true),
    98         TYPE_DECL(true),
    99 
    99 
   100         /**
   100         /**
   101          * A method declaration.
   101          * A method declaration.
   102          * The snippet is an instance of {@link jdk.jshell.MethodSnippet}.
   102          * The snippet is an instance of {@link jdk.jshell.MethodSnippet}.
   103          * <P>
   103          *
   104          * @jls 8.4: MethodDeclaration.
   104          * @jls 8.4: MethodDeclaration.
   105          * <P>
   105          * <P>
   106          * A method declaration is {@linkplain Kind#isPersistent() persistent}.
   106          * A method declaration is {@linkplain Kind#isPersistent() persistent}.
   107          */
   107          */
   108         METHOD(true),
   108         METHOD(true),
   113          * The snippet is an instance of {@link jdk.jshell.VarSnippet}.
   113          * The snippet is an instance of {@link jdk.jshell.VarSnippet}.
   114          * <P>
   114          * <P>
   115          * The variable may be with or without initializer, or be a temporary
   115          * The variable may be with or without initializer, or be a temporary
   116          * variable representing an expression -- see
   116          * variable representing an expression -- see
   117          * {@link jdk.jshell.Snippet.SubKind}to differentiate.
   117          * {@link jdk.jshell.Snippet.SubKind}to differentiate.
   118          * <P>
   118          *
   119          * @jls 8.3: FieldDeclaration.
   119          * @jls 8.3: FieldDeclaration.
   120          * <P>
   120          * <P>
   121          * A variable declaration is {@linkplain Kind#isPersistent() persistent}.
   121          * A variable declaration is {@linkplain Kind#isPersistent() persistent}.
   122          */
   122          */
   123         VAR(true),
   123         VAR(true),
   130          * variable ({@link jdk.jshell.Snippet.SubKind#VAR_VALUE_SUBKIND}) or an
   130          * variable ({@link jdk.jshell.Snippet.SubKind#VAR_VALUE_SUBKIND}) or an
   131          * assignment (both of which have natural referencing
   131          * assignment (both of which have natural referencing
   132          * names) -- see {@link jdk.jshell.Snippet.SubKind} to differentiate.
   132          * names) -- see {@link jdk.jshell.Snippet.SubKind} to differentiate.
   133          * All other expression forms (operators, method calls, ...) generate a
   133          * All other expression forms (operators, method calls, ...) generate a
   134          * scratch variable and so are instead of the VAR Kind.
   134          * scratch variable and so are instead of the VAR Kind.
   135          * <P>
   135          *
   136          * @jls 15: Expression.
   136          * @jls 15: Expression.
   137          */
   137          */
   138         EXPRESSION(false),
   138         EXPRESSION(false),
   139 
   139 
   140         /**
   140         /**
   141          * A statement.
   141          * A statement.
   142          * The snippet is an instance of {@link jdk.jshell.StatementSnippet}.
   142          * The snippet is an instance of {@link jdk.jshell.StatementSnippet}.
   143          * <P>
   143          *
   144          * @jls 14.5: Statement.
   144          * @jls 14.5: Statement.
   145          */
   145          */
   146         STATEMENT(false),
   146         STATEMENT(false),
   147 
   147 
   148         /**
   148         /**