showInlayHints method
Shows inlay hints in the editor.
This fetches inlay hints from the LSP server for the visible range and displays them inline in the code. Sets readOnly to true while hints are visible to prevent user input.
Inlay hints show type annotations (kind: 1) and parameter names (kind: 2).
Example:
// Call this when Ctrl+Alt is pressed
await controller.showInlayHints();
Implementation
Future<void> showInlayHints() async {
if (_inlayHintsVisible || lspConfig == null || openedFile == null) return;
_inlayHintsVisible = true;
readOnly = true;
try {
final endLine = lineCount > 500 ? 500 : lineCount;
final response = await lspConfig!.getInlayHints(
openedFile!,
0,
0,
endLine,
0,
);
final result = response['result'];
if (result is List) {
_inlayHints = result
.whereType<Map<String, dynamic>>()
.map((data) => InlayHint.fromLsp(data))
.toList();
} else {
_inlayHints = [];
}
inlayHintsChanged = true;
notifyListeners();
} catch (e) {
debugPrint('Error fetching inlay hints: $e');
_inlayHintsVisible = false;
readOnly = false;
}
}