MCPcopy Create free account
hub / github.com/Effect-TS/tsgo / getDisplayNode

Function getDisplayNode

internal/layergraph/extract.go:303–317  ·  view source on GitHub ↗

getDisplayNode returns the node used for display purposes. If the node's parent is a variable declaration and the node is the initializer, use the variable's name node instead.

(node *ast.Node)

Source from the content-addressed store, hash-verified

301// If the node's parent is a variable declaration and the node is the initializer,
302// use the variable's name node instead.
303func getDisplayNode(node *ast.Node) *ast.Node {
304 if node.Parent != nil && node.Parent.Kind == ast.KindVariableDeclaration {
305 varDecl := node.Parent.AsVariableDeclaration()
306 if varDecl.Initializer != nil && varDecl.Initializer == node {
307 return varDecl.Name()
308 }
309 }
310 if node.Parent != nil && node.Parent.Kind == ast.KindPropertyDeclaration {
311 propDecl := node.Parent.AsPropertyDeclaration()
312 if propDecl.Initializer != nil && propDecl.Initializer == node {
313 return propDecl.Name()
314 }
315 }
316 return node
317}
318
319// getAdjustedNode extracts the initializer expression from a declaration node
320// to follow during symbol resolution.

Callers 1

extractNodeInfoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected