Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for code completion in the scope provider API #312

Open
loradd opened this issue Mar 12, 2024 · 1 comment
Open

Support for code completion in the scope provider API #312

loradd opened this issue Mar 12, 2024 · 1 comment
Assignees

Comments

@loradd
Copy link
Member

loradd commented Mar 12, 2024

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.

@loradd loradd self-assigned this Mar 12, 2024
@ftomassetti
Copy link
Member

This may be useful indeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants