langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysis.java
author rfield
Wed, 08 Jun 2016 00:32:31 -0700
changeset 38908 f0c186d76c8a
parent 36160 f42d362d0d17
child 39370 437ba9bd2582
permissions -rw-r--r--
8139829: JShell API: No use of fields to return information from public types Reviewed-by: vromero
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     1
/*
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     4
 *
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    10
 *
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    15
 * accompanied this code).
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    16
 *
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    20
 *
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    23
 * questions.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    24
 */
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    25
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    26
package jdk.jshell;
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    27
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    28
import java.util.List;
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    29
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    30
/**
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    31
 * Provides analysis utilities for source code input.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    32
 * Optional functionality that provides for a richer interactive experience.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    33
 * Includes completion analysis:
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    34
 * Is the input a complete snippet of code?
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    35
 * Do I need to prompt for more input?
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    36
 * Would adding a semicolon make it complete?
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    37
 * Is there more than one snippet?
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    38
 * etc.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    39
 * Also includes completion suggestions, as might be used in tab-completion.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    40
 *
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    41
 */
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    42
public abstract class SourceCodeAnalysis {
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    43
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    44
    /**
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    45
     * Given an input string, find the first snippet of code (one statement,
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    46
     * definition, import, or expression) and evaluate if it is complete.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    47
     * @param input the input source string
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    48
     * @return a CompletionInfo instance with location and completeness info
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    49
     */
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    50
    public abstract CompletionInfo analyzeCompletion(String input);
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    51
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    52
    /**
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    53
     * Compute possible follow-ups for the given input.
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
    54
     * Uses information from the current {@code JShell} state, including
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    55
     * type information, to filter the suggestions.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    56
     * @param input the user input, so far
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    57
     * @param cursor the current position of the cursors in the given {@code input} text
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    58
     * @param anchor outgoing parameter - when an option will be completed, the text between
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    59
     *               the anchor and cursor will be deleted and replaced with the given option
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    60
     * @return list of candidate continuations of the given input.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    61
     */
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    62
    public abstract List<Suggestion> completionSuggestions(String input, int cursor, int[] anchor);
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    63
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    64
    /**
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    65
     * Compute a description/help string for the given user's input.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    66
     * @param input the snippet the user wrote so far
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    67
     * @param cursor the current position of the cursors in the given {@code input} text
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    68
     * @return description/help string for the given user's input
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    69
     */
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    70
    public abstract String documentation(String input, int cursor);
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    71
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    72
    /**
36160
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    73
     * Infer the type of the given expression. The expression spans from the beginning of {@code code}
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    74
     * to the given {@code cursor} position. Returns null if the type of the expression cannot
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    75
     * be inferred.
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    76
     *
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    77
     * @param code the expression for which the type should be inferred
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    78
     * @param cursor current cursor position in the given code
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    79
     * @return the inferred type, or null if it cannot be inferred
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    80
     */
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    81
    public abstract String analyzeType(String code, int cursor);
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    82
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    83
    /**
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    84
     * List qualified names known for the simple name in the given code immediately
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    85
     * to the left of the given cursor position. The qualified names are gathered by inspecting the
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    86
     * classpath used by eval (see {@link JShell#addToClasspath(java.lang.String)}).
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    87
     *
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    88
     * @param code the expression for which the candidate qualified names should be computed
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    89
     * @param cursor current cursor position in the given code
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    90
     * @return the known qualified names
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    91
     */
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    92
    public abstract QualifiedNames listQualifiedNames(String code, int cursor);
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    93
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
    94
    /**
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    95
     * Internal only constructor
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    96
     */
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    97
    SourceCodeAnalysis() {}
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    98
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    99
    /**
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   100
     * The result of {@code analyzeCompletion(String input)}.
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   101
     * Describes the completeness and position of the first snippet in the given input.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   102
     */
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   103
    public static class CompletionInfo {
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   104
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   105
        private final Completeness completeness;
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   106
        private final int unitEndPos;
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   107
        private final String source;
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   108
        private final String remaining;
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   109
36160
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   110
        CompletionInfo(Completeness completeness, int unitEndPos, String source, String remaining) {
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   111
            this.completeness = completeness;
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   112
            this.unitEndPos = unitEndPos;
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   113
            this.source = source;
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   114
            this.remaining = remaining;
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   115
        }
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   116
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   117
        /**
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   118
         * The analyzed completeness of the input.
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   119
         *
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   120
         * @return an enum describing the completeness of the input string.
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   121
         */
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   122
        public Completeness completeness() {
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   123
            return completeness;
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   124
        }
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   125
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   126
        /**
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   127
         * Input remaining after the complete part of the source.
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   128
         *
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   129
         * @return the portion of the input string that remains after the
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   130
         * complete Snippet
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   131
         */
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   132
        public String remaining() {
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   133
            return remaining;
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   134
        }
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   135
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   136
        /**
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   137
         * Source code for the first Snippet of code input. For example, first
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   138
         * statement, or first method declaration. Trailing semicolons will be
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   139
         * added, as needed.
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   140
         *
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   141
         * @return the source of the first encountered Snippet
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   142
         */
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   143
        public String source() {
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   144
            return source;
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   145
        }
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   146
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   147
        /**
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   148
         * The end of the first Snippet of source.
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   149
         *
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   150
         * @return the position of the end of the first Snippet in the input.
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   151
         */
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   152
        public int unitEndPos() {
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   153
            return unitEndPos;
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   154
        }
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   155
    }
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   156
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   157
    /**
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   158
     * Describes the completeness of the given input.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   159
     */
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   160
    public enum Completeness {
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   161
        /**
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   162
         * The input is a complete source snippet (declaration or statement) as is.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   163
         */
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   164
        COMPLETE(true),
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   165
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   166
        /**
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   167
         * With this addition of a semicolon the input is a complete source snippet.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   168
         * This will only be returned when the end of input is encountered.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   169
         */
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   170
        COMPLETE_WITH_SEMI(true),
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   171
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   172
        /**
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   173
         * There must be further source beyond the given input in order for it
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   174
         * to be complete.  A semicolon would not complete it.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   175
         * This will only be returned when the end of input is encountered.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   176
         */
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   177
        DEFINITELY_INCOMPLETE(false),
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   178
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   179
        /**
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   180
         * A statement with a trailing (non-terminated) empty statement.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   181
         * Though technically it would be a complete statement
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   182
         * with the addition of a semicolon, it is rare
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   183
         * that that assumption is the desired behavior.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   184
         * The input is considered incomplete.  Comments and white-space are
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   185
         * still considered empty.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   186
         */
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   187
        CONSIDERED_INCOMPLETE(false),
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   188
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   189
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   190
        /**
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   191
         * An empty input.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   192
         * The input is considered incomplete.  Comments and white-space are
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   193
         * still considered empty.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   194
         */
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   195
        EMPTY(false),
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   196
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   197
        /**
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   198
         * The completeness of the input could not be determined because it
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   199
         * contains errors. Error detection is not a goal of completeness
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   200
         * analysis, however errors interfered with determining its completeness.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   201
         * The input is considered complete because evaluating is the best
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   202
         * mechanism to get error information.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   203
         */
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   204
        UNKNOWN(true);
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   205
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   206
        private final boolean isComplete;
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   207
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   208
        Completeness(boolean isComplete) {
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   209
            this.isComplete = isComplete;
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   210
        }
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   211
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   212
        /**
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   213
         * Indicates whether the first snippet of source is complete.
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   214
         * For example, "{@code x=}" is not
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   215
         * complete, but "{@code x=2}" is complete, even though a subsequent line could
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   216
         * make it "{@code x=2+2}". Already erroneous code is marked complete.
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   217
         *
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   218
         * @return {@code true} if the input is or begins a complete Snippet;
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   219
         * otherwise {@code false}
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   220
         */
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   221
        public boolean isComplete() {
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   222
            return isComplete;
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   223
        }
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   224
    }
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   225
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   226
    /**
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   227
     * A candidate for continuation of the given user's input.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   228
     */
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   229
    public static class Suggestion {
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   230
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   231
        private final String continuation;
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   232
        private final boolean matchesType;
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   233
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   234
        /**
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   235
         * Create a {@code Suggestion} instance.
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   236
         *
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   237
         * @param continuation a candidate continuation of the user's input
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   238
         * @param matchesType does the candidate match the target type
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   239
         */
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   240
        public Suggestion(String continuation, boolean matchesType) {
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   241
            this.continuation = continuation;
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   242
            this.matchesType = matchesType;
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   243
        }
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   244
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   245
        /**
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   246
         * The candidate continuation of the given user's input.
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   247
         *
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   248
         * @return the continuation string
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   249
         */
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   250
        public String continuation() {
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   251
            return continuation;
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   252
        }
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   253
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   254
        /**
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   255
         * Indicates whether input continuation matches the target type and is thus
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   256
         * more likely to be the desired continuation. A matching continuation is
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   257
         * preferred.
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   258
         *
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   259
         * @return {@code true} if this suggested continuation matches the
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   260
         * target type; otherwise {@code false}
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   261
         */
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   262
        public boolean matchesType() {
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   263
            return matchesType;
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   264
        }
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   265
    }
36160
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   266
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   267
    /**
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   268
     * List of possible qualified names.
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   269
     */
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   270
    public static final class QualifiedNames {
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   271
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   272
        private final List<String> names;
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   273
        private final int simpleNameLength;
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   274
        private final boolean upToDate;
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   275
        private final boolean resolvable;
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   276
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   277
        QualifiedNames(List<String> names, int simpleNameLength, boolean upToDate, boolean resolvable) {
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   278
            this.names = names;
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   279
            this.simpleNameLength = simpleNameLength;
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   280
            this.upToDate = upToDate;
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   281
            this.resolvable = resolvable;
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   282
        }
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   283
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   284
        /**
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   285
         * Known qualified names for the given simple name in the original code.
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   286
         *
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   287
         * @return known qualified names
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   288
         */
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   289
        public List<String> getNames() {
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   290
            return names;
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   291
        }
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   292
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   293
        /**
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   294
         * The length of the simple name in the original code for which the
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   295
         * qualified names where gathered.
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   296
         *
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   297
         * @return the length of the simple name; -1 if there is no name immediately left to the cursor for
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   298
         *         which the candidates could be computed
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   299
         */
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   300
        public int getSimpleNameLength() {
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   301
            return simpleNameLength;
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   302
        }
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   303
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   304
        /**
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   305
         * Indicates whether the result is based on up to date data. The
36160
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   306
         * {@link SourceCodeAnalysis#listQualifiedNames(java.lang.String, int) listQualifiedNames}
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   307
         * method may return before the classpath is fully inspected, in which case this method will
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   308
         * return {@code false}. If the result is based on a fully inspected classpath, this method
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   309
         * will return {@code true}.
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   310
         *
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   311
         * @return {@code true} if the result is based on up-to-date data;
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   312
         * otherwise {@code false}
36160
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   313
         */
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   314
        public boolean isUpToDate() {
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   315
            return upToDate;
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   316
        }
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   317
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   318
        /**
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   319
         * Indicates whether the given simple name in the original code refers
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   320
         * to a resolvable element.
36160
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   321
         *
38908
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   322
         * @return {@code true} if the given simple name in the original code
f0c186d76c8a 8139829: JShell API: No use of fields to return information from public types
rfield
parents: 36160
diff changeset
   323
         * refers to a resolvable element; otherwise {@code false}
36160
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   324
         */
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   325
        public boolean isResolvable() {
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   326
            return resolvable;
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   327
        }
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   328
f42d362d0d17 8131027: JShell API/tool: suggest imports for a class
jlahoda
parents: 33362
diff changeset
   329
    }
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   330
}