jshell: better unresolved symbol handling
This commit is contained in:
@@ -55,6 +55,7 @@ import javax.swing.JTextArea;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.Segment;
|
||||
import jdk.jshell.DeclarationSnippet;
|
||||
import jdk.jshell.Diag;
|
||||
import jdk.jshell.JShell;
|
||||
import jdk.jshell.Snippet;
|
||||
@@ -315,11 +316,13 @@ public abstract class ShellPanel extends JPanel
|
||||
{
|
||||
Snippet snip = ev.snippet();
|
||||
offsets.put("#" + snip.id(), thisOffset);
|
||||
if (ev.status() != Snippet.Status.VALID && ev.status() != Snippet.Status.RECOVERABLE_DEFINED)
|
||||
if (ev.status() != Snippet.Status.VALID)
|
||||
{
|
||||
boolean handled = false;
|
||||
var diags = shell.diagnostics(snip).collect(Collectors.toList());
|
||||
for (var diag : diags)
|
||||
{
|
||||
handled = true;
|
||||
String msg = toStringDiagnostic(src, thisOffset, diag);
|
||||
if (isUserCode)
|
||||
{
|
||||
@@ -331,12 +334,24 @@ public abstract class ShellPanel extends JPanel
|
||||
throw new RuntimeException("prelude error: " + msg);
|
||||
}
|
||||
}
|
||||
if (diags.isEmpty())
|
||||
if (snip instanceof DeclarationSnippet)
|
||||
{
|
||||
var unresolved = shell.unresolvedDependencies((DeclarationSnippet) snip).collect(Collectors.toList());
|
||||
for (var ident : unresolved)
|
||||
{
|
||||
handled = true;
|
||||
logToConsole("Unresolved symbol: " + ident);
|
||||
}
|
||||
}
|
||||
if (!handled)
|
||||
{
|
||||
logToConsole("bad snippet" + ev.status());
|
||||
}
|
||||
if (ev.status() != Snippet.Status.RECOVERABLE_DEFINED)
|
||||
{
|
||||
break evaluation;
|
||||
}
|
||||
}
|
||||
if (ev.exception() != null)
|
||||
{
|
||||
if (isUserCode)
|
||||
|
||||
Reference in New Issue
Block a user