author | rfield |
Mon, 04 Apr 2016 10:31:20 -0700 | |
changeset 36990 | ec0b843a7af5 |
parent 36715 | ae6fa9280e0b |
child 38521 | f2fe39ab9256 |
permissions | -rw-r--r-- |
33362 | 1 |
/* |
2 |
* Copyright (c) 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.internal.jshell.tool; |
|
27 |
||
28 |
import jdk.jshell.SourceCodeAnalysis.CompletionInfo; |
|
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.awt.event.ActionListener; |
|
33 |
import java.io.IOException; |
|
34 |
import java.io.InputStream; |
|
35 |
import java.io.PrintStream; |
|
36 |
import java.io.UncheckedIOException; |
|
37 |
import java.lang.reflect.Method; |
|
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
38 |
import java.util.ArrayList; |
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; |
33362 | 41 |
import java.util.List; |
42 |
import java.util.Locale; |
|
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
43 |
import java.util.Map; |
33362 | 44 |
import java.util.Objects; |
45 |
import java.util.Optional; |
|
46 |
import java.util.function.Supplier; |
|
47 |
||
48 |
import jdk.internal.jline.NoInterruptUnixTerminal; |
|
49 |
import jdk.internal.jline.Terminal; |
|
50 |
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
|
51 |
import jdk.internal.jline.TerminalSupport; |
33362 | 52 |
import jdk.internal.jline.WindowsTerminal; |
53 |
import jdk.internal.jline.console.ConsoleReader; |
|
54 |
import jdk.internal.jline.console.KeyMap; |
|
55 |
import jdk.internal.jline.console.UserInterruptException; |
|
56 |
import jdk.internal.jline.console.completer.Completer; |
|
57 |
import jdk.internal.jshell.tool.StopDetectingInputStream.State; |
|
58 |
||
59 |
class ConsoleIOContext extends IOContext { |
|
60 |
||
61 |
final JShellTool repl; |
|
62 |
final StopDetectingInputStream input; |
|
63 |
final ConsoleReader in; |
|
64 |
final EditingHistory history; |
|
65 |
||
66 |
String prefix = ""; |
|
67 |
||
68 |
ConsoleIOContext(JShellTool repl, InputStream cmdin, PrintStream cmdout) throws Exception { |
|
69 |
this.repl = repl; |
|
70 |
this.input = new StopDetectingInputStream(() -> repl.state.stop(), ex -> repl.hard("Error on input: %s", ex)); |
|
71 |
Terminal term; |
|
36501 | 72 |
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
|
73 |
term = new TestTerminal(input); |
36501 | 74 |
} else if (System.getProperty("os.name").toLowerCase(Locale.US).contains(TerminalFactory.WINDOWS)) { |
33362 | 75 |
term = new JShellWindowsTerminal(input); |
76 |
} else { |
|
77 |
term = new JShellUnixTerminal(input); |
|
78 |
} |
|
79 |
term.init(); |
|
80 |
in = new ConsoleReader(cmdin, cmdout, term); |
|
81 |
in.setExpandEvents(false); |
|
82 |
in.setHandleUserInterrupt(true); |
|
36715
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
83 |
in.setHistory(history = new EditingHistory(repl.prefs) { |
33362 | 84 |
@Override protected CompletionInfo analyzeCompletion(String input) { |
85 |
return repl.analysis.analyzeCompletion(input); |
|
86 |
} |
|
87 |
}); |
|
88 |
in.setBellEnabled(true); |
|
89 |
in.addCompleter(new Completer() { |
|
90 |
private String lastTest; |
|
91 |
private int lastCursor; |
|
92 |
private boolean allowSmart = false; |
|
93 |
@Override public int complete(String test, int cursor, List<CharSequence> result) { |
|
94 |
int[] anchor = new int[] {-1}; |
|
95 |
List<Suggestion> suggestions; |
|
96 |
if (prefix.isEmpty() && test.trim().startsWith("/")) { |
|
97 |
suggestions = repl.commandCompletionSuggestions(test, cursor, anchor); |
|
98 |
} else { |
|
99 |
int prefixLength = prefix.length(); |
|
100 |
suggestions = repl.analysis.completionSuggestions(prefix + test, cursor + prefixLength, anchor); |
|
101 |
anchor[0] -= prefixLength; |
|
102 |
} |
|
103 |
if (!Objects.equals(lastTest, test) || lastCursor != cursor) |
|
104 |
allowSmart = true; |
|
105 |
||
106 |
boolean smart = allowSmart && |
|
107 |
suggestions.stream() |
|
108 |
.anyMatch(s -> s.isSmart); |
|
109 |
||
110 |
lastTest = test; |
|
111 |
lastCursor = cursor; |
|
112 |
allowSmart = !allowSmart; |
|
113 |
||
114 |
suggestions.stream() |
|
115 |
.filter(s -> !smart || s.isSmart) |
|
116 |
.map(s -> s.continuation) |
|
117 |
.forEach(result::add); |
|
118 |
||
119 |
boolean onlySmart = suggestions.stream() |
|
120 |
.allMatch(s -> s.isSmart); |
|
121 |
||
122 |
if (smart && !onlySmart) { |
|
123 |
Optional<String> prefix = |
|
124 |
suggestions.stream() |
|
125 |
.map(s -> s.continuation) |
|
126 |
.reduce(ConsoleIOContext::commonPrefix); |
|
127 |
||
128 |
String prefixStr = prefix.orElse("").substring(cursor - anchor[0]); |
|
129 |
try { |
|
130 |
in.putString(prefixStr); |
|
131 |
cursor += prefixStr.length(); |
|
132 |
} catch (IOException ex) { |
|
133 |
throw new IllegalStateException(ex); |
|
134 |
} |
|
36990 | 135 |
result.add(repl.messageFormat("jshell.console.see.more")); |
33362 | 136 |
return cursor; //anchor should not be used. |
137 |
} |
|
138 |
||
139 |
if (result.isEmpty()) { |
|
140 |
try { |
|
141 |
//provide "empty completion" feedback |
|
142 |
//XXX: this only works correctly when there is only one Completer: |
|
143 |
in.beep(); |
|
144 |
} catch (IOException ex) { |
|
145 |
throw new UncheckedIOException(ex); |
|
146 |
} |
|
147 |
} |
|
148 |
||
149 |
return anchor[0]; |
|
150 |
} |
|
151 |
}); |
|
152 |
bind(DOCUMENTATION_SHORTCUT, (ActionListener) evt -> documentation(repl)); |
|
153 |
bind(CTRL_UP, (ActionListener) evt -> moveHistoryToSnippet(((EditingHistory) in.getHistory())::previousSnippet)); |
|
154 |
bind(CTRL_DOWN, (ActionListener) evt -> moveHistoryToSnippet(((EditingHistory) in.getHistory())::nextSnippet)); |
|
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
155 |
for (FixComputer computer : FIX_COMPUTERS) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
156 |
for (String shortcuts : SHORTCUT_FIXES) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
157 |
bind(shortcuts + computer.shortcut, (ActionListener) evt -> fixes(computer)); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
158 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
159 |
} |
33362 | 160 |
} |
161 |
||
162 |
@Override |
|
163 |
public String readLine(String prompt, String prefix) throws IOException, InputInterruptedException { |
|
164 |
this.prefix = prefix; |
|
165 |
try { |
|
166 |
return in.readLine(prompt); |
|
167 |
} catch (UserInterruptException ex) { |
|
168 |
throw (InputInterruptedException) new InputInterruptedException().initCause(ex); |
|
169 |
} |
|
170 |
} |
|
171 |
||
172 |
@Override |
|
173 |
public boolean interactiveOutput() { |
|
174 |
return true; |
|
175 |
} |
|
176 |
||
177 |
@Override |
|
178 |
public Iterable<String> currentSessionHistory() { |
|
179 |
return history.currentSessionEntries(); |
|
180 |
} |
|
181 |
||
182 |
@Override |
|
183 |
public void close() throws IOException { |
|
184 |
history.save(); |
|
185 |
in.shutdown(); |
|
186 |
try { |
|
187 |
in.getTerminal().restore(); |
|
188 |
} catch (Exception ex) { |
|
189 |
throw new IOException(ex); |
|
190 |
} |
|
191 |
} |
|
192 |
||
193 |
private void moveHistoryToSnippet(Supplier<Boolean> action) { |
|
194 |
if (!action.get()) { |
|
195 |
try { |
|
196 |
in.beep(); |
|
197 |
} catch (IOException ex) { |
|
198 |
throw new IllegalStateException(ex); |
|
199 |
} |
|
200 |
} else { |
|
201 |
try { |
|
202 |
//could use: |
|
203 |
//in.resetPromptLine(in.getPrompt(), in.getHistory().current().toString(), -1); |
|
204 |
//but that would mean more re-writing on the screen, (and prints an additional |
|
205 |
//empty line), so using setBuffer directly: |
|
206 |
Method setBuffer = in.getClass().getDeclaredMethod("setBuffer", String.class); |
|
207 |
||
208 |
setBuffer.setAccessible(true); |
|
209 |
setBuffer.invoke(in, in.getHistory().current().toString()); |
|
210 |
in.flush(); |
|
211 |
} catch (ReflectiveOperationException | IOException ex) { |
|
212 |
throw new IllegalStateException(ex); |
|
213 |
} |
|
214 |
} |
|
215 |
} |
|
216 |
||
217 |
private void bind(String shortcut, Object action) { |
|
218 |
KeyMap km = in.getKeys(); |
|
219 |
for (int i = 0; i < shortcut.length(); i++) { |
|
220 |
Object value = km.getBound(Character.toString(shortcut.charAt(i))); |
|
221 |
if (value instanceof KeyMap) { |
|
222 |
km = (KeyMap) value; |
|
223 |
} else { |
|
224 |
km.bind(shortcut.substring(i), action); |
|
225 |
} |
|
226 |
} |
|
227 |
} |
|
228 |
||
229 |
private static final String DOCUMENTATION_SHORTCUT = "\033\133\132"; //Shift-TAB |
|
230 |
private static final String CTRL_UP = "\033\133\061\073\065\101"; //Ctrl-UP |
|
231 |
private static final String CTRL_DOWN = "\033\133\061\073\065\102"; //Ctrl-DOWN |
|
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
232 |
private static final String[] SHORTCUT_FIXES = { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
233 |
"\033\015", //Alt-Enter (Linux) |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
234 |
"\033\133\061\067\176", //F6/Alt-F1 (Mac) |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
235 |
"\u001BO3P" //Alt-F1 (Linux) |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
236 |
}; |
33362 | 237 |
|
238 |
private void documentation(JShellTool repl) { |
|
239 |
String buffer = in.getCursorBuffer().buffer.toString(); |
|
240 |
int cursor = in.getCursorBuffer().cursor; |
|
241 |
String doc; |
|
242 |
if (prefix.isEmpty() && buffer.trim().startsWith("/")) { |
|
243 |
doc = repl.commandDocumentation(buffer, cursor); |
|
244 |
} else { |
|
245 |
doc = repl.analysis.documentation(prefix + buffer, cursor + prefix.length()); |
|
246 |
} |
|
247 |
||
248 |
try { |
|
249 |
if (doc != null) { |
|
250 |
in.println(); |
|
251 |
in.println(doc); |
|
252 |
in.redrawLine(); |
|
253 |
in.flush(); |
|
254 |
} else { |
|
255 |
in.beep(); |
|
256 |
} |
|
257 |
} catch (IOException ex) { |
|
258 |
throw new IllegalStateException(ex); |
|
259 |
} |
|
260 |
} |
|
261 |
||
262 |
private static String commonPrefix(String str1, String str2) { |
|
263 |
for (int i = 0; i < str2.length(); i++) { |
|
264 |
if (!str1.startsWith(str2.substring(0, i + 1))) { |
|
265 |
return str2.substring(0, i); |
|
266 |
} |
|
267 |
} |
|
268 |
||
269 |
return str2; |
|
270 |
} |
|
271 |
||
272 |
@Override |
|
273 |
public boolean terminalEditorRunning() { |
|
274 |
Terminal terminal = in.getTerminal(); |
|
275 |
if (terminal instanceof JShellUnixTerminal) |
|
276 |
return ((JShellUnixTerminal) terminal).isRaw(); |
|
277 |
return false; |
|
278 |
} |
|
279 |
||
280 |
@Override |
|
281 |
public void suspend() { |
|
282 |
try { |
|
283 |
in.getTerminal().restore(); |
|
284 |
} catch (Exception ex) { |
|
285 |
throw new IllegalStateException(ex); |
|
286 |
} |
|
287 |
} |
|
288 |
||
289 |
@Override |
|
290 |
public void resume() { |
|
291 |
try { |
|
292 |
in.getTerminal().init(); |
|
293 |
} catch (Exception ex) { |
|
294 |
throw new IllegalStateException(ex); |
|
295 |
} |
|
296 |
} |
|
297 |
||
298 |
public void beforeUserCode() { |
|
299 |
input.setState(State.BUFFER); |
|
300 |
} |
|
301 |
||
302 |
public void afterUserCode() { |
|
303 |
input.setState(State.WAIT); |
|
304 |
} |
|
305 |
||
306 |
@Override |
|
307 |
public void replaceLastHistoryEntry(String source) { |
|
308 |
history.fullHistoryReplace(source); |
|
309 |
} |
|
310 |
||
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
311 |
//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
|
312 |
//and perform the selected one: |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
313 |
private void fixes(FixComputer computer) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
314 |
String input = prefix + in.getCursorBuffer().toString(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
315 |
int cursor = prefix.length() + in.getCursorBuffer().cursor; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
316 |
FixResult candidates = computer.compute(repl, input, cursor); |
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 |
try { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
319 |
final boolean printError = candidates.error != null && !candidates.error.isEmpty(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
320 |
if (printError) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
321 |
in.println(candidates.error); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
322 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
323 |
if (candidates.fixes.isEmpty()) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
324 |
in.beep(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
325 |
if (printError) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
326 |
in.redrawLine(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
327 |
in.flush(); |
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 |
} else if (candidates.fixes.size() == 1 && !computer.showMenu) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
330 |
if (printError) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
331 |
in.redrawLine(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
332 |
in.flush(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
333 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
334 |
candidates.fixes.get(0).perform(in); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
335 |
} else { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
336 |
List<Fix> fixes = new ArrayList<>(candidates.fixes); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
337 |
fixes.add(0, new Fix() { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
338 |
@Override |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
339 |
public String displayName() { |
36990 | 340 |
return repl.messageFormat("jshell.console.do.nothing"); |
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
341 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
342 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
343 |
@Override |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
344 |
public void perform(ConsoleReader in) throws IOException { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
345 |
in.redrawLine(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
346 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
347 |
}); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
348 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
349 |
Map<Character, Fix> char2Fix = new HashMap<>(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
350 |
in.println(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
351 |
for (int i = 0; i < fixes.size(); i++) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
352 |
Fix fix = fixes.get(i); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
353 |
char2Fix.put((char) ('0' + i), fix); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
354 |
in.println("" + i + ": " + fixes.get(i).displayName()); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
355 |
} |
36990 | 356 |
in.print(repl.messageFormat("jshell.console.choice")); |
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
357 |
in.flush(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
358 |
int read; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
359 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
360 |
read = in.readCharacter(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
361 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
362 |
Fix fix = char2Fix.get((char) read); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
363 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
364 |
if (fix == null) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
365 |
in.beep(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
366 |
fix = fixes.get(0); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
367 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
368 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
369 |
in.println(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
370 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
371 |
fix.perform(in); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
372 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
373 |
in.flush(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
374 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
375 |
} catch (IOException ex) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
376 |
ex.printStackTrace(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
377 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
378 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
379 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
380 |
/** |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
381 |
* 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
|
382 |
*/ |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
383 |
public interface Fix { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
384 |
/** |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
385 |
* A name that should be shown to the user. |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
386 |
*/ |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
387 |
public String displayName(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
388 |
/** |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
389 |
* Perform the given action. |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
390 |
*/ |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
391 |
public void perform(ConsoleReader in) throws IOException; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
392 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
393 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
394 |
/** |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
395 |
* A factory for {@link Fix}es. |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
396 |
*/ |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
397 |
public abstract static class FixComputer { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
398 |
private final char shortcut; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
399 |
private final boolean showMenu; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
400 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
401 |
/** |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
402 |
* 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
|
403 |
* 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
|
404 |
* 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
|
405 |
*/ |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
406 |
public FixComputer(char shortcut, boolean showMenu) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
407 |
this.shortcut = shortcut; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
408 |
this.showMenu = showMenu; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
409 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
410 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
411 |
/** |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
412 |
* Compute possible actions for the given code. |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
413 |
*/ |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
414 |
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
|
415 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
416 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
417 |
/** |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
418 |
* 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
|
419 |
*/ |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
420 |
public static class FixResult { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
421 |
public final List<Fix> fixes; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
422 |
public final String error; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
423 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
424 |
public FixResult(List<Fix> fixes, String error) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
425 |
this.fixes = fixes; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
426 |
this.error = error; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
427 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
428 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
429 |
|
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
430 |
private static final FixComputer[] FIX_COMPUTERS = new FixComputer[] { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
431 |
new FixComputer('v', false) { //compute "Introduce variable" Fix: |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
432 |
@Override |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
433 |
public FixResult compute(JShellTool repl, String code, int cursor) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
434 |
String type = repl.analysis.analyzeType(code, cursor); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
435 |
if (type == null) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
436 |
return new FixResult(Collections.emptyList(), null); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
437 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
438 |
return new FixResult(Collections.singletonList(new Fix() { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
439 |
@Override |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
440 |
public String displayName() { |
36990 | 441 |
return repl.messageFormat("jshell.console.create.variable"); |
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
442 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
443 |
@Override |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
444 |
public void perform(ConsoleReader in) throws IOException { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
445 |
in.redrawLine(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
446 |
in.setCursorPosition(0); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
447 |
in.putString(type + " = "); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
448 |
in.setCursorPosition(in.getCursorBuffer().cursor - 3); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
449 |
in.flush(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
450 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
451 |
}), null); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
452 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
453 |
}, |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
454 |
new FixComputer('i', true) { //compute "Add import" Fixes: |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
455 |
@Override |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
456 |
public FixResult compute(JShellTool repl, String code, int cursor) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
457 |
QualifiedNames res = repl.analysis.listQualifiedNames(code, cursor); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
458 |
List<Fix> fixes = new ArrayList<>(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
459 |
for (String fqn : res.getNames()) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
460 |
fixes.add(new Fix() { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
461 |
@Override |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
462 |
public String displayName() { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
463 |
return "import: " + fqn; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
464 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
465 |
@Override |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
466 |
public void perform(ConsoleReader in) throws IOException { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
467 |
repl.state.eval("import " + fqn + ";"); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
468 |
in.println("Imported: " + fqn); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
469 |
in.redrawLine(); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
470 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
471 |
}); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
472 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
473 |
if (res.isResolvable()) { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
474 |
return new FixResult(Collections.emptyList(), |
36990 | 475 |
repl.messageFormat("jshell.console.resolvable")); |
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
476 |
} else { |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
477 |
String error = ""; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
478 |
if (fixes.isEmpty()) { |
36990 | 479 |
error = repl.messageFormat("jshell.console.no.candidate"); |
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
480 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
481 |
if (!res.isUpToDate()) { |
36990 | 482 |
error += repl.messageFormat("jshell.console.incomplete"); |
36160
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
483 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
484 |
return new FixResult(fixes, error); |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
485 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
486 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
487 |
} |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
488 |
}; |
f42d362d0d17
8131027: JShell API/tool: suggest imports for a class
jlahoda
parents:
33362
diff
changeset
|
489 |
|
33362 | 490 |
private static final class JShellUnixTerminal extends NoInterruptUnixTerminal { |
491 |
||
492 |
private final StopDetectingInputStream input; |
|
493 |
||
494 |
public JShellUnixTerminal(StopDetectingInputStream input) throws Exception { |
|
495 |
this.input = input; |
|
496 |
} |
|
497 |
||
498 |
public boolean isRaw() { |
|
499 |
try { |
|
500 |
return getSettings().get("-a").contains("-icanon"); |
|
501 |
} catch (IOException | InterruptedException ex) { |
|
502 |
return false; |
|
503 |
} |
|
504 |
} |
|
505 |
||
506 |
@Override |
|
507 |
public InputStream wrapInIfNeeded(InputStream in) throws IOException { |
|
508 |
return input.setInputStream(super.wrapInIfNeeded(in)); |
|
509 |
} |
|
510 |
||
511 |
@Override |
|
512 |
public void disableInterruptCharacter() { |
|
513 |
} |
|
514 |
||
515 |
@Override |
|
516 |
public void enableInterruptCharacter() { |
|
517 |
} |
|
518 |
||
519 |
} |
|
520 |
||
521 |
private static final class JShellWindowsTerminal extends WindowsTerminal { |
|
522 |
||
523 |
private final StopDetectingInputStream input; |
|
524 |
||
525 |
public JShellWindowsTerminal(StopDetectingInputStream input) throws Exception { |
|
526 |
this.input = input; |
|
527 |
} |
|
528 |
||
529 |
@Override |
|
530 |
public void init() throws Exception { |
|
531 |
super.init(); |
|
532 |
setAnsiSupported(false); |
|
533 |
} |
|
534 |
||
535 |
@Override |
|
536 |
public InputStream wrapInIfNeeded(InputStream in) throws IOException { |
|
537 |
return input.setInputStream(super.wrapInIfNeeded(in)); |
|
538 |
} |
|
539 |
||
540 |
} |
|
36715
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
541 |
|
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
542 |
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
|
543 |
|
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
544 |
private final StopDetectingInputStream input; |
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
545 |
|
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
546 |
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
|
547 |
super(true); |
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
548 |
setAnsiSupported(false); |
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
549 |
setEchoEnabled(true); |
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
550 |
this.input = input; |
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
551 |
} |
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
552 |
|
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
553 |
@Override |
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
554 |
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
|
555 |
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
|
556 |
} |
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
557 |
|
ae6fa9280e0b
8152296: langtools/test/jdk/jshell/ToolReloadTest.java failing if there is not persisted history
jlahoda
parents:
36501
diff
changeset
|
558 |
} |
33362 | 559 |
} |