Skip to content

Improve logic for choosing value/type meanings in quick info #867

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 1 commit into from
May 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/checker/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ func (c *Checker) GetQuickInfoAtLocation(node *ast.Node) string {
return ""
}
flags := symbol.Flags
if flags&ast.SymbolFlagsType != 0 && !ast.IsInExpressionContext(node) {
// If the symbol has a type meaning and we're not in an expression context, remove any value meanings
flags &^= ast.SymbolFlagsValue
if flags&ast.SymbolFlagsType != 0 && (ast.IsPartOfTypeNode(node) || isTypeDeclarationName(node)) {
// If the symbol has a type meaning and we're in a type context, remove value-only meanings
Copy link
Preview

Copilot AI May 14, 2025

Choose a reason for hiding this comment

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

[nitpick] The updated condition clarifies when a node is in a type context, but consider adding a comment explaining why 'isTypeDeclarationName' is checked here to improve code clarity.

Suggested change
// If the symbol has a type meaning and we're in a type context, remove value-only meanings
// If the symbol has a type meaning and we're in a type context, remove value-only meanings.
// The `isTypeDeclarationName` function checks if the node represents a name in a type declaration,
// ensuring that type-related flags are preserved while excluding value-only flags.

Copilot uses AI. Check for mistakes.

Copy link
Member

Choose a reason for hiding this comment

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

These nitpick comments are getting awful

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed!

Copy link
Preview

Copilot AI May 14, 2025

Choose a reason for hiding this comment

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

[nitpick] The change from clearing all value flags to only clearing variable and function flags may be intentional; adding a clarifying comment on why other value flags are preserved would enhance maintainability.

Suggested change
// If the symbol has a type meaning and we're in a type context, remove value-only meanings
// If the symbol has a type meaning and we're in a type context, remove value-only meanings
// Specifically, clear the Variable and Function flags to avoid treating the symbol as a value.
// Other value flags are preserved intentionally to retain their specific meanings in this context.

Copilot uses AI. Check for mistakes.

flags &^= ast.SymbolFlagsVariable | ast.SymbolFlagsFunction
}
p := c.newPrinter(TypeFormatFlagsNone)
if isAlias {
Expand Down