< prev index next >

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

Print this page




  56      * return a snippet creation event.  The {@code Kind} of that Snippet
  57      * will be {@code METHOD}, from which you know that the subclass
  58      * of {@code Snippet} is {@code MethodSnippet} and it can be
  59      * cast as such.
  60      */
  61     public enum Kind {
  62         /**
  63          * An import declaration: {@code import} ...
  64          * The snippet is an instance of {@link jdk.jshell.ImportSnippet}.
  65          * <P>
  66          * An import can be a single type import
  67          * ({@link jdk.jshell.Snippet.SubKind#SINGLE_TYPE_IMPORT_SUBKIND}),
  68          * a static single import
  69          * ({@link jdk.jshell.Snippet.SubKind#SINGLE_STATIC_IMPORT_SUBKIND}),
  70          * an on-demand type import
  71          * ({@link jdk.jshell.Snippet.SubKind#TYPE_IMPORT_ON_DEMAND_SUBKIND}),
  72          * or a static on-demand type import
  73          * ({@link jdk.jshell.Snippet.SubKind#SINGLE_STATIC_IMPORT_SUBKIND}) --
  74          * use {@link jdk.jshell.Snippet#subKind()} to distinguish.
  75          *

  76          * <P>
  77          * An import declaration is {@linkplain Kind#isPersistent() persistent}.
  78          *
  79          * @jls 7.5 Import Declarations
  80          */
  81         IMPORT(true),
  82 
  83         /**
  84          * A type declaration.
  85          * Which includes: NormalClassDeclaration, EnumDeclaration,
  86          * NormalInterfaceDeclaration, and AnnotationTypeDeclaration.
  87          * The snippet is an instance of {@link jdk.jshell.TypeDeclSnippet}.
  88          * <P>
  89          * A type declaration may be an interface
  90          * {@link jdk.jshell.Snippet.SubKind#INTERFACE_SUBKIND},
  91          * classes {@link jdk.jshell.Snippet.SubKind#CLASS_SUBKIND}, enums, and
  92          * annotation interfaces -- see {@link jdk.jshell.Snippet.SubKind} to
  93          * differentiate.
  94          *

  95          * <P>
  96          * A type declaration is {@linkplain Kind#isPersistent() persistent}.
  97          *
  98          * @jls 7.6 Top Level Type Declarations
  99          */
 100         TYPE_DECL(true),
 101 
 102         /**
 103          * A method declaration.
 104          * The snippet is an instance of {@link jdk.jshell.MethodSnippet}.
 105          *

 106          * <P>
 107          * A method declaration is {@linkplain Kind#isPersistent() persistent}.
 108          *
 109          * @jls 8.4 Method Declarations
 110          */
 111         METHOD(true),
 112 
 113         /**
 114          * One variable declaration.
 115          * Corresponding to one <i>VariableDeclarator</i>.
 116          * The snippet is an instance of {@link jdk.jshell.VarSnippet}.
 117          * <P>
 118          * The variable may be with or without initializer, or be a temporary
 119          * variable representing an expression -- see
 120          * {@link jdk.jshell.Snippet.SubKind}to differentiate.
 121          *

 122          * <P>
 123          * A variable declaration is {@linkplain Kind#isPersistent() persistent}.
 124          *
 125          * @jls 8.3 Field Declarations
 126          */
 127         VAR(true),
 128 
 129         /**
 130          * An expression, with or without side-effects.
 131          * The snippet is an instance of {@link jdk.jshell.ExpressionSnippet}.
 132          * <P>
 133          * The expression is currently either a simple named reference to a
 134          * variable ({@link jdk.jshell.Snippet.SubKind#VAR_VALUE_SUBKIND}) or an
 135          * assignment (both of which have natural referencing
 136          * names) -- see {@link jdk.jshell.Snippet.SubKind} to differentiate.
 137          * All other expression forms (operators, method calls, ...) generate a
 138          * scratch variable and so are instead of the VAR Kind.
 139          *
 140          * @jls 15 Expressions
 141          */
 142         EXPRESSION(false),
 143 
 144         /**
 145          * A statement.




  56      * return a snippet creation event.  The {@code Kind} of that Snippet
  57      * will be {@code METHOD}, from which you know that the subclass
  58      * of {@code Snippet} is {@code MethodSnippet} and it can be
  59      * cast as such.
  60      */
  61     public enum Kind {
  62         /**
  63          * An import declaration: {@code import} ...
  64          * The snippet is an instance of {@link jdk.jshell.ImportSnippet}.
  65          * <P>
  66          * An import can be a single type import
  67          * ({@link jdk.jshell.Snippet.SubKind#SINGLE_TYPE_IMPORT_SUBKIND}),
  68          * a static single import
  69          * ({@link jdk.jshell.Snippet.SubKind#SINGLE_STATIC_IMPORT_SUBKIND}),
  70          * an on-demand type import
  71          * ({@link jdk.jshell.Snippet.SubKind#TYPE_IMPORT_ON_DEMAND_SUBKIND}),
  72          * or a static on-demand type import
  73          * ({@link jdk.jshell.Snippet.SubKind#SINGLE_STATIC_IMPORT_SUBKIND}) --
  74          * use {@link jdk.jshell.Snippet#subKind()} to distinguish.
  75          *
  76          * @jls 7.5 Import Declarations
  77          * <P>
  78          * An import declaration is {@linkplain Kind#isPersistent() persistent}.


  79          */
  80         IMPORT(true),
  81 
  82         /**
  83          * A type declaration.
  84          * Which includes: NormalClassDeclaration, EnumDeclaration,
  85          * NormalInterfaceDeclaration, and AnnotationTypeDeclaration.
  86          * The snippet is an instance of {@link jdk.jshell.TypeDeclSnippet}.
  87          * <P>
  88          * A type declaration may be an interface
  89          * {@link jdk.jshell.Snippet.SubKind#INTERFACE_SUBKIND},
  90          * classes {@link jdk.jshell.Snippet.SubKind#CLASS_SUBKIND}, enums, and
  91          * annotation interfaces -- see {@link jdk.jshell.Snippet.SubKind} to
  92          * differentiate.
  93          *
  94          * @jls 7.6 Top Level Type Declarations
  95          * <P>
  96          * A type declaration is {@linkplain Kind#isPersistent() persistent}.


  97          */
  98         TYPE_DECL(true),
  99 
 100         /**
 101          * A method declaration.
 102          * The snippet is an instance of {@link jdk.jshell.MethodSnippet}.
 103          *
 104          * @jls 8.4 Method Declarations
 105          * <P>
 106          * A method declaration is {@linkplain Kind#isPersistent() persistent}.


 107          */
 108         METHOD(true),
 109 
 110         /**
 111          * One variable declaration.
 112          * Corresponding to one <i>VariableDeclarator</i>.
 113          * The snippet is an instance of {@link jdk.jshell.VarSnippet}.
 114          * <P>
 115          * The variable may be with or without initializer, or be a temporary
 116          * variable representing an expression -- see
 117          * {@link jdk.jshell.Snippet.SubKind}to differentiate.
 118          *
 119          * @jls 8.3 Field Declarations
 120          * <P>
 121          * A variable declaration is {@linkplain Kind#isPersistent() persistent}.


 122          */
 123         VAR(true),
 124 
 125         /**
 126          * An expression, with or without side-effects.
 127          * The snippet is an instance of {@link jdk.jshell.ExpressionSnippet}.
 128          * <P>
 129          * The expression is currently either a simple named reference to a
 130          * variable ({@link jdk.jshell.Snippet.SubKind#VAR_VALUE_SUBKIND}) or an
 131          * assignment (both of which have natural referencing
 132          * names) -- see {@link jdk.jshell.Snippet.SubKind} to differentiate.
 133          * All other expression forms (operators, method calls, ...) generate a
 134          * scratch variable and so are instead of the VAR Kind.
 135          *
 136          * @jls 15 Expressions
 137          */
 138         EXPRESSION(false),
 139 
 140         /**
 141          * A statement.


< prev index next >