feat: add tab-completion in REPL and Meta.getModuleVariables API

Add tab-completion support to the interactive REPL by introducing a new `Meta.getModuleVariables` foreign method that returns all top-level variable names from a given module. The REPL's `run()` method now handles the tab key to append completions, and the `refreshLine` method accepts a boolean parameter to control whether completion hints are shown. Also fix the Ctrl-D exit logic (inverted condition) and remove the unused `EscapeBracket` class.
This commit is contained in:
Bob Nystrom
2016-05-22 22:32:17 +00:00
parent 38462ba4ed
commit 69498a4893
8 changed files with 177 additions and 25 deletions
+17
View File
@@ -0,0 +1,17 @@
import "meta" for Meta
var variables = Meta.getModuleVariables("main")
// Includes implicitly imported core stuff.
System.print(variables.contains("Object")) // expect: true
System.print(variables.contains("Bool")) // expect: true
// Includes top level variables.
System.print(variables.contains("variables")) // expect: true
// Even ones declared later.
System.print(variables.contains("later")) // expect: true
var later = "values"
System.print(variables.contains("unknown")) // expect: false
@@ -0,0 +1,3 @@
import "meta" for Meta
Meta.getModuleVariables(123) // expect runtime error: Module name must be a string.
@@ -0,0 +1,3 @@
import "meta" for Meta
Meta.getModuleVariables("unknown") // expect runtime error: Could not find a module named 'unknown'.