Skip to content

Commit 0e7ce69

Browse files
committed
chore: add some debug log informations for skipped library caches
1 parent 6dca5e0 commit 0e7ce69

File tree

2 files changed

+70
-63
lines changed

2 files changed

+70
-63
lines changed

robotcode/language_server/robotframework/diagnostics/imports_manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,8 @@ async def _get_libdoc() -> LibraryDoc:
939939

940940
spec_file = Path(self.lib_doc_cache_path, meta.filepath_base.with_suffix(".spec.json"))
941941
spec_file.write_text(as_json(result), "utf-8")
942+
else:
943+
self._logger.debug(lambda: f"Skip caching library {name}{args:r}")
942944
except (SystemExit, KeyboardInterrupt):
943945
raise
944946
except BaseException as e:

robotcode/language_server/robotframework/parts/robot_workspace.py

Lines changed: 68 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import asyncio
4+
import time
45
from typing import TYPE_CHECKING, Any, List, Optional
56

67
from ....utils.async_tools import Event, threaded
@@ -74,73 +75,77 @@ async def on_get_analysis_progress_mode(self, sender: Any, uri: Uri) -> Optional
7475

7576
@threaded()
7677
async def _load_workspace_documents(self, sender: Any) -> List[WorkspaceDocumentsResult]:
78+
start = time.monotonic()
79+
try:
80+
81+
result: List[WorkspaceDocumentsResult] = []
82+
83+
for folder in self.parent.workspace.workspace_folders:
84+
config = await self.parent.workspace.get_configuration(RobotCodeConfig, folder.uri)
85+
86+
async with self.parent.window.progress("Collect sources", cancellable=False):
87+
files = [
88+
f
89+
for f in iter_files(
90+
folder.uri.to_path(),
91+
f"**/*.{{{ROBOT_FILE_EXTENSION[1:]},{RESOURCE_FILE_EXTENSION[1:]}}}",
92+
ignore_patterns=config.workspace.exclude_patterns or [],
93+
absolute=True,
94+
)
95+
]
96+
97+
canceled = False
98+
async with self.parent.window.progress(
99+
"Load workspace", cancellable=True, current=0, max=len(files), start=False
100+
) as progress:
101+
for i, f in enumerate(files):
102+
try:
103+
if progress.is_canceled:
104+
canceled = True
105+
break
106+
107+
name = f.relative_to(folder.uri.to_path())
108+
109+
if config.analysis.progress_mode != AnalysisProgressMode.OFF:
110+
progress.begin()
111+
progress.report(
112+
f"Load {str(name)}"
113+
if config.analysis.progress_mode == AnalysisProgressMode.DETAILED
114+
else None,
115+
current=i,
116+
)
117+
118+
if not f.exists():
119+
continue
120+
121+
document = await self.parent.documents.get_or_open_document(f, "robotframework")
77122

78-
result: List[WorkspaceDocumentsResult] = []
79-
80-
for folder in self.parent.workspace.workspace_folders:
81-
config = await self.parent.workspace.get_configuration(RobotCodeConfig, folder.uri)
82-
83-
async with self.parent.window.progress("Collect sources", cancellable=False):
84-
files = [
85-
f
86-
for f in iter_files(
87-
folder.uri.to_path(),
88-
f"**/*.{{{ROBOT_FILE_EXTENSION[1:]},{RESOURCE_FILE_EXTENSION[1:]}}}",
89-
ignore_patterns=config.workspace.exclude_patterns or [],
90-
absolute=True,
91-
)
92-
]
93-
94-
canceled = False
95-
async with self.parent.window.progress(
96-
"Load workspace", cancellable=True, current=0, max=len(files), start=False
97-
) as progress:
98-
for i, f in enumerate(files):
99-
try:
100-
if progress.is_canceled:
101-
canceled = True
102-
break
103-
104-
name = f.relative_to(folder.uri.to_path())
105-
106-
if config.analysis.progress_mode != AnalysisProgressMode.OFF:
107-
progress.begin()
108-
progress.report(
109-
f"Load {str(name)}"
110-
if config.analysis.progress_mode == AnalysisProgressMode.DETAILED
111-
else None,
112-
current=i,
113-
)
114-
115-
if not f.exists():
116-
continue
117-
118-
document = await self.parent.documents.get_or_open_document(f, "robotframework")
119-
120-
if not document.opened_in_editor:
121-
await (await self.parent.documents_cache.get_namespace(document)).ensure_initialized()
122-
123-
if config.analysis.diagnostic_mode == DiagnosticsMode.WORKSPACE:
124-
result.append(
125-
WorkspaceDocumentsResult(
126-
str(name)
127-
if config.analysis.progress_mode == AnalysisProgressMode.DETAILED
128-
else None,
129-
document,
123+
if not document.opened_in_editor:
124+
await (await self.parent.documents_cache.get_namespace(document)).ensure_initialized()
125+
126+
if config.analysis.diagnostic_mode == DiagnosticsMode.WORKSPACE:
127+
result.append(
128+
WorkspaceDocumentsResult(
129+
str(name)
130+
if config.analysis.progress_mode == AnalysisProgressMode.DETAILED
131+
else None,
132+
document,
133+
)
130134
)
131-
)
132135

133-
except (SystemExit, KeyboardInterrupt, asyncio.CancelledError):
134-
raise
135-
except BaseException as e:
136-
self._logger.exception(e)
136+
except (SystemExit, KeyboardInterrupt, asyncio.CancelledError):
137+
raise
138+
except BaseException as e:
139+
self._logger.exception(e)
137140

138-
self.workspace_loaded.set()
141+
self.workspace_loaded.set()
139142

140-
if canceled:
141-
return []
143+
if canceled:
144+
return []
142145

143-
if config.analysis.max_project_file_count > 0 and len(files) > config.analysis.max_project_file_count:
144-
result = result[: config.analysis.max_project_file_count]
146+
if config.analysis.max_project_file_count > 0 and len(files) > config.analysis.max_project_file_count:
147+
result = result[: config.analysis.max_project_file_count]
145148

146-
return result
149+
return result
150+
finally:
151+
self._logger.debug(f"Workspace loaded in {time.monotonic() - start}s")

0 commit comments

Comments
 (0)