JetBrainsCodeEditor: Use FileProxy to support reading of external files

This adds support for external files to JetBrainsFindDeclarationTool

CodeEditor: Guard use of edited_file_context against use with ext. files
This commit is contained in:
Dominik Jain authored and Dominik Jain committed 2026-07-17 14:27:47 +02:00
1 parent 04445da438
commit 1940fc6d43
2 files changed
+5 -2

No files matched your search

+1
View File
@@ -20,6 +20,7 @@ Status of the `main` branch. Changes prior to the next official version change w
- Allow external files from dependencies (specified via references like "<ext:FileUtil.class|472e0a13>") to be
- read via `ReadFileTool`
- searched via `SearchForPatternTool`
- used in `JetBrainsFindDeclarationTool`
when using plugin version 2023.3.3+
# v1.6.0 (2026-07-16)
+4 -2
View File
@@ -13,6 +13,7 @@ from solidlsp.ls import LSPFileBuffer
from solidlsp.ls_utils import PathUtils, TextUtils
from .project import Project
from .util.file_proxy import FileProxy
log = logging.getLogger(__name__)
TSymbol = TypeVar("TSymbol", bound=Symbol)
@@ -78,6 +79,8 @@ class CodeEditor(Generic[TSymbol], ABC):
"""
Context manager for editing a file.
"""
if FileProxy.is_external_path(relative_path):
raise ValueError(f"Cannot edit external file: {relative_path}")
with self._open_file_context(relative_path) as edited_file:
yield edited_file
# save the file
@@ -400,8 +403,7 @@ class JetBrainsCodeEditor(CodeEditor[JetBrainsSymbol]):
super().__init__(relative_path)
path = os.path.join(project.project_root, relative_path)
log.info("Editing file: %s", path)
with open(path, encoding=project.project_config.encoding) as f:
self._content = f.read()
self._content = FileProxy.from_project_relative_path(project, relative_path).get_contents()
def get_contents(self) -> str:
return self._content