Files
nx_post_support/server/src/tools/inlay_hint.py
T
2025-08-01 13:35:02 +02:00

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,
)
)