author | rfield |
Tue, 11 Apr 2017 17:26:52 -0700 | |
changeset 44683 | 610dc2b48954 |
parent 44459 | 5224425af378 |
child 45501 | a13e5e2ee35e |
permissions | -rw-r--r-- |
33362 | 1 |
/* |
44459 | 2 |
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
33362 | 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.internal.jshell.tool; |
|
27 |
||
41865 | 28 |
import jdk.jshell.SourceCodeAnalysis.Documentation; |
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
29 |
import jdk.jshell.SourceCodeAnalysis.QualifiedNames; |
33362 | 30 |
import jdk.jshell.SourceCodeAnalysis.Suggestion; |
31 |
||
32 |
import java.io.IOException; |
|
33 |
import java.io.InputStream; |
|
41628 | 34 |
import java.io.InterruptedIOException; |
33362 | 35 |
import java.io.PrintStream; |
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
36 |
import java.util.ArrayList; |
41865 | 37 |
import java.util.Arrays; |
38521 | 38 |
import java.util.Collection; |
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
39 |
import java.util.Collections; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
40 |
import java.util.HashMap; |
41865 | 41 |
import java.util.Iterator; |
33362 | 42 |
import java.util.List; |
43 |
import java.util.Locale; |
|
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
44 |
import java.util.Map; |
33362 | 45 |
import java.util.Optional; |
44459 | 46 |
import java.util.function.BooleanSupplier; |
41865 | 47 |
import java.util.function.Function; |
38521 | 48 |
import java.util.stream.Collectors; |
49 |
import java.util.stream.Stream; |
|
33362 | 50 |
|
41865 | 51 |
import jdk.internal.shellsupport.doc.JavadocFormatter; |
33362 | 52 |
import jdk.internal.jline.NoInterruptUnixTerminal; |
53 |
import jdk.internal.jline.Terminal; |
|
54 |
import jdk.internal.jline.TerminalFactory; |
|
36715
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
55 |
import jdk.internal.jline.TerminalSupport; |
33362 | 56 |
import jdk.internal.jline.WindowsTerminal; |
57 |
import jdk.internal.jline.console.ConsoleReader; |
|
58 |
import jdk.internal.jline.console.KeyMap; |
|
43363
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
59 |
import jdk.internal.jline.console.Operation; |
33362 | 60 |
import jdk.internal.jline.console.UserInterruptException; |
40767 | 61 |
import jdk.internal.jline.console.history.History; |
62 |
import jdk.internal.jline.console.history.MemoryHistory; |
|
38521 | 63 |
import jdk.internal.jline.extra.EditingHistory; |
44459 | 64 |
import jdk.internal.jline.internal.NonBlockingInputStream; |
33362 | 65 |
import jdk.internal.jshell.tool.StopDetectingInputStream.State; |
41631
a348d1cc8d9d
8166183: jshell tool: on return from Ctrl-Z, garbage on screen, dies with Ctrl-C
jlahoda
parents:
41628
diff
changeset
|
66 |
import jdk.internal.misc.Signal; |
a348d1cc8d9d
8166183: jshell tool: on return from Ctrl-Z, garbage on screen, dies with Ctrl-C
jlahoda
parents:
41628
diff
changeset
|
67 |
import jdk.internal.misc.Signal.Handler; |
33362 | 68 |
|
69 |
class ConsoleIOContext extends IOContext { |
|
70 |
||
38521 | 71 |
private static final String HISTORY_LINE_PREFIX = "HISTORY_LINE_"; |
72 |
||
33362 | 73 |
final JShellTool repl; |
74 |
final StopDetectingInputStream input; |
|
75 |
final ConsoleReader in; |
|
76 |
final EditingHistory history; |
|
40767 | 77 |
final MemoryHistory userInputHistory = new MemoryHistory(); |
33362 | 78 |
|
79 |
String prefix = ""; |
|
80 |
||
81 |
ConsoleIOContext(JShellTool repl, InputStream cmdin, PrintStream cmdout) throws Exception { |
|
82 |
this.repl = repl; |
|
44188
3f2047e62102
8176412: jshell tool: automatic imports are excluded on /reload causing it to fail
rfield
parents:
43773
diff
changeset
|
83 |
this.input = new StopDetectingInputStream(() -> repl.stop(), ex -> repl.hard("Error on input: %s", ex)); |
33362 | 84 |
Terminal term; |
36501 | 85 |
if (System.getProperty("test.jdk") != null) { |
36715
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
86 |
term = new TestTerminal(input); |
36501 | 87 |
} else if (System.getProperty("os.name").toLowerCase(Locale.US).contains(TerminalFactory.WINDOWS)) { |
33362 | 88 |
term = new JShellWindowsTerminal(input); |
89 |
} else { |
|
90 |
term = new JShellUnixTerminal(input); |
|
91 |
} |
|
92 |
term.init(); |
|
44459 | 93 |
List<CompletionTask> completionTODO = new ArrayList<>(); |
43363
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
94 |
in = new ConsoleReader(cmdin, cmdout, term) { |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
95 |
@Override public KeyMap getKeys() { |
44459 | 96 |
return new CheckCompletionKeyMap(super.getKeys(), completionTODO); |
97 |
} |
|
98 |
@Override |
|
99 |
protected boolean complete() throws IOException { |
|
100 |
return ConsoleIOContext.this.complete(completionTODO); |
|
43363
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
101 |
} |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
102 |
}; |
33362 | 103 |
in.setExpandEvents(false); |
104 |
in.setHandleUserInterrupt(true); |
|
38521 | 105 |
List<String> persistenHistory = Stream.of(repl.prefs.keys()) |
106 |
.filter(key -> key.startsWith(HISTORY_LINE_PREFIX)) |
|
107 |
.sorted() |
|
42843
a8d83044a192
8170162: jshell tool: no mechanism to programmatically launch
rfield
parents:
42827
diff
changeset
|
108 |
.map(key -> repl.prefs.get(key)) |
38521 | 109 |
.collect(Collectors.toList()); |
110 |
in.setHistory(history = new EditingHistory(in, persistenHistory) { |
|
111 |
@Override protected boolean isComplete(CharSequence input) { |
|
38908
f0c186d76c8a
8139829: JShell API: No use of fields to return information from public types
rfield
parents:
38541
diff
changeset
|
112 |
return repl.analysis.analyzeCompletion(input.toString()).completeness().isComplete(); |
33362 | 113 |
} |
114 |
}); |
|
115 |
in.setBellEnabled(true); |
|
38541
44e95493fd13
8131017: jshell tool: pasting code with tabs invokes tab completion
jlahoda
parents:
38521
diff
changeset
|
116 |
in.setCopyPasteDetection(true); |
44459 | 117 |
bind(FIXES_SHORTCUT, (Runnable) () -> fixes()); |
41631
a348d1cc8d9d
8166183: jshell tool: on return from Ctrl-Z, garbage on screen, dies with Ctrl-C
jlahoda
parents:
41628
diff
changeset
|
118 |
try { |
a348d1cc8d9d
8166183: jshell tool: on return from Ctrl-Z, garbage on screen, dies with Ctrl-C
jlahoda
parents:
41628
diff
changeset
|
119 |
Signal.handle(new Signal("CONT"), new Handler() { |
a348d1cc8d9d
8166183: jshell tool: on return from Ctrl-Z, garbage on screen, dies with Ctrl-C
jlahoda
parents:
41628
diff
changeset
|
120 |
@Override public void handle(Signal sig) { |
a348d1cc8d9d
8166183: jshell tool: on return from Ctrl-Z, garbage on screen, dies with Ctrl-C
jlahoda
parents:
41628
diff
changeset
|
121 |
try { |
a348d1cc8d9d
8166183: jshell tool: on return from Ctrl-Z, garbage on screen, dies with Ctrl-C
jlahoda
parents:
41628
diff
changeset
|
122 |
in.getTerminal().reset(); |
a348d1cc8d9d
8166183: jshell tool: on return from Ctrl-Z, garbage on screen, dies with Ctrl-C
jlahoda
parents:
41628
diff
changeset
|
123 |
in.redrawLine(); |
a348d1cc8d9d
8166183: jshell tool: on return from Ctrl-Z, garbage on screen, dies with Ctrl-C
jlahoda
parents:
41628
diff
changeset
|
124 |
in.flush(); |
a348d1cc8d9d
8166183: jshell tool: on return from Ctrl-Z, garbage on screen, dies with Ctrl-C
jlahoda
parents:
41628
diff
changeset
|
125 |
} catch (Exception ex) { |
a348d1cc8d9d
8166183: jshell tool: on return from Ctrl-Z, garbage on screen, dies with Ctrl-C
jlahoda
parents:
41628
diff
changeset
|
126 |
ex.printStackTrace(); |
a348d1cc8d9d
8166183: jshell tool: on return from Ctrl-Z, garbage on screen, dies with Ctrl-C
jlahoda
parents:
41628
diff
changeset
|
127 |
} |
a348d1cc8d9d
8166183: jshell tool: on return from Ctrl-Z, garbage on screen, dies with Ctrl-C
jlahoda
parents:
41628
diff
changeset
|
128 |
} |
a348d1cc8d9d
8166183: jshell tool: on return from Ctrl-Z, garbage on screen, dies with Ctrl-C
jlahoda
parents:
41628
diff
changeset
|
129 |
}); |
a348d1cc8d9d
8166183: jshell tool: on return from Ctrl-Z, garbage on screen, dies with Ctrl-C
jlahoda
parents:
41628
diff
changeset
|
130 |
} catch (IllegalArgumentException ignored) { |
a348d1cc8d9d
8166183: jshell tool: on return from Ctrl-Z, garbage on screen, dies with Ctrl-C
jlahoda
parents:
41628
diff
changeset
|
131 |
//the CONT signal does not exist on this platform |
a348d1cc8d9d
8166183: jshell tool: on return from Ctrl-Z, garbage on screen, dies with Ctrl-C
jlahoda
parents:
41628
diff
changeset
|
132 |
} |
33362 | 133 |
} |
134 |
||
135 |
@Override |
|
136 |
public String readLine(String prompt, String prefix) throws IOException, InputInterruptedException { |
|
137 |
this.prefix = prefix; |
|
138 |
try { |
|
139 |
return in.readLine(prompt); |
|
140 |
} catch (UserInterruptException ex) { |
|
141 |
throw (InputInterruptedException) new InputInterruptedException().initCause(ex); |
|
142 |
} |
|
143 |
} |
|
144 |
||
145 |
@Override |
|
146 |
public boolean interactiveOutput() { |
|
147 |
return true; |
|
148 |
} |
|
149 |
||
150 |
@Override |
|
151 |
public Iterable<String> currentSessionHistory() { |
|
152 |
return history.currentSessionEntries(); |
|
153 |
} |
|
154 |
||
155 |
@Override |
|
156 |
public void close() throws IOException { |
|
38521 | 157 |
//save history: |
42843
a8d83044a192
8170162: jshell tool: no mechanism to programmatically launch
rfield
parents:
42827
diff
changeset
|
158 |
for (String key : repl.prefs.keys()) { |
a8d83044a192
8170162: jshell tool: no mechanism to programmatically launch
rfield
parents:
42827
diff
changeset
|
159 |
if (key.startsWith(HISTORY_LINE_PREFIX)) { |
a8d83044a192
8170162: jshell tool: no mechanism to programmatically launch
rfield
parents:
42827
diff
changeset
|
160 |
repl.prefs.remove(key); |
38521 | 161 |
} |
42843
a8d83044a192
8170162: jshell tool: no mechanism to programmatically launch
rfield
parents:
42827
diff
changeset
|
162 |
} |
a8d83044a192
8170162: jshell tool: no mechanism to programmatically launch
rfield
parents:
42827
diff
changeset
|
163 |
Collection<? extends String> savedHistory = history.save(); |
a8d83044a192
8170162: jshell tool: no mechanism to programmatically launch
rfield
parents:
42827
diff
changeset
|
164 |
if (!savedHistory.isEmpty()) { |
a8d83044a192
8170162: jshell tool: no mechanism to programmatically launch
rfield
parents:
42827
diff
changeset
|
165 |
int len = (int) Math.ceil(Math.log10(savedHistory.size()+1)); |
a8d83044a192
8170162: jshell tool: no mechanism to programmatically launch
rfield
parents:
42827
diff
changeset
|
166 |
String format = HISTORY_LINE_PREFIX + "%0" + len + "d"; |
a8d83044a192
8170162: jshell tool: no mechanism to programmatically launch
rfield
parents:
42827
diff
changeset
|
167 |
int index = 0; |
a8d83044a192
8170162: jshell tool: no mechanism to programmatically launch
rfield
parents:
42827
diff
changeset
|
168 |
for (String historyLine : savedHistory) { |
a8d83044a192
8170162: jshell tool: no mechanism to programmatically launch
rfield
parents:
42827
diff
changeset
|
169 |
repl.prefs.put(String.format(format, index++), historyLine); |
38521 | 170 |
} |
171 |
} |
|
42843
a8d83044a192
8170162: jshell tool: no mechanism to programmatically launch
rfield
parents:
42827
diff
changeset
|
172 |
repl.prefs.flush(); |
33362 | 173 |
in.shutdown(); |
174 |
try { |
|
175 |
in.getTerminal().restore(); |
|
176 |
} catch (Exception ex) { |
|
177 |
throw new IOException(ex); |
|
178 |
} |
|
38909
80e42e2d475b
8158174: jshell tool: leaks threads waiting on StopDetectingInputStream
jlahoda
parents:
38908
diff
changeset
|
179 |
input.shutdown(); |
33362 | 180 |
} |
181 |
||
182 |
private void bind(String shortcut, Object action) { |
|
183 |
KeyMap km = in.getKeys(); |
|
184 |
for (int i = 0; i < shortcut.length(); i++) { |
|
185 |
Object value = km.getBound(Character.toString(shortcut.charAt(i))); |
|
186 |
if (value instanceof KeyMap) { |
|
187 |
km = (KeyMap) value; |
|
188 |
} else { |
|
189 |
km.bind(shortcut.substring(i), action); |
|
190 |
} |
|
191 |
} |
|
192 |
} |
|
193 |
||
44459 | 194 |
private static final String FIXES_SHORTCUT = "\033\133\132"; //Shift-TAB |
33362 | 195 |
|
44459 | 196 |
private static final String LINE_SEPARATOR = System.getProperty("line.separator"); |
197 |
private static final String LINE_SEPARATORS2 = LINE_SEPARATOR + LINE_SEPARATOR; |
|
41865 | 198 |
|
44459 | 199 |
@SuppressWarnings("fallthrough") |
200 |
private boolean complete(List<CompletionTask> todo) { |
|
201 |
//The completion has multiple states (invoked by subsequent presses of <tab>). |
|
202 |
//On the first invocation in a given sequence, all steps are precomputed |
|
203 |
//and placed into the todo list. The todo list is then followed on both the first |
|
204 |
//and subsequent <tab> presses: |
|
33362 | 205 |
try { |
44459 | 206 |
String text = in.getCursorBuffer().toString(); |
207 |
int cursor = in.getCursorBuffer().cursor; |
|
208 |
if (todo.isEmpty()) { |
|
209 |
int[] anchor = new int[] {-1}; |
|
210 |
List<Suggestion> suggestions; |
|
211 |
List<String> doc; |
|
212 |
boolean command = prefix.isEmpty() && text.trim().startsWith("/"); |
|
213 |
if (command) { |
|
214 |
suggestions = repl.commandCompletionSuggestions(text, cursor, anchor); |
|
215 |
doc = repl.commandDocumentation(text, cursor, true); |
|
41865 | 216 |
} else { |
44459 | 217 |
int prefixLength = prefix.length(); |
218 |
suggestions = repl.analysis.completionSuggestions(prefix + text, cursor + prefixLength, anchor); |
|
219 |
anchor[0] -= prefixLength; |
|
220 |
doc = repl.analysis.documentation(prefix + text, cursor + prefix.length(), false) |
|
221 |
.stream() |
|
222 |
.map(Documentation::signature) |
|
223 |
.collect(Collectors.toList()); |
|
224 |
} |
|
225 |
long smartCount = suggestions.stream().filter(Suggestion::matchesType).count(); |
|
226 |
boolean hasSmart = smartCount > 0 && smartCount <= in.getAutoprintThreshold(); |
|
227 |
boolean hasBoth = hasSmart && |
|
228 |
suggestions.stream() |
|
229 |
.map(s -> s.matchesType()) |
|
230 |
.distinct() |
|
231 |
.count() == 2; |
|
232 |
boolean tooManyItems = suggestions.size() > in.getAutoprintThreshold(); |
|
233 |
CompletionTask ordinaryCompletion = new OrdinaryCompletionTask(suggestions, anchor[0], !command && !doc.isEmpty(), hasSmart); |
|
234 |
CompletionTask allCompletion = new AllSuggestionsCompletionTask(suggestions, anchor[0]); |
|
41865 | 235 |
|
44459 | 236 |
//the main decission tree: |
237 |
if (command) { |
|
238 |
CompletionTask shortDocumentation = new CommandSynopsisTask(doc); |
|
239 |
CompletionTask fullDocumentation = new CommandFullDocumentationTask(todo); |
|
41865 | 240 |
|
44459 | 241 |
if (!doc.isEmpty()) { |
242 |
if (tooManyItems) { |
|
243 |
todo.add(new NoopCompletionTask()); |
|
244 |
todo.add(allCompletion); |
|
245 |
} else { |
|
246 |
todo.add(ordinaryCompletion); |
|
41865 | 247 |
} |
44459 | 248 |
todo.add(shortDocumentation); |
249 |
todo.add(fullDocumentation); |
|
250 |
} else { |
|
251 |
todo.add(new NoSuchCommandCompletionTask()); |
|
252 |
} |
|
253 |
} else { |
|
254 |
if (doc.isEmpty()) { |
|
255 |
if (hasSmart) { |
|
256 |
todo.add(ordinaryCompletion); |
|
257 |
} else if (tooManyItems) { |
|
258 |
todo.add(new NoopCompletionTask()); |
|
259 |
} |
|
260 |
if (!hasSmart || hasBoth) { |
|
261 |
todo.add(allCompletion); |
|
262 |
} |
|
263 |
} else { |
|
264 |
CompletionTask shortDocumentation = new ExpressionSignaturesTask(doc); |
|
265 |
CompletionTask fullDocumentation = new ExpressionJavadocTask(todo); |
|
41865 | 266 |
|
44459 | 267 |
if (hasSmart) { |
268 |
todo.add(ordinaryCompletion); |
|
269 |
} |
|
270 |
todo.add(shortDocumentation); |
|
271 |
if (!hasSmart || hasBoth) { |
|
272 |
todo.add(allCompletion); |
|
273 |
} |
|
274 |
if (tooManyItems) { |
|
275 |
todo.add(todo.size() - 1, fullDocumentation); |
|
276 |
} else { |
|
277 |
todo.add(fullDocumentation); |
|
41865 | 278 |
} |
279 |
} |
|
280 |
} |
|
33362 | 281 |
} |
44459 | 282 |
|
283 |
boolean success = false; |
|
284 |
boolean repaint = true; |
|
285 |
||
286 |
OUTER: while (!todo.isEmpty()) { |
|
287 |
CompletionTask.Result result = todo.remove(0).perform(text, cursor); |
|
288 |
||
289 |
switch (result) { |
|
290 |
case CONTINUE: |
|
291 |
break; |
|
292 |
case SKIP_NOREPAINT: |
|
293 |
repaint = false; |
|
294 |
case SKIP: |
|
295 |
todo.clear(); |
|
296 |
//intentional fall-through |
|
297 |
case FINISH: |
|
298 |
success = true; |
|
299 |
//intentional fall-through |
|
300 |
case NO_DATA: |
|
301 |
if (!todo.isEmpty()) { |
|
302 |
in.println(); |
|
303 |
in.println(todo.get(0).description()); |
|
304 |
} |
|
305 |
break OUTER; |
|
306 |
} |
|
307 |
} |
|
308 |
||
309 |
if (repaint) { |
|
310 |
in.redrawLine(); |
|
311 |
in.flush(); |
|
312 |
} |
|
313 |
||
314 |
return success; |
|
33362 | 315 |
} catch (IOException ex) { |
316 |
throw new IllegalStateException(ex); |
|
317 |
} |
|
318 |
} |
|
319 |
||
44459 | 320 |
private CompletionTask.Result doPrintFullDocumentation(List<CompletionTask> todo, List<String> doc, boolean command) { |
321 |
if (doc != null && !doc.isEmpty()) { |
|
322 |
Terminal term = in.getTerminal(); |
|
323 |
int pageHeight = term.getHeight() - NEEDED_LINES; |
|
324 |
List<CompletionTask> thisTODO = new ArrayList<>(); |
|
325 |
||
326 |
for (Iterator<String> docIt = doc.iterator(); docIt.hasNext(); ) { |
|
327 |
String currentDoc = docIt.next(); |
|
328 |
String[] lines = currentDoc.split("\n"); |
|
329 |
int firstLine = 0; |
|
330 |
||
331 |
while (firstLine < lines.length) { |
|
332 |
boolean first = firstLine == 0; |
|
333 |
String[] thisPageLines = |
|
334 |
Arrays.copyOfRange(lines, |
|
335 |
firstLine, |
|
336 |
Math.min(firstLine + pageHeight, lines.length)); |
|
337 |
||
338 |
thisTODO.add(new CompletionTask() { |
|
339 |
@Override |
|
340 |
public String description() { |
|
341 |
String key = !first ? "jshell.console.see.next.page" |
|
342 |
: command ? "jshell.console.see.next.command.doc" |
|
343 |
: "jshell.console.see.next.javadoc"; |
|
344 |
||
345 |
return repl.getResourceString(key); |
|
346 |
} |
|
347 |
||
348 |
@Override |
|
349 |
public Result perform(String text, int cursor) throws IOException { |
|
350 |
in.println(); |
|
351 |
for (String line : thisPageLines) { |
|
352 |
in.println(line); |
|
353 |
} |
|
354 |
return Result.FINISH; |
|
355 |
} |
|
356 |
}); |
|
357 |
||
358 |
firstLine += pageHeight; |
|
359 |
} |
|
360 |
} |
|
361 |
||
362 |
todo.addAll(0, thisTODO); |
|
363 |
||
364 |
return CompletionTask.Result.CONTINUE; |
|
365 |
} |
|
366 |
||
367 |
return CompletionTask.Result.FINISH; |
|
368 |
} |
|
369 |
//where: |
|
370 |
private static final int NEEDED_LINES = 4; |
|
371 |
||
33362 | 372 |
private static String commonPrefix(String str1, String str2) { |
373 |
for (int i = 0; i < str2.length(); i++) { |
|
374 |
if (!str1.startsWith(str2.substring(0, i + 1))) { |
|
375 |
return str2.substring(0, i); |
|
376 |
} |
|
377 |
} |
|
378 |
||
379 |
return str2; |
|
380 |
} |
|
381 |
||
44459 | 382 |
private interface CompletionTask { |
383 |
public String description(); |
|
384 |
public Result perform(String text, int cursor) throws IOException; |
|
385 |
||
386 |
enum Result { |
|
387 |
NO_DATA, |
|
388 |
CONTINUE, |
|
389 |
FINISH, |
|
390 |
SKIP, |
|
391 |
SKIP_NOREPAINT; |
|
392 |
} |
|
393 |
} |
|
394 |
||
395 |
private final class NoopCompletionTask implements CompletionTask { |
|
396 |
||
397 |
@Override |
|
398 |
public String description() { |
|
399 |
throw new UnsupportedOperationException("Should not get here."); |
|
400 |
} |
|
401 |
||
402 |
@Override |
|
403 |
public Result perform(String text, int cursor) throws IOException { |
|
404 |
return Result.FINISH; |
|
405 |
} |
|
406 |
||
407 |
} |
|
408 |
||
409 |
private final class NoSuchCommandCompletionTask implements CompletionTask { |
|
410 |
||
411 |
@Override |
|
412 |
public String description() { |
|
413 |
throw new UnsupportedOperationException("Should not get here."); |
|
414 |
} |
|
415 |
||
416 |
@Override |
|
417 |
public Result perform(String text, int cursor) throws IOException { |
|
418 |
in.println(); |
|
419 |
in.println(repl.getResourceString("jshell.console.no.such.command")); |
|
420 |
in.println(); |
|
421 |
return Result.SKIP; |
|
422 |
} |
|
423 |
||
424 |
} |
|
425 |
||
426 |
private final class OrdinaryCompletionTask implements CompletionTask { |
|
427 |
private final List<Suggestion> suggestions; |
|
428 |
private final int anchor; |
|
429 |
private final boolean cont; |
|
430 |
private final boolean smart; |
|
431 |
||
432 |
public OrdinaryCompletionTask(List<Suggestion> suggestions, |
|
433 |
int anchor, |
|
434 |
boolean cont, |
|
435 |
boolean smart) { |
|
436 |
this.suggestions = suggestions; |
|
437 |
this.anchor = anchor; |
|
438 |
this.cont = cont; |
|
439 |
this.smart = smart; |
|
440 |
} |
|
441 |
||
442 |
@Override |
|
443 |
public String description() { |
|
444 |
throw new UnsupportedOperationException("Should not get here."); |
|
445 |
} |
|
446 |
||
447 |
@Override |
|
448 |
public Result perform(String text, int cursor) throws IOException { |
|
449 |
List<CharSequence> toShow; |
|
450 |
||
451 |
if (smart) { |
|
452 |
toShow = |
|
453 |
suggestions.stream() |
|
454 |
.filter(Suggestion::matchesType) |
|
455 |
.map(Suggestion::continuation) |
|
456 |
.distinct() |
|
457 |
.collect(Collectors.toList()); |
|
458 |
} else { |
|
459 |
toShow = |
|
460 |
suggestions.stream() |
|
461 |
.map(Suggestion::continuation) |
|
462 |
.distinct() |
|
463 |
.collect(Collectors.toList()); |
|
464 |
} |
|
465 |
||
466 |
if (toShow.isEmpty()) { |
|
467 |
return Result.CONTINUE; |
|
468 |
} |
|
469 |
||
470 |
Optional<String> prefix = |
|
471 |
suggestions.stream() |
|
472 |
.map(Suggestion::continuation) |
|
473 |
.reduce(ConsoleIOContext::commonPrefix); |
|
474 |
||
475 |
String prefixStr = prefix.orElse("").substring(cursor - anchor); |
|
476 |
in.putString(prefixStr); |
|
477 |
||
478 |
boolean showItems = toShow.size() > 1 || smart; |
|
479 |
||
480 |
if (showItems) { |
|
481 |
in.println(); |
|
482 |
in.printColumns(toShow); |
|
483 |
} |
|
484 |
||
485 |
if (!prefixStr.isEmpty()) |
|
486 |
return showItems ? Result.SKIP : Result.SKIP_NOREPAINT; |
|
487 |
||
488 |
return cont ? Result.CONTINUE : Result.FINISH; |
|
489 |
} |
|
490 |
||
491 |
} |
|
492 |
||
493 |
private final class AllSuggestionsCompletionTask implements CompletionTask { |
|
494 |
private final List<Suggestion> suggestions; |
|
495 |
private final int anchor; |
|
496 |
||
497 |
public AllSuggestionsCompletionTask(List<Suggestion> suggestions, |
|
498 |
int anchor) { |
|
499 |
this.suggestions = suggestions; |
|
500 |
this.anchor = anchor; |
|
501 |
} |
|
502 |
||
503 |
@Override |
|
504 |
public String description() { |
|
505 |
if (suggestions.size() <= in.getAutoprintThreshold()) { |
|
506 |
return repl.getResourceString("jshell.console.completion.all.completions"); |
|
507 |
} else { |
|
508 |
return repl.messageFormat("jshell.console.completion.all.completions.number", suggestions.size()); |
|
509 |
} |
|
510 |
} |
|
511 |
||
512 |
@Override |
|
513 |
public Result perform(String text, int cursor) throws IOException { |
|
514 |
List<String> candidates = |
|
515 |
suggestions.stream() |
|
516 |
.map(Suggestion::continuation) |
|
517 |
.distinct() |
|
518 |
.collect(Collectors.toList()); |
|
519 |
||
520 |
Optional<String> prefix = |
|
521 |
candidates.stream() |
|
522 |
.reduce(ConsoleIOContext::commonPrefix); |
|
523 |
||
524 |
String prefixStr = prefix.map(str -> str.substring(cursor - anchor)).orElse(""); |
|
525 |
in.putString(prefixStr); |
|
526 |
if (candidates.size() > 1) { |
|
527 |
in.println(); |
|
528 |
in.printColumns(candidates); |
|
529 |
} |
|
530 |
return suggestions.isEmpty() ? Result.NO_DATA : Result.FINISH; |
|
531 |
} |
|
532 |
||
533 |
} |
|
534 |
||
535 |
private final class CommandSynopsisTask implements CompletionTask { |
|
536 |
||
537 |
private final List<String> synopsis; |
|
538 |
||
539 |
public CommandSynopsisTask(List<String> synposis) { |
|
540 |
this.synopsis = synposis; |
|
541 |
} |
|
542 |
||
543 |
@Override |
|
544 |
public String description() { |
|
545 |
return repl.getResourceString("jshell.console.see.synopsis"); |
|
546 |
} |
|
547 |
||
548 |
@Override |
|
549 |
public Result perform(String text, int cursor) throws IOException { |
|
550 |
try { |
|
551 |
in.println(); |
|
552 |
in.println(synopsis.stream() |
|
553 |
.map(l -> l.replaceAll("\n", LINE_SEPARATOR)) |
|
554 |
.collect(Collectors.joining(LINE_SEPARATORS2))); |
|
555 |
} catch (IOException ex) { |
|
556 |
throw new IllegalStateException(ex); |
|
557 |
} |
|
558 |
return Result.FINISH; |
|
559 |
} |
|
560 |
||
561 |
} |
|
562 |
||
563 |
private final class CommandFullDocumentationTask implements CompletionTask { |
|
564 |
||
565 |
private final List<CompletionTask> todo; |
|
566 |
||
567 |
public CommandFullDocumentationTask(List<CompletionTask> todo) { |
|
568 |
this.todo = todo; |
|
569 |
} |
|
570 |
||
571 |
@Override |
|
572 |
public String description() { |
|
573 |
return repl.getResourceString("jshell.console.see.full.documentation"); |
|
574 |
} |
|
575 |
||
576 |
@Override |
|
577 |
public Result perform(String text, int cursor) throws IOException { |
|
578 |
List<String> fullDoc = repl.commandDocumentation(text, cursor, false); |
|
579 |
return doPrintFullDocumentation(todo, fullDoc, true); |
|
580 |
} |
|
581 |
||
582 |
} |
|
583 |
||
584 |
private final class ExpressionSignaturesTask implements CompletionTask { |
|
585 |
||
586 |
private final List<String> doc; |
|
587 |
||
588 |
public ExpressionSignaturesTask(List<String> doc) { |
|
589 |
this.doc = doc; |
|
590 |
} |
|
591 |
||
592 |
@Override |
|
593 |
public String description() { |
|
594 |
throw new UnsupportedOperationException("Should not get here."); |
|
595 |
} |
|
596 |
||
597 |
@Override |
|
598 |
public Result perform(String text, int cursor) throws IOException { |
|
599 |
in.println(); |
|
600 |
in.println(repl.getResourceString("jshell.console.completion.current.signatures")); |
|
601 |
in.println(doc.stream().collect(Collectors.joining(LINE_SEPARATOR))); |
|
602 |
return Result.FINISH; |
|
603 |
} |
|
604 |
||
605 |
} |
|
606 |
||
607 |
private final class ExpressionJavadocTask implements CompletionTask { |
|
608 |
||
609 |
private final List<CompletionTask> todo; |
|
610 |
||
611 |
public ExpressionJavadocTask(List<CompletionTask> todo) { |
|
612 |
this.todo = todo; |
|
613 |
} |
|
614 |
||
615 |
@Override |
|
616 |
public String description() { |
|
617 |
return repl.getResourceString("jshell.console.see.documentation"); |
|
618 |
} |
|
619 |
||
620 |
@Override |
|
621 |
public Result perform(String text, int cursor) throws IOException { |
|
622 |
//schedule showing javadoc: |
|
623 |
Terminal term = in.getTerminal(); |
|
624 |
JavadocFormatter formatter = new JavadocFormatter(term.getWidth(), |
|
625 |
term.isAnsiSupported()); |
|
626 |
Function<Documentation, String> convertor = d -> formatter.formatJavadoc(d.signature(), d.javadoc()) + |
|
627 |
(d.javadoc() == null ? repl.messageFormat("jshell.console.no.javadoc") |
|
628 |
: ""); |
|
629 |
List<String> doc = repl.analysis.documentation(prefix + text, cursor + prefix.length(), true) |
|
630 |
.stream() |
|
631 |
.map(convertor) |
|
632 |
.collect(Collectors.toList()); |
|
633 |
return doPrintFullDocumentation(todo, doc, false); |
|
634 |
} |
|
635 |
||
636 |
} |
|
637 |
||
33362 | 638 |
@Override |
639 |
public boolean terminalEditorRunning() { |
|
640 |
Terminal terminal = in.getTerminal(); |
|
43583
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
641 |
if (terminal instanceof SuspendableTerminal) |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
642 |
return ((SuspendableTerminal) terminal).isRaw(); |
33362 | 643 |
return false; |
644 |
} |
|
645 |
||
646 |
@Override |
|
647 |
public void suspend() { |
|
43583
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
648 |
Terminal terminal = in.getTerminal(); |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
649 |
if (terminal instanceof SuspendableTerminal) |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
650 |
((SuspendableTerminal) terminal).suspend(); |
33362 | 651 |
} |
652 |
||
653 |
@Override |
|
654 |
public void resume() { |
|
43583
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
655 |
Terminal terminal = in.getTerminal(); |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
656 |
if (terminal instanceof SuspendableTerminal) |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
657 |
((SuspendableTerminal) terminal).resume(); |
33362 | 658 |
} |
659 |
||
42843
a8d83044a192
8170162: jshell tool: no mechanism to programmatically launch
rfield
parents:
42827
diff
changeset
|
660 |
@Override |
33362 | 661 |
public void beforeUserCode() { |
40767 | 662 |
synchronized (this) { |
663 |
inputBytes = null; |
|
664 |
} |
|
33362 | 665 |
input.setState(State.BUFFER); |
666 |
} |
|
667 |
||
42843
a8d83044a192
8170162: jshell tool: no mechanism to programmatically launch
rfield
parents:
42827
diff
changeset
|
668 |
@Override |
33362 | 669 |
public void afterUserCode() { |
670 |
input.setState(State.WAIT); |
|
671 |
} |
|
672 |
||
673 |
@Override |
|
674 |
public void replaceLastHistoryEntry(String source) { |
|
675 |
history.fullHistoryReplace(source); |
|
676 |
} |
|
677 |
||
44459 | 678 |
private static final long ESCAPE_TIMEOUT = 100; |
679 |
||
680 |
private void fixes() { |
|
681 |
try { |
|
682 |
int c = in.readCharacter(); |
|
683 |
||
684 |
if (c == (-1)) { |
|
685 |
return ; |
|
686 |
} |
|
687 |
||
688 |
for (FixComputer computer : FIX_COMPUTERS) { |
|
689 |
if (computer.shortcut == c) { |
|
690 |
fixes(computer); |
|
691 |
return ; |
|
692 |
} |
|
693 |
} |
|
694 |
||
695 |
readOutRemainingEscape(c); |
|
696 |
||
697 |
in.beep(); |
|
698 |
in.println(); |
|
699 |
in.println(repl.getResourceString("jshell.fix.wrong.shortcut")); |
|
700 |
in.redrawLine(); |
|
701 |
in.flush(); |
|
702 |
} catch (IOException ex) { |
|
703 |
ex.printStackTrace(); |
|
704 |
} |
|
705 |
} |
|
706 |
||
707 |
private void readOutRemainingEscape(int c) throws IOException { |
|
708 |
if (c == '\033') { |
|
709 |
//escape, consume waiting input: |
|
710 |
InputStream inp = in.getInput(); |
|
711 |
||
712 |
if (inp instanceof NonBlockingInputStream) { |
|
713 |
NonBlockingInputStream nbis = (NonBlockingInputStream) inp; |
|
714 |
||
715 |
while (nbis.isNonBlockingEnabled() && nbis.peek(ESCAPE_TIMEOUT) > 0) { |
|
716 |
in.readCharacter(); |
|
717 |
} |
|
718 |
} |
|
719 |
} |
|
720 |
} |
|
721 |
||
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
722 |
//compute possible options/Fixes based on the selected FixComputer, present them to the user, |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
723 |
//and perform the selected one: |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
724 |
private void fixes(FixComputer computer) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
725 |
String input = prefix + in.getCursorBuffer().toString(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
726 |
int cursor = prefix.length() + in.getCursorBuffer().cursor; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
727 |
FixResult candidates = computer.compute(repl, input, cursor); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
728 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
729 |
try { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
730 |
final boolean printError = candidates.error != null && !candidates.error.isEmpty(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
731 |
if (printError) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
732 |
in.println(candidates.error); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
733 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
734 |
if (candidates.fixes.isEmpty()) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
735 |
in.beep(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
736 |
if (printError) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
737 |
in.redrawLine(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
738 |
in.flush(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
739 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
740 |
} else if (candidates.fixes.size() == 1 && !computer.showMenu) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
741 |
if (printError) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
742 |
in.redrawLine(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
743 |
in.flush(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
744 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
745 |
candidates.fixes.get(0).perform(in); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
746 |
} else { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
747 |
List<Fix> fixes = new ArrayList<>(candidates.fixes); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
748 |
fixes.add(0, new Fix() { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
749 |
@Override |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
750 |
public String displayName() { |
36990 | 751 |
return repl.messageFormat("jshell.console.do.nothing"); |
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
752 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
753 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
754 |
@Override |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
755 |
public void perform(ConsoleReader in) throws IOException { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
756 |
in.redrawLine(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
757 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
758 |
}); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
759 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
760 |
Map<Character, Fix> char2Fix = new HashMap<>(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
761 |
in.println(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
762 |
for (int i = 0; i < fixes.size(); i++) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
763 |
Fix fix = fixes.get(i); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
764 |
char2Fix.put((char) ('0' + i), fix); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
765 |
in.println("" + i + ": " + fixes.get(i).displayName()); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
766 |
} |
36990 | 767 |
in.print(repl.messageFormat("jshell.console.choice")); |
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
768 |
in.flush(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
769 |
int read; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
770 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
771 |
read = in.readCharacter(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
772 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
773 |
Fix fix = char2Fix.get((char) read); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
774 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
775 |
if (fix == null) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
776 |
in.beep(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
777 |
fix = fixes.get(0); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
778 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
779 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
780 |
in.println(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
781 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
782 |
fix.perform(in); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
783 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
784 |
in.flush(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
785 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
786 |
} catch (IOException ex) { |
44459 | 787 |
throw new IllegalStateException(ex); |
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
788 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
789 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
790 |
|
40767 | 791 |
private byte[] inputBytes; |
792 |
private int inputBytesPointer; |
|
793 |
||
794 |
@Override |
|
41628 | 795 |
public synchronized int readUserInput() throws IOException { |
40767 | 796 |
while (inputBytes == null || inputBytes.length <= inputBytesPointer) { |
797 |
boolean prevHandleUserInterrupt = in.getHandleUserInterrupt(); |
|
798 |
History prevHistory = in.getHistory(); |
|
799 |
||
800 |
try { |
|
801 |
input.setState(State.WAIT); |
|
802 |
in.setHandleUserInterrupt(true); |
|
803 |
in.setHistory(userInputHistory); |
|
804 |
inputBytes = (in.readLine("") + System.getProperty("line.separator")).getBytes(); |
|
805 |
inputBytesPointer = 0; |
|
806 |
} catch (UserInterruptException ex) { |
|
41628 | 807 |
throw new InterruptedIOException(); |
40767 | 808 |
} finally { |
809 |
in.setHistory(prevHistory); |
|
810 |
in.setHandleUserInterrupt(prevHandleUserInterrupt); |
|
811 |
input.setState(State.BUFFER); |
|
812 |
} |
|
813 |
} |
|
814 |
return inputBytes[inputBytesPointer++]; |
|
815 |
} |
|
816 |
||
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
817 |
/** |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
818 |
* A possible action which the user can choose to perform. |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
819 |
*/ |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
820 |
public interface Fix { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
821 |
/** |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
822 |
* A name that should be shown to the user. |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
823 |
*/ |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
824 |
public String displayName(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
825 |
/** |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
826 |
* Perform the given action. |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
827 |
*/ |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
828 |
public void perform(ConsoleReader in) throws IOException; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
829 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
830 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
831 |
/** |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
832 |
* A factory for {@link Fix}es. |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
833 |
*/ |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
834 |
public abstract static class FixComputer { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
835 |
private final char shortcut; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
836 |
private final boolean showMenu; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
837 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
838 |
/** |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
839 |
* Construct a new FixComputer. {@code shortcut} defines the key which should trigger this FixComputer. |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
840 |
* If {@code showMenu} is {@code false}, and this computer returns exactly one {@code Fix}, |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
841 |
* no options will be show to the user, and the given {@code Fix} will be performed. |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
842 |
*/ |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
843 |
public FixComputer(char shortcut, boolean showMenu) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
844 |
this.shortcut = shortcut; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
845 |
this.showMenu = showMenu; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
846 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
847 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
848 |
/** |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
849 |
* Compute possible actions for the given code. |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
850 |
*/ |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
851 |
public abstract FixResult compute(JShellTool repl, String code, int cursor); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
852 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
853 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
854 |
/** |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
855 |
* A list of {@code Fix}es with a possible error that should be shown to the user. |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
856 |
*/ |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
857 |
public static class FixResult { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
858 |
public final List<Fix> fixes; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
859 |
public final String error; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
860 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
861 |
public FixResult(List<Fix> fixes, String error) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
862 |
this.fixes = fixes; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
863 |
this.error = error; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
864 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
865 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
866 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
867 |
private static final FixComputer[] FIX_COMPUTERS = new FixComputer[] { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
868 |
new FixComputer('v', false) { //compute "Introduce variable" Fix: |
41996
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
869 |
private void performToVar(ConsoleReader in, String type) throws IOException { |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
870 |
in.redrawLine(); |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
871 |
in.setCursorPosition(0); |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
872 |
in.putString(type + " = "); |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
873 |
in.setCursorPosition(in.getCursorBuffer().cursor - 3); |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
874 |
in.flush(); |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
875 |
} |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
876 |
|
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
877 |
@Override |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
878 |
public FixResult compute(JShellTool repl, String code, int cursor) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
879 |
String type = repl.analysis.analyzeType(code, cursor); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
880 |
if (type == null) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
881 |
return new FixResult(Collections.emptyList(), null); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
882 |
} |
41996
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
883 |
List<Fix> fixes = new ArrayList<>(); |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
884 |
fixes.add(new Fix() { |
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
885 |
@Override |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
886 |
public String displayName() { |
36990 | 887 |
return repl.messageFormat("jshell.console.create.variable"); |
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
888 |
} |
41996
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
889 |
|
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
890 |
@Override |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
891 |
public void perform(ConsoleReader in) throws IOException { |
41996
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
892 |
performToVar(in, type); |
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
893 |
} |
41996
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
894 |
}); |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
895 |
int idx = type.lastIndexOf("."); |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
896 |
if (idx > 0) { |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
897 |
String stype = type.substring(idx + 1); |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
898 |
QualifiedNames res = repl.analysis.listQualifiedNames(stype, stype.length()); |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
899 |
if (res.isUpToDate() && res.getNames().contains(type) |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
900 |
&& !res.isResolvable()) { |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
901 |
fixes.add(new Fix() { |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
902 |
@Override |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
903 |
public String displayName() { |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
904 |
return "import: " + type + ". " + |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
905 |
repl.messageFormat("jshell.console.create.variable"); |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
906 |
} |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
907 |
|
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
908 |
@Override |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
909 |
public void perform(ConsoleReader in) throws IOException { |
44188
3f2047e62102
8176412: jshell tool: automatic imports are excluded on /reload causing it to fail
rfield
parents:
43773
diff
changeset
|
910 |
repl.processCompleteSource("import " + type + ";"); |
41996
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
911 |
in.println("Imported: " + type); |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
912 |
performToVar(in, stype); |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
913 |
} |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
914 |
}); |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
915 |
} |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
916 |
} |
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
917 |
return new FixResult(fixes, null); |
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
918 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
919 |
}, |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
920 |
new FixComputer('i', true) { //compute "Add import" Fixes: |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
921 |
@Override |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
922 |
public FixResult compute(JShellTool repl, String code, int cursor) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
923 |
QualifiedNames res = repl.analysis.listQualifiedNames(code, cursor); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
924 |
List<Fix> fixes = new ArrayList<>(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
925 |
for (String fqn : res.getNames()) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
926 |
fixes.add(new Fix() { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
927 |
@Override |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
928 |
public String displayName() { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
929 |
return "import: " + fqn; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
930 |
} |
41996
389212e0746c
8166333: jshell tool: shortcut var does not import its type
rfield
parents:
41934
diff
changeset
|
931 |
|
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
932 |
@Override |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
933 |
public void perform(ConsoleReader in) throws IOException { |
44188
3f2047e62102
8176412: jshell tool: automatic imports are excluded on /reload causing it to fail
rfield
parents:
43773
diff
changeset
|
934 |
repl.processCompleteSource("import " + fqn + ";"); |
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
935 |
in.println("Imported: " + fqn); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
936 |
in.redrawLine(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
937 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
938 |
}); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
939 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
940 |
if (res.isResolvable()) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
941 |
return new FixResult(Collections.emptyList(), |
36990 | 942 |
repl.messageFormat("jshell.console.resolvable")); |
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
943 |
} else { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
944 |
String error = ""; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
945 |
if (fixes.isEmpty()) { |
36990 | 946 |
error = repl.messageFormat("jshell.console.no.candidate"); |
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
947 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
948 |
if (!res.isUpToDate()) { |
36990 | 949 |
error += repl.messageFormat("jshell.console.incomplete"); |
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
950 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
951 |
return new FixResult(fixes, error); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
952 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
953 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
954 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
955 |
}; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
956 |
|
43583
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
957 |
private static final class JShellUnixTerminal extends NoInterruptUnixTerminal implements SuspendableTerminal { |
33362 | 958 |
|
959 |
private final StopDetectingInputStream input; |
|
960 |
||
961 |
public JShellUnixTerminal(StopDetectingInputStream input) throws Exception { |
|
962 |
this.input = input; |
|
963 |
} |
|
964 |
||
965 |
public boolean isRaw() { |
|
966 |
try { |
|
967 |
return getSettings().get("-a").contains("-icanon"); |
|
968 |
} catch (IOException | InterruptedException ex) { |
|
969 |
return false; |
|
970 |
} |
|
971 |
} |
|
972 |
||
973 |
@Override |
|
974 |
public InputStream wrapInIfNeeded(InputStream in) throws IOException { |
|
975 |
return input.setInputStream(super.wrapInIfNeeded(in)); |
|
976 |
} |
|
977 |
||
978 |
@Override |
|
979 |
public void disableInterruptCharacter() { |
|
980 |
} |
|
981 |
||
982 |
@Override |
|
983 |
public void enableInterruptCharacter() { |
|
984 |
} |
|
985 |
||
43583
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
986 |
@Override |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
987 |
public void suspend() { |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
988 |
try { |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
989 |
getSettings().restore(); |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
990 |
super.disableInterruptCharacter(); |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
991 |
} catch (Exception ex) { |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
992 |
throw new IllegalStateException(ex); |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
993 |
} |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
994 |
} |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
995 |
|
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
996 |
@Override |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
997 |
public void resume() { |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
998 |
try { |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
999 |
init(); |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1000 |
} catch (Exception ex) { |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1001 |
throw new IllegalStateException(ex); |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1002 |
} |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1003 |
} |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1004 |
|
33362 | 1005 |
} |
1006 |
||
43583
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1007 |
private static final class JShellWindowsTerminal extends WindowsTerminal implements SuspendableTerminal { |
33362 | 1008 |
|
1009 |
private final StopDetectingInputStream input; |
|
1010 |
||
1011 |
public JShellWindowsTerminal(StopDetectingInputStream input) throws Exception { |
|
1012 |
this.input = input; |
|
1013 |
} |
|
1014 |
||
1015 |
@Override |
|
1016 |
public void init() throws Exception { |
|
1017 |
super.init(); |
|
1018 |
setAnsiSupported(false); |
|
1019 |
} |
|
1020 |
||
1021 |
@Override |
|
1022 |
public InputStream wrapInIfNeeded(InputStream in) throws IOException { |
|
1023 |
return input.setInputStream(super.wrapInIfNeeded(in)); |
|
1024 |
} |
|
1025 |
||
43583
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1026 |
@Override |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1027 |
public void suspend() { |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1028 |
try { |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1029 |
restore(); |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1030 |
setConsoleMode(getConsoleMode() & ~ConsoleMode.ENABLE_PROCESSED_INPUT.code); |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1031 |
} catch (Exception ex) { |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1032 |
throw new IllegalStateException(ex); |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1033 |
} |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1034 |
} |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1035 |
|
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1036 |
@Override |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1037 |
public void resume() { |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1038 |
try { |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1039 |
restore(); |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1040 |
init(); |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1041 |
} catch (Exception ex) { |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1042 |
throw new IllegalStateException(ex); |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1043 |
} |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1044 |
} |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1045 |
|
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1046 |
@Override |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1047 |
public boolean isRaw() { |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1048 |
return (getConsoleMode() & ConsoleMode.ENABLE_LINE_INPUT.code) == 0; |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1049 |
} |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1050 |
|
33362 | 1051 |
} |
36715
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
1052 |
|
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
1053 |
private static final class TestTerminal extends TerminalSupport { |
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
1054 |
|
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
1055 |
private final StopDetectingInputStream input; |
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
1056 |
|
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
1057 |
public TestTerminal(StopDetectingInputStream input) throws Exception { |
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
1058 |
super(true); |
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
1059 |
setAnsiSupported(false); |
44459 | 1060 |
setEchoEnabled(false); |
36715
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
1061 |
this.input = input; |
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
1062 |
} |
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
1063 |
|
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
1064 |
@Override |
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
1065 |
public InputStream wrapInIfNeeded(InputStream in) throws IOException { |
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
1066 |
return input.setInputStream(super.wrapInIfNeeded(in)); |
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
1067 |
} |
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
1068 |
|
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
1069 |
} |
43363
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1070 |
|
43583
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1071 |
private interface SuspendableTerminal { |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1072 |
public void suspend(); |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1073 |
public void resume(); |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1074 |
public boolean isRaw(); |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1075 |
} |
d16e490ec827
8173653: jshell tool: ctrl-C when in external editor aborts jshell -- history lost
jlahoda
parents:
43363
diff
changeset
|
1076 |
|
43363
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1077 |
private static final class CheckCompletionKeyMap extends KeyMap { |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1078 |
|
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1079 |
private final KeyMap del; |
44459 | 1080 |
private final List<CompletionTask> completionTODO; |
43363
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1081 |
|
44459 | 1082 |
public CheckCompletionKeyMap(KeyMap del, List<CompletionTask> completionTODO) { |
43363
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1083 |
super(del.getName(), del.isViKeyMap()); |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1084 |
this.del = del; |
44459 | 1085 |
this.completionTODO = completionTODO; |
43363
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1086 |
} |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1087 |
|
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1088 |
@Override |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1089 |
public void bind(CharSequence keySeq, Object function) { |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1090 |
del.bind(keySeq, function); |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1091 |
} |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1092 |
|
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1093 |
@Override |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1094 |
public void bindIfNotBound(CharSequence keySeq, Object function) { |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1095 |
del.bindIfNotBound(keySeq, function); |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1096 |
} |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1097 |
|
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1098 |
@Override |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1099 |
public void from(KeyMap other) { |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1100 |
del.from(other); |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1101 |
} |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1102 |
|
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1103 |
@Override |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1104 |
public Object getAnotherKey() { |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1105 |
return del.getAnotherKey(); |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1106 |
} |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1107 |
|
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1108 |
@Override |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1109 |
public Object getBound(CharSequence keySeq) { |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1110 |
Object res = del.getBound(keySeq); |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1111 |
|
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1112 |
if (res != Operation.COMPLETE) { |
44459 | 1113 |
completionTODO.clear(); |
43363
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1114 |
} |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1115 |
|
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1116 |
return res; |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1117 |
} |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1118 |
|
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1119 |
@Override |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1120 |
public void setBlinkMatchingParen(boolean on) { |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1121 |
del.setBlinkMatchingParen(on); |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1122 |
} |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1123 |
|
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1124 |
@Override |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1125 |
public String toString() { |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1126 |
return "check: " + del.toString(); |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1127 |
} |
a4ed2006a4c5
8153759: jshell tool: Smart completion detection is not reliable
jlahoda
parents:
42843
diff
changeset
|
1128 |
} |
44459 | 1129 |
} |