Improve handling of glob support in FileProxy, fixing tests

This commit is contained in:
Dominik Jain authored and Dominik Jain committed 2026-07-01 17:00:00 +02:00
1 parent 3096ac4fe2
commit d5d88d72eb
2 files changed
+14 -3

No files matched your search

+11 -3
View File
@@ -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}")
+3
View File
@@ -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):