Skip to content

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Port global completions #858

wants to merge 13 commits into from

Conversation

gabritto
Copy link
Member

This PR ports global completions, a.k.a. completions you get from symbols collected by tryGetGlobalSymbols.

@Copilot Copilot AI review requested due to automatic review settings May 12, 2025 15:22
@gabritto gabritto marked this pull request as draft May 12, 2025 15:22
Copy link
Contributor

@Copilot Copilot AI left a 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"

@gabritto gabritto force-pushed the gabritto/globalcompletion branch from 263cc4d to a101a6e Compare May 12, 2025 16:11
@gabritto gabritto marked this pull request as ready for review May 12, 2025 16:33
@andrewbranch
Copy link
Member

Are there any notable deviations from Strada that should get special attention in a code review?

@gabritto
Copy link
Member Author

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 is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed
return false

case ast.KindForStatement,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
case ast.KindForStatement,
// Add a corresponding case to ast.go if modifying this
case ast.KindForStatement,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

??

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

Successfully merging this pull request may close these issues.

3 participants