@@ -69,36 +69,24 @@ func findDefinition(root ast.Node, params *protocol.DefinitionParams, vm *jsonne
69
69
case * ast.Var :
70
70
log .Debugf ("Found Var node %s" , deepestNode .Id )
71
71
72
- var (
73
- filename string
74
- resultRange , resultSelectionRange protocol.Range
75
- )
72
+ var objectRange processing.ObjectRange
76
73
77
74
if bind := processing .FindBindByIdViaStack (searchStack , deepestNode .Id ); bind != nil {
78
- locRange := bind .LocRange
79
- if ! locRange .Begin .IsSet () {
80
- locRange = * bind .Body .Loc ()
81
- }
82
- filename = locRange .FileName
83
- resultRange = position .RangeASTToProtocol (locRange )
84
- resultSelectionRange = position .NewProtocolRange (
85
- locRange .Begin .Line - 1 ,
86
- locRange .Begin .Column - 1 ,
87
- locRange .Begin .Line - 1 ,
88
- locRange .Begin .Column - 1 + len (bind .Variable ),
89
- )
75
+ objectRange = processing .LocalBindToRange (bind )
90
76
} else if param := processing .FindParameterByIdViaStack (searchStack , deepestNode .Id ); param != nil {
91
- filename = param .LocRange .FileName
92
- resultRange = position .RangeASTToProtocol (param .LocRange )
93
- resultSelectionRange = position .RangeASTToProtocol (param .LocRange )
77
+ objectRange = processing.ObjectRange {
78
+ Filename : param .LocRange .FileName ,
79
+ FullRange : param .LocRange ,
80
+ SelectionRange : param .LocRange ,
81
+ }
94
82
} else {
95
83
return nil , fmt .Errorf ("no matching bind found for %s" , deepestNode .Id )
96
84
}
97
85
98
86
response = append (response , protocol.DefinitionLink {
99
- TargetURI : protocol .DocumentURI (filename ),
100
- TargetRange : resultRange ,
101
- TargetSelectionRange : resultSelectionRange ,
87
+ TargetURI : protocol .DocumentURI (objectRange . Filename ),
88
+ TargetRange : position . RangeASTToProtocol ( objectRange . FullRange ) ,
89
+ TargetSelectionRange : position . RangeASTToProtocol ( objectRange . SelectionRange ) ,
102
90
})
103
91
case * ast.SuperIndex , * ast.Index :
104
92
indexSearchStack := nodestack .NewNodeStack (deepestNode )
0 commit comments