Given a language implementation and a list of filenames, do these things: 1. Read/parse source ASTs 2. Find all groups (classes/modules) and nodes (functions) (a lot happens here) 3. Trim namespaces / functions that we don't want 4. Consolidate groups / nodes given all we know s
(sources, extension, no_trimming, exclude_namespaces, exclude_functions,
include_only_namespaces, include_only_functions,
skip_parse_errors, lang_params)
| 430 | |
| 431 | |
| 432 | def map_it(sources, extension, no_trimming, exclude_namespaces, exclude_functions, |
| 433 | include_only_namespaces, include_only_functions, |
| 434 | skip_parse_errors, lang_params): |
| 435 | ''' |
| 436 | Given a language implementation and a list of filenames, do these things: |
| 437 | 1. Read/parse source ASTs |
| 438 | 2. Find all groups (classes/modules) and nodes (functions) (a lot happens here) |
| 439 | 3. Trim namespaces / functions that we don't want |
| 440 | 4. Consolidate groups / nodes given all we know so far |
| 441 | 5. Attempt to resolve the variables (point them to a node or group) |
| 442 | 6. Find all calls between all nodes |
| 443 | 7. Loudly complain about duplicate edges that were skipped |
| 444 | 8. Trim nodes that didn't connect to anything |
| 445 | |
| 446 | :param list[str] sources: |
| 447 | :param str extension: |
| 448 | :param bool no_trimming: |
| 449 | :param list exclude_namespaces: |
| 450 | :param list exclude_functions: |
| 451 | :param list include_only_namespaces: |
| 452 | :param list include_only_functions: |
| 453 | :param bool skip_parse_errors: |
| 454 | :param LanguageParams lang_params: |
| 455 | |
| 456 | :rtype: (list[Group], list[Node], list[Edge]) |
| 457 | ''' |
| 458 | |
| 459 | language = LANGUAGES[extension] |
| 460 | |
| 461 | # 0. Assert dependencies |
| 462 | language.assert_dependencies() |
| 463 | |
| 464 | # 1. Read/parse source ASTs |
| 465 | file_ast_trees = [] |
| 466 | for source in sources: |
| 467 | try: |
| 468 | file_ast_trees.append((source, language.get_tree(source, lang_params))) |
| 469 | except Exception as ex: |
| 470 | if skip_parse_errors: |
| 471 | logging.warning("Could not parse %r. (%r) Skipping...", source, ex) |
| 472 | else: |
| 473 | raise ex |
| 474 | |
| 475 | # 2. Find all groups (classes/modules) and nodes (functions) (a lot happens here) |
| 476 | file_groups = [] |
| 477 | for source, file_ast_tree in file_ast_trees: |
| 478 | file_group = make_file_group(file_ast_tree, source, extension) |
| 479 | file_groups.append(file_group) |
| 480 | |
| 481 | # 3. Trim namespaces / functions to exactly what we want |
| 482 | if exclude_namespaces or include_only_namespaces: |
| 483 | file_groups = _limit_namespaces(file_groups, exclude_namespaces, include_only_namespaces) |
| 484 | if exclude_functions or include_only_functions: |
| 485 | file_groups = _limit_functions(file_groups, exclude_functions, include_only_functions) |
| 486 | |
| 487 | # 4. Consolidate structures |
| 488 | all_subgroups = flatten(g.all_groups() for g in file_groups) |
| 489 | all_nodes = flatten(g.all_nodes() for g in file_groups) |
no test coverage detected