1515 service reads from that commit's analysis.json and call graph (static_analysis.pkl), each fact once:
1616 the methods and graph nodes as one table per file, the calls, the component tree, and the few
1717 analysis edges that are no call. Analyses are read through analysis_reader, which takes either of
18- Core's analysis.json formats, legacy or "v1" .
18+ Core's analysis.json formats, current or legacy .
1919- metadata.json: the review artifact's metadata, with the merge base as the base.
2020- pr.json: the pull request's title, body, head commit and commit subjects.
2121- pr-files.json: the files changed between the two analysed commits, as GitHub's compare API lists them.
7878from urllib .parse import quote , urlparse
7979from urllib .request import Request , urlopen
8080
81- from analysis_reader import Method , component_members , method_edges , method_spans
81+ from analysis_reader import Analysis , Method , read
8282
8383# The service's limits on a request, which move with it. A Function URL takes 6 MB, measured after
8484# base64, and a compressed body goes through base64 on the way in: 4.5 MB of it arrives, and 5 MB is
@@ -298,7 +298,7 @@ def member(self, key: str) -> int | str:
298298 return key if row is None else row .number
299299
300300
301- def side_document (analysis : dict , graph : dict ) -> dict :
301+ def side_document (analysis : Analysis , graph : dict ) -> dict :
302302 """One commit's analysis and call graph as the service reads them, each fact once. The service's
303303 bundle.expand_side turns it back into both, in every field a feature reads.
304304
@@ -313,7 +313,7 @@ def side_document(analysis: dict, graph: dict) -> dict:
313313 (a key where the analysis lacks the method), or null for a parent holding exactly its children's.
314314 - extra_edges: the analysis's edges that are no call. The rest repeat the calls: on crate one of
315315 149,316 is not a call."""
316- table = _Table (method_spans ( analysis ) )
316+ table = _Table (analysis . methods )
317317 spans = []
318318 for name , node in (graph .get ("nodes" ) or {}).items ():
319319 row = table .add_node (name , node )
@@ -322,14 +322,14 @@ def side_document(analysis: dict, graph: dict) -> dict:
322322 files = table .number_rows ()
323323 calls , unplaced = _calls (graph .get ("edges" ) or [], table )
324324 called = {(caller , callee ) for caller , callees in calls for callee , * _ in callees }
325- edges = {(table .member (source ), table .member (target )) for source , target in method_edges ( analysis ) }
325+ edges = {(table .member (source ), table .member (target )) for source , target in analysis . edges }
326326 return {
327327 "version" : 1 ,
328328 "files" : files ,
329329 "unplaced" : unplaced ,
330330 "graph_spans" : [[row .number , start , end ] for row , start , end in spans ],
331331 "components" : _components (analysis , table ),
332- "relations" : _relations (analysis .get ("components_relations" )),
332+ "relations" : _relations (analysis .document . get ("components_relations" )),
333333 "calls" : calls ,
334334 "extra_edges" : sorted (edges - called , key = repr ),
335335 }
@@ -350,15 +350,15 @@ def _calls(edges: list[dict], table: _Table) -> tuple[list, list[str]]:
350350 return [[caller , by_caller [caller ]] for caller in sorted (by_caller )], unplaced
351351
352352
353- def _components (analysis : dict , table : _Table ) -> list :
353+ def _components (analysis : Analysis , table : _Table ) -> list :
354354 """The component tree in pre-order, each `[id, name, description, parent, members, relations]`.
355355 A parent's members are null when they are exactly its children's, which the service rebuilds."""
356- flat = _flatten (analysis .get ("components" ))
356+ flat = _flatten (analysis .document . get ("components" ))
357357 children : list [list [int ]] = [[] for _ in flat ]
358358 for position , (_ , parent ) in enumerate (flat ):
359359 if parent >= 0 :
360360 children [parent ].append (position )
361- by_file = component_members ( analysis )
361+ by_file = analysis . members
362362 members = [
363363 [table .member (f"{ path } |{ name } " ) for path , names in by_file [component ["component_id" ]].items () for name in names ]
364364 for component , _ in flat
@@ -437,7 +437,7 @@ def collect(env: dict) -> dict:
437437
438438def _side (analysis_path : Path ) -> str :
439439 """The side document of the commit whose analysis this is; its call graph lies beside it."""
440- analysis = json .loads (analysis_path .read_text ())
440+ analysis = read ( json .loads (analysis_path .read_text () ))
441441 graph = call_graph (analysis_path .parent / "static_analysis.pkl" )
442442 return json .dumps (side_document (analysis , graph ), separators = ("," , ":" ))
443443
0 commit comments