@@ -41,6 +41,24 @@ func References(ctx context.Context, s Snapshot, f FileHandle, pp protocol.Posit
41
41
fset = s .View ().Session ().Cache ().FileSet ()
42
42
)
43
43
44
+ // Make sure declaration is the first item in the response.
45
+ if includeDeclaration {
46
+ rng , err := objToMappedRange (s .View (), qualifiedObjs [0 ].pkg , qualifiedObjs [0 ].obj )
47
+ if err != nil {
48
+ return nil , err
49
+ }
50
+
51
+ ident , _ := qualifiedObjs [0 ].node .(* ast.Ident )
52
+ references = append (references , & ReferenceInfo {
53
+ mappedRange : rng ,
54
+ Name : qualifiedObjs [0 ].obj .Name (),
55
+ ident : ident ,
56
+ obj : qualifiedObjs [0 ].obj ,
57
+ pkg : qualifiedObjs [0 ].pkg ,
58
+ isDeclaration : true ,
59
+ })
60
+ }
61
+
44
62
for _ , qo := range qualifiedObjs {
45
63
var searchPkgs []Package
46
64
@@ -90,22 +108,5 @@ func References(ctx context.Context, s Snapshot, f FileHandle, pp protocol.Posit
90
108
}
91
109
}
92
110
93
- if includeDeclaration {
94
- rng , err := objToMappedRange (s .View (), qualifiedObjs [0 ].pkg , qualifiedObjs [0 ].obj )
95
- if err != nil {
96
- return nil , err
97
- }
98
-
99
- ident , _ := qualifiedObjs [0 ].node .(* ast.Ident )
100
- references = append (references , & ReferenceInfo {
101
- mappedRange : rng ,
102
- Name : qualifiedObjs [0 ].obj .Name (),
103
- ident : ident ,
104
- obj : qualifiedObjs [0 ].obj ,
105
- pkg : qualifiedObjs [0 ].pkg ,
106
- isDeclaration : true ,
107
- })
108
- }
109
-
110
111
return references , nil
111
112
}
0 commit comments