Get the entire AST for this file :param filename str: :param lang_params LanguageParams: :rtype: ast
(filename, lang_params)
| 259 | |
| 260 | @staticmethod |
| 261 | def get_tree(filename, lang_params): |
| 262 | """ |
| 263 | Get the entire AST for this file |
| 264 | |
| 265 | :param filename str: |
| 266 | :param lang_params LanguageParams: |
| 267 | :rtype: ast |
| 268 | """ |
| 269 | script_loc = os.path.join(os.path.dirname(os.path.realpath(__file__)), |
| 270 | "get_ast.js") |
| 271 | cmd = ["node", script_loc, lang_params.source_type, filename] |
| 272 | try: |
| 273 | output = subprocess.check_output(cmd, stderr=subprocess.PIPE) |
| 274 | except subprocess.CalledProcessError: |
| 275 | raise AssertionError( |
| 276 | "Acorn could not parse file %r. You may have a JS syntax error or " |
| 277 | "if this is an es6-style source, you may need to run code2flow " |
| 278 | "with --source-type=module. " |
| 279 | "For more detail, try running the command " |
| 280 | "\n acorn %s\n" |
| 281 | "Warning: Acorn CANNOT parse all javascript files. See their docs. " % |
| 282 | (filename, filename)) from None |
| 283 | tree = json.loads(output) |
| 284 | assert isinstance(tree, dict) |
| 285 | assert tree['type'] == 'Program' |
| 286 | return tree |
| 287 | |
| 288 | @staticmethod |
| 289 | def separate_namespaces(tree): |
nothing calls this directly
no outgoing calls
no test coverage detected