author | rfield |
Wed, 08 Jun 2016 00:32:31 -0700 | |
changeset 38908 | f0c186d76c8a |
parent 36160 | f42d362d0d17 |
child 39370 | 437ba9bd2582 |
permissions | -rw-r--r-- |
33362 | 1 |
/* |
2 |
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
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 |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
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 java.util.List; |
|
29 |
||
30 |
/** |
|
31 |
* Provides analysis utilities for source code input. |
|
32 |
* Optional functionality that provides for a richer interactive experience. |
|
33 |
* Includes completion analysis: |
|
34 |
* Is the input a complete snippet of code? |
|
35 |
* Do I need to prompt for more input? |
|
36 |
* Would adding a semicolon make it complete? |
|
37 |
* Is there more than one snippet? |
|
38 |
* etc. |
|
39 |
* Also includes completion suggestions, as might be used in tab-completion. |
|
40 |
* |
|
41 |
*/ |
|
42 |
public abstract class SourceCodeAnalysis { |
|
43 |
||
44 |
/** |
|
45 |
* Given an input string, find the first snippet of code (one statement, |
|
46 |
* definition, import, or expression) and evaluate if it is complete. |
|
47 |
* @param input the input source string |
|
48 |
* @return a CompletionInfo instance with location and completeness info |
|
49 |
*/ |
|
50 |
public abstract CompletionInfo analyzeCompletion(String input); |
|
51 |
||
52 |
/** |
|
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 | 55 |
* type information, to filter the suggestions. |
56 |
* @param input the user input, so far |
|
57 |
* @param cursor the current position of the cursors in the given {@code input} text |
|
58 |
* @param anchor outgoing parameter - when an option will be completed, the text between |
|
59 |
* the anchor and cursor will be deleted and replaced with the given option |
|
60 |
* @return list of candidate continuations of the given input. |
|
61 |
*/ |
|
62 |
public abstract List<Suggestion> completionSuggestions(String input, int cursor, int[] anchor); |
|
63 |
||
64 |
/** |
|
65 |
* Compute a description/help string for the given user's input. |
|
66 |
* @param input the snippet the user wrote so far |
|
67 |
* @param cursor the current position of the cursors in the given {@code input} text |
|
68 |
* @return description/help string for the given user's input |
|
69 |
*/ |
|
70 |
public abstract String documentation(String input, int cursor); |
|
71 |
||
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 | 95 |
* Internal only constructor |
96 |
*/ |
|
97 |
SourceCodeAnalysis() {} |
|
98 |
||
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 | 101 |
* Describes the completeness and position of the first snippet in the given input. |
102 |
*/ |
|
103 |
public static class CompletionInfo { |
|
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 | 111 |
this.completeness = completeness; |
112 |
this.unitEndPos = unitEndPos; |
|
113 |
this.source = source; |
|
114 |
this.remaining = remaining; |
|
115 |
} |
|
116 |
||
117 |
/** |
|
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 | 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 | 125 |
|
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 | 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 | 135 |
|
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 | 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 | 146 |
|
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 | 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 | 155 |
} |
156 |
||
157 |
/** |
|
158 |
* Describes the completeness of the given input. |
|
159 |
*/ |
|
160 |
public enum Completeness { |
|
161 |
/** |
|
162 |
* The input is a complete source snippet (declaration or statement) as is. |
|
163 |
*/ |
|
164 |
COMPLETE(true), |
|
165 |
||
166 |
/** |
|
167 |
* With this addition of a semicolon the input is a complete source snippet. |
|
168 |
* This will only be returned when the end of input is encountered. |
|
169 |
*/ |
|
170 |
COMPLETE_WITH_SEMI(true), |
|
171 |
||
172 |
/** |
|
173 |
* There must be further source beyond the given input in order for it |
|
174 |
* to be complete. A semicolon would not complete it. |
|
175 |
* This will only be returned when the end of input is encountered. |
|
176 |
*/ |
|
177 |
DEFINITELY_INCOMPLETE(false), |
|
178 |
||
179 |
/** |
|
180 |
* A statement with a trailing (non-terminated) empty statement. |
|
181 |
* Though technically it would be a complete statement |
|
182 |
* with the addition of a semicolon, it is rare |
|
183 |
* that that assumption is the desired behavior. |
|
184 |
* The input is considered incomplete. Comments and white-space are |
|
185 |
* still considered empty. |
|
186 |
*/ |
|
187 |
CONSIDERED_INCOMPLETE(false), |
|
188 |
||
189 |
||
190 |
/** |
|
191 |
* An empty input. |
|
192 |
* The input is considered incomplete. Comments and white-space are |
|
193 |
* still considered empty. |
|
194 |
*/ |
|
195 |
EMPTY(false), |
|
196 |
||
197 |
/** |
|
198 |
* The completeness of the input could not be determined because it |
|
199 |
* contains errors. Error detection is not a goal of completeness |
|
200 |
* analysis, however errors interfered with determining its completeness. |
|
201 |
* The input is considered complete because evaluating is the best |
|
202 |
* mechanism to get error information. |
|
203 |
*/ |
|
204 |
UNKNOWN(true); |
|
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 | 207 |
|
208 |
Completeness(boolean isComplete) { |
|
209 |
this.isComplete = isComplete; |
|
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 | 224 |
} |
225 |
||
226 |
/** |
|
227 |
* A candidate for continuation of the given user's input. |
|
228 |
*/ |
|
229 |
public static class Suggestion { |
|
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 | 234 |
/** |
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 | 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 | 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 | 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 | 243 |
} |
244 |
||
245 |
/** |
|
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 | 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 | 253 |
|
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 | 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 | 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 | 330 |
} |