Skip to content

Commit e447950

Browse files
Copilotjakebailey
andcommitted
Remove nil check and handle empty declarations correctly
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
1 parent f6734f9 commit e447950

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

internal/ls/findallreferences.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -592,11 +592,15 @@ func (l *LanguageService) ProvideSymbolsAndEntries(ctx context.Context, uri lspr
592592
symbol := checker.GetSymbolAtLocation(core.IfElse(node.Kind == ast.KindConstructor && node.Parent.Name() != nil, node.Parent.Name(), node))
593593
done()
594594
if symbol != nil {
595-
// Disallow rename for elements that are defined in the standard TypeScript library.
596-
if symbol.Declarations != nil && core.Some(symbol.Declarations, func(declaration *ast.Node) bool {
597-
return isDefinedInLibraryFile(program, declaration)
598-
}) {
599-
return node, nil, false
595+
// Only allow a symbol to be renamed if it actually has at least one declaration.
596+
declarations := symbol.Declarations
597+
if len(declarations) > 0 {
598+
// Disallow rename for elements that are defined in the standard TypeScript library.
599+
if core.Some(declarations, func(declaration *ast.Node) bool {
600+
return isDefinedInLibraryFile(program, declaration)
601+
}) {
602+
return node, nil, false
603+
}
600604
}
601605
}
602606
}

0 commit comments

Comments
 (0)