SERVER-103729 fix browser for new fields and switch to space rather than tab to separate loc from ctx (#36647)

GitOrigin-RevId: 710a49d9d21f6098879ebd85cf7da6d29588b084
This commit is contained in:
Mathias Stearn 2025-05-29 19:57:43 +02:00 committed by MongoDB Bot
parent 4164f376ba
commit eb948d70a0
4 changed files with 26 additions and 6 deletions

View File

@ -1110,6 +1110,16 @@ tasks:
- "./src/evergreen/run_python_script_with_report.sh"
- "validate-module-calls"
- "modules_poc/merge_decls.py"
- command: subprocess.exec
type: test
params:
binary: bash
args:
- "./src/evergreen/run_python_script_with_report.sh"
- "ensure-browser-can-parse-output"
- "modules_poc/browse.py"
- "merged_decls.json"
- "--parse-only"
- name: bazel_coverage
tags: ["assigned_to_jira_team_devprod_correctness", "auxiliary"]

View File

@ -49,7 +49,7 @@ class LocAndContext(NamedTuple):
@classmethod
def parse(cls, usage: str):
loc, ctx = usage.split("\t")
loc, _, ctx = usage.partition(" ")
return cls(Loc.parse(loc), sys.intern(ctx))
@ -224,11 +224,11 @@ def add_mod_loc_mapping_nodes(node: TreeNode, usages: Usages, kind: str, expand=
continue
# Currently only STATIC_ASSERT doesn't have a name.
[kind, *name] = loc.ctx.split(" ", 1)
kind, _, name = loc.ctx.partition(" ")
mod_node.add_leaf(
Text.assemble(
fancy_kind(kind),
Text(" " + name[0], style="bold bright_white") if name else "",
Text(" " + name, style="bold bright_white") if name else "",
f" {loc.loc}",
),
loc.loc,
@ -516,6 +516,9 @@ for d in raw_decls:
for mod, locs in d["other_mods"].items():
locs.sort()
d["other_mods"][mod] = [Loc.parse(loc) for loc in locs]
# For now these aren't used in the browser
del d["vis_from"]
del d["vis_from_non_ns"]
decls = sorted((Decl(**d) for d in raw_decls), key=lambda d: d.loc)
del raw_decls
@ -565,7 +568,7 @@ for f in files.values():
files = {k: v for k, v in sorted(files.items(), key=lambda kv: kv[1].unknown_count, reverse=True)}
modules = {d.mod for d in decls}
if __name__ == "__main__":
if __name__ == "__main__" and "--parse-only" not in sys.argv:
app = ModularityApp()
app.run()

View File

@ -784,7 +784,7 @@ def find_usages(mod: str, c: Cursor, context: DecoratedCursor | None):
# if this fails, something is missing in context_kinds or namespace_scope_context_kinds
assert context
usage = f"{pretty_location(c.location)}\t{context.string_for_context}"
usage = f"{pretty_location(c.location)} {context.string_for_context}"
d.used_from.setdefault(mod, set()).add(usage)

View File

@ -11,7 +11,14 @@ def _group_by_vis_map(vis_from):
group_by(.mod) |
map({
mod: .[0].mod,
locs: [.[].locs[]] | map(split("\t") | .[1]) | unique,
locs: [
.[].locs[] |
split(" ") |
if length == 3
then "\(.[1]) \(.[2])" # CXX_METHOD Foo::bar
else "\(.[1]) \(.[0])" # STATIC_ASSERT src/mongo/foo.cpp:123:45
end
] | unique,
}),
});