Skip to content

Expose bind diags in LSP, show dead/deprecated code #955

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

Merged
merged 3 commits into from
May 28, 2025

Conversation

jakebailey
Copy link
Member

@jakebailey jakebailey commented May 27, 2025

Fixes #941

image

@jakebailey jakebailey requested review from gabritto and Copilot May 27, 2025 19:15
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 surfaces bind errors in the LSP diagnostic stream and tags diagnostics marked as unnecessary or deprecated.

  • Always include bind diagnostics alongside semantic diagnostics in GetDocumentDiagnostics
  • Introduce ReportsUnnecessary/ReportsDeprecated flags on ast.Diagnostic and emit LSP tags
  • Add ptrToSliceIfNonEmpty helper for optional slice pointers

Reviewed Changes

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

File Description
internal/ls/diagnostics.go Combined bind + semantic diagnostics, added diagnostic tags, and updated slice handling
internal/ast/diagnostic.go Added boolean flags & accessors to propagate unnecessary/deprecated diagnostics
Comments suppressed due to low confidence (1)

internal/ls/diagnostics.go:90

  • Add or update unit tests to verify that diagnostics with ReportsUnnecessary and ReportsDeprecated produce the correct LSP tags in the output.
Tags:               ptrToSliceIfNonEmpty(tags),

@jakebailey jakebailey marked this pull request as draft May 27, 2025 20:31
@jakebailey jakebailey marked this pull request as ready for review May 27, 2025 20:53
@jakebailey jakebailey requested a review from andrewbranch May 27, 2025 20:53
@@ -452,6 +456,39 @@ func (p *Program) getSemanticDiagnosticsForFile(ctx context.Context, sourceFile
return filtered
}

func (p *Program) getSuggestionDiagnosticsForFile(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic {
Copy link
Member Author

Choose a reason for hiding this comment

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

This all is pretty duplicative but I'm not about to attempt to refactor it into some generic version, honestly.

@jakebailey jakebailey requested a review from gabritto May 28, 2025 01:05
@jakebailey jakebailey added this pull request to the merge queue May 28, 2025
Merged via the queue into main with commit dc21070 May 28, 2025
23 checks passed
@jakebailey jakebailey deleted the jabaile/bind-diags-and-tags branch May 29, 2025 03:46
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.

tsgo does not detect unreachable code
2 participants