Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

fix(ingestion): stop caching parses made without the language's grammar (#4703)

Raghav Chamadiyaaec8c11498ad
diff --git a/packages/core/src/repowise/core/ingestion/models.py b/packages/core/src/repowise/core/ingestion/models.py
index e47cc84a2..ba8392dc6 100644
--- a/packages/core/src/repowise/core/ingestion/models.py
+++ b/packages/core/src/repowise/core/ingestion/models.py
@@ -797,6 +797,9 @@ class ParsedFile:
references: list[CallSite] = field(default_factory=list)
# Salesforce objects and fields this file names (see ``salesforce_schema``).
schema_refs: list[SchemaReference] = field(default_factory=list)
+ # Parsed without its language's grammar (not installed, or a download
+ # failed): a stand-in the parse cache must not keep once the grammar loads.
+ grammar_missing: bool = False
@property
def symbol_count(self) -> int:
diff --git a/packages/core/src/repowise/core/ingestion/parse_cache.py b/packages/core/src/repowise/core/ingestion/parse_cache.py
index d1506d04c..4739017ff 100644
--- a/packages/core/src/repowise/core/ingestion/parse_cache.py
+++ b/packages/core/src/repowise/core/ingestion/parse_cache.py
@@ -185,6 +185,8 @@ class ParseCache:
def put(self, parsed: ParsedFile, content_hash: str) -> None:
"""Snapshot *parsed* (call before any graph build mutates it)."""
+ if parsed.grammar_missing:
+ return # re-parse next run, when the grammar may have loaded
try:
blob = pickle.dumps(parsed, protocol=pickle.HIGHEST_PROTOCOL)
except Exception as exc:
diff --git a/packages/core/src/repowise/core/ingestion/parser/__init__.py b/packages/core/src/repowise/core/ingestion/parser/__init__.py
index 1ec853171..6a935985e 100644
--- a/packages/core/src/repowise/core/ingestion/parser/__init__.py
+++ b/packages/core/src/repowise/core/ingestion/parser/__init__.py
@@ -294,6 +294,7 @@ def _parse_without_grammar(
docstring=None,
parse_errors=[],
content_hash=content_hash,
+ grammar_missing=config is not None and language is None,
)
diff --git a/tests/unit/ingestion/parser/golden/apex.json b/tests/unit/ingestion/parser/golden/apex.json
index 998c37207..c0018796a 100644
--- a/tests/unit/ingestion/parser/golden/apex.json
+++ b/tests/unit/ingestion/parser/golden/apex.json
@@ -637,7 +637,8 @@
"Name"
]
}
- ]
+ ],
+ "grammar_missing": false
},
"apex/AccountTrigger.trigger": {
"file_info": {
@@ -753,7 +754,8 @@
"line": 1,
"path": []
}
- ]
+ ],
+ "grammar_missing": false
},
"apex/assertions.cls": {
"file_info": {
@@ -1230,7 +1232,8 @@
"line": 34,
"path": []
}
- ]
+ ],
+ "grammar_missing": false
},
"apex/classes.cls": {
"file_info": {
@@ -1719,7 +1722,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"apex/health_markers.cls": {
"file_info": {
@@ -2514,7 +2518,8 @@
"OwnerId"
]
}
- ]
+ ],
+ "grammar_missing": false
},
"apex/HealthMarkersTest.cls": {
"file_info": {
@@ -2700,7 +2705,8 @@
"line": 12,
"path": []
}
- ]
+ ],
+ "grammar_missing": false
},
"apex/nested.cls": {
"file_info": {
@@ -2906,7 +2912,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"apex/perf_io_in_loop.cls": {
"file_info": {
@@ -4125,6 +4132,7 @@
"Id"
]
}
- ]
+ ],
+ "grammar_missing": false
}
}
diff --git a/tests/unit/ingestion/parser/golden/cpp.json b/tests/unit/ingestion/parser/golden/cpp.json
index f1fb285d8..fff0653d6 100644
--- a/tests/unit/ingestion/parser/golden/cpp.json
+++ b/tests/unit/ingestion/parser/golden/cpp.json
@@ -364,7 +364,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"cpp/classes.cpp": {
"file_info": {
@@ -698,7 +699,8 @@
"argument_names": null
}
],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"cpp/nested.cpp": {
"file_info": {
@@ -800,6 +802,7 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
}
}
diff --git a/tests/unit/ingestion/parser/golden/csharp.json b/tests/unit/ingestion/parser/golden/csharp.json
index 0cc32ea94..3e0feb8d5 100644
--- a/tests/unit/ingestion/parser/golden/csharp.json
+++ b/tests/unit/ingestion/parser/golden/csharp.json
@@ -513,7 +513,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"csharp/assertions.cs": {
"file_info": {
@@ -900,7 +901,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"csharp/classes.cs": {
"file_info": {
@@ -1292,7 +1294,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"csharp/nested.cs": {
"file_info": {
@@ -1413,6 +1416,7 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
}
}
diff --git a/tests/unit/ingestion/parser/golden/dart.json b/tests/unit/ingestion/parser/golden/dart.json
index 4963f0c34..1659e98f3 100644
--- a/tests/unit/ingestion/parser/golden/dart.json
+++ b/tests/unit/ingestion/parser/golden/dart.json
@@ -75,7 +75,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"dart/classes.dart": {
"file_info": {
@@ -337,7 +338,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"dart/nested.dart": {
"file_info": {
@@ -439,7 +441,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"dart/perf_io_in_loop.dart": {
"file_info": {
@@ -750,6 +753,7 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
}
}
diff --git a/tests/unit/ingestion/parser/golden/go.json b/tests/unit/ingestion/parser/golden/go.json
index 55c42b629..450a5d1a8 100644
--- a/tests/unit/ingestion/parser/golden/go.json
+++ b/tests/unit/ingestion/parser/golden/go.json
@@ -99,7 +99,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"go/nested.go": {
"file_info": {
@@ -177,7 +178,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"go/perf_io_in_loop.go": {
"file_info": {
@@ -675,6 +677,7 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
}
}
diff --git a/tests/unit/ingestion/parser/golden/java.json b/tests/unit/ingestion/parser/golden/java.json
index ccfe21197..0aa6a85f2 100644
--- a/tests/unit/ingestion/parser/golden/java.json
+++ b/tests/unit/ingestion/parser/golden/java.json
@@ -120,7 +120,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"java/Nested.java": {
"file_info": {
@@ -218,7 +219,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"java/PerfIoInLoop.java": {
"file_info": {
@@ -778,6 +780,7 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
}
}
diff --git a/tests/unit/ingestion/parser/golden/javascript.json b/tests/unit/ingestion/parser/golden/javascript.json
index a8af2450c..217fab3e0 100644
--- a/tests/unit/ingestion/parser/golden/javascript.json
+++ b/tests/unit/ingestion/parser/golden/javascript.json
@@ -72,7 +72,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"javascript/route.js": {
"file_info": {
@@ -502,6 +503,7 @@
"argument_names": null
}
],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
}
}
diff --git a/tests/unit/ingestion/parser/golden/kotlin.json b/tests/unit/ingestion/parser/golden/kotlin.json
index 20bff71e2..dadb70aed 100644
--- a/tests/unit/ingestion/parser/golden/kotlin.json
+++ b/tests/unit/ingestion/parser/golden/kotlin.json
@@ -364,7 +364,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"kotlin/classes.kt": {
"file_info": {
@@ -741,7 +742,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"kotlin/nested.kt": {
"file_info": {
@@ -843,6 +845,7 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
}
}
diff --git a/tests/unit/ingestion/parser/golden/lean.json b/tests/unit/ingestion/parser/golden/lean.json
index 29bd8d1a6..87dc9b5fc 100644
--- a/tests/unit/ingestion/parser/golden/lean.json
+++ b/tests/unit/ingestion/parser/golden/lean.json
@@ -25,7 +25,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"lean/Main.lean": {
"file_info": {
@@ -90,7 +91,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"lean/Plain/Local.lean": {
"file_info": {
@@ -118,7 +120,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"lean/Public/Visible.lean": {
"file_info": {
@@ -146,6 +149,7 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
}
}
diff --git a/tests/unit/ingestion/parser/golden/pascal.json b/tests/unit/ingestion/parser/golden/pascal.json
index 38b8a6e5f..77f73dbe2 100644
--- a/tests/unit/ingestion/parser/golden/pascal.json
+++ b/tests/unit/ingestion/parser/golden/pascal.json
@@ -51,7 +51,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"pascal/nested.pas": {
"file_info": {
@@ -146,6 +147,7 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
}
}
diff --git a/tests/unit/ingestion/parser/golden/php.json b/tests/unit/ingestion/parser/golden/php.json
index 08b7cc2a4..399b4dcbd 100644
--- a/tests/unit/ingestion/parser/golden/php.json
+++ b/tests/unit/ingestion/parser/golden/php.json
@@ -243,7 +243,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"php/classes.php": {
"file_info": {
@@ -755,7 +756,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"php/clean.php": {
"file_info": {
@@ -833,7 +835,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"php/nested.php": {
"file_info": {
@@ -1136,6 +1139,7 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
}
}
diff --git a/tests/unit/ingestion/parser/golden/python.json b/tests/unit/ingestion/parser/golden/python.json
index f3bbcdd41..3a6652555 100644
--- a/tests/unit/ingestion/parser/golden/python.json
+++ b/tests/unit/ingestion/parser/golden/python.json
@@ -235,7 +235,8 @@
],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"python/classes.py": {
"file_info": {
@@ -560,7 +561,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"python/complex.py": {
"file_info": {
@@ -614,7 +616,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"python/conditionals.py": {
"file_info": {
@@ -716,7 +719,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"python/match.py": {
"file_info": {
@@ -794,7 +798,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"python/nested.py": {
"file_info": {
@@ -872,7 +877,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"python/perf_io_in_loop.py": {
"file_info": {
@@ -1650,7 +1656,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"python/py_overload_init.py": {
"file_info": {
@@ -2010,6 +2017,7 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
}
}
diff --git a/tests/unit/ingestion/parser/golden/ruby.json b/tests/unit/ingestion/parser/golden/ruby.json
index 435b2fc94..00c5253c3 100644
--- a/tests/unit/ingestion/parser/golden/ruby.json
+++ b/tests/unit/ingestion/parser/golden/ruby.json
@@ -243,7 +243,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"ruby/classes.rb": {
"file_info": {
@@ -575,7 +576,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"ruby/nested.rb": {
"file_info": {
@@ -966,7 +968,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"ruby/perf_io_in_loop.rb": {
"file_info": {
@@ -1775,6 +1778,7 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
}
}
diff --git a/tests/unit/ingestion/parser/golden/rust.json b/tests/unit/ingestion/parser/golden/rust.json
index 529e030e9..86b5c9660 100644
--- a/tests/unit/ingestion/parser/golden/rust.json
+++ b/tests/unit/ingestion/parser/golden/rust.json
@@ -99,7 +99,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"rust/flat_match.rs": {
"file_info": {
@@ -197,7 +198,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"rust/nested.rs": {
"file_info": {
@@ -272,7 +274,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"rust/perf_io_in_loop.rs": {
"file_info": {
@@ -810,6 +813,7 @@
"argument_names": null
}
],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
}
}
diff --git a/tests/unit/ingestion/parser/golden/scala.json b/tests/unit/ingestion/parser/golden/scala.json
index ebfd1f256..8e12c6c10 100644
--- a/tests/unit/ingestion/parser/golden/scala.json
+++ b/tests/unit/ingestion/parser/golden/scala.json
@@ -237,7 +237,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"scala/classes.scala": {
"file_info": {
@@ -731,7 +732,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"scala/nested.scala": {
"file_info": {
@@ -923,7 +925,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"scala/perf_io_in_loop.scala": {
"file_info": {
@@ -1519,6 +1522,7 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
}
}
diff --git a/tests/unit/ingestion/parser/golden/shell.json b/tests/unit/ingestion/parser/golden/shell.json
index 2306a78b7..43ac222d5 100644
--- a/tests/unit/ingestion/parser/golden/shell.json
+++ b/tests/unit/ingestion/parser/golden/shell.json
@@ -124,7 +124,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"shell/functions.sh": {
"file_info": {
@@ -259,7 +260,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"shell/sourcing.sh": {
"file_info": {
@@ -415,7 +417,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"shell/zero_functions.sh": {
"file_info": {
@@ -460,7 +463,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"shell/zshisms.zsh": {
"file_info": {
@@ -531,6 +535,7 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
}
}
diff --git a/tests/unit/ingestion/parser/golden/swift.json b/tests/unit/ingestion/parser/golden/swift.json
index 9a49642b7..7cd0a4461 100644
--- a/tests/unit/ingestion/parser/golden/swift.json
+++ b/tests/unit/ingestion/parser/golden/swift.json
@@ -375,7 +375,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"swift/nested.swift": {
"file_info": {
@@ -473,6 +474,7 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
}
}
diff --git a/tests/unit/ingestion/parser/golden/typescript.json b/tests/unit/ingestion/parser/golden/typescript.json
index df97feb72..3fa00e20d 100644
--- a/tests/unit/ingestion/parser/golden/typescript.json
+++ b/tests/unit/ingestion/parser/golden/typescript.json
@@ -721,7 +721,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"typescript/classes.ts": {
"file_info": {
@@ -1020,7 +1021,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"typescript/conditionals.ts": {
"file_info": {
@@ -1122,7 +1124,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"typescript/nested.ts": {
"file_info": {
@@ -1200,7 +1203,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"typescript/perf_io_in_loop.ts": {
"file_info": {
@@ -1425,7 +1429,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"typescript/ts_class_modifiers.ts": {
"file_info": {
@@ -1843,7 +1848,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"typescript/ts_module_consts.ts": {
"file_info": {
@@ -2031,7 +2037,8 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
},
"typescript/ts_overload_fn_method.ts": {
"file_info": {
@@ -2359,6 +2366,7 @@
"local_refs": [],
"registrars": [],
"references": [],
- "schema_refs": []
+ "schema_refs": [],
+ "grammar_missing": false
}
}
diff --git a/tests/unit/ingestion/test_parse_cache.py b/tests/unit/ingestion/test_parse_cache.py
index da994f07b..e610dbcf1 100644
--- a/tests/unit/ingestion/test_parse_cache.py
+++ b/tests/unit/ingestion/test_parse_cache.py
@@ -311,3 +311,30 @@ def test_cache_hit_stamps_content_hash(repo):
hit = cache.get(fi, content_hash)
assert hit is not None
assert hit.content_hash == content_hash
+
+
+def test_parse_without_grammar_is_not_cached(repo, monkeypatch):
+ """A file parsed while its grammar was unavailable (a failed download, a
+ missing package) must re-parse once the grammar loads, not be served
+ symbol-less from the cache."""
+ from repowise.core.ingestion import parser as parser_mod
+ from repowise.core.ingestion.parser import ASTParser
+
+ fi = _make_file_info(repo / "util.py", "util.py")
+ source = (repo / "util.py").read_bytes()
+ content_hash = compute_content_hash(source)
+
+ monkeypatch.setattr(parser_mod, "_get_language", lambda _tag: None)
+ degraded = ASTParser().parse_file(fi, source)
+ assert degraded.grammar_missing and degraded.symbols == []
+
+ cache = ParseCache(repo / ".repowise")
+ cache.put(degraded, content_hash)
+ cache.save()
+ monkeypatch.undo()
+
+ cache = ParseCache(repo / ".repowise")
+ cache.load()
+ assert cache.get(fi, content_hash) is None
+ parsed = ASTParser().parse_file(fi, source)
+ assert not parsed.grammar_missing and parsed.symbols