ambitgraph 0.9.3__tar.gz → 0.9.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ambitgraph-0.9.3/ambitgraph.egg-info → ambitgraph-0.9.4}/PKG-INFO +1 -1
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/edges.py +6 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/langs.py +17 -4
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/symbols.py +361 -22
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/tables.py +37 -3
- {ambitgraph-0.9.3 → ambitgraph-0.9.4/ambitgraph.egg-info}/PKG-INFO +1 -1
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/pyproject.toml +1 -1
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/LICENSE +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/MANIFEST.in +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/README.md +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_contracts/__init__.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_contracts/edge.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_contracts/envelope.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_contracts/fields.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_contracts/grant.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_contracts/household.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_map/__init__.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_map/__main__.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_map/ambit-map-enrich.md +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_map/ambit-mapllm-contract.md +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_map/assistant.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_map/cli.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_map/daemon.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_map/dialects/__init__.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_map/dialects/contract.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_map/dialects/express_pack.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_map/dialects/fastapi_pack.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_map/dialects/flask_pack.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_map/dialects/nextjs_pack.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_map/dialects/supabase_pack.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_map/langmirror.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_map/load.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_map/mapllm.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_map/model.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_map/orchestrate.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_map/registry.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_map/serve.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_telegraph/__init__.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_telegraph/cli.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_telegraph/export.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_telegraph/ledger.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_telegraph/responsibility.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambit_telegraph/store.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/WALKTHROUGH.md +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/__init__.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/__main__.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/_delimited.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/cli.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/cockpit.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/codelib.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/config.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/console.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/demo.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/design_tokens.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/docs_discovery.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/doctor.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/duplication.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/emit.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/engine_identity.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/estimate.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/eval.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/explain.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/explain_stage.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/families.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/feeds.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/gate.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/gate_check.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/gate_server.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/harvest.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/html_safe.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/inventory.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/jscalls.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/jsobjects.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/mds.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/merge.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/merge_jsp.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/objects.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/omniscient_next/__init__.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/omniscient_next/_init_js.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/omniscient_next/charts.js +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/omniscient_next/classdiagram.js +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/omniscient_next/escape.js +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/omniscient_next/filterpanel.js +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/omniscient_next/graph.js +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/omniscient_next/insideview.js +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/omniscient_next/library.js +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/omniscient_next/next_embed.css +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/omniscient_next/objectcard.js +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/omniscient_next/paths.js +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/omniscient_next/search.js +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/omniscient_next/siderail.js +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/omniscient_next/standalone.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/omniscient_next/wholemap.js +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/parameterize.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/pipeline.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/portal.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/prompts.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/pycalls.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/pyshapes.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/ratify.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/report.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/reports.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/responsibility.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/sample.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/secretary.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/shell.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/stages.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/tasks.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/text_capture.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph/urcode.py +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph.egg-info/SOURCES.txt +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph.egg-info/dependency_links.txt +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph.egg-info/entry_points.txt +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph.egg-info/requires.txt +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/ambitgraph.egg-info/top_level.txt +0 -0
- {ambitgraph-0.9.3 → ambitgraph-0.9.4}/setup.cfg +0 -0
|
@@ -6950,6 +6950,12 @@ def build_edges_artifact(repo, symbols_artifact: dict, cfg, *,
|
|
|
6950
6950
|
# channel systems. JS/TS only, 0 on every corpus with none.
|
|
6951
6951
|
"event_sites_refused": event_sites_refused,
|
|
6952
6952
|
}
|
|
6953
|
+
# the files whose block comment never closes, as the table plane listed
|
|
6954
|
+
# them: the text after such a comment's opener was not read. Present only
|
|
6955
|
+
# when there is such a file, so a scan with none carries no key; its
|
|
6956
|
+
# sentence rides table_result["blind"] under the same condition.
|
|
6957
|
+
if table_result.get("comment_unclosed_files"):
|
|
6958
|
+
coverage["comment_unclosed_files"] = table_result["comment_unclosed_files"]
|
|
6953
6959
|
# The java exact-evidence tiers' counters: each token is its own
|
|
6954
6960
|
# flat, additive coverage key, present only when nonzero -- a scan
|
|
6955
6961
|
# with no such site (every non-java corpus included) carries none of
|
|
@@ -404,15 +404,28 @@ _GRAMMARLESS_BLANK_CONFIG = {
|
|
|
404
404
|
# comments are read. Guarded by tests/test_mapllm_blank.py ::
|
|
405
405
|
# test_kotlin_nested_block_comments_are_read_as_one_comment, named by
|
|
406
406
|
# symbol rather than by line because offsets go stale as code moves.
|
|
407
|
+
#
|
|
408
|
+
# string_reader names blank()'s Kotlin reader because A KOTLIN STRING MAY
|
|
409
|
+
# HOLD CODE: `"${if (deep) "/**/*.kt" else "/*.kt"}"` is ONE string, and
|
|
410
|
+
# the quotes inside its template belong to inner strings. The general
|
|
411
|
+
# string branch ends a string at the first unescaped quote, so it takes
|
|
412
|
+
# the inner strings' text for code -- and that text here spells a block
|
|
413
|
+
# comment opener. With nesting on, that false opener raises the depth,
|
|
414
|
+
# the file's next real comment cannot bring it back to zero, and the rest
|
|
415
|
+
# of the file is blanked: every table statement after it is lost. The
|
|
416
|
+
# reader ends the string where the language does. It is named here, not
|
|
417
|
+
# passed as a function, because this module is the lexical TABLE and
|
|
418
|
+
# symbols.py, which holds the readers, imports it. Guarded by
|
|
419
|
+
# tests/test_kotlin_string_templates.py.
|
|
407
420
|
".kt": dict(line_comments=("//",), block_comments=(("/*", "*/"),),
|
|
408
421
|
preserve_strings=('"', "'"), preserve_triple_quotes=('"""',),
|
|
409
|
-
nested_block_comments=True),
|
|
422
|
+
nested_block_comments=True, string_reader="kotlin"),
|
|
410
423
|
# KOTLIN SCRIPT. A VALUE COPY of ".kt" above, deliberately spelled out
|
|
411
424
|
# rather than aliased: this map is read as a table, and an entry that is a
|
|
412
425
|
# reference reads as a different KIND of thing than its neighbours. .kts is
|
|
413
426
|
# the same language and the same lexer -- build.gradle.kts is Kotlin -- so
|
|
414
|
-
# every word of the ".kt" comment above, INCLUDING THE NESTING OPT-IN
|
|
415
|
-
# applies here unchanged. Admitted in the same commit as .kt because
|
|
427
|
+
# every word of the ".kt" comment above, INCLUDING THE NESTING OPT-IN
|
|
428
|
+
# AND THE STRING READER, applies here unchanged. Admitted in the same commit as .kt because
|
|
416
429
|
# admitting one without the other leaves the other's files unmanifested,
|
|
417
430
|
# and an unadmitted extension is not reported as skipped -- it is simply
|
|
418
431
|
# absent from every coverage surface, so the miss is silent. Measured on
|
|
@@ -420,7 +433,7 @@ _GRAMMARLESS_BLANK_CONFIG = {
|
|
|
420
433
|
# .kt and 44 .kts, so dropping .kts would hide 44 of 617 Kotlin files.
|
|
421
434
|
".kts": dict(line_comments=("//",), block_comments=(("/*", "*/"),),
|
|
422
435
|
preserve_strings=('"', "'"), preserve_triple_quotes=('"""',),
|
|
423
|
-
nested_block_comments=True),
|
|
436
|
+
nested_block_comments=True, string_reader="kotlin"),
|
|
424
437
|
}
|
|
425
438
|
|
|
426
439
|
# THE BLANKING MODEL for JSP's own host-language lexical shape -- the
|
|
@@ -1152,6 +1152,207 @@ def _python_fstring_span(text: str, i: int, depth: int = 0) -> tuple:
|
|
|
1152
1152
|
return i, False
|
|
1153
1153
|
|
|
1154
1154
|
|
|
1155
|
+
# ===========================================================================
|
|
1156
|
+
# STRING READERS -- blank()'s `string_reader` hook. The general string
|
|
1157
|
+
# branches assume a string's own quote never occurs, unescaped, inside its
|
|
1158
|
+
# body. A language whose strings hold CODE breaks that: the code may hold
|
|
1159
|
+
# further strings, and a quote inside it belongs to the inner string. A
|
|
1160
|
+
# reader knows one language's rule for where such a string ends.
|
|
1161
|
+
#
|
|
1162
|
+
# A reader is called with the text and the index of a character that may
|
|
1163
|
+
# open one of its strings. It returns None -- no string of its kind opens
|
|
1164
|
+
# here, or one it cannot close -- or
|
|
1165
|
+
# (body_start, closer_start, span_end, comment_spans)
|
|
1166
|
+
# the string's body between its delimiters, the index just past its closer,
|
|
1167
|
+
# and the comments found in the code the string holds, as (start, end)
|
|
1168
|
+
# pairs in ascending order. blank() decides what is emitted for the span;
|
|
1169
|
+
# a reader only measures it. A reader that returns None computes no
|
|
1170
|
+
# fallback: blank()'s general branches then read the same position, so a
|
|
1171
|
+
# string a reader cannot close is read exactly as it is with no reader.
|
|
1172
|
+
# ===========================================================================
|
|
1173
|
+
|
|
1174
|
+
_KOTLIN_STRING_MAX_DEPTH = 200
|
|
1175
|
+
|
|
1176
|
+
|
|
1177
|
+
def _kotlin_character_literal_end(text: str, j: int):
|
|
1178
|
+
"""Return the index just past the character literal that opens at `j`.
|
|
1179
|
+
Logic: a backslash skips itself and the next character, the next single
|
|
1180
|
+
quote closes the literal, and a literal cannot cross a line.
|
|
1181
|
+
|
|
1182
|
+
@param text: the source text (str)
|
|
1183
|
+
@param j: the index of the literal's opening single quote (int)
|
|
1184
|
+
@return: the index just past the closing quote, or None when the line or
|
|
1185
|
+
the text ends first (int or None)
|
|
1186
|
+
"""
|
|
1187
|
+
n = len(text) # n: the text's length
|
|
1188
|
+
k = j + 1 # k: the scan position inside the literal
|
|
1189
|
+
while k < n:
|
|
1190
|
+
c = text[k] # c: the character under the scan
|
|
1191
|
+
if c == "\\" and k + 1 < n:
|
|
1192
|
+
k += 2
|
|
1193
|
+
continue
|
|
1194
|
+
if c == "'":
|
|
1195
|
+
return k + 1
|
|
1196
|
+
if c == "\n":
|
|
1197
|
+
return None
|
|
1198
|
+
k += 1
|
|
1199
|
+
return None
|
|
1200
|
+
|
|
1201
|
+
|
|
1202
|
+
def _kotlin_template_end(text: str, j: int, depth: int, comment_spans: list):
|
|
1203
|
+
"""Return the index just past the closing brace of a Kotlin template.
|
|
1204
|
+
Logic: the text after `${` is code. Braces are counted so a lambda's or a
|
|
1205
|
+
block's closing brace does not end the template; a double quote opens a
|
|
1206
|
+
string read by the string reader itself, so nothing inside it is taken
|
|
1207
|
+
for code; a character literal is skipped whole; a comment is skipped and
|
|
1208
|
+
recorded. The template ends at the closing brace met at brace depth zero.
|
|
1209
|
+
|
|
1210
|
+
@param text: the source text (str)
|
|
1211
|
+
@param j: the index just past the template's `${` (int)
|
|
1212
|
+
@param depth: how many strings enclose this template (int)
|
|
1213
|
+
@param comment_spans: the (start, end) pairs found so far, appended to (list)
|
|
1214
|
+
@return: the index just past the template's closing brace, or None when
|
|
1215
|
+
the template, a string in it or a comment in it never closes
|
|
1216
|
+
(int or None)
|
|
1217
|
+
"""
|
|
1218
|
+
n = len(text) # n: the text's length
|
|
1219
|
+
open_braces = 0 # braces opened inside the template and not yet closed
|
|
1220
|
+
while j < n:
|
|
1221
|
+
c = text[j] # c: the character under the scan
|
|
1222
|
+
if c == '"':
|
|
1223
|
+
inner = _kotlin_string_span(text, j, depth + 1, comment_spans)
|
|
1224
|
+
if inner is None:
|
|
1225
|
+
return None
|
|
1226
|
+
j = inner[2] # resume just past the inner string's closer
|
|
1227
|
+
continue
|
|
1228
|
+
if c == "'":
|
|
1229
|
+
j = _kotlin_character_literal_end(text, j)
|
|
1230
|
+
if j is None:
|
|
1231
|
+
return None
|
|
1232
|
+
continue
|
|
1233
|
+
if text.startswith("//", j):
|
|
1234
|
+
line_end = text.find("\n", j)
|
|
1235
|
+
line_end = n if line_end == -1 else line_end
|
|
1236
|
+
comment_spans.append((j, line_end))
|
|
1237
|
+
j = line_end
|
|
1238
|
+
continue
|
|
1239
|
+
if text.startswith("/*", j):
|
|
1240
|
+
comment_end, closed = _walk_nested_block_comment(text, j, "/*", "*/")
|
|
1241
|
+
if not closed:
|
|
1242
|
+
return None
|
|
1243
|
+
comment_spans.append((j, comment_end))
|
|
1244
|
+
j = comment_end
|
|
1245
|
+
continue
|
|
1246
|
+
if c == "{":
|
|
1247
|
+
open_braces += 1
|
|
1248
|
+
elif c == "}":
|
|
1249
|
+
if open_braces == 0:
|
|
1250
|
+
return j + 1
|
|
1251
|
+
open_braces -= 1
|
|
1252
|
+
j += 1
|
|
1253
|
+
return None
|
|
1254
|
+
|
|
1255
|
+
|
|
1256
|
+
def _kotlin_string_span(text: str, i: int, depth: int = 0, comment_spans=None):
|
|
1257
|
+
'''Measure the Kotlin string that opens at `i` -- blank()'s reader "kotlin".
|
|
1258
|
+
Logic: three quotes open a raw string, one quote a one-line string. In
|
|
1259
|
+
both, `${` opens a template whose code is read by `_kotlin_template_end`,
|
|
1260
|
+
and `$name` is plain text. A one-line string honours backslash escapes
|
|
1261
|
+
(so an escaped quote or dollar is text), closes at the next quote, and
|
|
1262
|
+
cannot cross a line in its own text -- though a template inside it can. A
|
|
1263
|
+
raw string has no escapes and closes at a run of three or more quotes,
|
|
1264
|
+
of which the last three are the closer and any before them are text.
|
|
1265
|
+
|
|
1266
|
+
@param text: the source text (str)
|
|
1267
|
+
@param i: the index of the opening double quote (int)
|
|
1268
|
+
@param depth: how many strings enclose this one; past
|
|
1269
|
+
_KOTLIN_STRING_MAX_DEPTH the reader declines (int)
|
|
1270
|
+
@param comment_spans: the (start, end) pairs found so far, or None to
|
|
1271
|
+
start a new list (list or None)
|
|
1272
|
+
@return: (body_start, closer_start, span_end, comment_spans), or None
|
|
1273
|
+
when the string or anything inside it never closes (tuple or None)
|
|
1274
|
+
'''
|
|
1275
|
+
if depth > _KOTLIN_STRING_MAX_DEPTH:
|
|
1276
|
+
return None
|
|
1277
|
+
if comment_spans is None:
|
|
1278
|
+
comment_spans = []
|
|
1279
|
+
n = len(text) # n: the text's length
|
|
1280
|
+
raw = text.startswith('"""', i)
|
|
1281
|
+
body_start = i + (3 if raw else 1)
|
|
1282
|
+
j = body_start # j: the scan position inside the string
|
|
1283
|
+
while j < n:
|
|
1284
|
+
c = text[j] # c: the character under the scan
|
|
1285
|
+
if c == '"':
|
|
1286
|
+
if not raw:
|
|
1287
|
+
return body_start, j, j + 1, comment_spans
|
|
1288
|
+
run_end = j
|
|
1289
|
+
while run_end < n and text[run_end] == '"':
|
|
1290
|
+
run_end += 1
|
|
1291
|
+
if run_end - j >= 3:
|
|
1292
|
+
# the last three quotes of the run close; earlier ones are text
|
|
1293
|
+
return body_start, run_end - 3, run_end, comment_spans
|
|
1294
|
+
j = run_end
|
|
1295
|
+
continue
|
|
1296
|
+
if not raw:
|
|
1297
|
+
if c == "\\" and j + 1 < n:
|
|
1298
|
+
j += 2
|
|
1299
|
+
continue
|
|
1300
|
+
if c == "\n":
|
|
1301
|
+
return None
|
|
1302
|
+
if text.startswith("${", j):
|
|
1303
|
+
j = _kotlin_template_end(text, j + 2, depth, comment_spans)
|
|
1304
|
+
if j is None:
|
|
1305
|
+
return None
|
|
1306
|
+
continue
|
|
1307
|
+
j += 1
|
|
1308
|
+
return None
|
|
1309
|
+
|
|
1310
|
+
|
|
1311
|
+
# name -> (the characters that can open one of the reader's strings, the reader).
|
|
1312
|
+
# The opener set lets blank() skip the call at every other character.
|
|
1313
|
+
_STRING_READERS = {
|
|
1314
|
+
"kotlin": ('"', _kotlin_string_span),
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
|
|
1318
|
+
def _string_reader_named(name):
|
|
1319
|
+
"""Return the opener characters and the function of the reader `name`.
|
|
1320
|
+
|
|
1321
|
+
@param name: a key of _STRING_READERS, or None for no reader (str or None)
|
|
1322
|
+
@return: (opener characters, reader function), or ("", None) for None (tuple)
|
|
1323
|
+
@raise ValueError: `name` is not a registered reader -- reading the text
|
|
1324
|
+
with no reader instead would be the mis-read the name was given
|
|
1325
|
+
to prevent, with no sign of it
|
|
1326
|
+
"""
|
|
1327
|
+
if name is None:
|
|
1328
|
+
return "", None
|
|
1329
|
+
if name not in _STRING_READERS:
|
|
1330
|
+
raise ValueError(
|
|
1331
|
+
f"blank(): no string reader named {name!r}; "
|
|
1332
|
+
f"known: {sorted(_STRING_READERS)}")
|
|
1333
|
+
return _STRING_READERS[name]
|
|
1334
|
+
|
|
1335
|
+
|
|
1336
|
+
def _keep_span_blanking(text: str, start: int, end: int, spans: list) -> str:
|
|
1337
|
+
"""Return text[start:end] verbatim except for `spans`, which are blanked.
|
|
1338
|
+
|
|
1339
|
+
@param text: the source text (str)
|
|
1340
|
+
@param start: the first index kept (int)
|
|
1341
|
+
@param end: the index just past the last one kept (int)
|
|
1342
|
+
@param spans: (start, end) pairs inside the range, ascending and
|
|
1343
|
+
non-overlapping (list)
|
|
1344
|
+
@return: the range, same length and newlines, each span as spaces (str)
|
|
1345
|
+
"""
|
|
1346
|
+
pieces = []
|
|
1347
|
+
position = start
|
|
1348
|
+
for span_start, span_end in spans:
|
|
1349
|
+
pieces.append(text[position:span_start])
|
|
1350
|
+
pieces.append(_blank_span(text[span_start:span_end]))
|
|
1351
|
+
position = span_end
|
|
1352
|
+
pieces.append(text[position:end])
|
|
1353
|
+
return "".join(pieces)
|
|
1354
|
+
|
|
1355
|
+
|
|
1155
1356
|
def blank(text: str, *, line_comments=(), block_comments=(),
|
|
1156
1357
|
strings=(), triple_quotes=(), preserve_strings=(),
|
|
1157
1358
|
preserve_triple_quotes=(), passthrough=(),
|
|
@@ -1161,7 +1362,9 @@ def blank(text: str, *, line_comments=(), block_comments=(),
|
|
|
1161
1362
|
delimited=(), preserve_delimited=(),
|
|
1162
1363
|
line_anchored_block_comments=(),
|
|
1163
1364
|
nested_block_comments: bool = False,
|
|
1164
|
-
python_fstrings: bool = False
|
|
1365
|
+
python_fstrings: bool = False,
|
|
1366
|
+
string_reader: str | None = None,
|
|
1367
|
+
report: dict | None = None) -> str:
|
|
1165
1368
|
"""Length-and-newline-preserving blank of comments and string-literal
|
|
1166
1369
|
CONTENT. A single hand-written scan (mirroring the mechanism, not the
|
|
1167
1370
|
code, of scan.py:84-122): one pass, one state at a time, so a `//`
|
|
@@ -1336,7 +1539,32 @@ def blank(text: str, *, line_comments=(), block_comments=(),
|
|
|
1336
1539
|
stopped the read. Emission still follows the ordinary
|
|
1337
1540
|
strings/triple_quotes vs. preserve_strings/preserve_triple_quotes
|
|
1338
1541
|
choice, keyed by whichever of those sets actually names this
|
|
1339
|
-
string's own delimiter.
|
|
1542
|
+
string's own delimiter.
|
|
1543
|
+
|
|
1544
|
+
`string_reader` (default None -- every caller that names none is
|
|
1545
|
+
unchanged): the NAME of a reader registered in _STRING_READERS, for a
|
|
1546
|
+
language whose strings hold code that may itself hold strings (Kotlin's
|
|
1547
|
+
`${...}` template). At a character that can open one of the reader's
|
|
1548
|
+
strings the reader is asked to measure it. When it returns a span, that
|
|
1549
|
+
span is emitted whole by the caller's own choice for the string's
|
|
1550
|
+
delimiter: blanked where the delimiter is in strings/triple_quotes;
|
|
1551
|
+
delimiters kept and body blanked where it is in interior_blank_strings;
|
|
1552
|
+
kept verbatim where it is in preserve_strings/preserve_triple_quotes,
|
|
1553
|
+
except that comments inside the code the string holds are blanked -- they
|
|
1554
|
+
are comments in the language, and a comments-only view that kept them
|
|
1555
|
+
would hand a commented-out statement to its readers. When the reader
|
|
1556
|
+
returns None, or the caller names the delimiter in none of those sets,
|
|
1557
|
+
nothing is emitted here and the branches below read the same position:
|
|
1558
|
+
the reader never computes a fallback of its own. An unregistered name
|
|
1559
|
+
raises ValueError.
|
|
1560
|
+
|
|
1561
|
+
`report` (default None): a dict this call marks with
|
|
1562
|
+
"block_comment_unclosed": True when a block comment of any form -- first
|
|
1563
|
+
closer, nesting, or line-anchored -- runs to the end of the text with no
|
|
1564
|
+
closer. The text after such a comment's opener is not read; the mark is
|
|
1565
|
+
how a caller that knows which file this is can say so. A comment whose
|
|
1566
|
+
closer is the last characters of the text is closed and leaves no mark."""
|
|
1567
|
+
reader_openers, read_string = _string_reader_named(string_reader)
|
|
1340
1568
|
out = []
|
|
1341
1569
|
i, n = 0, len(text)
|
|
1342
1570
|
pending_heredocs = [] # (tag, indent_allowed) opened on the current
|
|
@@ -1383,6 +1611,34 @@ def blank(text: str, *, line_comments=(), block_comments=(),
|
|
|
1383
1611
|
# scanned exactly as it would be with `python_fstrings`
|
|
1384
1612
|
# off, by construction rather than by a second,
|
|
1385
1613
|
# separately-maintained span computation.
|
|
1614
|
+
# THE STRING READER, before the triple-quote branch for the same
|
|
1615
|
+
# reason as the formatted-string branch above: a marker-to-next-marker
|
|
1616
|
+
# scan ends a string at a quote that belongs to a string inside it.
|
|
1617
|
+
# Entered only at a character the reader's strings can open. A span
|
|
1618
|
+
# the reader returns is emitted by the caller's own choice for its
|
|
1619
|
+
# delimiter; a declined string, or a delimiter the caller names in no
|
|
1620
|
+
# set, emits nothing and falls to the branches below.
|
|
1621
|
+
if read_string is not None and text[i] in reader_openers:
|
|
1622
|
+
measured = read_string(text, i)
|
|
1623
|
+
if measured is not None:
|
|
1624
|
+
body_start, closer_start, span_end, comment_spans = measured
|
|
1625
|
+
delimiter = text[i:body_start]
|
|
1626
|
+
if delimiter in strings or delimiter in triple_quotes:
|
|
1627
|
+
out.append(_blank_span(text[i:span_end]))
|
|
1628
|
+
i = span_end
|
|
1629
|
+
continue
|
|
1630
|
+
if delimiter in interior_blank_strings:
|
|
1631
|
+
out.append(delimiter)
|
|
1632
|
+
out.append(_blank_span(text[body_start:closer_start]))
|
|
1633
|
+
out.append(text[closer_start:span_end])
|
|
1634
|
+
i = span_end
|
|
1635
|
+
continue
|
|
1636
|
+
if (delimiter in preserve_strings
|
|
1637
|
+
or delimiter in preserve_triple_quotes):
|
|
1638
|
+
out.append(_keep_span_blanking(
|
|
1639
|
+
text, i, span_end, comment_spans))
|
|
1640
|
+
i = span_end
|
|
1641
|
+
continue
|
|
1386
1642
|
matched_triple = next((tq for tq in triple_quotes
|
|
1387
1643
|
if text.startswith(tq, i)), None)
|
|
1388
1644
|
preserve_triple = None
|
|
@@ -1468,6 +1724,7 @@ def blank(text: str, *, line_comments=(), block_comments=(),
|
|
|
1468
1724
|
if anchored:
|
|
1469
1725
|
close = anchored[1]
|
|
1470
1726
|
span_end = n
|
|
1727
|
+
closed = False
|
|
1471
1728
|
j = text.find("\n", i)
|
|
1472
1729
|
while j != -1:
|
|
1473
1730
|
start = j + 1
|
|
@@ -1476,8 +1733,11 @@ def blank(text: str, *, line_comments=(), block_comments=(),
|
|
|
1476
1733
|
or text[start + len(close)] in " \t\r\n")):
|
|
1477
1734
|
eol = text.find("\n", start)
|
|
1478
1735
|
span_end = (eol + 1) if eol != -1 else n
|
|
1736
|
+
closed = True
|
|
1479
1737
|
break
|
|
1480
1738
|
j = text.find("\n", start)
|
|
1739
|
+
if not closed and report is not None:
|
|
1740
|
+
report["block_comment_unclosed"] = True
|
|
1481
1741
|
out.append(_blank_span(text[i:span_end]))
|
|
1482
1742
|
i = span_end
|
|
1483
1743
|
continue
|
|
@@ -1492,11 +1752,26 @@ def blank(text: str, *, line_comments=(), block_comments=(),
|
|
|
1492
1752
|
# tail of what cannot compile.
|
|
1493
1753
|
span_end = _skip_nested_block_comment(
|
|
1494
1754
|
text, i, block[0], block[1])
|
|
1755
|
+
# WHETHER IT CLOSED. The helper's answer is an end index, and
|
|
1756
|
+
# an index at the end of the text is two different facts: a
|
|
1757
|
+
# comment whose closer is the text's last characters, and one
|
|
1758
|
+
# whose depth never returned to zero. Neither the index nor
|
|
1759
|
+
# the text's last characters can say which (`/* a /* b */`
|
|
1760
|
+
# ends in a closer and is still one level deep), so the walk
|
|
1761
|
+
# behind the helper is asked -- for this one comment, and
|
|
1762
|
+
# only when a caller wants the report.
|
|
1763
|
+
closed = True
|
|
1764
|
+
if span_end == n and report is not None:
|
|
1765
|
+
closed = _walk_nested_block_comment(
|
|
1766
|
+
text, i, block[0], block[1])[1]
|
|
1495
1767
|
else:
|
|
1496
1768
|
# UNTOUCHED, TEXTUALLY, so every caller that does not opt in
|
|
1497
1769
|
# is byte-identical BY CONSTRUCTION rather than by testing.
|
|
1498
1770
|
end = text.find(block[1], i + len(block[0]))
|
|
1499
1771
|
span_end = (end + len(block[1])) if end != -1 else n
|
|
1772
|
+
closed = end != -1
|
|
1773
|
+
if not closed and report is not None:
|
|
1774
|
+
report["block_comment_unclosed"] = True
|
|
1500
1775
|
out.append(_blank_span(text[i:span_end]))
|
|
1501
1776
|
i = span_end
|
|
1502
1777
|
continue
|
|
@@ -1762,8 +2037,14 @@ _JSP_TOP_LEVEL_CONFIG = langs._JSP_TOP_LEVEL_CONFIG
|
|
|
1762
2037
|
_JSP_CODE_SPAN = langs._JSP_CODE_SPAN
|
|
1763
2038
|
|
|
1764
2039
|
|
|
1765
|
-
def _jsp_top_level_blank(text: str) -> str:
|
|
1766
|
-
|
|
2040
|
+
def _jsp_top_level_blank(text: str, report: dict | None = None) -> str:
|
|
2041
|
+
"""Return a JSP file with its top-level `<%-- --%>` comments blanked.
|
|
2042
|
+
|
|
2043
|
+
@param text: the JSP source (str)
|
|
2044
|
+
@param report: blank()'s report, marked when such a comment never closes (dict or None)
|
|
2045
|
+
@return: the text, same length and newlines (str)
|
|
2046
|
+
"""
|
|
2047
|
+
return blank(text, report=report, **_JSP_TOP_LEVEL_CONFIG)
|
|
1767
2048
|
|
|
1768
2049
|
|
|
1769
2050
|
def _jsp_reblank_spans(top_blanked: str, raw_text: str, span_blank) -> str:
|
|
@@ -1784,7 +2065,10 @@ def _jsp_reblank_spans(top_blanked: str, raw_text: str, span_blank) -> str:
|
|
|
1784
2065
|
return "".join(out)
|
|
1785
2066
|
|
|
1786
2067
|
|
|
1787
|
-
def _jsp_comments_only_java(body: str) -> str:
|
|
2068
|
+
def _jsp_comments_only_java(body: str, report: dict | None = None) -> str:
|
|
2069
|
+
# `report` is blank()'s report, marked when a comment in this span's body
|
|
2070
|
+
# never closes; the unread text then runs to the end of the span.
|
|
2071
|
+
#
|
|
1788
2072
|
# a fix found while building request_sites' external-URL
|
|
1789
2073
|
# read: zeroing `strings` to () WITHOUT moving those quote chars into
|
|
1790
2074
|
# `preserve_strings` leaves the quote char unrecognized by blank() at
|
|
@@ -1821,7 +2105,7 @@ def _jsp_comments_only_java(body: str) -> str:
|
|
|
1821
2105
|
# unterminated-preserve-triple rule -- java-only (see blank()'s own
|
|
1822
2106
|
# docstring on this parameter for why it defaults to False and is
|
|
1823
2107
|
# never flipped for Python/shell's hash-syntax family).
|
|
1824
|
-
return blank(body, strict_unterminated_triple=True, **cfg)
|
|
2108
|
+
return blank(body, strict_unterminated_triple=True, report=report, **cfg)
|
|
1825
2109
|
|
|
1826
2110
|
|
|
1827
2111
|
# ===========================================================================
|
|
@@ -1923,7 +2207,8 @@ def blank_for_ext(ext: str, text: str, *, allow_unknown: bool = False,
|
|
|
1923
2207
|
|
|
1924
2208
|
|
|
1925
2209
|
def blank_comments_only(ext: str, text: str, *, allow_unknown: bool = False,
|
|
1926
|
-
lang: str | None = None
|
|
2210
|
+
lang: str | None = None,
|
|
2211
|
+
report: dict | None = None) -> str:
|
|
1927
2212
|
"""Like blank_for_ext, but does NOT blank string-literal content.
|
|
1928
2213
|
The includes/references extractors read a TARGET PATH that lives
|
|
1929
2214
|
inside a quoted string (`<%@ include file="x.jsp" %>`,
|
|
@@ -1954,14 +2239,21 @@ def blank_comments_only(ext: str, text: str, *, allow_unknown: bool = False,
|
|
|
1954
2239
|
the table-harvest lane's own false-fact class, closed here without
|
|
1955
2240
|
ever claiming a symbol grammar this engine does not have (see that
|
|
1956
2241
|
map's own module-level comment). An extension neither map knows still
|
|
1957
|
-
falls back to the old fail-open passthrough, unchanged.
|
|
2242
|
+
falls back to the old fail-open passthrough, unchanged.
|
|
2243
|
+
|
|
2244
|
+
`report` is blank()'s report, handed to every blanker call this function
|
|
2245
|
+
makes for the text -- the grammarless entry's, a grammar'd language's,
|
|
2246
|
+
and both pieces of a JSP file (its top level and each code span's body)
|
|
2247
|
+
-- so one dict says whether a block comment anywhere in the file ran to
|
|
2248
|
+
the end of what it was read in with no closer."""
|
|
1958
2249
|
lang = lang or _lang_or_raise(ext, "blank_comments_only", allow_unknown)
|
|
1959
2250
|
if lang is None:
|
|
1960
2251
|
gcfg = _GRAMMARLESS_BLANK_CONFIG.get(ext.lower())
|
|
1961
|
-
return blank(text, **gcfg) if gcfg is not None else text
|
|
2252
|
+
return blank(text, report=report, **gcfg) if gcfg is not None else text
|
|
1962
2253
|
if lang == "jsp":
|
|
1963
|
-
top = _jsp_top_level_blank(text)
|
|
1964
|
-
return _jsp_reblank_spans(
|
|
2254
|
+
top = _jsp_top_level_blank(text, report)
|
|
2255
|
+
return _jsp_reblank_spans(
|
|
2256
|
+
top, text, lambda body: _jsp_comments_only_java(body, report))
|
|
1965
2257
|
# See _jsp_comments_only_java's own
|
|
1966
2258
|
# comment just above for the mechanism: `.pop` into preserve_strings/
|
|
1967
2259
|
# preserve_triple_quotes (not a bare `= ()`) is what keeps the quote
|
|
@@ -1981,7 +2273,8 @@ def blank_comments_only(ext: str, text: str, *, allow_unknown: bool = False,
|
|
|
1981
2273
|
# test_40_hash_unterminated_triple_quote_blanks_to_eof_like_a_real_
|
|
1982
2274
|
# container pins it, unrelated to this change). sh/sql carry no
|
|
1983
2275
|
# triple_quotes key at all, so the flag is inert for them either way.
|
|
1984
|
-
return blank(text, strict_unterminated_triple=(lang == "java"),
|
|
2276
|
+
return blank(text, strict_unterminated_triple=(lang == "java"),
|
|
2277
|
+
report=report, **cfg)
|
|
1985
2278
|
|
|
1986
2279
|
|
|
1987
2280
|
# The comment-blanking law, extended to the CALL-NAME seam: the
|
|
@@ -2120,6 +2413,8 @@ class FileCache:
|
|
|
2120
2413
|
self.repo = Path(repo)
|
|
2121
2414
|
self._raw: dict = dict(texts or {})
|
|
2122
2415
|
self._blanked_comments_only: dict = {}
|
|
2416
|
+
# the files whose comments-only view ended inside a block comment
|
|
2417
|
+
self._comment_unclosed: set = set()
|
|
2123
2418
|
self._blanked_for_gate_matching: dict = {}
|
|
2124
2419
|
self._blanked_for_ext: dict = {}
|
|
2125
2420
|
self._header_lang: dict = {}
|
|
@@ -2191,10 +2486,28 @@ class FileCache:
|
|
|
2191
2486
|
lang = self.lang_of(uid, ext)
|
|
2192
2487
|
key = (uid, lang)
|
|
2193
2488
|
if key not in self._blanked_comments_only:
|
|
2489
|
+
report = {}
|
|
2194
2490
|
self._blanked_comments_only[key] = blank_comments_only(
|
|
2195
|
-
ext, self.raw(uid), allow_unknown=True, lang=lang
|
|
2491
|
+
ext, self.raw(uid), allow_unknown=True, lang=lang,
|
|
2492
|
+
report=report)
|
|
2493
|
+
if report.get("block_comment_unclosed"):
|
|
2494
|
+
self._comment_unclosed.add(uid)
|
|
2196
2495
|
return self._blanked_comments_only[key]
|
|
2197
2496
|
|
|
2497
|
+
def comment_unclosed(self, uid: str, ext: str) -> bool:
|
|
2498
|
+
"""Say whether a block comment in the file never closes as read.
|
|
2499
|
+
Logic: the mark is taken while the comments-only view is built, so the
|
|
2500
|
+
view is built here first if no reader has asked for it yet.
|
|
2501
|
+
|
|
2502
|
+
@param uid: the file's repository-relative path (str)
|
|
2503
|
+
@param ext: the file's extension, lower case (str)
|
|
2504
|
+
@return: True when the text after some block comment's opener was not
|
|
2505
|
+
read -- to the end of the file, or of the JSP code span that
|
|
2506
|
+
holds the comment (bool)
|
|
2507
|
+
"""
|
|
2508
|
+
self.blanked_comments_only(uid, ext)
|
|
2509
|
+
return uid in self._comment_unclosed
|
|
2510
|
+
|
|
2198
2511
|
def blanked_for_ext(self, uid: str, ext: str) -> str:
|
|
2199
2512
|
"""The per-scan cache (PY import-clause parsing): the shared per-scan
|
|
2200
2513
|
memo for the FULL (string-AND-comment) blanking mode -- same
|
|
@@ -6525,20 +6838,39 @@ def _swift_string_spans(text):
|
|
|
6525
6838
|
return spans
|
|
6526
6839
|
|
|
6527
6840
|
def _skip_nested_block_comment(text, i, opener, closer):
|
|
6528
|
-
"""
|
|
6529
|
-
|
|
6841
|
+
"""Return the index just past a NESTING block comment's outer closer.
|
|
6842
|
+
Logic: the walk itself is `_walk_nested_block_comment`; this is its answer
|
|
6843
|
+
for a caller that needs only where the comment ends.
|
|
6844
|
+
|
|
6845
|
+
@param text: the source text (str)
|
|
6846
|
+
@param i: the index of the comment's opener (int)
|
|
6847
|
+
@param opener: the opening marker (str)
|
|
6848
|
+
@param closer: the closing marker (str)
|
|
6849
|
+
@return: the index just past the outer closer, or len(text) when the
|
|
6850
|
+
comment never closes (int)
|
|
6851
|
+
"""
|
|
6852
|
+
return _walk_nested_block_comment(text, i, opener, closer)[0]
|
|
6853
|
+
|
|
6854
|
+
|
|
6855
|
+
def _walk_nested_block_comment(text, i, opener, closer):
|
|
6856
|
+
"""Walk a NESTING block comment from `i`; return the index just past its
|
|
6857
|
+
OUTER closer and whether that closer was found — the shared mechanism,
|
|
6858
|
+
with its markers as parameters.
|
|
6859
|
+
|
|
6860
|
+
The second value exists because the end of the text is two different
|
|
6861
|
+
facts: a comment whose closer is the text's last characters ends there
|
|
6862
|
+
CLOSED, and a comment whose depth never returns to zero ends there
|
|
6863
|
+
UNCLOSED. Only the walk knows which.
|
|
6530
6864
|
|
|
6531
6865
|
Nesting languages need this because a marker-to-next-marker scan closes at
|
|
6532
6866
|
the FIRST closer, which leaves `/* /* */ */`'s tail as live code and mints
|
|
6533
6867
|
declarations out of a comment's interior.
|
|
6534
6868
|
|
|
6535
6869
|
LANE-AGNOSTIC BY CONSTRUCTION: nothing here names a language. Swift passes
|
|
6536
|
-
`("/*", "*/")`; any other nesting language passes its own pair.
|
|
6537
|
-
from `_swift_skip_block_comment` as a PURE EQUIVALENCE REFACTOR — same
|
|
6538
|
-
walk, same returns, markers lifted out of the literals.
|
|
6870
|
+
`("/*", "*/")`; any other nesting language passes its own pair.
|
|
6539
6871
|
|
|
6540
|
-
UNTERMINATED → EOF, DELIBERATELY. When depth never returns to
|
|
6541
|
-
|
|
6872
|
+
UNTERMINATED → EOF, DELIBERATELY. When depth never returns to zero the
|
|
6873
|
+
end returned is `len(text)`, so an unterminated nest fails CLOSED and
|
|
6542
6874
|
mints nothing from the tail of what cannot compile; any bounded
|
|
6543
6875
|
alternative fails OPEN, leaving that tail live. A limit nobody asserts is
|
|
6544
6876
|
a limit nobody can rely on, so it is stated here and pinned by a test.
|
|
@@ -6550,6 +6882,13 @@ def _skip_nested_block_comment(text, i, opener, closer):
|
|
|
6550
6882
|
it would be a behaviour change wearing a refactor's hat. Whoever admits a
|
|
6551
6883
|
marker of another length changes this line in a FEATURE commit, with its
|
|
6552
6884
|
own red-first test.
|
|
6885
|
+
|
|
6886
|
+
@param text: the source text (str)
|
|
6887
|
+
@param i: the index of the comment's opener (int)
|
|
6888
|
+
@param opener: the opening marker (str)
|
|
6889
|
+
@param closer: the closing marker (str)
|
|
6890
|
+
@return: (the index just past the outer closer, True), or
|
|
6891
|
+
(len(text), False) when the depth never returns to zero (tuple)
|
|
6553
6892
|
"""
|
|
6554
6893
|
depth = 0
|
|
6555
6894
|
n = len(text)
|
|
@@ -6562,10 +6901,10 @@ def _skip_nested_block_comment(text, i, opener, closer):
|
|
|
6562
6901
|
depth -= 1
|
|
6563
6902
|
i += len(closer)
|
|
6564
6903
|
if depth == 0:
|
|
6565
|
-
return i
|
|
6904
|
+
return i, True
|
|
6566
6905
|
continue
|
|
6567
6906
|
i += 1
|
|
6568
|
-
return n
|
|
6907
|
+
return n, False
|
|
6569
6908
|
|
|
6570
6909
|
def _swift_consume_string(text, i, kind, hashes):
|
|
6571
6910
|
"""Consume a string body from `i` to its closing delimiter. Returns
|
|
@@ -60,6 +60,29 @@ INSERT_FORMS_BLIND_SENTENCE = (
|
|
|
60
60
|
"correctly, as a write -- the REPLACE INTO pattern matches inside it "
|
|
61
61
|
"regardless of the leading INSERT OR."
|
|
62
62
|
)
|
|
63
|
+
# Present only when a file has such a comment; built per scan because it
|
|
64
|
+
# carries the count and one file name.
|
|
65
|
+
COMMENT_UNCLOSED_SENTENCE_PREFIX = "a block comment never closes in "
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def comment_unclosed_blind_sentence(files: list) -> str:
|
|
69
|
+
"""Return the sentence that says some files' tails were not read.
|
|
70
|
+
Logic: a block comment with no closer is read to the end of its text, so
|
|
71
|
+
a table statement written after its opener is absent from this plane. The
|
|
72
|
+
sentence counts the files, names the first in sorted order, and points at
|
|
73
|
+
the coverage key that lists them all.
|
|
74
|
+
|
|
75
|
+
@param files: the files whose block comment never closes, at least one (list of str)
|
|
76
|
+
@return: one sentence starting with COMMENT_UNCLOSED_SENTENCE_PREFIX (str)
|
|
77
|
+
"""
|
|
78
|
+
ordered = sorted(files)
|
|
79
|
+
count = len(ordered)
|
|
80
|
+
return (
|
|
81
|
+
f"{COMMENT_UNCLOSED_SENTENCE_PREFIX}{count} file{'' if count == 1 else 's'}, "
|
|
82
|
+
"so no table statement after its opener was read there -- to the end "
|
|
83
|
+
"of the file, or of the JSP code span that holds it. The files are "
|
|
84
|
+
f"listed in coverage.comment_unclosed_files; the first is {ordered[0]}."
|
|
85
|
+
)
|
|
63
86
|
|
|
64
87
|
# A tiny reserved-word guard, checked against every _VERB_PATTERNS
|
|
65
88
|
# candidate name, not only a FROM-scoped one: the check in _table_sites
|
|
@@ -190,16 +213,21 @@ def build_tables(repo, uids: list, cache=None) -> dict:
|
|
|
190
213
|
omitted, this function builds its own throwaway cache
|
|
191
214
|
(sym.FileCache or None)
|
|
192
215
|
@return: {"tables": [rows...], "table_index": {...},
|
|
193
|
-
"unvalidated_names": N, "blind": [sentences...]}
|
|
216
|
+
"unvalidated_names": N, "blind": [sentences...]}, plus
|
|
217
|
+
"comment_unclosed_files": [uids...] only when some file's block
|
|
218
|
+
comment never closes (dict)
|
|
194
219
|
"""
|
|
195
220
|
repo = Path(repo)
|
|
196
221
|
cache = cache if cache is not None else sym.FileCache(repo)
|
|
197
222
|
per_file = {}
|
|
198
223
|
validated = set()
|
|
224
|
+
comment_unclosed = [] # the files whose tail this plane did not read
|
|
199
225
|
|
|
200
226
|
for uid in uids:
|
|
201
227
|
ext = Path(uid).suffix.lower() # ext: uid's extension (short for "extension")
|
|
202
228
|
blanked = cache.blanked_comments_only(uid, ext)
|
|
229
|
+
if cache.comment_unclosed(uid, ext):
|
|
230
|
+
comment_unclosed.append(uid)
|
|
203
231
|
sites = _table_sites(blanked)
|
|
204
232
|
per_file[uid] = (blanked, sites) # keep this file's text and sites together, for pass 2
|
|
205
233
|
for _start, op, name, string_built, validates in sites: # start position unused here
|
|
@@ -262,8 +290,14 @@ def build_tables(repo, uids: list, cache=None) -> dict:
|
|
|
262
290
|
blind.append(KNOWN_LIMITATION_BLIND_SENTENCE)
|
|
263
291
|
blind.append(INSERT_FORMS_BLIND_SENTENCE)
|
|
264
292
|
|
|
265
|
-
|
|
266
|
-
|
|
293
|
+
result = {"tables": rows, "table_index": table_index,
|
|
294
|
+
"unvalidated_names": unvalidated_names, "blind": blind}
|
|
295
|
+
# the list and its sentence appear only when there is such a file, so a
|
|
296
|
+
# tree with none returns exactly the four keys above
|
|
297
|
+
if comment_unclosed:
|
|
298
|
+
blind.append(comment_unclosed_blind_sentence(comment_unclosed))
|
|
299
|
+
result["comment_unclosed_files"] = sorted(comment_unclosed)
|
|
300
|
+
return result
|
|
267
301
|
|
|
268
302
|
|
|
269
303
|
def reconcile_table_totals(tables_indexed: int, table_index: dict) -> None:
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "ambitgraph"
|
|
7
|
-
version = "0.9.
|
|
7
|
+
version = "0.9.4"
|
|
8
8
|
description = "Read-only codebase scan: reusable units, families, roles, ownership candidates, duplication."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|