mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-13 04:15:11 +00:00
Improve handling of glob support in FileProxy, fixing tests
This commit is contained in:
1 parent
3096ac4fe2
commit
d5d88d72eb
2 files changed
+14
-3
No files matched your search
@@ -19,6 +19,12 @@ class FileProxy(ABC):
|
||||
def get_relative_path(self) -> str:
|
||||
""":return: the relative path reported by Serena (actual relative path or encoded external path)"""
|
||||
|
||||
@abstractmethod
|
||||
def is_glob_supported(self):
|
||||
"""
|
||||
:return: whether the proxy supports glob filtering based on its relative path
|
||||
"""
|
||||
|
||||
|
||||
class LocalProjectFileProxy(FileProxy):
|
||||
def __init__(self, relative_path: str, project: "Project"):
|
||||
@@ -33,6 +39,9 @@ class LocalProjectFileProxy(FileProxy):
|
||||
def get_relative_path(self) -> str:
|
||||
return self._relative_path
|
||||
|
||||
def is_glob_supported(self):
|
||||
return True
|
||||
|
||||
|
||||
class FileCollection:
|
||||
def __init__(self, file_proxies: list[FileProxy]):
|
||||
@@ -67,9 +76,8 @@ class FileCollection:
|
||||
|
||||
filtered_files = []
|
||||
for f in self._file_proxies:
|
||||
if isinstance(f, LocalProjectFileProxy):
|
||||
local_file: LocalProjectFileProxy = f
|
||||
path = local_file.get_relative_path()
|
||||
if f.is_glob_supported():
|
||||
path = f.get_relative_path()
|
||||
if include_glob_matcher:
|
||||
if not include_glob_matcher.matches(path):
|
||||
log.debug(f"Skipping {path}: does not match include pattern {paths_include_glob}")
|
||||
|
||||
@@ -233,6 +233,9 @@ class MockFileProxy(FileProxy):
|
||||
def get_relative_path(self) -> str:
|
||||
return self.relative_path
|
||||
|
||||
def is_glob_supported(self):
|
||||
return True
|
||||
|
||||
|
||||
class MockFileCollection(FileCollection):
|
||||
def __init__(self, file_paths, mock_reader: Callable[[str], str] = mock_reader_always_match):
|
||||
|
||||
Reference in new issue
Block a user