Get the entire AST for this file :param filename str: :param lang_params LanguageParams: :rtype: ast
(filename, lang_params)
| 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): |
no test coverage detected