Skip to content

Commit 10d981f

Browse files
committed
feat(langserver): show variable type in hover for RF 7.3
1 parent 73cda66 commit 10d981f

File tree

52 files changed

+3241
-1189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3241
-1189
lines changed

packages/language_server/src/robotcode/language_server/robotframework/parts/hover.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def _hover_default(self, nodes: List[ast.AST], document: TextDocument, position:
163163
else:
164164
value = ""
165165

166-
text = f"### {variable.type.value.title()} `{variable.name}`\n\n"
166+
text = f"### {variable.type.value.title()} `{variable.full_name}`\n\n"
167167

168168
if value:
169169
text += "```python\n"

packages/robot/src/robotcode/robot/diagnostics/entities.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from robotcode.core.lsp.types import Position, Range
2020

2121
from ..utils.ast import range_from_token
22-
from ..utils.variables import VariableMatcher
22+
from ..utils.variables import VariableMatcher, search_variable
2323

2424
if TYPE_CHECKING:
2525
from robotcode.robot.diagnostics.library_doc import KeywordDoc, LibraryDoc
@@ -191,7 +191,13 @@ class VariableDefinition(SourceEntity):
191191

192192
@functools.cached_property
193193
def matcher(self) -> VariableMatcher:
194-
return VariableMatcher(self.name)
194+
return search_variable(self.name)
195+
196+
@functools.cached_property
197+
def full_name(self) -> str:
198+
m = self.matcher
199+
value_type = f": {self.value_type}" if self.value_type else ""
200+
return f"{m.identifier}{{{m.base.strip()}{value_type}}}"
195201

196202
@single_call
197203
def __hash__(self) -> int:

tests/robotcode/language_server/robotframework/parts/_regtest_outputs/rf41/test_references.test[references.robot-036-004-simple_keyword_call].out

Lines changed: 66 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -223,46 +223,55 @@ result:
223223
range:
224224
end:
225225
character: 7
226-
line: 8
226+
line: 10
227227
start:
228228
character: 4
229-
line: 8
229+
line: 10
230230
uri: rf73/variable_conversion.robot
231231
- !Location
232232
range:
233233
end:
234234
character: 7
235-
line: 9
235+
line: 11
236236
start:
237237
character: 4
238-
line: 9
238+
line: 11
239239
uri: rf73/variable_conversion.robot
240240
- !Location
241241
range:
242242
end:
243243
character: 7
244-
line: 10
244+
line: 12
245245
start:
246246
character: 4
247-
line: 10
247+
line: 12
248248
uri: rf73/variable_conversion.robot
249249
- !Location
250250
range:
251251
end:
252252
character: 7
253-
line: 20
253+
line: 13
254254
start:
255255
character: 4
256-
line: 20
256+
line: 13
257257
uri: rf73/variable_conversion.robot
258258
- !Location
259259
range:
260260
end:
261261
character: 7
262-
line: 21
262+
line: 14
263263
start:
264264
character: 4
265-
line: 21
265+
line: 14
266+
uri: rf73/variable_conversion.robot
267+
- !Location
268+
range:
269+
end:
270+
character: 7
271+
line: 15
272+
start:
273+
character: 4
274+
line: 15
266275
uri: rf73/variable_conversion.robot
267276
- !Location
268277
range:
@@ -273,95 +282,122 @@ result:
273282
character: 4
274283
line: 25
275284
uri: rf73/variable_conversion.robot
285+
- !Location
286+
range:
287+
end:
288+
character: 7
289+
line: 26
290+
start:
291+
character: 4
292+
line: 26
293+
uri: rf73/variable_conversion.robot
294+
- !Location
295+
range:
296+
end:
297+
character: 7
298+
line: 30
299+
start:
300+
character: 4
301+
line: 30
302+
uri: rf73/variable_conversion.robot
276303
- !Location
277304
range:
278305
end:
279306
character: 11
280-
line: 31
307+
line: 36
281308
start:
282309
character: 8
283-
line: 31
310+
line: 36
284311
uri: rf73/variable_conversion.robot
285312
- !Location
286313
range:
287314
end:
288315
character: 11
289-
line: 35
316+
line: 40
290317
start:
291318
character: 8
292-
line: 35
319+
line: 40
293320
uri: rf73/variable_conversion.robot
294321
- !Location
295322
range:
296323
end:
297324
character: 7
298-
line: 40
325+
line: 45
299326
start:
300327
character: 4
301-
line: 40
328+
line: 45
302329
uri: rf73/variable_conversion.robot
303330
- !Location
304331
range:
305332
end:
306333
character: 7
307-
line: 47
334+
line: 55
308335
start:
309336
character: 4
310-
line: 47
337+
line: 55
311338
uri: rf73/variable_conversion.robot
312339
- !Location
313340
range:
314341
end:
315342
character: 7
316-
line: 48
343+
line: 56
317344
start:
318345
character: 4
319-
line: 48
346+
line: 56
320347
uri: rf73/variable_conversion.robot
321348
- !Location
322349
range:
323350
end:
324351
character: 7
325-
line: 49
352+
line: 57
326353
start:
327354
character: 4
328-
line: 49
355+
line: 57
329356
uri: rf73/variable_conversion.robot
330357
- !Location
331358
range:
332359
end:
333360
character: 7
334-
line: 50
361+
line: 58
335362
start:
336363
character: 4
337-
line: 50
364+
line: 58
338365
uri: rf73/variable_conversion.robot
339366
- !Location
340367
range:
341368
end:
342369
character: 7
343-
line: 54
370+
line: 62
344371
start:
345372
character: 4
346-
line: 54
373+
line: 62
347374
uri: rf73/variable_conversion.robot
348375
- !Location
349376
range:
350377
end:
351378
character: 7
352-
line: 55
379+
line: 63
353380
start:
354381
character: 4
355-
line: 55
382+
line: 63
383+
uri: rf73/variable_conversion.robot
384+
- !Location
385+
range:
386+
end:
387+
character: 7
388+
line: 67
389+
start:
390+
character: 4
391+
line: 67
356392
uri: rf73/variable_conversion.robot
357393
- !Location
358394
range:
359395
end:
360396
character: 7
361-
line: 59
397+
line: 80
362398
start:
363399
character: 4
364-
line: 59
400+
line: 80
365401
uri: rf73/variable_conversion.robot
366402
- !Location
367403
range:

0 commit comments

Comments
 (0)