Skip to content

Commit 48e3163

Browse files
committed
fixed var declaration and nil checking nits
1 parent 45cd07b commit 48e3163

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

internal/ls/documenthighlights.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func (l *LanguageService) ProvideDocumentHighlights(ctx context.Context, documen
2121
node := astnav.GetTouchingPropertyName(sourceFile, position)
2222

2323
if node.Parent.Kind == ast.KindJsxOpeningElement || (node.Parent.Kind == ast.KindJsxClosingElement && node.Parent.TagName() == node) {
24-
documentHighlights := []*lsproto.DocumentHighlight{}
24+
var documentHighlights []*lsproto.DocumentHighlight
2525
kind := lsproto.DocumentHighlightKindRead
2626
if node.Parent.Kind == ast.KindJsxOpeningElement {
2727
documentHighlights = append(documentHighlights, &lsproto.DocumentHighlight{
@@ -41,7 +41,7 @@ func (l *LanguageService) ProvideDocumentHighlights(ctx context.Context, documen
4141
}
4242

4343
documentHighlights := l.getSemanticDocumentHighlights(ctx, position, node, program, sourceFile)
44-
if documentHighlights == nil {
44+
if len(documentHighlights) == 0 {
4545
documentHighlights = l.getSyntacticDocumentHighlights(node, sourceFile)
4646
}
4747
// if nil is passed here we never generate an error, just pass an empty higlight
@@ -173,7 +173,7 @@ func (l *LanguageService) highlightSpans(nodes []*ast.Node, sourceFile *ast.Sour
173173

174174
func (l *LanguageService) getFromAllDeclarations(nodeTest func(*ast.Node) bool, keywords []ast.Kind, node *ast.Node, sourceFile *ast.SourceFile) []*lsproto.DocumentHighlight {
175175
return l.useParent(node.Parent, nodeTest, func(decl *ast.Node, sf *ast.SourceFile) []*ast.Node {
176-
symbolDecls := []*ast.Node{}
176+
var symbolDecls []*ast.Node
177177
if ast.CanHaveSymbol(decl) {
178178
symbol := decl.Symbol()
179179
if ast.CanHaveSymbol(decl) && symbol != nil && symbol.Declarations != nil {

0 commit comments

Comments
 (0)