MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / get_tree

Method get_tree

code2flow/php.py:244–264  ·  view source on GitHub ↗

Get the entire AST for this file :param filename str: :param lang_params LanguageParams: :rtype: ast

(filename, lang_params)

Source from the content-addressed store, hash-verified

242
243 @staticmethod
244 def get_tree(filename, lang_params):
245 """
246 Get the entire AST for this file
247
248 :param filename str:
249 :param lang_params LanguageParams:
250 :rtype: ast
251 """
252
253 outp, returncode = run_ast_parser(filename)
254 if returncode:
255 raise AssertionError(
256 "Could not parse file %r. You may have a syntax error. "
257 "For more detail, try running with `php %s`. " %
258 (filename, filename))
259
260 tree = json.loads(outp)
261 assert isinstance(tree, list)
262 if len(tree) == 1 and tree[0]['nodeType'] == 'Stmt_InlineHTML':
263 raise AssertionError("Tried to parse a file that is not likely PHP")
264 return tree
265
266 @staticmethod
267 def separate_namespaces(tree):

Callers 1

map_itFunction · 0.45

Calls 1

run_ast_parserFunction · 0.85

Tested by

no test coverage detected