MCPcopy Create free account
hub / github.com/Tencent/CodeAnalysis / Loong

Class Loong

client/tool/util/loong/loong_beta.py:23–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21
22
23class Loong(object):
24 def __init__(
25 self,
26 dbdir: str,
27 project_root: str,
28 jar_mode: bool = False,
29 ):
30 self.dbdir = dbdir
31 self.project_root = project_root
32 self.jar_mode = jar_mode
33
34 self.tool_home = os.environ.get("LOONG_BETA_HOME", "")
35
36 def parse(self):
37 cmds = self.get_cmd("APIFinder2", [
38 "path=%s" % self.project_root,
39 "useapi=true",
40 "out=%s" % os.path.join(self.dbdir, "codedog_bc.db"),
41 ])
42 SubProcController(
43 cmds,
44 stdout_line_callback=subprocc_log,
45 stderr_line_callback=subprocc_log,
46 ).wait()
47
48 def scan(self) -> list:
49 options = [
50 "--dbdir",
51 self.dbdir,
52 "--project_root",
53 self.project_root,
54 ]
55 if self.jar_mode:
56 options.append("--jar_mode")
57 cmds = self.get_cmd("Loong", options)
58 spc = SubProcController(
59 cmds,
60 stdout_line_callback=subprocc_log,
61 stderr_line_callback=subprocc_log,
62 )
63 spc.wait()
64
65 output_path = os.path.join(self.dbdir, "result.json")
66 f = open(output_path)
67 result = json.load(f)
68 f.close()
69 if not result:
70 result = []
71 return result
72
73 def get_cmd(self, tool_name: str, options: list) -> list:
74 tool_path = os.path.join(self.tool_home, "bin", settings.PLATFORMS[sys.platform], tool_name)
75 if settings.PLATFORMS[sys.platform] == "windows":
76 tool_path = f"{tool_path}.exe"
77 cmds = [tool_path]
78 cmds.extend(options)
79 return cmds
80

Callers 2

analyzeMethod · 0.90
analyzeMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected