Support for code completion in the scope provider API
Code completion requests could be answered using the scoping rules defined through a language-specific scope provider. In order to enable such feature, ScopeDescription must support searching for all symbols names - possibly filtered through a text string. I suggest adding the following method to ScopeDescription:
fun allVisibleNames(filter: String = ""): Sequence<String> = sequence<String>{
// include names from all local nodes in this scope
namesToLocalSymbolNodes.keys.filter { it.contains(filter) }.forEach { yield(it) }
// include names from all external symbols in this scope
namesToExternalSymbolIdentifiers.keys.filter { it.contains(filter) }.forEach { yield(it) }
// include all visible names from the parent scope (if any)
parent?.allVisibleNames(filter)?.also { yieldAll(it) }
}
Furthermore, the ScopeProvider should provide support to retrieve scopes from string property names and node types, e.g. scopeFor(nodeType: String, propertyName: String): ScopeDescription?. In this way, we would need to retrieve Node instances before asking for the scope of a given reference - which would be cumbersome in the language server and require some sort of node repository access before. This feature would enable computing scopes from information contained in SymbolDescriptions.
This may be useful indeed