@@ -4,6 +4,7 @@ local await = require 'await'
44local conv = require ' proto.converter'
55local getRef = require ' core.reference'
66local lang = require ' language'
7+ local client = require ' client'
78
89--- @class parser.state
910--- @field package _codeLens ? codeLens
8889function mt :resolveReference (source )
8990 local refs = getRef (self .uri , source .finish , false )
9091 local count = refs and # refs or 0
91- local command = conv .command (
92- lang .script (' COMMAND_REFERENCE_COUNT' , count ),
93- ' ' ,
94- {}
95- )
96- return command
92+ if client .getOption (' codeLensViewReferences' ) then
93+ local locations = {}
94+ for _ , ref in ipairs (refs or {}) do
95+ local state = files .getState (ref .uri )
96+ if state then
97+ locations [# locations + 1 ] = conv .location (
98+ ref .uri ,
99+ conv .packRange (state , ref .target .start , ref .target .finish )
100+ )
101+ end
102+ end
103+ local command = conv .command (
104+ lang .script (' COMMAND_REFERENCE_COUNT' , count ),
105+ ' lua.showReferences' ,
106+ {
107+ self .uri ,
108+ conv .packPosition (self .state , source .start ),
109+ locations ,
110+ }
111+ )
112+ return command
113+ else
114+ local command = conv .command (
115+ lang .script (' COMMAND_REFERENCE_COUNT' , count ),
116+ ' ' ,
117+ {}
118+ )
119+ return command
120+ end
97121end
98122
99123--- @async
0 commit comments