Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions graphify/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -3345,6 +3345,39 @@ def extract(paths: list[Path], cache_root: Path | None = None) -> dict:
# Cross-file call resolution for all languages
# Each extractor saved unresolved calls in raw_calls. Now that we have all
# nodes from all files, resolve any callee that exists in another file.
_BCL_METHOD_BLOCKLIST = frozenset({
"contains", "equals", "gethashcode", "tostring", "gettype",
"compareto", "startswith", "endswith", "replace", "split",
"trim", "trimstart", "trimend", "substring", "indexof",
"lastindexof", "insert", "remove", "toarray", "tolist",
"todictionary", "count", "any", "all", "first", "firstordefault",
"last", "lastordefault", "single", "singleordefault",
"where", "select", "selectmany", "orderby", "orderbydescending",
"groupby", "skip", "take", "aggregate", "sum", "min", "max",
"average", "concat", "zip", "distinct", "union", "intersect",
"except", "reverse", "append", "prepend", "add", "clear",
"dispose", "close", "read", "write", "flush", "seek",
"getawaiter", "getresult", "configureawait",
"trygetvalue", "containskey", "containsvalue",
"format", "join", "isnullorempty", "isnullorwhitespace",
"parse", "tryparse",
"listasync", "getasync", "saveasync", "deleteasync",
"updateasync", "createasync", "findasync", "existsasync",
"executeasync", "sendasync", "receiveasync",
"openasync", "closeasync", "readasync", "writeasync",
"createdbcontext", "abortwithstatus",
"abortwithstatuscode", "map", "mapget", "mappost", "mapput",
"mapdelete", "useswagger", "useswaggerui",
"addsingleton", "addscoped", "addtransient",
"useendpoints", "userouting", "useauthorization",
"useauthentication", "usecors", "usehttpsredirection",
"getlogger", "loginformation", "logwarning", "logerror",
"logdebug", "logcritical",
"ok", "notfound", "badrequest", "unauthorized",
"nocontent", "created", "accepted",
"run", "build", "createbuilder",
})

global_label_to_nid: dict[str, str] = {}
for n in all_nodes:
raw = n.get("label", "")
Expand All @@ -3358,6 +3391,8 @@ def extract(paths: list[Path], cache_root: Path | None = None) -> dict:
callee = rc.get("callee", "")
if not callee:
continue
if callee.lower() in _BCL_METHOD_BLOCKLIST:
continue
tgt = global_label_to_nid.get(callee.lower())
caller = rc["caller_nid"]
if tgt and tgt != caller and (caller, tgt) not in existing_pairs:
Expand Down