equal
deleted
inserted
replaced
96 import jdk.internal.jshell.tool.Feedback.FormatAction; |
96 import jdk.internal.jshell.tool.Feedback.FormatAction; |
97 import jdk.internal.jshell.tool.Feedback.FormatCase; |
97 import jdk.internal.jshell.tool.Feedback.FormatCase; |
98 import jdk.internal.jshell.tool.Feedback.FormatResolve; |
98 import jdk.internal.jshell.tool.Feedback.FormatResolve; |
99 import jdk.internal.jshell.tool.Feedback.FormatWhen; |
99 import jdk.internal.jshell.tool.Feedback.FormatWhen; |
100 import static java.util.stream.Collectors.toList; |
100 import static java.util.stream.Collectors.toList; |
|
101 import static jdk.jshell.Snippet.Kind.METHOD; |
101 import static java.util.stream.Collectors.toMap; |
102 import static java.util.stream.Collectors.toMap; |
102 import static jdk.jshell.Snippet.SubKind.VAR_VALUE_SUBKIND; |
103 import static jdk.jshell.Snippet.SubKind.VAR_VALUE_SUBKIND; |
103 |
104 |
104 /** |
105 /** |
105 * Command line REPL tool for Java using the JShell API. |
106 * Command line REPL tool for Java using the JShell API. |
2137 |
2138 |
2138 } |
2139 } |
2139 } |
2140 } |
2140 //where |
2141 //where |
2141 void printUnresolved(UnresolvedReferenceException ex) { |
2142 void printUnresolved(UnresolvedReferenceException ex) { |
2142 MethodSnippet corralled = ex.getMethodSnippet(); |
2143 DeclarationSnippet corralled = ex.getSnippet(); |
2143 List<Diag> otherErrors = errorsOnly(state.diagnostics(corralled)); |
2144 List<Diag> otherErrors = errorsOnly(state.diagnostics(corralled)); |
2144 StringBuilder sb = new StringBuilder(); |
2145 StringBuilder sb = new StringBuilder(); |
2145 if (otherErrors.size() > 0) { |
2146 if (otherErrors.size() > 0) { |
2146 if (state.unresolvedDependencies(corralled).size() > 0) { |
2147 if (state.unresolvedDependencies(corralled).size() > 0) { |
2147 sb.append(" and"); |
2148 sb.append(" and"); |
2153 } |
2154 } |
2154 } else { |
2155 } else { |
2155 sb.append("."); |
2156 sb.append("."); |
2156 } |
2157 } |
2157 |
2158 |
2158 hard("Attempted to call %s which cannot be invoked until%s", corralled.name(), |
2159 String format = corralled.kind() == METHOD |
|
2160 ? "Attempted to call %s which cannot be invoked until%s" |
|
2161 : "Attempted to use %s which cannot be accessed until%s"; |
|
2162 hard(format, corralled.name(), |
2159 unresolved(corralled), sb.toString()); |
2163 unresolved(corralled), sb.toString()); |
2160 if (otherErrors.size() > 0) { |
2164 if (otherErrors.size() > 0) { |
2161 printDiagnostics(corralled.source(), otherErrors, true); |
2165 printDiagnostics(corralled.source(), otherErrors, true); |
2162 } |
2166 } |
2163 } |
2167 } |