Skip to content

Port more of member completions + tests #833

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 6 commits into
base: main
Choose a base branch
from

Conversation

gabritto
Copy link
Member

@gabritto gabritto commented Apr 28, 2025

Follow-up of #811.
In this PR:

  • More member completions unit tests.
  • Ported code from the vscode TS extension that computed replacement range (i.e. LSP text edit) and filter text.
  • Implemented findChildOfKind, which was needed for the tuple completion case.

The code in ls/testsetup.go is temporary while we don't have real fourslash test infra, and is used for parsing markers in the unit tests. I got it from @navya9singh's signature help branch. I also tested the scenarios in the unit tests in vscode.

@Copilot Copilot AI review requested due to automatic review settings April 28, 2025 16:16
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 adds more unit tests for member completions while improving several completion‐related helper functions and message clarity. Key changes include:

  • Refining the implementation of findChildOfKind in utilities.go (with updated parameter naming and token‐scanning logic) and marking functions for signature help.
  • Adding a temporary test setup file for marker parsing in testsetup.go and updating the error message in languageservice.go.
  • Renaming internal functions in astnav/tokens.go and introducing ForEachChildAndJSDoc in ast/utilities.go to support more comprehensive AST traversal.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/ls/utilities.go Updated findChildOfKind with improved naming and token scanning logic.
internal/ls/testsetup.go Introduced temporary test setup for marker parsing in unit tests.
internal/ls/languageservice.go Enhanced error message to include the file name.
internal/ls/completions.go Renamed deprecation function and adjusted text-edit/commit characters logic.
internal/astnav/tokens.go Renamed visitEachChildAndJSDoc to exported VisitEachChildAndJSDoc.
internal/ast/utilities.go Added ForEachChildAndJSDoc to handle complete child traversal including JSDoc.
Comments suppressed due to low confidence (6)

internal/ls/utilities.go:85

  • Renaming the parameter from 'node' to 'containingNode' improves clarity; ensure that all references within the function remain consistent.
func findChildOfKind(containingNode *ast.Node, kind ast.Kind, sourceFile *ast.SourceFile) *ast.Node {

internal/ls/completions.go:1250

  • The duplicate declaration of 'textEdit' has been removed and the text edit adjustment logic for member completions is restructured; verify that this change is fully covered by unit tests.
return &lsproto.CompletionItem{

internal/astnav/tokens.go:137

  • Renaming 'visitEachChildAndJSDoc' to 'VisitEachChildAndJSDoc' for export consistency is appropriate; ensure that its usage is reflected in all affected call sites.
VisitEachChildAndJSDoc(current, sourceFile, nodeVisitor)

internal/ls/testsetup.go:64

  • [nitpick] Ensure that the new test setup implementation covers all marker parsing scenarios, including edge cases with multiple files or unusual marker formats.
testFileInfo := parseFileContent(currentFileContent, fileName, &markerPositions, &markers)

internal/ast/utilities.go:2796

  • The new ForEachChildAndJSDoc function provides a tidy way to traverse child nodes along with JSDoc comments; verify that its behavior is as expected for all AST node variants.
func ForEachChildAndJSDoc(node *Node, sourceFile *SourceFile, v Visitor) bool {

internal/ls/languageservice.go:69

  • The updated error message now includes the file name, which improves debuggability; verify that this aligns with the project's logging standards.
panic("file not found: " + fileName)

@gabritto gabritto changed the title Tests and fixes for member completions Port more of member completions + tests Apr 28, 2025
@gabritto gabritto requested a review from navya9singh April 29, 2025 20:29
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.

1 participant