MCPcopy Create free account
hub / github.com/microsoft/typescript-go / getDeclarationNameForKeyword

Function getDeclarationNameForKeyword

internal/ls/definition.go:137–148  ·  view source on GitHub ↗
(node *ast.Node)

Source from the content-addressed store, hash-verified

135}
136
137func getDeclarationNameForKeyword(node *ast.Node) *ast.Node {
138 if node.Kind >= ast.KindFirstKeyword && node.Kind <= ast.KindLastKeyword {
139 if ast.IsVariableDeclarationList(node.Parent) {
140 if decl := core.FirstOrNil(node.Parent.AsVariableDeclarationList().Declarations.Nodes); decl != nil && decl.Name() != nil {
141 return decl.Name()
142 }
143 } else if node.Parent.DeclarationData() != nil && node.Parent.Name() != nil && node.Pos() < node.Parent.Name().Pos() {
144 return node.Parent.Name()
145 }
146 }
147 return node
148}
149
150type fileRange struct {
151 fileName string

Callers 3

ProvideTypeDefinitionMethod · 0.85

Calls 6

FirstOrNilFunction · 0.92
NameMethod · 0.65
DeclarationDataMethod · 0.65
PosMethod · 0.65

Tested by

no test coverage detected