mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-05 01:50:27 +08:00
feat: 更新 LSP 测试,调整测试文件和增加分析等待时间
This commit is contained in:
@@ -987,28 +987,35 @@ class StandaloneLspManager:
|
||||
file_path: str,
|
||||
line: int,
|
||||
character: int,
|
||||
wait_for_analysis: float = 2.0,
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""Prepare call hierarchy items for a position.
|
||||
|
||||
|
||||
Args:
|
||||
file_path: Path to the source file
|
||||
line: Line number (1-indexed)
|
||||
character: Character position (1-indexed)
|
||||
|
||||
wait_for_analysis: Time to wait for server analysis (seconds)
|
||||
|
||||
Returns:
|
||||
List of CallHierarchyItem dicts
|
||||
"""
|
||||
state = await self._get_server(file_path)
|
||||
if not state:
|
||||
return []
|
||||
|
||||
|
||||
# Check if call hierarchy is supported
|
||||
if not state.capabilities.get("callHierarchyProvider"):
|
||||
return []
|
||||
|
||||
|
||||
# Open document first
|
||||
await self._open_document(state, file_path)
|
||||
|
||||
|
||||
# Wait for language server to complete analysis
|
||||
# This is critical for Pyright to return valid call hierarchy items
|
||||
if wait_for_analysis > 0:
|
||||
await asyncio.sleep(wait_for_analysis)
|
||||
|
||||
result = await self._send_request(
|
||||
state,
|
||||
"textDocument/prepareCallHierarchy",
|
||||
@@ -1017,10 +1024,10 @@ class StandaloneLspManager:
|
||||
"position": self._to_position(line, character),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
if not result or not isinstance(result, list):
|
||||
return []
|
||||
|
||||
|
||||
return result
|
||||
|
||||
async def get_incoming_calls(
|
||||
|
||||
@@ -42,16 +42,20 @@ class AssociationTreeBuilder:
|
||||
self,
|
||||
lsp_manager: StandaloneLspManager,
|
||||
timeout: float = 5.0,
|
||||
analysis_wait: float = 2.0,
|
||||
):
|
||||
"""Initialize AssociationTreeBuilder.
|
||||
|
||||
Args:
|
||||
lsp_manager: StandaloneLspManager instance for LSP communication
|
||||
timeout: Timeout for individual LSP requests in seconds
|
||||
analysis_wait: Time to wait for LSP analysis on first file (seconds)
|
||||
"""
|
||||
self.lsp_manager = lsp_manager
|
||||
self.timeout = timeout
|
||||
self.analysis_wait = analysis_wait
|
||||
self.visited: Set[str] = set()
|
||||
self._analyzed_files: Set[str] = set() # Track files already analyzed
|
||||
|
||||
async def build_tree(
|
||||
self,
|
||||
@@ -78,6 +82,12 @@ class AssociationTreeBuilder:
|
||||
tree = CallTree()
|
||||
self.visited.clear()
|
||||
|
||||
# Determine wait time - only wait for analysis on first encounter of file
|
||||
wait_time = 0.0
|
||||
if seed_file_path not in self._analyzed_files:
|
||||
wait_time = self.analysis_wait
|
||||
self._analyzed_files.add(seed_file_path)
|
||||
|
||||
# Get call hierarchy items for the seed position
|
||||
try:
|
||||
hierarchy_items = await asyncio.wait_for(
|
||||
@@ -85,8 +95,9 @@ class AssociationTreeBuilder:
|
||||
file_path=seed_file_path,
|
||||
line=seed_line,
|
||||
character=seed_character,
|
||||
wait_for_analysis=wait_time,
|
||||
),
|
||||
timeout=self.timeout,
|
||||
timeout=self.timeout + wait_time,
|
||||
)
|
||||
except asyncio.TimeoutError:
|
||||
logger.warning(
|
||||
|
||||
Reference in New Issue
Block a user