-
Notifications
You must be signed in to change notification settings - Fork 653
Port global completions #858
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ports global completions by updating the logic to use the symbols gathered via tryGetGlobalSymbols. Key changes include:
- Introducing the use of maps.Copy in scanner initialization.
- Refactoring utility functions (e.g. in ls/utilities.go and symbol_display.go) and renaming some checker functions to their exported forms.
- Adding a new test setup for processing marker ranges.
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
internal/scanner/scanner.go | Uses maps.Copy to copy token text mappings during initialization. |
internal/ls/utilities.go | Adds and refactors helper functions for token scanning and child traversal. |
internal/ls/symbol_display.go | Modifies the logic determining local variable/function context. |
internal/ls/testsetup.go | Introduces new test setup and marker parsing functions. |
internal/checker/* | Renames several internal checker functions to exported forms and updates calls accordingly. |
internal/astnav/tokens.go, internal/ast/* | Adjustments to AST utilities and token visitor functions to support new patterns. |
Comments suppressed due to low confidence (2)
internal/ls/symbol_display.go:290
- The change from using 'continue' to 'break' in the loop over parent nodes may alter the original iteration logic used to determine local variable/function context. Please verify that breaking out of the loop upon encountering a SourceFile or ModuleBlock is the intended behavior for all cases.
for ; !ast.IsFunctionBlock(parent); parent = parent.Parent { if parent.Kind == ast.KindSourceFile || parent.Kind == ast.KindModuleBlock { break } }
internal/scanner/scanner.go:6
- The introduction of maps.Copy to copy token mappings is a clean use of the new Go functionality; please ensure that our build and runtime environments support the required Go version.
import (
"fmt"
"iter"
"maps"
"strconv"
263cc4d
to
a101a6e
Compare
Are there any notable deviations from Strada that should get special attention in a code review? |
Good question. I don't think there are any for this PR, at least not that I can think of. I'll try to keep that in mind and call it out on future PRs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
internal/checker/flow.go
Outdated
@@ -333,7 +333,7 @@ func (c *Checker) narrowTypeByAssertion(f *FlowState, t *Type, expr *ast.Node) * | |||
return c.narrowTypeByAssertion(f, c.narrowTypeByAssertion(f, t, node.AsBinaryExpression().Left), node.AsBinaryExpression().Right) | |||
} | |||
if node.AsBinaryExpression().OperatorToken.Kind == ast.KindBarBarToken { | |||
return c.getUnionType([]*Type{c.narrowTypeByAssertion(f, t, node.AsBinaryExpression().Left), c.narrowTypeByAssertion(f, t, node.AsBinaryExpression().Right)}) | |||
return c.GetUnionType([]*Type{c.narrowTypeByAssertion(f, t, node.AsBinaryExpression().Left), c.narrowTypeByAssertion(f, t, node.AsBinaryExpression().Right)}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, but maybe we should just declare a new one and keep the existing calls internal to reduce the diff? Maybe it's pointless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though it is a lot of lines in this PR...
Yeah, for some reason the insert/replace positions are messed up I think, I don't know yet where the positions go wrong. I'll debug and update with a fix tomorrow. Update: fixed by #866. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before we merge this, I believe that @ahejlsberg wanted to see about not renaming the methods but instead declaring exported wrappers in a new file in the checker package. Would probably be good to do that now instead of churning back and forth.
This PR ports global completions, a.k.a. completions you get from symbols collected by
tryGetGlobalSymbols
.