feat(lsp): add call hierarchy support for TCL and MOM
Adds LSP call hierarchy support for TCL procedures and MOM events. A symbol index and identity logic underpin incoming and outgoing calls. LSP call hierarchy features are wired and changelog/README updated. - Implement data encoding for call hierarchy items and identity restoration - Wire LSP server to expose prepare_call_hierarchy, incoming_calls, and outgoing_calls - Add tests for cross-file calls and edge cases
This commit is contained in:
@@ -51,8 +51,12 @@ from tools.inlay_hint import (
|
||||
)
|
||||
from tools.navigation import (
|
||||
SymbolIdentity,
|
||||
call_hierarchy_identity,
|
||||
call_hierarchy_items,
|
||||
definition_identities,
|
||||
incoming_call_hierarchy,
|
||||
matching_occurrences,
|
||||
outgoing_call_hierarchy,
|
||||
symbol_at_position,
|
||||
workspace_symbols,
|
||||
)
|
||||
@@ -629,6 +633,45 @@ def workspace_symbol(params: lsp.WorkspaceSymbolParams):
|
||||
return workspace_symbols(LSP_SERVER.navigation_snapshot(), params.query)
|
||||
|
||||
|
||||
@LSP_SERVER.feature(lsp.TEXT_DOCUMENT_PREPARE_CALL_HIERARCHY)
|
||||
def prepare_call_hierarchy(params: lsp.CallHierarchyPrepareParams):
|
||||
context = _navigation_context(params.text_document.uri, params.position)
|
||||
if context is None:
|
||||
return None
|
||||
|
||||
indexes, _, _, identity = context
|
||||
items = call_hierarchy_items(identity, indexes)
|
||||
return items or None
|
||||
|
||||
|
||||
@LSP_SERVER.feature(lsp.CALL_HIERARCHY_INCOMING_CALLS)
|
||||
def incoming_calls(params: lsp.CallHierarchyIncomingCallsParams):
|
||||
identity = call_hierarchy_identity(params.item)
|
||||
if identity is None:
|
||||
return []
|
||||
|
||||
indexes = LSP_SERVER.navigation_snapshot()
|
||||
return incoming_call_hierarchy(
|
||||
identity,
|
||||
indexes,
|
||||
definition_identities(indexes),
|
||||
)
|
||||
|
||||
|
||||
@LSP_SERVER.feature(lsp.CALL_HIERARCHY_OUTGOING_CALLS)
|
||||
def outgoing_calls(params: lsp.CallHierarchyOutgoingCallsParams):
|
||||
identity = call_hierarchy_identity(params.item)
|
||||
if identity is None:
|
||||
return []
|
||||
|
||||
indexes = LSP_SERVER.navigation_snapshot()
|
||||
return outgoing_call_hierarchy(
|
||||
identity,
|
||||
indexes,
|
||||
definition_identities(indexes),
|
||||
)
|
||||
|
||||
|
||||
# **********************************************************
|
||||
# Linting features end here
|
||||
# **********************************************************
|
||||
@@ -704,6 +747,7 @@ def initialize(params: lsp.InitializeParams) -> lsp.InitializeResult:
|
||||
references_provider=True,
|
||||
rename_provider=lsp.RenameOptions(prepare_provider=True),
|
||||
workspace_symbol_provider=True,
|
||||
call_hierarchy_provider=True,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user