langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java
changeset 42827 36468b5fa7f4
parent 41937 1313399705e9
child 43759 61535ac55add
equal deleted inserted replaced
42826:563b42fc70ba 42827:36468b5fa7f4
   880             }
   880             }
   881         }
   881         }
   882 
   882 
   883         void showTruncationSettings(Mode sm) {
   883         void showTruncationSettings(Mode sm) {
   884             if (sm == null) {
   884             if (sm == null) {
   885                 modeMap.values().forEach(m -> showTruncationSettings(m));
   885                 modeMap.values().forEach(this::showTruncationSettings);
   886             } else {
   886             } else {
   887                 List<Mode.Setting> trunc = sm.cases.get(TRUNCATION_FIELD);
   887                 List<Mode.Setting> trunc = sm.cases.get(TRUNCATION_FIELD);
   888                 if (trunc != null) {
   888                 if (trunc != null) {
   889                     trunc.forEach(s -> {
   889                     trunc.forEach(s -> {
   890                         hard("/set truncation %s %s %s",
   890                         hard("/set truncation %s %s %s",
   895             }
   895             }
   896         }
   896         }
   897 
   897 
   898         void showPromptSettings(Mode sm) {
   898         void showPromptSettings(Mode sm) {
   899             if (sm == null) {
   899             if (sm == null) {
   900                 modeMap.values().forEach(m -> showPromptSettings(m));
   900                 modeMap.values().forEach(this::showPromptSettings);
   901             } else {
   901             } else {
   902                 hard("/set prompt %s %s %s",
   902                 hard("/set prompt %s %s %s",
   903                         sm.name,
   903                         sm.name,
   904                         toStringLiteral(sm.prompt),
   904                         toStringLiteral(sm.prompt),
   905                         toStringLiteral(sm.continuationPrompt));
   905                         toStringLiteral(sm.continuationPrompt));
   906             }
   906             }
   907         }
   907         }
   908 
   908 
   909         void showModeSettings(String umode, String msg) {
   909         void showModeSettings(String umode, String msg) {
   910             if (umode == null) {
   910             if (umode == null) {
   911                 modeMap.values().forEach(n -> showModeSettings(n));
   911                 modeMap.values().forEach(this::showModeSettings);
   912             } else {
   912             } else {
   913                 Mode m;
   913                 Mode m;
   914                 String retained = retainedMap.get(umode);
   914                 String retained = retainedMap.get(umode);
   915                 if (retained == null) {
   915                 if (retained == null) {
   916                     m = searchForMode(umode, msg);
   916                     m = searchForMode(umode, msg);
  1270         private String toIdentifier(String id, String err) {
  1270         private String toIdentifier(String id, String err) {
  1271             if (!valid || id == null) {
  1271             if (!valid || id == null) {
  1272                 return null;
  1272                 return null;
  1273             }
  1273             }
  1274             if (at.isQuoted() ||
  1274             if (at.isQuoted() ||
  1275                     !id.codePoints().allMatch(cp -> Character.isJavaIdentifierPart(cp))) {
  1275                     !id.codePoints().allMatch(Character::isJavaIdentifierPart)) {
  1276                 errorat(err, id);
  1276                 errorat(err, id);
  1277                 return null;
  1277                 return null;
  1278             }
  1278             }
  1279             return id;
  1279             return id;
  1280         }
  1280         }
  1305                 return m;
  1305                 return m;
  1306             }
  1306             }
  1307             // Failing an exact match, go searching
  1307             // Failing an exact match, go searching
  1308             Mode[] matches = modeMap.entrySet().stream()
  1308             Mode[] matches = modeMap.entrySet().stream()
  1309                     .filter(e -> e.getKey().startsWith(umode))
  1309                     .filter(e -> e.getKey().startsWith(umode))
  1310                     .map(e -> e.getValue())
  1310                     .map(Entry::getValue)
  1311                     .toArray(size -> new Mode[size]);
  1311                     .toArray(Mode[]::new);
  1312             if (matches.length == 1) {
  1312             if (matches.length == 1) {
  1313                 return matches[0];
  1313                 return matches[0];
  1314             } else {
  1314             } else {
  1315                 if (msg != null) {
  1315                 if (msg != null) {
  1316                     hardmsg(msg, "");
  1316                     hardmsg(msg, "");