8147515: JShell: Internationalize

Reviewed-by: jlahoda
This commit is contained in:
Robert Field 2016-04-04 10:31:20 -07:00
parent 871832c718
commit a80f850898
13 changed files with 998 additions and 516 deletions

View File

@ -132,7 +132,7 @@ class ConsoleIOContext extends IOContext {
} catch (IOException ex) {
throw new IllegalStateException(ex);
}
result.add("<press tab to see more>");
result.add(repl.messageFormat("jshell.console.see.more"));
return cursor; //anchor should not be used.
}
@ -337,7 +337,7 @@ class ConsoleIOContext extends IOContext {
fixes.add(0, new Fix() {
@Override
public String displayName() {
return "Do nothing";
return repl.messageFormat("jshell.console.do.nothing");
}
@Override
@ -353,7 +353,7 @@ class ConsoleIOContext extends IOContext {
char2Fix.put((char) ('0' + i), fix);
in.println("" + i + ": " + fixes.get(i).displayName());
}
in.print("Choice: ");
in.print(repl.messageFormat("jshell.console.choice"));
in.flush();
int read;
@ -438,7 +438,7 @@ class ConsoleIOContext extends IOContext {
return new FixResult(Collections.singletonList(new Fix() {
@Override
public String displayName() {
return "Create variable";
return repl.messageFormat("jshell.console.create.variable");
}
@Override
public void perform(ConsoleReader in) throws IOException {
@ -472,14 +472,14 @@ class ConsoleIOContext extends IOContext {
}
if (res.isResolvable()) {
return new FixResult(Collections.emptyList(),
"\nThe identifier is resolvable in this context.");
repl.messageFormat("jshell.console.resolvable"));
} else {
String error = "";
if (fixes.isEmpty()) {
error = "\nNo candidate fully qualified names found to import.";
error = repl.messageFormat("jshell.console.no.candidate");
}
if (!res.isUpToDate()) {
error += "\nResults may be incomplete; try again later for complete results.";
error += repl.messageFormat("jshell.console.incomplete");
}
return new FixResult(fixes, error);
}

View File

@ -33,10 +33,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import static java.util.stream.Collectors.joining;
/**
@ -113,22 +111,6 @@ class Feedback {
return new Setter(tool, at).setPrompt();
}
public void printFeedbackHelp(JShellTool tool) {
new Setter(tool, null).printFeedbackHelp();
}
public void printFormatHelp(JShellTool tool) {
new Setter(tool, null).printFormatHelp();
}
public void printNewModeHelp(JShellTool tool) {
new Setter(tool, null).printNewModeHelp();
}
public void printPromptHelp(JShellTool tool) {
new Setter(tool, null).printPromptHelp();
}
{
for (FormatCase e : EnumSet.allOf(FormatCase.class))
selectorMap.put(e.name().toLowerCase(Locale.US), e);
@ -555,38 +537,18 @@ class Feedback {
this.at = at;
}
void hard(String format, Object... args) {
tool.hard(format, args);
}
void hardrb(String key) {
tool.hardrb(key);
}
<E extends Enum<E>> void hardEnums(EnumSet<E> es, Function<E, String> e2s) {
hardPairs(es.stream(), ev -> ev.name().toLowerCase(Locale.US), e2s);
}
<T> void hardPairs(Stream<T> stream, Function<T, String> a, Function<T, String> b) {
tool.hardPairs(stream, a, b);
}
void fluff(String format, Object... args) {
tool.fluff(format, args);
}
void error(String format, Object... args) {
tool.error(format, args);
void fluffmsg(String format, Object... args) {
tool.fluffmsg(format, args);
}
void errorat(String format, Object... args) {
Object[] a2 = Arrays.copyOf(args, args.length + 1);
a2[args.length] = at.whole();
tool.error(format + " -- /set %s", a2);
}
void fluffRaw(String format, Object... args) {
tool.fluffRaw(format, args);
void errorat(String messageKey, Object... args) {
Object[] a2 = Arrays.copyOf(args, args.length + 2);
a2[args.length] = "/set " + at.whole();
tool.errormsg(messageKey, a2);
}
// For /set prompt <mode> "<prompt>" "<continuation-prompt>"
@ -597,7 +559,7 @@ class Feedback {
if (valid) {
m.setPrompts(prompt, continuationPrompt);
} else {
fluff("See '/help /set prompt' for help");
fluffmsg("jshell.msg.see", "/help /set prompt");
}
return valid;
}
@ -606,17 +568,17 @@ class Feedback {
boolean setNewMode() {
String umode = at.next();
if (umode == null) {
errorat("Expected new feedback mode");
errorat("jshell.err.feedback.expected.new.feedback.mode");
valid = false;
}
if (modeMap.containsKey(umode)) {
errorat("Expected a new feedback mode name. %s is a known feedback mode", umode);
errorat("jshell.err.feedback.expected.mode.name", umode);
valid = false;
}
String[] fluffOpt = at.next("command", "quiet");
boolean fluff = fluffOpt == null || fluffOpt.length != 1 || "command".equals(fluffOpt[0]);
if (fluffOpt != null && fluffOpt.length != 1) {
errorat("Specify either 'command' or 'quiet'");
errorat("jshell.err.feedback.command.quiet");
valid = false;
}
Mode om = null;
@ -629,9 +591,9 @@ class Feedback {
? new Mode(umode, fluff, om)
: new Mode(umode, fluff);
modeMap.put(umode, nm);
fluff("Created new feedback mode: %s", nm.name);
fluffmsg("jshell.msg.feedback.new.mode", nm.name);
} else {
fluff("See '/help /set newmode' for help");
fluffmsg("jshell.msg.see", "/help /set newmode");
}
return valid;
}
@ -641,9 +603,9 @@ class Feedback {
Mode m = nextMode();
if (valid && m != null) {
mode = m;
fluff("Feedback mode: %s", mode.name);
fluffmsg("jshell.msg.feedback.mode", mode.name);
} else {
fluff("See '/help /set feedback' for help");
fluffmsg("jshell.msg.see", "/help /set feedback");
}
return valid;
}
@ -653,7 +615,7 @@ class Feedback {
Mode m = nextMode();
String field = at.next();
if (field == null || at.isQuoted()) {
errorat("Expected field name missing");
errorat("jshell.err.feedback.expected.field");
valid = false;
}
String format = valid? nextFormat() : null;
@ -675,7 +637,7 @@ class Feedback {
format));
}
} else {
fluff("See '/help /set format' for help");
fluffmsg("jshell.msg.see", "/help /set format");
}
return valid;
}
@ -687,7 +649,7 @@ class Feedback {
Mode toMode(String umode) {
if (umode == null) {
errorat("Expected a feedback mode");
errorat("jshell.err.feedback.expected.mode");
valid = false;
return null;
}
@ -705,11 +667,11 @@ class Feedback {
} else {
valid = false;
if (matches.length == 0) {
errorat("Does not match any current feedback mode: %s", umode);
errorat("jshell.err.feedback.does.not.match.mode", umode);
} else {
errorat("Matches more then one current feedback mode: %s", umode);
errorat("jshell.err.feedback.ambiguous.mode", umode);
}
fluff("The feedback mode should be one of the following:");
fluffmsg("jshell.msg.feedback.mode.following");
modeMap.keySet().stream()
.forEach(mk -> fluff(" %s", mk));
return null;
@ -720,12 +682,12 @@ class Feedback {
final String nextFormat() {
String format = at.next();
if (format == null) {
errorat("Expected format missing");
errorat("jshell.err.feedback.expected.format");
valid = false;
return null;
}
if (!at.isQuoted()) {
errorat("Format '%s' must be quoted", format);
errorat("jshell.err.feedback.must.be.quoted", format);
valid = false;
return null;
}
@ -748,19 +710,19 @@ class Feedback {
if (!as.isEmpty()) {
Selector<?> sel = selectorMap.get(as);
if (sel == null) {
errorat("Not a valid selector %s in %s", as, s);
errorat("jshell.err.feedback.not.a.valid.selector", as, s);
valid = false;
return;
}
SelectorCollector<?> collector = sel.collector(this);
if (lastCollector == null) {
if (!collector.isEmpty()) {
errorat("Selector kind in multiple sections of selector list %s in %s", as, s);
errorat("jshell.err.feedback.multiple.sections", as, s);
valid = false;
return;
}
} else if (collector != lastCollector) {
errorat("Different selector kinds in same sections of selector list %s in %s", as, s);
errorat("jshell.err.feedback.different.selector.kinds", as, s);
valid = false;
return;
}
@ -771,36 +733,5 @@ class Feedback {
}
}
}
final void printFormatHelp() {
hardrb("help.set.format");
hardrb("help.set.format.case");
hardEnums(EnumSet.allOf(FormatCase.class), ev -> ev.doc);
hardrb("help.set.format.action");
hardEnums(EnumSet.allOf(FormatAction.class), ev -> ev.doc);
hardrb("help.set.format.when");
hardEnums(EnumSet.allOf(FormatWhen.class), ev -> ev.doc);
hardrb("help.set.format.resolve");
hardEnums(EnumSet.allOf(FormatResolve.class), ev -> ev.doc);
hardrb("help.set.format.unresolved");
hardEnums(EnumSet.allOf(FormatUnresolved.class), ev -> ev.doc);
hardrb("help.set.format.errors");
hardEnums(EnumSet.allOf(FormatErrors.class), ev -> ev.doc);
hardrb("help.set.format.end");
}
final void printFeedbackHelp() {
hardrb("help.set.feedback");
modeMap.keySet().stream()
.forEach(m -> hard(" %s", m));
}
final void printNewModeHelp() {
hardrb("help.set.newmode");
}
final void printPromptHelp() {
hardrb("help.set.prompt");
}
}
}

View File

@ -23,9 +23,359 @@
# questions.
#
jshell.msg.welcome =\
Welcome to JShell -- Version {0}\n\
For an introduction type: /help intro\n
jshell.err.opt.classpath.conflict = Conflicting -classpath option.
jshell.err.opt.classpath.arg = Argument to -classpath missing.
jshell.err.opt.startup.conflict = Conflicting -startup or -nostartup option.
jshell.err.opt.unknown = Unknown option: {0}
jshell.msg.terminated =\
State engine terminated.\n\
Restore definitions with: /reload restore
jshell.msg.use.one.of = Use one of: {0}
jshell.err.def.or.id.not.found = No definition or id found named: {0}
jshell.msg.see.classes.etc = See /classes, /methods, /vars, or /list
jshell.err.arg = Invalid ''{0}'' argument: {1}
jshell.msg.see = See {0} for help.
jshell.err.file.not.accessible = File ''{1}'' for ''{0}'' is not accessible: {2}
jshell.err.file.not.found = File ''{1}'' for ''{0}'' is not found: {2}
jshell.err.file.exception = File ''{1}'' for ''{0}'' threw exception: {2}
jshell.err.file.filename = ''{0}'' requires a filename argument.
jshell.err.startup.unexpected.exception = Unexpected exception reading start-up: {0}
jshell.err.unexpected.exception = Unexpected exception: {0}
jshell.err.no.such.command.or.snippet.id = No such command or snippet id: {0}
jshell.err.command.ambiguous = Command: ''{0}'' is ambiguous: {1}
jshell.err.set.editor.arg = The ''/set editor'' command requires a path argument
jshell.msg.set.editor.set = Editor set to: {0}
jshell.msg.try.list.without.args = Try ''/list'' without arguments.
jshell.msg.no.active = There are no active definitions.
jshell.msg.resetting = Resetting...
jshell.msg.resetting.state = Resetting state.
jshell.err.reload.no.previous = No previous history to restore
jshell.err.reload.restarting.previous.state = Restarting and restoring from previous state.
jshell.err.reload.restarting.state = Restarting and restoring state.
jshell.msg.vars.not.active = (not-active)
jshell.err.out.of.range = Out of range
jshell.msg.error = Error:
jshell.msg.warning = Warning:
jshell.err.set.arg = The ''/set'' command requires a sub-command and arguments. See: ''/help /set''
jshell.err.set.ambiguous = Ambiguous sub-command argument to ''/set'': {0}
jshell.err.classpath.arg = The /classpath command requires a path argument.
jshell.msg.classpath = Path ''{0}'' added to classpath
jshell.err.help.arg = No commands or subjects start with the provided argument: {0}
jshell.msg.help.begin =\
Type a Java language expression, statement, or declaration.\n\
Or type one of the following commands:\n
jshell.msg.help.subject =\n\
For more information type ''/help'' followed by the name of command or a subject.\n\
For example ''/help /list'' or ''/help intro''. Subjects:\n
jshell.err.drop.arg =\
In the /drop argument, please specify an import, variable, method, or class to drop.\n\
Specify by id or name. Use /list to see ids. Use /reset to reset all state.
jshell.msg.drop.not.active = The argument did not specify an active import, variable, method, or class to drop.
jshell.err.drop.ambiguous = The argument references more than one import, variable, method, or class.
jshell.err.failed = Failed.
jshell.msg.native.method = Native Method
jshell.msg.unknown.source = Unknown Source
jshell.msg.goodbye = Goodbye
jshell.msg.help.for.help = Type /help for help.
jshell.err.feedback.expected.new.feedback.mode = Expected new feedback mode -- {0}
jshell.err.feedback.expected.mode.name = Expected a new feedback mode name. ''{0}'' is a known feedback mode -- {1}
jshell.err.feedback.command.quiet = Specify either ''command'' or ''quiet'' -- {0}
jshell.err.feedback.expected.field = Expected field name missing -- {0}
jshell.err.feedback.expected.mode = Expected a feedback mode -- {0}
jshell.err.feedback.does.not.match.mode = Does not match any current feedback mode: {0} -- {1}
jshell.err.feedback.ambiguous.mode = Matches more then one current feedback mode: {0} -- {1}
jshell.err.feedback.expected.format = Expected format missing -- {0}
jshell.err.feedback.must.be.quoted = Format ''{0}'' must be quoted -- {1}
jshell.err.feedback.not.a.valid.selector = Not a valid selector ''{0}'' in ''{1}'' -- {2}
jshell.err.feedback.multiple.sections = Selector kind in multiple sections of selector list ''{0}'' in ''{1}'' -- {2}
jshell.err.feedback.different.selector.kinds = Different selector kinds in same sections of selector list ''{0}'' in ''{1}'' -- {2}
jshell.msg.feedback.new.mode = Created new feedback mode: {0}
jshell.msg.feedback.mode = Feedback mode: {0}
jshell.msg.feedback.mode.following = The feedback mode should be one of the following:
jshell.console.see.more = <press tab to see more>
jshell.console.do.nothing = Do nothing
jshell.console.choice = Choice: \
jshell.console.create.variable = Create variable
jshell.console.resolvable = \nThe identifier is resolvable in this context.
jshell.console.no.candidate = \nNo candidate fully qualified names found to import.
jshell.console.incomplete = \nResults may be incomplete; try again later for complete results.
help.usage = \
Usage: jshell <options> <load files>\n\
where possible options include:\n\t\
-classpath <path> Specify where to find user class files\n\t\
-cp <path> Specify where to find user class files\n\t\
-startup <file> One run replacement for the start-up definitions\n\t\
-nostartup Do not run the start-up definitions\n\t\
-help Print a synopsis of standard options\n\t\
-version Version information\n
help.list.summary = list the source you have typed
help.list.args = [all|start|<name or id>]
help.list =\
Show the source of snippets, prefaced with the snippet id.\n\
\n\
/list\n\t\
List the currently active snippets of code that you typed or read with /open\n\n\
/list start\n\t\
List the automatically evaluated start-up snippets\n\n\
/list all\n\t\
List all snippets including failed, overwritten, dropped, and start-up\n\n\
/list <name>\n\t\
List snippets with the specified name (preference for active snippets)\n\n\
/list <id>\n\t\
List the snippet with the specified snippet id
help.edit.summary = edit a source entry referenced by name or id
help.edit.args = <name or id>
help.edit =\
Edit a snippet or snippets of source in an external editor.\n\
The editor to use is set with /set editor.\n\
If no editor has been set, a simple editor will be launched.\n\
\n\
/edit <name>\n\t\
Edit the snippet or snippets with the specified name (preference for active snippets)\n\n\
/edit <id>\n\t\
Edit the snippet with the specified snippet id\n\n\
/edit\n\t\
Edit the currently active snippets of code that you typed or read with /open
help.drop.summary = delete a source entry referenced by name or id
help.drop.args = <name or id>
help.drop =\
Drop a snippet -- making it inactive.\n\
\n\
/drop <name>\n\t\
Drop the snippet with the specified name\n\n\
/drop <id>\n\t\
Drop the snippet with the specified snippet id
help.save.summary = Save snippet source to a file.
help.save.args = [all|history|start] <file>
help.save =\
Save the specified snippets and/or commands to the specified file.\n\
\n\
/save <file>\n\t\
Save the source of current active snippets to the file.\n\n\
/save all <file>\n\t\
Save the source of all snippets to the file.\n\t\
Includes source including overwritten, failed, and start-up code.\n\n\
/save history <file>\n\t\
Save the sequential history of all commands and snippets entered since jshell was launched.\n\n\
/save start <file>\n\t\
Save the default start-up definitions to the file.
help.open.summary = open a file as source input
help.open.args = <file>
help.open =\
Open a file and read its contents as snippets and commands.\n\
\n\
/open <file>\n\t\
Read the specified file as jshell input.
help.vars.summary = list the declared variables and their values
help.vars.args =
help.vars =\
List the type, name, and value of the current active jshell variables.
help.methods.summary = list the declared methods and their signatures
help.methods.args =
help.methods =\
List the name, parameter types, and return type of the current active jshell methods.
help.classes.summary = list the declared classes
help.classes.args =
help.classes =\
List the current active jshell classes, interfaces, and enums.
help.imports.summary = list the imported items
help.imports.args =
help.imports =\
List the current active jshell imports.
help.exit.summary = exit jshell
help.exit.args =
help.exit =\
Leave the jshell tool. No work is saved.\n\
Save any work before using this command
help.reset.summary = reset jshell
help.reset.args =
help.reset =\
Reset the jshell tool code and execution state:\n\t\
* All entered code is lost.\n\t\
* Start-up code is re-executed.\n\t\
* The execution state is restarted.\n\t\
* The classpath is cleared.\n\
Tool settings are maintained, as set with: /set ...\n\
Save any work before using this command
help.reload.summary = reset and replay relevant history -- current or previous (restore)
help.reload.args = [restore] [quiet]
help.reload =\
Reset the jshell tool code and execution state then replay each\n\
jshell valid command and valid snippet in the order they were entered.\n\
\n\
/reload\n\t\
Reset and replay the valid history since jshell was entered, or\n\t\
a /reset, or /reload command was executed -- whichever is most\n\t\
recent.\n\n\
/reload restore\n\t\
Reset and replay the valid history between the previous and most\n\t\
recent time that jshell was entered, or a /reset, or /reload\n\t\
command was executed. This can thus be used to restore a previous\n\t\
jshell tool sesson.\n\n\
/reload [restore] quiet\n\t\
With the 'quiet' argument the replay is not shown. Errors will display.
help.classpath.summary = add a path to the classpath
help.classpath.args = <path>
help.classpath =\
Append a additional path to the classpath.
help.history.summary = history of what you have typed
help.history.args =
help.history =\
Display the history of snippet and command input since this jshell was launched.
help.debug.summary = toggle debugging of the jshell
help.debug.args = [0][r][g][f][c][d][e]
help.debug =\
Display debugging information for the jshell implementation.\n\
0: Debugging off\n\
r: Tool level debugging on\n\
g: General debugging on\n\
f: File manager debugging on\n\
c: Completion analysis debugging on\n\
d: Dependency debugging on\n\
e: Event debugging on
help.help.summary = get information about jshell
help.help.args = [<command>|<subject>]
help.help =\
Display information about jshell.\n\
/help\n\t\
List the jshell commands and help subjects.\n\n\
/help <command>\n\t\
Display information about the specified comand. The slash must be included.\n\t\
Only the first few letters of the command are needed -- if more than one\n\t\
each will be displayed. Example: /help /li\n\n\
/help <subject>\n\t\
Display information about the specified help subject. Example: /help intro
help.set.summary = set jshell configuration information
help.set.args = editor|start|feedback|newmode|prompt|format ...
help.set =\
Set jshell configuration information, including:\n\
the external editor to use, the start-up definitions to use, a new feedback mode,\n\
the command prompt, the feedback mode to use, or the format of output.\n\
\n\
/set editor <command> <optional-arg>...\n\t\
Specify the command to launch for the /edit command.\n\t\
The <command> is an operating system dependent string.\n\n\
/set start <file>\n\t\
The contents of the specified <file> become the default start-up snippets and commands.\n\n\
/set feedback <mode>\n\t\
Set the feedback mode describing displayed feedback for entered snippets and commands.\n\n\
/set newmode <new-mode> [command|quiet [<old-mode>]]\n\t\
Create a user-defined feedback mode, optionally copying from an existing mode.\n\n\
/set prompt <mode> "<prompt>" "<continuation-prompt>"\n\t\
Set the displayed prompts for a given feedback mode.\n\n\
/set format <mode> <field> "<format>" <selector>...\n\t\
Configure a feedback mode by setting the format of a field when the selector matchs.\n\n\
To get more information about one of these forms, use /help with the form specified.\n\
For example: /help /set format
help.quest.summary = get information about jshell
help.quest.args = [<command>|<subject>]
help.quest =\
Display information about jshell (abbreviation for /help).\n\
/?\n\t\
Display list of commands and help subjects.\n\
/? <command>\n\t\
Display information about the specified comand. The slash must be included.\n\t\
Only the first few letters of the command are needed -- if more than one\n\t\
match, each will be displayed. Example: /? /li\n\
/? <subject>\n\t\
Display information about the specified help subject. Example: /? intro
help.bang.summary = re-run last snippet
help.bang.args =
help.bang =\
Reevaluate the most recently entered snippet.
help.id.summary = re-run snippet by id
help.id.args =
help.id =\
Reevaluate the snippet specified by the id.
help.previous.summary = re-run n-th previous snippet
help.previous.args =
help.previous =\
Reevaluate the n-th most recently entered snippet.
help.intro.summary = an introduction to the jshell tool
help.intro =\
The jshell tool allows you to execute Java code, getting immediate results.\n\
You can enter a Java definition (variable, method, class, etc), like: int x = 8\n\
or a Java expression, like: x + x\n\
or a Java statement or import.\n\
These little chunks of Java code are called 'snippets'.\n\
\n\
There are also jshell commands that allow you to understand and\n\
control what you are doing, like: /list\n\
\n\
For a list of commands: /help
help.shortcuts.summary = a description of shortcuts
help.shortcuts =\
Supported shortcuts include:\n\
\n\
<tab>\n\t\t\
After entering the first few letters of a Java identifier,\n\t\t\
a jshell command, or, in some cases, a jshell command argument,\n\t\t\
press the <tab> key to complete the input.\n\t\t\
If there is more than one completion, show possible completions.\n\n\
Shift-<tab>\n\t\t\
After the name and open parenthesis of a method or constructor invocation,\n\t\t\
hold the <shift> key and press the <tab> to see a synopsis of all\n\t\t\
matching methods/constructors.\n\n\
<fix-shortcut> v\n\t\t\
After a complete expression, press "<fix-shortcut> v" to introduce a new variable\n\t\t\
whose type is based on the type of the expression.\n\t\t\
The "<fix-shortcut>" is either Alt-F1 or Alt-Enter, depending on the platform.\n\n\
<fix-shortcut> i\n\t\t\
After an unresolvable identifier, press "<fix-shortcut> i" and jshell will propose\n\t\t\
possible fully qualified names based on the content of the specified classpath.\n\t\t\
The "<fix-shortcut>" is either Alt-F1 or Alt-Enter, depending on the platform.
help.set.format = \
Set the format for reporting a snippet event.\n\
\n\
\n\t\
/set format <mode> <field> "<format>" <selector>...\n\
\n\
Where <mode> is the name of a previously defined feedback mode -- see '/help /set newmode'.\n\
@ -56,14 +406,42 @@ Where <selector> is the context in which the format is applied.\n\
The structure of selector is a hyphen separated list of selector kind lists.\n\
A selector kind list is a comma separated list of values of one selector kind.\n\
A selector matches if each selector kind list matches; A selector kind list\n\
matches if one of the values matches.\n
help.set.format.case = The case selector kind describes the kind of snippet. The values are:\n
help.set.format.action = The action selector kind describes what happened to the snippet. The values are:\n
help.set.format.when = The when-did-it-occur selector kind describes if this is a direct or indirect action. The values are:\n
help.set.format.resolve = The resolution-state selector kind describes the state of resolution/definition of the snippet. The values are:\n
help.set.format.unresolved = The unresolved-count selector kind describes the number of unresolved references. The values are:\n
help.set.format.errors = The errors-count selector kind describes the number of errors. The values are:\n
help.set.format.end = \n\
matches if one of the values matches.\n\n\
The case selector kind describes the kind of snippet. The values are:\n\t\
import -- import declaration\n\t\
class -- class declaration\n\t\
interface -- interface declaration\n\t\
enum -- enum declaration\n\t\
annotation -- annotation interface declaration\n\t\
method -- method declaration -- note: {type}==parameter-types\n\t\
vardecl -- variable declaration without init\n\t\
varinit -- variable declaration with init\n\t\
expression -- expression -- note: {name}==scratch-variable-name\n\t\
varvalue -- variable value expression\n\t\
assignment -- assign variable\n\t\
statement -- statement\n\
The action selector kind describes what happened to the snippet. The values are:\n\t\
added -- snippet has been added\n\t\
modified -- an existing snippet has been modified\n\t\
replaced -- an existing snippet has been replaced with a new snippet\n\t\
overwrote -- an existing snippet has been overwritten\n\t\
dropped -- snippet has been dropped\n\t\
used -- snippet was used when it cannot be\n\
The when-did-it-occur selector kind describes if this is a direct or indirect action. The values are:\n\t\
primary -- the entered snippet\n\t\
update -- an update to a dependent snippet\n\
The resolution-state selector kind describes the state of resolution/definition of the snippet. The values are:\n\t\
ok -- resolved correctly\n\t\
defined -- defined despite recoverably unresolved references\n\t\
notdefined -- not defined because of recoverably unresolved references\n\
The unresolved-count selector kind describes the number of unresolved references. The values are:\n\t\
unresolved0 -- no names are unresolved\n\t\
unresolved1 -- one name is unresolved\n\t\
unresolved2 -- two or more names are unresolved\n\
The errors-count selector kind describes the number of errors. The values are:\n\t\
error0 -- no errors\n\t\
error1 -- one error\n\t\
error2 -- two or more errors\n\n\
Examples:\n\t\
/set format myformat action 'Created' added-primary\n\t\
/set format myformat action 'Update replaced' replaced-update\n\t\
@ -73,7 +451,7 @@ Note that subsequent selectors for a field may overwrite some or all of previous
help.set.feedback = \
Set the feedback mode describing displayed feedback for entered snippets and commands.\n\
\n\
\n\t\
/set feedback <mode>\n\
\n\
Where <mode> is the name of a previously defined feedback mode.\n\
@ -83,7 +461,7 @@ Currently defined feedback modes:\n
help.set.newmode = \
Create a user-defined feedback mode, optionally copying from an existing mode.\n\
\n\
\n\t\
/set newmode <new-mode> [command|quiet [<old-mode>]]\n\
\n\
Where <new-mode> is the name of a mode you wish to create.\n\
@ -96,15 +474,32 @@ Use '/set feedback' to use the new mode.\n\
help.set.prompt = \
Set the prompts. Both the normal prompt and the continuation-prompt must be set.\n\
\n\
/set prompt <mode> \"<prompt>\" \"<continuation-propmt>\"\n\
\n\t\
/set prompt <mode> \"<prompt>\" \"<continuation-prompt>\"\n\
\n\
Where <mode> is the name of a previously defined feedback mode.\n\
Where <prompt> and <continuation-propmt> are quoted strings printed as input prompts;\n\
Where <prompt> and <continuation-prompt> are quoted strings printed as input prompts;\n\
Both may optionally contain '%s' which will be substituted with the next snippet id --\n\
note that what is entered may not be assigned that id, for example it may be an error or command.\n\
The continuation-prompt is used on the second and subsequent lines of a multi-line snippet.\n
help.set.editor =\
Specify the command to launch for the /edit command.\n\
\n\t\
/set editor <command> <optional-arg>...\n\
\n\
The <command> is an operating system dependent string.\n\
The <command> may include space-separated arguments (such as flags) -- <optional-arg>....\n\
When /edit is used, the temporary file to edit will be appended as the last argument.
help.set.start =\
Set the start-up configuration -- a sequence of snippets and commands read at start-up.\n\
\n\t\
/set start <file>\n\
\n\
The contents of the specified <file> become the default start-up snippets and commands --\n\
which are run when the jshell tool is started or reset.
startup.feedback = \
/set newmode normal command \n\
/set prompt normal '\\n-> ' '>> ' \n\

View File

@ -651,17 +651,19 @@ class Eval {
ModifierDiagnostic(List<Modifier> list, boolean fatal) {
this.fatal = fatal;
StringBuilder sb = new StringBuilder();
sb.append((list.size() > 1) ? "Modifiers " : "Modifier ");
for (Modifier mod : list) {
sb.append("'");
sb.append(mod.toString());
sb.append("' ");
}
sb.append("not permitted in top-level declarations");
if (!fatal) {
sb.append(", ignored");
}
this.message = sb.toString();
String key = (list.size() > 1)
? fatal
? "jshell.diag.modifier.plural.fatal"
: "jshell.diag.modifier.plural.ignore"
: fatal
? "jshell.diag.modifier.single.fatal"
: "jshell.diag.modifier.single.ignore";
this.message = state.messageFormat(key, sb.toString());
}
@Override

View File

@ -29,12 +29,14 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.text.MessageFormat;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.Objects;
import java.util.ResourceBundle;
import java.util.function.BiFunction;
import java.util.function.Consumer;
@ -42,7 +44,6 @@ import java.util.function.Supplier;
import jdk.internal.jshell.debug.InternalDebugControl;
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toList;
import static jdk.internal.jshell.debug.InternalDebugControl.DBG_EVNT;
import static jdk.jshell.Util.expunge;
import jdk.jshell.Snippet.Status;
@ -91,10 +92,11 @@ public class JShell implements AutoCloseable {
private final Map<Subscription, Consumer<SnippetEvent>> keyStatusListeners = new HashMap<>();
private boolean closed = false;
private ExecutionControl executionControl = null;
private SourceCodeAnalysisImpl sourceCodeAnalysis = null;
private static final String L10N_RB_NAME = "jdk.jshell.resources.l10n";
private static ResourceBundle outputRB = null;
JShell(Builder b) {
this.in = b.in;
@ -558,8 +560,8 @@ public class JShell implements AutoCloseable {
checkIfAlive();
checkValidSnippet(snippet);
if (snippet.status() != Status.VALID) {
throw new IllegalArgumentException("Snippet parameter of varValue() '" +
snippet + "' must be VALID, it is: " + snippet.status());
throw new IllegalArgumentException(
messageFormat("jshell.exc.var.not.valid", snippet, snippet.status()));
}
String value = executionControl().commandVarValue(maps.classFullName(snippet), snippet.name());
return expunge(value);
@ -680,7 +682,7 @@ public class JShell implements AutoCloseable {
*/
private void checkIfAlive() throws IllegalStateException {
if (closed) {
throw new IllegalStateException("JShell (" + this + ") has been closed.");
throw new IllegalStateException(messageFormat("jshell.exc.closed", this));
}
}
@ -693,13 +695,36 @@ public class JShell implements AutoCloseable {
*/
private Snippet checkValidSnippet(Snippet sn) {
if (sn == null) {
throw new NullPointerException("Snippet must not be null");
throw new NullPointerException(messageFormat("jshell.exc.null"));
} else {
if (sn.key().state() != this) {
throw new IllegalArgumentException("Snippet not from this JShell");
throw new IllegalArgumentException(messageFormat("jshell.exc.alien"));
}
return sn;
}
}
/**
* Format using resource bundle look-up using MessageFormat
*
* @param key the resource key
* @param args
*/
String messageFormat(String key, Object... args) {
if (outputRB == null) {
try {
outputRB = ResourceBundle.getBundle(L10N_RB_NAME);
} catch (MissingResourceException mre) {
throw new InternalError("Cannot find ResourceBundle: " + L10N_RB_NAME);
}
}
String s;
try {
s = outputRB.getString(key);
} catch (MissingResourceException mre) {
throw new InternalError("Missing resource: " + key + " in " + L10N_RB_NAME);
}
return MessageFormat.format(s, args);
}
}

View File

@ -0,0 +1,34 @@
#
# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
jshell.diag.modifier.plural.fatal = Modifiers {0} not permitted in top-level declarations
jshell.diag.modifier.plural.ignore = Modifiers {0} not permitted in top-level declarations, ignored
jshell.diag.modifier.single.fatal = Modifier {0} not permitted in top-level declarations
jshell.diag.modifier.single.ignore = Modifier {0} not permitted in top-level declarations, ignored
jshell.exc.null = Snippet must not be null
jshell.exc.alien = Snippet not from this JShell
jshell.exc.closed = JShell ({0}) has been closed.
jshell.exc.var.not.valid = Snippet parameter of varValue() {0} must be VALID, it is: {1}

View File

@ -29,6 +29,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;
@ -194,10 +195,10 @@ public class ReplToolTesting {
}
public void test(boolean isDefaultStartUp, String[] args, ReplTest... tests) {
test(isDefaultStartUp, args, DEFAULT_STARTUP_MESSAGE, tests);
test(Locale.ROOT, isDefaultStartUp, args, DEFAULT_STARTUP_MESSAGE, tests);
}
public void test(boolean isDefaultStartUp, String[] args, String startUpMessage, ReplTest... tests) {
public void test(Locale locale, boolean isDefaultStartUp, String[] args, String startUpMessage, ReplTest... tests) {
this.isDefaultStartUp = isDefaultStartUp;
initSnippets();
ReplTest[] wtests = new ReplTest[tests.length + 3];
@ -206,7 +207,7 @@ public class ReplToolTesting {
wtests[1] = a -> assertCommand(a, "/debug 0", null);
System.arraycopy(tests, 0, wtests, 2, tests.length);
wtests[tests.length + 2] = a -> assertCommand(a, "/exit", null);
testRaw(args, wtests);
testRaw(locale, args, wtests);
}
private void initSnippets() {
@ -230,7 +231,7 @@ public class ReplToolTesting {
prefs = new MemoryPreferences();
}
public void testRaw(String[] args, ReplTest... tests) {
public void testRaw(Locale locale, String[] args, ReplTest... tests) {
cmdin = new WaitingTestingInputStream();
cmdout = new ByteArrayOutputStream();
cmderr = new ByteArrayOutputStream();
@ -246,7 +247,8 @@ public class ReplToolTesting {
userin,
new PrintStream(userout),
new PrintStream(usererr),
prefs);
prefs,
locale);
repl.testPrompt = true;
try {
repl.start(args);
@ -258,7 +260,7 @@ public class ReplToolTesting {
String ceos = getCommandErrorOutput();
String uos = getUserOutput();
String ueos = getUserErrorOutput();
assertTrue((cos.isEmpty() || cos.startsWith("| Goodbye")),
assertTrue((cos.isEmpty() || cos.startsWith("| Goodbye") || !locale.equals(Locale.ROOT)),
"Expected a goodbye, but got: " + cos);
assertTrue(ceos.isEmpty(), "Expected empty error output, got: " + ceos);
assertTrue(uos.isEmpty(), "Expected empty output, got: " + uos);
@ -459,7 +461,7 @@ public class ReplToolTesting {
private List<String> computeCompletions(String code, boolean isSmart) {
JShellTool js = this.repl != null ? this.repl
: new JShellTool(null, null, null, null, null, null, null, prefs);
: new JShellTool(null, null, null, null, null, null, null, prefs, Locale.ROOT);
int cursor = code.indexOf('|');
code = code.replace("|", "");
assertTrue(cursor > -1, "'|' not found: " + code);

View File

@ -37,6 +37,7 @@ import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.Locale;
import java.util.function.Consumer;
import jdk.internal.jshell.tool.JShellTool;
@ -55,7 +56,8 @@ public class StartOptionTest {
private JShellTool getShellTool() {
return new JShellTool(null, new PrintStream(out), new PrintStream(err), null, null, null,
null, new ReplToolTesting.MemoryPreferences());
null, new ReplToolTesting.MemoryPreferences(),
Locale.ROOT);
}
private String getOutput() {
@ -116,10 +118,10 @@ public class StartOptionTest {
Compiler compiler = new Compiler();
Path p = compiler.getPath("file.txt");
compiler.writeToFile(p);
start("", "Argument to -startup missing.\n", "-startup");
start("", "'-startup' requires a filename argument.\n", "-startup");
start("", "Conflicting -startup or -nostartup option.\n", "-startup", p.toString(), "-startup", p.toString());
start("", "Conflicting -startup or -nostartup option.\n", "-nostartup", "-startup", p.toString());
start("", "Conflicting -startup option.\n", "-startup", p.toString(), "-nostartup");
start("", "Conflicting -startup or -nostartup option.\n", "-startup", p.toString(), "-nostartup");
}
@Test

View File

@ -43,6 +43,7 @@ import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Scanner;
import java.util.function.BiFunction;
import java.util.function.Consumer;
@ -463,7 +464,7 @@ public class ToolBasicTest extends ReplToolTesting {
(a) -> assertCommandCheckOutput(a, "printf(\"\")", assertStartsWith("| Error:\n| cannot find symbol"))
);
test((a) -> assertCommand(a, "printf(\"A\")", "", "", null, "A", ""));
test(false, new String[]{"-startup", "UNKNOWN"}, "| File 'UNKNOWN' for start-up is not found.");
test(Locale.ROOT, false, new String[]{"-startup", "UNKNOWN"}, "| File 'UNKNOWN' for start-up is not found.");
} finally {
removeStartup();
}
@ -478,9 +479,9 @@ public class ToolBasicTest extends ReplToolTesting {
(a) -> assertCommand(a, "a", "| Variable a of type double has value 10.0\n")
);
Path unknown = compiler.getPath("UNKNOWN.jar");
test(true, new String[]{unknown.toString()},
"| File '" + unknown
+ "' is not found: " + unresolvableMessage(unknown) + "\n");
test(Locale.ROOT, true, new String[]{unknown.toString()},
"| File " + unknown
+ " is not found: " + unresolvableMessage(unknown) + "\n");
}
public void testReset() {

View File

@ -62,7 +62,7 @@ public class ToolFormatTest extends ReplToolTesting {
(a) -> assertCommand(a, "/set format test result '={value} ' expression", ""),
(a) -> assertCommand(a, "/set format test display '{pre}{action}{ftype}{fname}{result}{resolve}'", ""),
(a) -> assertCommand(a, "/set format test display '{pre}HI this is enum' enum", ""),
(a) -> assertCommand(a, "/set feedback test", "$ Feedback mode: test"),
(a) -> assertCommandOutputStartsWith(a, "/set feedback test", "$ Feedback mode: test"),
(a) -> assertCommand(a, "class D {}", "$ ADD :D OK"),
(a) -> assertCommand(a, "void m() {}", "$ ADD []:m OK"),
(a) -> assertCommand(a, "interface EX extends EEX {}", "$ ADD :EX NODEF"),
@ -184,18 +184,18 @@ public class ToolFormatTest extends ReplToolTesting {
(a) -> assertCommandOutputStartsWith(a, "/set newmode te2",
"| Created new feedback mode: te2"),
(a) -> assertCommandOutputStartsWith(a, "/set newmode te2 command",
"| Expected a new feedback mode name. te2 is a known feedback mode"),
"| Expected a new feedback mode name. 'te2' is a known feedback mode"),
(a) -> assertCommandOutputStartsWith(a, "/set newmode te command normal",
"| Created new feedback mode: te"),
(a) -> assertCommand(a, "/set format te errorpre 'ERROR: '", ""),
(a) -> assertCommandOutputStartsWith(a, "/set feedback te",
""),
(a) -> assertCommandOutputStartsWith(a, "/set ",
"ERROR: The /set command requires arguments"),
"ERROR: The '/set' command requires a sub-command and arguments"),
(a) -> assertCommandOutputStartsWith(a, "/set xyz",
"ERROR: Not a valid argument to /set"),
"ERROR: Invalid '/set' argument: xyz"),
(a) -> assertCommandOutputStartsWith(a, "/set f",
"ERROR: Ambiguous argument to /set"),
"ERROR: Ambiguous sub-command argument to '/set': f"),
(a) -> assertCommandOutputStartsWith(a, "/set feedback",
"ERROR: Expected a feedback mode"),
(a) -> assertCommandOutputStartsWith(a, "/set feedback xyz",
@ -266,19 +266,4 @@ public class ToolFormatTest extends ReplToolTesting {
});
}
}
public void testSetHelpError() {
try {
test(
(a) -> assertCommandOutputStartsWith(a, "/set newmode te command normal", "| Created new feedback mode: te"),
(a) -> assertCommand(a, "/set format te errorpre 'ERROR: '", ""),
(a) -> assertCommandOutputStartsWith(a, "/set feedback te", "| Feedback mode: te"),
(a) -> assertCommandOutputContains(a, "/help /set xyz", "ERROR: Not a valid argument to /set: xyz"),
(a) -> assertCommandOutputContains(a, "/help /set f", "ERROR: Ambiguous argument to /set: f")
);
} finally {
assertCommandCheckOutput(false, "/set feedback normal", s -> {
});
}
}
}

View File

@ -0,0 +1,202 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8147515
* @summary Tests for output customization
* @library /tools/lib
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
* jdk.jdeps/com.sun.tools.javap
* jdk.jshell/jdk.internal.jshell.tool
* @build KullaTesting TestingInputStream toolbox.ToolBox Compiler
* @run testng ToolLocaleMessageTest
*/
import java.util.Locale;
import org.testng.annotations.Test;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
@Test
public class ToolLocaleMessageTest extends ReplToolTesting {
void testLocale(ReplTest... tests) {
test(Locale.getDefault(), false, new String[]{"-nostartup"}, "", tests);
}
void assertCommandOK(boolean after, String cmd, String... contains) {
assertCommandCheckOutput(after, cmd, s -> {
assertFalse(s.contains("Exception"), "Output of '" + cmd + "' has Exception: " + s);
assertFalse(s.contains("ERROR:"), "Output of '" + cmd + "' has error: " + s);
for (String m : contains) {
assertTrue(s.contains(m), "Expected to find '" + m + "' in output of '" + cmd + "' -- output: " + s);
}
});
}
void assertCommandFail(boolean after, String cmd, String... contains) {
assertCommandCheckOutput(after, cmd, s -> {
assertFalse(s.contains("Exception"), "Output of '" + cmd + "' has Exception: " + s);
assertTrue(s.contains("ERROR:"), "Expected to find error in output of '" + cmd + "' has error: " + s);
for (String m : contains) {
assertTrue(s.contains(m), "Expected to find '" + m + "' in output of '" + cmd + "' -- output: " + s);
}
});
}
public void testTerminate() {
testLocale(
(a) -> assertCommandOK(a, "System.exit(1)", "/reload")
);
}
public void testSample() {
try {
testLocale(
(a) -> assertCommandOK(a, "/set newmode test command normal", "test"),
(a) -> assertCommandOK(a, "/set format test errorpre 'ERROR: '"),
(a) -> assertCommandOK(a, "/set feedback test", "test"),
(a) -> assertCommandFail(a, "/turkey", "/turkey"),
(a) -> assertCommandFail(a, "/s", "/set"),
(a) -> assertCommandOK(a, "void m() { blah(); }", "blah"),
(a) -> assertCommandOK(a, "void m() {}"),
(a) -> assertCommandOK(a, "class C {}"),
(a) -> assertCommandOK(a, "47"),
(a) -> assertCommandOK(a, "double d"),
(a) -> assertCommandOK(a, "/drop m", "m"),
(a) -> assertCommandOK(a, "void dup() {}"),
(a) -> assertCommandOK(a, "int dup"),
(a) -> assertCommandOK(a, "/set feedback normal", "normal")
);
} finally {
assertCommandOK(false, "/set feedback normal");
}
}
public void testCommand() {
try {
testLocale(
(a) -> assertCommandOK(a, "/set newmode test command normal", "test"),
(a) -> assertCommandOK(a, "/set format test errorpre 'ERROR: '"),
(a) -> assertCommandOK(a, "/set feedback test", "test"),
(a) -> assertCommandFail(a, "/list zebra"),
(a) -> assertCommandFail(a, "/set editor", "/set editor"),
(a) -> assertCommandFail(a, "/set snowball", "/set", "snowball"),
(a) -> assertCommandFail(a, "/set", "/set", "/help"),
(a) -> assertCommandFail(a, "/set f", "feedback"),
(a) -> assertCommandFail(a, "/classpath", "/classpath"),
(a) -> assertCommandFail(a, "/help rabbits", "rabbits"),
(a) -> assertCommandFail(a, "/drop"),
(a) -> assertCommandFail(a, "/drop rats"),
(a) -> assertCommandOK(a, "void dup() {}"),
(a) -> assertCommandOK(a, "int dup"),
(a) -> assertCommandFail(a, "/drop dup"),
(a) -> assertCommandFail(a, "/edit zebra", "zebra"),
(a) -> assertCommandFail(a, "/list zebra", "zebra", "/list"),
(a) -> assertCommandFail(a, "/open", "/open"),
(a) -> assertCommandFail(a, "/open zebra", "zebra", "/open"),
(a) -> assertCommandFail(a, "/reload zebra", "zebra", "/reload"),
(a) -> assertCommandFail(a, "/save", "/save"),
(a) -> assertCommandFail(a, "/-99"),
(a) -> assertCommandOK(a, "/set feedback normal", "normal")
);
} finally {
assertCommandOK(false, "/set feedback normal");
}
}
public void testHelp() {
testLocale(
(a) -> assertCommandOK(a, "/help", "/list", "/save", "/set", "[restore]"),
(a) -> assertCommandOK(a, "/help /list", "start", "all"),
(a) -> assertCommandOK(a, "/help /edit", "/set editor"),
(a) -> assertCommandOK(a, "/help /drop", "/drop"),
(a) -> assertCommandOK(a, "/help /save", "all", "start"),
(a) -> assertCommandOK(a, "/help /open", "/open"),
(a) -> assertCommandOK(a, "/help /reload", "restore"),
(a) -> assertCommandOK(a, "/help /help", "intro"),
(a) -> assertCommandOK(a, "/help /set", "newmode"),
(a) -> assertCommandOK(a, "/help /?", "intro"),
(a) -> assertCommandOK(a, "/help intro", "/help"),
(a) -> assertCommandOK(a, "/help /set format", "import", "case", "{value}", "added"),
(a) -> assertCommandOK(a, "/help /set feedback", "newmode"),
(a) -> assertCommandOK(a, "/help /set newmode", "feedback"),
(a) -> assertCommandOK(a, "/help /set prompt", "/set prompt"),
(a) -> assertCommandOK(a, "/help /set editor", "/edit")
);
}
public void testFeedbackError() {
try {
testLocale(
(a) -> assertCommandOK(a, "/set newmode tee command foo", "foo"),
(a) -> assertCommandOK(a, "/set newmode tee flurb", "command", "quiet"),
(a) -> assertCommandOK(a, "/set newmode te2", "te2"),
(a) -> assertCommandOK(a, "/set newmode te2 command", "te2"),
(a) -> assertCommandOK(a, "/set newmode te command normal", "te"),
(a) -> assertCommandOK(a, "/set format te errorpre 'ERROR: '"),
(a) -> assertCommandOK(a, "/set feedback te"),
(a) -> assertCommandFail(a, "/set "),
(a) -> assertCommandFail(a, "/set xyz", "xyz"),
(a) -> assertCommandFail(a, "/set f", "/set", "f"),
(a) -> assertCommandFail(a, "/set feedback"),
(a) -> assertCommandFail(a, "/set feedback xyz"),
(a) -> assertCommandFail(a, "/set format"),
(a) -> assertCommandFail(a, "/set format xyz"),
(a) -> assertCommandFail(a, "/set format t"),
(a) -> assertCommandFail(a, "/set format te"),
(a) -> assertCommandFail(a, "/set format te fld"),
(a) -> assertCommandFail(a, "/set format te fld aaa", "aaa"),
(a) -> assertCommandFail(a, "/set format te fld 'aaa' frog"),
(a) -> assertCommandFail(a, "/set format te fld 'aaa' import-frog"),
(a) -> assertCommandFail(a, "/set format te fld 'aaa' import-import"),
(a) -> assertCommandFail(a, "/set format te fld 'aaa' import,added"),
(a) -> assertCommandFail(a, "/set newmode"),
(a) -> assertCommandFail(a, "/set newmode te"),
(a) -> assertCommandFail(a, "/set newmode x xyz"),
(a) -> assertCommandFail(a, "/set newmode x quiet y"),
(a) -> assertCommandFail(a, "/set prompt"),
(a) -> assertCommandFail(a, "/set prompt te"),
(a) -> assertCommandFail(a, "/set prompt te aaa xyz", "aaa"),
(a) -> assertCommandFail(a, "/set prompt te 'aaa' xyz", "xyz"),
(a) -> assertCommandFail(a, "/set prompt"),
(a) -> assertCommandFail(a, "/set prompt te"),
(a) -> assertCommandFail(a, "/set prompt te aaa"),
(a) -> assertCommandFail(a, "/set prompt te 'aaa'"),
(a) -> assertCommandOK(a, "/set feedback normal")
);
} finally {
assertCommandOK(false, "/set feedback normal");
}
}
}

View File

@ -71,7 +71,7 @@ public class ToolReloadTest extends ReplToolTesting {
Path classpath = compiler.getPath(outDir);
test(
(a) -> assertCommand(a, "/classpath " + classpath,
String.format("| Path %s added to classpath\n", classpath)),
String.format("| Path '%s' added to classpath\n", classpath)),
(a) -> assertMethod(a, "String foo() { return (new pkg.A()).toString(); }",
"()String", "foo"),
(a) -> assertVariable(a, "String", "v", "foo()", "\"A\""),