30 lines
959 B
Python
30 lines
959 B
Python
import lsprotocol.types as lsp
|
|
from tclint.syntax_tree import Visitor, Command
|
|
|
|
|
|
class InlayHintGenerator(Visitor):
|
|
def __init__(self, proc_signatures):
|
|
self.proc_signatures = proc_signatures
|
|
self.hints = []
|
|
|
|
def visit_command(self, command: Command):
|
|
name = getattr(command.routine, "contents", None)
|
|
if name not in self.proc_signatures:
|
|
return
|
|
|
|
param_names = self.proc_signatures[name]
|
|
for idx, arg in enumerate(command.args):
|
|
if idx >= len(param_names):
|
|
break
|
|
param_name = param_names[idx]
|
|
|
|
if arg.pos:
|
|
line, col = arg.pos
|
|
self.hints.append(
|
|
lsp.InlayHint(
|
|
position=lsp.Position(line=line - 1, character=col - 1),
|
|
label=f"{param_name}:",
|
|
kind=lsp.InlayHintKind.Parameter,
|
|
)
|
|
)
|