oxc-project / oxc-project/backlog
New APIs for interacting with `ScopeTree` and `SymbolTable`
@overlookmotel is already working on this.
Since Oct 10, 2024.
- Dominant language
- No language data
- Stars
- 7
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Currently to get flags for a scope:
ctx.scopes().get_flags(scope_id)
We could instead support:
scope_id.flags(ctx)
Implemented as:
impl ScopeId {
pub fn flags<C: ScopesAccessor>(self, ctx: &C) {
ctx.scopes().get_flags(self)
}
}
trait ScopesAccessor {
fn scopes(&self) -> &ScopeTree;
}
ScopesAccessor trait would be implemented on Semantic, TraverseCtx, LinterCtx and any other structs which hold a copy of ScopeTree. Then we can centralize logic for acting on scopes in this trait.
Similarly, would also have these traits:
SymbolsAccessorNodesAccessorAstBuilderAccessorSymbolsAndScopesAccessor: SymbolsAccessor + ScopesAccessorSymbolsAndScopesAndAstBuilderAccessor: SymbolsAndScopesAccessor + AstBuilderAccessorSymbolsAndScopesAndNodesAccessor: SymbolsAndScopesAccessor + NodesAccessor
All logic for manipulating scopes/symbols/references/nodes would be implemented on these traits (or perhaps they delegate to a set of common functions, to keep the generic method impls on the traits slim).
Related to oxc-project/oxc#9607.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.