Skip to content

Commit cac53b0

Browse files
authored
feat: Disable File Parse Mode (#651)
# Motivation <!-- Why is this change necessary? --> # Content <!-- Please include a summary of the change --> # Testing <!-- How was the change tested? --> # Please check the following before marking your PR as ready for review - [ ] I have added tests for my changes - [ ] I have updated the documentation or added new documentation as needed
1 parent 7be765c commit cac53b0

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

src/codegen/configs/models/codebase.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def __init__(self, prefix: str = "CODEBASE", *args, **kwargs) -> None:
1515
full_range_index: bool = False
1616
ignore_process_errors: bool = True
1717
disable_graph: bool = False
18+
disable_file_parse: bool = False
1819
generics: bool = True
1920
import_resolution_overrides: dict[str, str] = Field(default_factory=lambda: {})
2021
ts_dependency_manager: bool = False

src/codegen/sdk/codebase/codebase_context.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,9 @@ def build_graph(self, repo_operator: RepoOperator) -> None:
211211

212212
# =====[ Add all files to the graph in parallel ]=====
213213
syncs = defaultdict(lambda: [])
214-
for filepath, _ in repo_operator.iter_files(subdirs=self.projects[0].subdirectories, extensions=self.extensions, ignore_list=GLOBAL_FILE_IGNORE_LIST):
215-
syncs[SyncType.ADD].append(self.to_absolute(filepath))
214+
if not self.config.disable_file_parse:
215+
for filepath, _ in repo_operator.iter_files(subdirs=self.projects[0].subdirectories, extensions=self.extensions, ignore_list=GLOBAL_FILE_IGNORE_LIST):
216+
syncs[SyncType.ADD].append(self.to_absolute(filepath))
216217
logger.info(f"> Parsing {len(syncs[SyncType.ADD])} files in {self.projects[0].subdirectories or 'ALL'} subdirectories with {self.extensions} extensions")
217218
self._process_diff_files(syncs, incremental=False)
218219
files: list[SourceFile] = self.get_nodes(NodeType.FILE)
@@ -252,19 +253,20 @@ def apply_diffs(self, diff_list: list[DiffLite]) -> None:
252253
else:
253254
logger.warning(f"Unhandled diff change type: {diff.change_type}")
254255
by_sync_type = defaultdict(lambda: [])
255-
for filepath, sync_type in files_to_sync.items():
256-
if self.get_file(filepath) is None:
257-
if sync_type is SyncType.DELETE:
258-
# SourceFile is already deleted, nothing to do here
259-
continue
260-
elif sync_type is SyncType.REPARSE:
261-
# SourceFile needs to be parsed for the first time
262-
sync_type = SyncType.ADD
263-
elif sync_type is SyncType.ADD:
264-
# If the file was deleted earlier, we need to reparse so we can remove old edges
265-
sync_type = SyncType.REPARSE
266-
267-
by_sync_type[sync_type].append(filepath)
256+
if not self.config.disable_file_parse:
257+
for filepath, sync_type in files_to_sync.items():
258+
if self.get_file(filepath) is None:
259+
if sync_type is SyncType.DELETE:
260+
# SourceFile is already deleted, nothing to do here
261+
continue
262+
elif sync_type is SyncType.REPARSE:
263+
# SourceFile needs to be parsed for the first time
264+
sync_type = SyncType.ADD
265+
elif sync_type is SyncType.ADD:
266+
# If the file was deleted earlier, we need to reparse so we can remove old edges
267+
sync_type = SyncType.REPARSE
268+
269+
by_sync_type[sync_type].append(filepath)
268270
self.generation += 1
269271
self._process_diff_files(by_sync_type)
270272

0 commit comments

Comments
 (0)