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)
| 301 | // If the node's parent is a variable declaration and the node is the initializer, |
| 302 | // use the variable's name node instead. |
| 303 | func 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. |