libv8 6.7.288.46.1 → 7.3.492.27.0beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/CHANGELOG.md +4 -0
- data/README.md +2 -0
- data/ext/libv8/builder.rb +6 -2
- data/lib/libv8/version.rb +1 -1
- data/vendor/depot_tools/.gitattributes +1 -0
- data/vendor/depot_tools/.gitignore +7 -0
- data/vendor/depot_tools/CROS_OWNERS +5 -0
- data/vendor/depot_tools/OWNERS +12 -1
- data/vendor/depot_tools/PRESUBMIT.py +16 -9
- data/vendor/depot_tools/README.md +9 -2
- data/vendor/depot_tools/autoninja +14 -6
- data/vendor/depot_tools/autoninja.bat +11 -1
- data/vendor/depot_tools/autoninja.py +40 -18
- data/vendor/depot_tools/bb +12 -0
- data/vendor/depot_tools/bb.bat +7 -0
- data/vendor/depot_tools/bootstrap/win/manifest.txt +1 -1
- data/vendor/depot_tools/bootstrap/win/manifest_bleeding_edge.txt +1 -1
- data/vendor/depot_tools/bootstrap/win/win_tools.py +2 -1
- data/vendor/depot_tools/buildbucket.py +57 -4
- data/vendor/depot_tools/cipd +157 -44
- data/vendor/depot_tools/cipd.bat +51 -14
- data/vendor/depot_tools/cipd.ps1 +104 -42
- data/vendor/depot_tools/cipd_client_version +1 -1
- data/vendor/depot_tools/cipd_client_version.digests +21 -0
- data/vendor/depot_tools/cipd_manifest.txt +19 -6
- data/vendor/depot_tools/cipd_manifest.versions +318 -0
- data/vendor/depot_tools/clang_format.py +4 -4
- data/vendor/depot_tools/cpplint.py +44 -199
- data/vendor/depot_tools/dart_format.py +2 -2
- data/vendor/depot_tools/detect_host_arch.py +8 -3
- data/vendor/depot_tools/download_from_google_storage.py +47 -39
- data/vendor/depot_tools/fetch.py +30 -18
- data/vendor/depot_tools/fetch_configs/android_internal.py +34 -0
- data/vendor/depot_tools/fetch_configs/chromium.py +18 -1
- data/vendor/depot_tools/fetch_configs/config_util.py +4 -2
- data/vendor/depot_tools/fetch_configs/inspector_protocol.py +40 -0
- data/vendor/depot_tools/fetch_configs/node-ci.py +41 -0
- data/vendor/depot_tools/fix_encoding.py +3 -3
- data/vendor/depot_tools/gclient +1 -1
- data/vendor/depot_tools/gclient.py +415 -198
- data/vendor/depot_tools/gclient_eval.py +220 -171
- data/vendor/depot_tools/gclient_paths.py +142 -0
- data/vendor/depot_tools/gclient_scm.py +200 -51
- data/vendor/depot_tools/gclient_utils.py +88 -191
- data/vendor/depot_tools/gerrit_client.py +13 -0
- data/vendor/depot_tools/gerrit_util.py +158 -23
- data/vendor/depot_tools/git-nav-upstream +1 -1
- data/vendor/depot_tools/git_cache.py +77 -24
- data/vendor/depot_tools/git_cl.py +705 -1099
- data/vendor/depot_tools/git_common.py +9 -6
- data/vendor/depot_tools/git_map_branches.py +19 -2
- data/vendor/depot_tools/git_nav_downstream.py +3 -4
- data/vendor/depot_tools/git_rebase_update.py +14 -0
- data/vendor/depot_tools/git_reparent_branch.py +8 -2
- data/vendor/depot_tools/gn.py +38 -3
- data/vendor/depot_tools/gsutil.py +8 -3
- data/vendor/depot_tools/gsutil.py.bat +15 -0
- data/vendor/depot_tools/gsutil.vpython +16 -0
- data/vendor/depot_tools/infra/config/OWNERS +0 -1
- data/vendor/depot_tools/infra/config/recipes.cfg +3 -2
- data/vendor/depot_tools/lucicfg +12 -0
- data/vendor/depot_tools/lucicfg.bat +7 -0
- data/vendor/depot_tools/man/html/git-map-branches.html +34 -2
- data/vendor/depot_tools/man/html/git-new-branch.html +40 -32
- data/vendor/depot_tools/man/man1/git-map-branches.1 +24 -5
- data/vendor/depot_tools/man/man1/git-new-branch.1 +35 -27
- data/vendor/depot_tools/man/src/git-map-branches.demo.1.sh +1 -0
- data/vendor/depot_tools/man/src/git-map-branches.txt +10 -0
- data/vendor/depot_tools/man/src/git-new-branch.demo.1.sh +9 -4
- data/vendor/depot_tools/man/src/git-new-branch.txt +1 -1
- data/vendor/depot_tools/metrics.README.md +98 -0
- data/vendor/depot_tools/metrics.py +296 -0
- data/vendor/depot_tools/metrics_utils.py +303 -0
- data/vendor/depot_tools/my_activity.py +91 -29
- data/vendor/depot_tools/ninja +1 -1
- data/vendor/depot_tools/ninjalog.README.md +64 -0
- data/vendor/depot_tools/ninjalog_uploader.py +232 -0
- data/vendor/depot_tools/ninjalog_uploader_wrapper.py +116 -0
- data/vendor/depot_tools/owners.py +30 -13
- data/vendor/depot_tools/owners_finder.py +5 -2
- data/vendor/depot_tools/presubmit_canned_checks.py +188 -29
- data/vendor/depot_tools/presubmit_support.py +18 -41
- data/vendor/depot_tools/pylintrc +23 -19
- data/vendor/depot_tools/recipes/OWNERS +2 -0
- data/vendor/depot_tools/recipes/README.recipes.md +344 -151
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/OWNERS +2 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/__init__.py +2 -16
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/api.py +141 -99
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic.json +5 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_luci.json +5 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_with_branch_heads.json +6 -98
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/clobber.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/deprecated_got_revision_mapping.json +45 -5
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_rebase_patch_ref.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_reset.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{tryjob.json → input_commit_with_id_without_repo.json} +6 -11
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{tryjob_empty_revision.json → multiple_patch_refs.json} +8 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_apply_patch_on_gclient.json +19 -29
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{trychange.json → refs.json} +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/reset_root_solution_revision.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail.json +51 -6
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch.json +50 -6
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch_download.json +51 -6
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle.json +17 -25
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_branch_heads.json +17 -25
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_feature_branch.json +18 -26
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8_feature_branch.json +18 -26
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_webrtc.json +26 -28
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8.json +45 -5
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8_head_by_default.json +17 -25
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/unrecognized_commit_repo.json +13 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_manifest_name.json +13 -152
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_tags.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.py +185 -202
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/resources/bot_update.py +52 -157
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/test_api.py +5 -14
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/tests/ensure_checkout.py +34 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/api.py +14 -2
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic_pkg.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-failed.json +7 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-many-instances.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/mac64.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_file.json +9 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_mode.json +9 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_verfile.json +9 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/win64.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk arch.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk bits.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_32.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_32.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_mips_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/mac_intel_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_32.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/api.py +13 -8
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic.json +18 -12
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic_luci.json +18 -12
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/win.json +18 -12
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.py +3 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/__init__.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/api.py +58 -46
- data/vendor/depot_tools/recipes/recipe_modules/gclient/config.py +65 -22
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/basic.json +20 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/buildbot.json +20 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/revision.json +20 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/tryserver.json +20 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.py +5 -2
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/patch_project.py +62 -14
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/api.py +24 -38
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/examples/full.expected/basic.json +56 -50
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/examples/full.py +15 -9
- data/vendor/depot_tools/recipes/recipe_modules/git/__init__.py +4 -1
- data/vendor/depot_tools/recipes/recipe_modules/git/api.py +34 -22
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_branch.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_file_name.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_hash.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_luci.json +222 -0
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_ref.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_submodule_update_force.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_tags.json +224 -0
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/can_fail_build.json +10 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cannot_fail_build.json +5 -7
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cat-file_test.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_delta.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_failed.json +5 -7
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output_fails_build.json +10 -5
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/curl_trace_file.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/git-cache-checkout.json +8 -9
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/platform_win.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/rebase_failed.json +12 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/remote_not_origin.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/set_got_revision.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.py +27 -11
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/api.py +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/examples/full.expected/basic.json +12 -13
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/__init__.py +5 -0
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/api.py +120 -5
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/examples/full.expected/basic.json +45 -3
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/examples/full.py +25 -0
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/resources/gerrit_client.py +56 -4
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/tests/parse_repo_url.expected/basic.json +6 -0
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/tests/parse_repo_url.py +49 -0
- data/vendor/depot_tools/recipes/recipe_modules/gsutil/api.py +24 -13
- data/vendor/depot_tools/recipes/recipe_modules/gsutil/examples/full.expected/basic.json +13 -14
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/basic.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_linux.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_mac.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_win.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_linux.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_mac.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_win.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_linux.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_mac.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_win.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/path_config.py +1 -2
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/__init__.py +35 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/api.py +116 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/linux.json +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/mac.json +82 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/win.json +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.py +23 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/__init__.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/api.py +2 -7
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/examples/full.expected/basic.json +7 -6
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/__init__.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/api.py +117 -8
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/basic_tags.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/set_failure_hash_with_no_steps.json +7 -4
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch.json +98 -7
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch_and_target_ref.json +147 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch.json +8 -5
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch_luci.json +8 -5
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch.json +9 -6
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch_new.json +9 -6
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.py +27 -2
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/test_api.py +14 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/__init__.py +25 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/api.py +137 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/linux.json +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/mac.json +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/win.json +107 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.py +26 -0
- data/vendor/depot_tools/recipes/recipes.py +37 -27
- data/vendor/depot_tools/recipes/recipes/fetch_end_to_end_test.expected/basic.json +7 -10
- data/vendor/depot_tools/repo +34 -8
- data/vendor/depot_tools/roll_dep.py +52 -49
- data/vendor/depot_tools/scm.py +38 -23
- data/vendor/depot_tools/setup_color.py +4 -2
- data/vendor/depot_tools/split_cl.py +32 -4
- data/vendor/depot_tools/subprocess2.py +22 -4
- data/vendor/depot_tools/third_party/httplib2/README.chromium +2 -2
- data/vendor/depot_tools/third_party/httplib2/__init__.py +242 -158
- data/vendor/depot_tools/third_party/httplib2/cacerts.txt +57 -44
- data/vendor/depot_tools/third_party/httplib2/socks.py +15 -5
- data/vendor/depot_tools/third_party/logilab/README.chromium +2 -4
- data/vendor/depot_tools/third_party/logilab/astroid/README.chromium +2 -1
- data/vendor/depot_tools/third_party/logilab/astroid/__init__.py +10 -5
- data/vendor/depot_tools/third_party/logilab/astroid/__pkginfo__.py +5 -5
- data/vendor/depot_tools/third_party/logilab/astroid/arguments.py +233 -0
- data/vendor/depot_tools/third_party/logilab/astroid/as_string.py +82 -33
- data/vendor/depot_tools/third_party/logilab/astroid/bases.py +137 -153
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{builtin_inference.py → brain_builtin_inference.py} +117 -26
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_dateutil.py +15 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{py2gi.py → brain_gi.py} +48 -8
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{py2mechanize.py → brain_mechanize.py} +0 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{pynose.py → brain_nose.py} +4 -1
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_numpy.py +62 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_pytest.py +76 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_qt.py +44 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{pysix_moves.py → brain_six.py} +28 -1
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_ssl.py +65 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_stdlib.py +473 -0
- data/vendor/depot_tools/third_party/logilab/astroid/builder.py +104 -81
- data/vendor/depot_tools/third_party/logilab/astroid/context.py +81 -0
- data/vendor/depot_tools/third_party/logilab/astroid/decorators.py +75 -0
- data/vendor/depot_tools/third_party/logilab/astroid/exceptions.py +20 -0
- data/vendor/depot_tools/third_party/logilab/astroid/inference.py +137 -183
- data/vendor/depot_tools/third_party/logilab/astroid/manager.py +45 -169
- data/vendor/depot_tools/third_party/logilab/astroid/mixins.py +37 -14
- data/vendor/depot_tools/third_party/logilab/astroid/modutils.py +112 -41
- data/vendor/depot_tools/third_party/logilab/astroid/node_classes.py +243 -156
- data/vendor/depot_tools/third_party/logilab/astroid/nodes.py +35 -22
- data/vendor/depot_tools/third_party/logilab/astroid/objects.py +186 -0
- data/vendor/depot_tools/third_party/logilab/astroid/protocols.py +157 -102
- data/vendor/depot_tools/third_party/logilab/astroid/raw_building.py +32 -8
- data/vendor/depot_tools/third_party/logilab/astroid/rebuilder.py +372 -309
- data/vendor/depot_tools/third_party/logilab/astroid/scoped_nodes.py +652 -420
- data/vendor/depot_tools/third_party/logilab/astroid/test_utils.py +4 -21
- data/vendor/depot_tools/third_party/logilab/astroid/transforms.py +96 -0
- data/vendor/depot_tools/third_party/logilab/astroid/util.py +89 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/LICENSE +19 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/README.chromium +11 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/__init__.py +20 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/cext.c +1421 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/compat.py +9 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/simple.py +246 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/slots.py +414 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/utils.py +13 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/LICENSE +24 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/README.chromium +11 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/__init__.py +19 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/_wrappers.c +2729 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/arguments.py +96 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/decorators.py +512 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/importer.py +228 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/wrappers.py +901 -0
- data/vendor/depot_tools/third_party/pylint/README.chromium +2 -25
- data/vendor/depot_tools/third_party/pylint/__pkginfo__.py +13 -3
- data/vendor/depot_tools/third_party/pylint/checkers/__init__.py +1 -2
- data/vendor/depot_tools/third_party/pylint/checkers/async.py +82 -0
- data/vendor/depot_tools/third_party/pylint/checkers/base.py +893 -119
- data/vendor/depot_tools/third_party/pylint/checkers/classes.py +342 -204
- data/vendor/depot_tools/third_party/pylint/checkers/design_analysis.py +51 -34
- data/vendor/depot_tools/third_party/pylint/checkers/exceptions.py +84 -47
- data/vendor/depot_tools/third_party/pylint/checkers/format.py +55 -30
- data/vendor/depot_tools/third_party/pylint/checkers/imports.py +314 -73
- data/vendor/depot_tools/third_party/pylint/checkers/logging.py +10 -8
- data/vendor/depot_tools/third_party/pylint/checkers/misc.py +2 -1
- data/vendor/depot_tools/third_party/pylint/checkers/newstyle.py +45 -48
- data/vendor/depot_tools/third_party/pylint/checkers/python3.py +31 -21
- data/vendor/depot_tools/third_party/pylint/checkers/raw_metrics.py +3 -3
- data/vendor/depot_tools/third_party/pylint/checkers/similar.py +4 -5
- data/vendor/depot_tools/third_party/pylint/checkers/spelling.py +24 -10
- data/vendor/depot_tools/third_party/pylint/checkers/stdlib.py +120 -56
- data/vendor/depot_tools/third_party/pylint/checkers/strings.py +38 -35
- data/vendor/depot_tools/third_party/pylint/checkers/typecheck.py +485 -138
- data/vendor/depot_tools/third_party/pylint/checkers/utils.py +319 -142
- data/vendor/depot_tools/third_party/pylint/checkers/variables.py +329 -207
- data/vendor/depot_tools/third_party/pylint/config.py +739 -76
- data/vendor/depot_tools/third_party/pylint/epylint.py +9 -5
- data/vendor/depot_tools/third_party/pylint/extensions/__init__.py +0 -0
- data/vendor/depot_tools/third_party/pylint/extensions/check_docs.py +311 -0
- data/vendor/depot_tools/third_party/pylint/extensions/check_elif.py +62 -0
- data/vendor/depot_tools/third_party/{logilab/common → pylint}/graph.py +30 -133
- data/vendor/depot_tools/third_party/pylint/gui.py +2 -2
- data/vendor/depot_tools/third_party/pylint/interfaces.py +21 -3
- data/vendor/depot_tools/third_party/pylint/lint.py +123 -140
- data/vendor/depot_tools/third_party/pylint/pyreverse/diadefslib.py +10 -13
- data/vendor/depot_tools/third_party/pylint/pyreverse/diagrams.py +15 -4
- data/vendor/depot_tools/third_party/pylint/pyreverse/inspector.py +372 -0
- data/vendor/depot_tools/third_party/pylint/pyreverse/main.py +30 -7
- data/vendor/depot_tools/third_party/pylint/pyreverse/utils.py +80 -2
- data/vendor/depot_tools/third_party/{logilab/common → pylint/pyreverse}/vcgutils.py +19 -37
- data/vendor/depot_tools/third_party/pylint/pyreverse/writer.py +3 -4
- data/vendor/depot_tools/third_party/pylint/reporters/__init__.py +34 -18
- data/vendor/depot_tools/third_party/pylint/reporters/guireporter.py +1 -1
- data/vendor/depot_tools/third_party/pylint/reporters/html.py +10 -3
- data/vendor/depot_tools/third_party/pylint/reporters/json.py +10 -4
- data/vendor/depot_tools/third_party/pylint/reporters/text.py +94 -3
- data/vendor/depot_tools/third_party/pylint/reporters/ureports/__init__.py +106 -0
- data/vendor/depot_tools/third_party/{logilab/common → pylint/reporters}/ureports/html_writer.py +17 -57
- data/vendor/depot_tools/third_party/{logilab/common → pylint/reporters}/ureports/nodes.py +52 -74
- data/vendor/depot_tools/third_party/{logilab/common → pylint/reporters}/ureports/text_writer.py +14 -60
- data/vendor/depot_tools/third_party/pylint/testutils.py +22 -20
- data/vendor/depot_tools/third_party/pylint/utils.py +268 -44
- data/vendor/depot_tools/third_party/repo/progress.py +42 -0
- data/vendor/depot_tools/update_depot_tools +1 -1
- data/vendor/depot_tools/upload_metrics.py +25 -0
- data/vendor/depot_tools/win_toolchain/get_toolchain_if_necessary.py +45 -15
- data/vendor/depot_tools/win_toolchain/package_from_installed.py +71 -24
- data/vendor/depot_tools/yapf +1 -1
- data/vendor/depot_tools/yapf.bat +1 -1
- metadata +92 -77
- data/vendor/depot_tools/git-crsync +0 -3
- data/vendor/depot_tools/infra/config/cq.cfg +0 -32
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/apply_gerrit_ref.json +0 -29
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/apply_gerrit_ref_custom.json +0 -29
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/buildbot.json +0 -105
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/shallow.json +0 -195
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle_deprecated.json +0 -248
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8.json +0 -248
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_manifest_name_no_patch.json +0 -105
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/resources/apply_gerrit.py +0 -33
- data/vendor/depot_tools/third_party/logilab/astroid/brain/py2pytest.py +0 -31
- data/vendor/depot_tools/third_party/logilab/astroid/brain/py2qt4.py +0 -22
- data/vendor/depot_tools/third_party/logilab/astroid/brain/py2stdlib.py +0 -334
- data/vendor/depot_tools/third_party/logilab/astroid/inspector.py +0 -273
- data/vendor/depot_tools/third_party/logilab/astroid/utils.py +0 -239
- data/vendor/depot_tools/third_party/logilab/common/LICENSE.txt +0 -339
- data/vendor/depot_tools/third_party/logilab/common/README.chromium +0 -11
- data/vendor/depot_tools/third_party/logilab/common/__init__.py +0 -175
- data/vendor/depot_tools/third_party/logilab/common/__pkginfo__.py +0 -57
- data/vendor/depot_tools/third_party/logilab/common/cache.py +0 -114
- data/vendor/depot_tools/third_party/logilab/common/changelog.py +0 -238
- data/vendor/depot_tools/third_party/logilab/common/clcommands.py +0 -334
- data/vendor/depot_tools/third_party/logilab/common/cli.py +0 -211
- data/vendor/depot_tools/third_party/logilab/common/compat.py +0 -78
- data/vendor/depot_tools/third_party/logilab/common/configuration.py +0 -1105
- data/vendor/depot_tools/third_party/logilab/common/contexts.py +0 -5
- data/vendor/depot_tools/third_party/logilab/common/corbautils.py +0 -117
- data/vendor/depot_tools/third_party/logilab/common/daemon.py +0 -101
- data/vendor/depot_tools/third_party/logilab/common/date.py +0 -335
- data/vendor/depot_tools/third_party/logilab/common/dbf.py +0 -231
- data/vendor/depot_tools/third_party/logilab/common/debugger.py +0 -214
- data/vendor/depot_tools/third_party/logilab/common/decorators.py +0 -281
- data/vendor/depot_tools/third_party/logilab/common/deprecation.py +0 -189
- data/vendor/depot_tools/third_party/logilab/common/fileutils.py +0 -404
- data/vendor/depot_tools/third_party/logilab/common/interface.py +0 -71
- data/vendor/depot_tools/third_party/logilab/common/logging_ext.py +0 -195
- data/vendor/depot_tools/third_party/logilab/common/modutils.py +0 -702
- data/vendor/depot_tools/third_party/logilab/common/optik_ext.py +0 -392
- data/vendor/depot_tools/third_party/logilab/common/optparser.py +0 -92
- data/vendor/depot_tools/third_party/logilab/common/proc.py +0 -277
- data/vendor/depot_tools/third_party/logilab/common/pyro_ext.py +0 -180
- data/vendor/depot_tools/third_party/logilab/common/pytest.py +0 -1199
- data/vendor/depot_tools/third_party/logilab/common/registry.py +0 -1119
- data/vendor/depot_tools/third_party/logilab/common/shellutils.py +0 -462
- data/vendor/depot_tools/third_party/logilab/common/sphinx_ext.py +0 -87
- data/vendor/depot_tools/third_party/logilab/common/sphinxutils.py +0 -122
- data/vendor/depot_tools/third_party/logilab/common/table.py +0 -929
- data/vendor/depot_tools/third_party/logilab/common/tasksqueue.py +0 -101
- data/vendor/depot_tools/third_party/logilab/common/testlib.py +0 -1392
- data/vendor/depot_tools/third_party/logilab/common/textutils.py +0 -537
- data/vendor/depot_tools/third_party/logilab/common/tree.py +0 -369
- data/vendor/depot_tools/third_party/logilab/common/umessage.py +0 -194
- data/vendor/depot_tools/third_party/logilab/common/ureports/__init__.py +0 -172
- data/vendor/depot_tools/third_party/logilab/common/ureports/docbook_writer.py +0 -140
- data/vendor/depot_tools/third_party/logilab/common/urllib2ext.py +0 -89
- data/vendor/depot_tools/third_party/logilab/common/visitor.py +0 -109
- data/vendor/depot_tools/third_party/logilab/common/xmlrpcutils.py +0 -131
- data/vendor/depot_tools/third_party/logilab/common/xmlutils.py +0 -61
@@ -19,9 +19,8 @@
|
|
19
19
|
(build_* functions) or from living object (object_build_* functions)
|
20
20
|
"""
|
21
21
|
|
22
|
-
__docformat__ = "restructuredtext en"
|
23
|
-
|
24
22
|
import sys
|
23
|
+
import os
|
25
24
|
from os.path import abspath
|
26
25
|
from inspect import (getargspec, isdatadescriptor, isfunction, ismethod,
|
27
26
|
ismethoddescriptor, isclass, isbuiltin, ismodule)
|
@@ -35,6 +34,8 @@ from astroid.manager import AstroidManager
|
|
35
34
|
MANAGER = AstroidManager()
|
36
35
|
|
37
36
|
_CONSTANTS = tuple(CONST_CLS) # the keys of CONST_CLS eg python builtin types
|
37
|
+
_JYTHON = os.name == 'java'
|
38
|
+
_BUILTINS = vars(six.moves.builtins)
|
38
39
|
|
39
40
|
def _io_discrepancy(member):
|
40
41
|
# _io module names itself `io`: http://bugs.python.org/issue18602
|
@@ -48,6 +49,18 @@ def _attach_local_node(parent, node, name):
|
|
48
49
|
node.name = name # needed by add_local_node
|
49
50
|
parent.add_local_node(node)
|
50
51
|
|
52
|
+
|
53
|
+
def _add_dunder_class(func, member):
|
54
|
+
"""Add a __class__ member to the given func node, if we can determine it."""
|
55
|
+
python_cls = member.__class__
|
56
|
+
cls_name = getattr(python_cls, '__name__', None)
|
57
|
+
if not cls_name:
|
58
|
+
return
|
59
|
+
bases = [ancestor.__name__ for ancestor in python_cls.__bases__]
|
60
|
+
ast_klass = build_class(cls_name, bases, python_cls.__doc__)
|
61
|
+
func._instance_attrs['__class__'] = [ast_klass]
|
62
|
+
|
63
|
+
|
51
64
|
_marker = object()
|
52
65
|
|
53
66
|
def attach_dummy_node(node, name, object=_marker):
|
@@ -170,6 +183,7 @@ def object_build_methoddescriptor(node, member, localname):
|
|
170
183
|
# and empty argument list
|
171
184
|
func.args.args = None
|
172
185
|
node.add_local_node(func, localname)
|
186
|
+
_add_dunder_class(func, member)
|
173
187
|
|
174
188
|
def _base_class_object_build(node, member, basenames, name=None, localname=None):
|
175
189
|
"""create astroid for a living class object, with a given set of base names
|
@@ -196,7 +210,7 @@ def _base_class_object_build(node, member, basenames, name=None, localname=None)
|
|
196
210
|
valnode.object = obj
|
197
211
|
valnode.parent = klass
|
198
212
|
valnode.lineno = 1
|
199
|
-
klass.
|
213
|
+
klass._instance_attrs[name] = [valnode]
|
200
214
|
return klass
|
201
215
|
|
202
216
|
|
@@ -228,7 +242,7 @@ class InspectBuilder(object):
|
|
228
242
|
except AttributeError:
|
229
243
|
# in jython, java modules have no __doc__ (see #109562)
|
230
244
|
node = build_module(modname)
|
231
|
-
node.
|
245
|
+
node.source_file = path and abspath(path) or path
|
232
246
|
node.name = modname
|
233
247
|
MANAGER.cache_module(node)
|
234
248
|
node.package = hasattr(module, '__path__')
|
@@ -273,7 +287,7 @@ class InspectBuilder(object):
|
|
273
287
|
continue
|
274
288
|
if member in self._done:
|
275
289
|
class_node = self._done[member]
|
276
|
-
if not class_node in node.
|
290
|
+
if not class_node in node._locals.get(name, ()):
|
277
291
|
node.add_local_node(class_node, name)
|
278
292
|
else:
|
279
293
|
class_node = object_build_class(node, member, name)
|
@@ -307,7 +321,8 @@ class InspectBuilder(object):
|
|
307
321
|
traceback.print_exc()
|
308
322
|
modname = None
|
309
323
|
if modname is None:
|
310
|
-
if name in ('__new__', '__subclasshook__')
|
324
|
+
if (name in ('__new__', '__subclasshook__')
|
325
|
+
or (name in _BUILTINS and _JYTHON)):
|
311
326
|
# Python 2.5.1 (r251:54863, Sep 1 2010, 22:03:14)
|
312
327
|
# >>> print object.__new__.__module__
|
313
328
|
# None
|
@@ -315,7 +330,13 @@ class InspectBuilder(object):
|
|
315
330
|
else:
|
316
331
|
attach_dummy_node(node, name, member)
|
317
332
|
return True
|
318
|
-
|
333
|
+
|
334
|
+
real_name = {
|
335
|
+
'gtk': 'gtk_gtk',
|
336
|
+
'_io': 'io',
|
337
|
+
}.get(modname, modname)
|
338
|
+
|
339
|
+
if real_name != self._module.__name__:
|
319
340
|
# check if it sounds valid and then add an import node, else use a
|
320
341
|
# dummy node
|
321
342
|
try:
|
@@ -337,13 +358,16 @@ def _astroid_bootstrapping(astroid_builtin=None):
|
|
337
358
|
# this boot strapping is necessary since we need the Const nodes to
|
338
359
|
# inspect_build builtins, and then we can proxy Const
|
339
360
|
if astroid_builtin is None:
|
340
|
-
from
|
361
|
+
from six.moves import builtins
|
341
362
|
astroid_builtin = Astroid_BUILDER.inspect_build(builtins)
|
342
363
|
|
343
364
|
for cls, node_cls in CONST_CLS.items():
|
344
365
|
if cls is type(None):
|
345
366
|
proxy = build_class('NoneType')
|
346
367
|
proxy.parent = astroid_builtin
|
368
|
+
elif cls is type(NotImplemented):
|
369
|
+
proxy = build_class('NotImplementedType')
|
370
|
+
proxy.parent = astroid_builtin
|
347
371
|
else:
|
348
372
|
proxy = astroid_builtin.getattr(cls.__name__)[0]
|
349
373
|
if cls in (dict, list, set, tuple):
|
@@ -20,10 +20,10 @@ order to get a single Astroid representation
|
|
20
20
|
"""
|
21
21
|
|
22
22
|
import sys
|
23
|
+
import _ast
|
23
24
|
from _ast import (
|
24
|
-
Expr as Discard, Str,
|
25
25
|
# binary operators
|
26
|
-
Add,
|
26
|
+
Add, Div, FloorDiv, Mod, Mult, Pow, Sub, BitAnd, BitOr, BitXor,
|
27
27
|
LShift, RShift,
|
28
28
|
# logical operators
|
29
29
|
And, Or,
|
@@ -50,6 +50,9 @@ _BIN_OP_CLASSES = {Add: '+',
|
|
50
50
|
LShift: '<<',
|
51
51
|
RShift: '>>',
|
52
52
|
}
|
53
|
+
if sys.version_info >= (3, 5):
|
54
|
+
from _ast import MatMult
|
55
|
+
_BIN_OP_CLASSES[MatMult] = '@'
|
53
56
|
|
54
57
|
_BOOL_OP_CLASSES = {And: 'and',
|
55
58
|
Or: 'or',
|
@@ -79,19 +82,11 @@ CONST_NAME_TRANSFORMS = {'None': None,
|
|
79
82
|
}
|
80
83
|
|
81
84
|
REDIRECT = {'arguments': 'Arguments',
|
82
|
-
'Attribute': 'Getattr',
|
83
85
|
'comprehension': 'Comprehension',
|
84
|
-
'Call': 'CallFunc',
|
85
|
-
'ClassDef': 'Class',
|
86
86
|
"ListCompFor": 'Comprehension',
|
87
87
|
"GenExprFor": 'Comprehension',
|
88
88
|
'excepthandler': 'ExceptHandler',
|
89
|
-
'Expr': 'Discard',
|
90
|
-
'FunctionDef': 'Function',
|
91
|
-
'GeneratorExp': 'GenExpr',
|
92
|
-
'ImportFrom': 'From',
|
93
89
|
'keyword': 'Keyword',
|
94
|
-
'Repr': 'Backquote',
|
95
90
|
}
|
96
91
|
PY3K = sys.version_info >= (3, 0)
|
97
92
|
PY34 = sys.version_info >= (3, 4)
|
@@ -99,7 +94,7 @@ PY34 = sys.version_info >= (3, 4)
|
|
99
94
|
def _init_set_doc(node, newnode):
|
100
95
|
newnode.doc = None
|
101
96
|
try:
|
102
|
-
if isinstance(node.body[0],
|
97
|
+
if isinstance(node.body[0], _ast.Expr) and isinstance(node.body[0].value, _ast.Str):
|
103
98
|
newnode.doc = node.body[0].value.s
|
104
99
|
node.body = node.body[1:]
|
105
100
|
|
@@ -122,9 +117,21 @@ def _create_yield_node(node, parent, rebuilder, factory):
|
|
122
117
|
newnode = factory()
|
123
118
|
_lineno_parent(node, newnode, parent)
|
124
119
|
if node.value is not None:
|
125
|
-
newnode.value = rebuilder.visit(node.value, newnode)
|
120
|
+
newnode.value = rebuilder.visit(node.value, newnode, None)
|
126
121
|
return newnode
|
127
122
|
|
123
|
+
def _visit_or_none(node, attr, visitor, parent, assign_ctx, visit='visit',
|
124
|
+
**kws):
|
125
|
+
"""If the given node has an attribute, visits the attribute, and
|
126
|
+
otherwise returns None.
|
127
|
+
|
128
|
+
"""
|
129
|
+
value = getattr(node, attr, None)
|
130
|
+
if value:
|
131
|
+
return getattr(visitor, visit)(value, parent, assign_ctx, **kws)
|
132
|
+
else:
|
133
|
+
return None
|
134
|
+
|
128
135
|
|
129
136
|
class TreeRebuilder(object):
|
130
137
|
"""Rebuilds the _ast tree to become an Astroid tree"""
|
@@ -133,10 +140,9 @@ class TreeRebuilder(object):
|
|
133
140
|
self._manager = manager
|
134
141
|
self.asscontext = None
|
135
142
|
self._global_names = []
|
136
|
-
self.
|
143
|
+
self._import_from_nodes = []
|
137
144
|
self._delayed_assattr = []
|
138
145
|
self._visit_meths = {}
|
139
|
-
self._transform = manager.transform
|
140
146
|
self._peepholer = astpeephole.ASTPeepholeOptimizer()
|
141
147
|
|
142
148
|
def visit_module(self, node, modname, modpath, package):
|
@@ -146,10 +152,10 @@ class TreeRebuilder(object):
|
|
146
152
|
newnode.parent = None
|
147
153
|
_init_set_doc(node, newnode)
|
148
154
|
newnode.body = [self.visit(child, newnode) for child in node.body]
|
149
|
-
newnode.
|
150
|
-
return
|
155
|
+
newnode.source_file = modpath
|
156
|
+
return newnode
|
151
157
|
|
152
|
-
def visit(self, node, parent):
|
158
|
+
def visit(self, node, parent, assign_ctx=None):
|
153
159
|
cls = node.__class__
|
154
160
|
if cls in self._visit_meths:
|
155
161
|
visit_method = self._visit_meths[cls]
|
@@ -158,7 +164,7 @@ class TreeRebuilder(object):
|
|
158
164
|
visit_name = 'visit_' + REDIRECT.get(cls_name, cls_name).lower()
|
159
165
|
visit_method = getattr(self, visit_name)
|
160
166
|
self._visit_meths[cls] = visit_method
|
161
|
-
return
|
167
|
+
return visit_method(node, parent, assign_ctx)
|
162
168
|
|
163
169
|
def _save_assignment(self, node, name=None):
|
164
170
|
"""save assignement situation since node.parent is not available yet"""
|
@@ -167,15 +173,14 @@ class TreeRebuilder(object):
|
|
167
173
|
else:
|
168
174
|
node.parent.set_local(node.name, node)
|
169
175
|
|
170
|
-
|
171
|
-
def visit_arguments(self, node, parent):
|
176
|
+
def visit_arguments(self, node, parent, assign_ctx=None):
|
172
177
|
"""visit a Arguments node by returning a fresh instance of it"""
|
173
178
|
newnode = new.Arguments()
|
174
179
|
newnode.parent = parent
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
180
|
+
newnode.args = [self.visit(child, newnode, "Assign")
|
181
|
+
for child in node.args]
|
182
|
+
newnode.defaults = [self.visit(child, newnode, assign_ctx)
|
183
|
+
for child in node.defaults]
|
179
184
|
newnode.kwonlyargs = []
|
180
185
|
newnode.kw_defaults = []
|
181
186
|
vararg, kwarg = node.vararg, node.kwarg
|
@@ -185,21 +190,21 @@ class TreeRebuilder(object):
|
|
185
190
|
if PY34:
|
186
191
|
if vararg.annotation:
|
187
192
|
newnode.varargannotation = self.visit(vararg.annotation,
|
188
|
-
newnode)
|
193
|
+
newnode, assign_ctx)
|
189
194
|
vararg = vararg.arg
|
190
195
|
elif PY3K and node.varargannotation:
|
191
196
|
newnode.varargannotation = self.visit(node.varargannotation,
|
192
|
-
newnode)
|
197
|
+
newnode, assign_ctx)
|
193
198
|
if kwarg:
|
194
199
|
if PY34:
|
195
200
|
if kwarg.annotation:
|
196
201
|
newnode.kwargannotation = self.visit(kwarg.annotation,
|
197
|
-
newnode)
|
202
|
+
newnode, assign_ctx)
|
198
203
|
kwarg = kwarg.arg
|
199
204
|
elif PY3K:
|
200
205
|
if node.kwargannotation:
|
201
206
|
newnode.kwargannotation = self.visit(node.kwargannotation,
|
202
|
-
newnode)
|
207
|
+
newnode, assign_ctx)
|
203
208
|
newnode.vararg = vararg
|
204
209
|
newnode.kwarg = kwarg
|
205
210
|
# save argument names in locals:
|
@@ -209,81 +214,59 @@ class TreeRebuilder(object):
|
|
209
214
|
newnode.parent.set_local(kwarg, newnode)
|
210
215
|
return newnode
|
211
216
|
|
212
|
-
def
|
217
|
+
def visit_assignattr(self, node, parent, assign_ctx=None):
|
213
218
|
"""visit a AssAttr node by returning a fresh instance of it"""
|
214
|
-
|
215
|
-
newnode = new.AssAttr()
|
219
|
+
newnode = new.AssignAttr()
|
216
220
|
_lineno_parent(node, newnode, parent)
|
217
|
-
newnode.expr = self.visit(node.expr, newnode)
|
218
|
-
self.asscontext = assc
|
221
|
+
newnode.expr = self.visit(node.expr, newnode, assign_ctx)
|
219
222
|
self._delayed_assattr.append(newnode)
|
220
223
|
return newnode
|
221
224
|
|
222
|
-
def visit_assert(self, node, parent):
|
225
|
+
def visit_assert(self, node, parent, assign_ctx=None):
|
223
226
|
"""visit a Assert node by returning a fresh instance of it"""
|
224
227
|
newnode = new.Assert()
|
225
228
|
_lineno_parent(node, newnode, parent)
|
226
|
-
newnode.test = self.visit(node.test, newnode)
|
229
|
+
newnode.test = self.visit(node.test, newnode, assign_ctx)
|
227
230
|
if node.msg is not None:
|
228
|
-
newnode.fail = self.visit(node.msg, newnode)
|
231
|
+
newnode.fail = self.visit(node.msg, newnode, assign_ctx)
|
229
232
|
return newnode
|
230
233
|
|
231
|
-
def visit_assign(self, node, parent):
|
234
|
+
def visit_assign(self, node, parent, assign_ctx=None):
|
232
235
|
"""visit a Assign node by returning a fresh instance of it"""
|
233
236
|
newnode = new.Assign()
|
234
237
|
_lineno_parent(node, newnode, parent)
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
if (isinstance(klass, new.Class)
|
242
|
-
and isinstance(newnode.value, new.CallFunc)
|
243
|
-
and isinstance(newnode.value.func, new.Name)):
|
244
|
-
func_name = newnode.value.func.name
|
245
|
-
for ass_node in newnode.targets:
|
246
|
-
try:
|
247
|
-
meth = klass[ass_node.name]
|
248
|
-
if isinstance(meth, new.Function):
|
249
|
-
if func_name in ('classmethod', 'staticmethod'):
|
250
|
-
meth.type = func_name
|
251
|
-
elif func_name == 'classproperty': # see lgc.decorators
|
252
|
-
meth.type = 'classmethod'
|
253
|
-
meth.extra_decorators.append(newnode.value)
|
254
|
-
except (AttributeError, KeyError):
|
255
|
-
continue
|
256
|
-
return newnode
|
257
|
-
|
258
|
-
def visit_assname(self, node, parent, node_name=None):
|
238
|
+
newnode.targets = [self.visit(child, newnode, "Assign")
|
239
|
+
for child in node.targets]
|
240
|
+
newnode.value = self.visit(node.value, newnode, None)
|
241
|
+
return newnode
|
242
|
+
|
243
|
+
def visit_assignname(self, node, parent, assign_ctx=None, node_name=None):
|
259
244
|
'''visit a node and return a AssName node'''
|
260
|
-
newnode = new.
|
245
|
+
newnode = new.AssignName()
|
261
246
|
_set_infos(node, newnode, parent)
|
262
247
|
newnode.name = node_name
|
263
248
|
self._save_assignment(newnode)
|
264
249
|
return newnode
|
265
250
|
|
266
|
-
def visit_augassign(self, node, parent):
|
251
|
+
def visit_augassign(self, node, parent, assign_ctx=None):
|
267
252
|
"""visit a AugAssign node by returning a fresh instance of it"""
|
268
253
|
newnode = new.AugAssign()
|
269
254
|
_lineno_parent(node, newnode, parent)
|
270
255
|
newnode.op = _BIN_OP_CLASSES[node.op.__class__] + "="
|
271
|
-
|
272
|
-
newnode.
|
273
|
-
self.asscontext = None
|
274
|
-
newnode.value = self.visit(node.value, newnode)
|
256
|
+
newnode.target = self.visit(node.target, newnode, "Assign")
|
257
|
+
newnode.value = self.visit(node.value, newnode, None)
|
275
258
|
return newnode
|
276
259
|
|
277
|
-
def
|
260
|
+
def visit_repr(self, node, parent, assign_ctx=None):
|
278
261
|
"""visit a Backquote node by returning a fresh instance of it"""
|
279
|
-
newnode = new.
|
262
|
+
newnode = new.Repr()
|
280
263
|
_lineno_parent(node, newnode, parent)
|
281
|
-
newnode.value = self.visit(node.value, newnode)
|
264
|
+
newnode.value = self.visit(node.value, newnode, assign_ctx)
|
282
265
|
return newnode
|
283
266
|
|
284
|
-
def visit_binop(self, node, parent):
|
267
|
+
def visit_binop(self, node, parent, assign_ctx=None):
|
285
268
|
"""visit a BinOp node by returning a fresh instance of it"""
|
286
|
-
if isinstance(node.left, BinOp) and self._manager.optimize_ast:
|
269
|
+
if isinstance(node.left, _ast.BinOp) and self._manager.optimize_ast:
|
287
270
|
# Optimize BinOp operations in order to remove
|
288
271
|
# redundant recursion. For instance, if the
|
289
272
|
# following code is parsed in order to obtain
|
@@ -296,264 +279,299 @@ class TreeRebuilder(object):
|
|
296
279
|
# problem for the correctness of the program).
|
297
280
|
#
|
298
281
|
# ("a" + "b" + # one thousand more + "c")
|
299
|
-
|
300
|
-
if
|
301
|
-
_lineno_parent(node,
|
302
|
-
return
|
282
|
+
optimized = self._peepholer.optimize_binop(node)
|
283
|
+
if optimized:
|
284
|
+
_lineno_parent(node, optimized, parent)
|
285
|
+
return optimized
|
303
286
|
|
304
287
|
newnode = new.BinOp()
|
305
288
|
_lineno_parent(node, newnode, parent)
|
306
|
-
newnode.left = self.visit(node.left, newnode)
|
307
|
-
newnode.right = self.visit(node.right, newnode)
|
289
|
+
newnode.left = self.visit(node.left, newnode, assign_ctx)
|
290
|
+
newnode.right = self.visit(node.right, newnode, assign_ctx)
|
308
291
|
newnode.op = _BIN_OP_CLASSES[node.op.__class__]
|
309
292
|
return newnode
|
310
293
|
|
311
|
-
def visit_boolop(self, node, parent):
|
294
|
+
def visit_boolop(self, node, parent, assign_ctx=None):
|
312
295
|
"""visit a BoolOp node by returning a fresh instance of it"""
|
313
296
|
newnode = new.BoolOp()
|
314
297
|
_lineno_parent(node, newnode, parent)
|
315
|
-
newnode.values = [self.visit(child, newnode)
|
298
|
+
newnode.values = [self.visit(child, newnode, assign_ctx)
|
299
|
+
for child in node.values]
|
316
300
|
newnode.op = _BOOL_OP_CLASSES[node.op.__class__]
|
317
301
|
return newnode
|
318
302
|
|
319
|
-
def visit_break(self, node, parent):
|
303
|
+
def visit_break(self, node, parent, assign_ctx=None):
|
320
304
|
"""visit a Break node by returning a fresh instance of it"""
|
321
305
|
newnode = new.Break()
|
322
306
|
_set_infos(node, newnode, parent)
|
323
307
|
return newnode
|
324
308
|
|
325
|
-
def
|
309
|
+
def visit_call(self, node, parent, assign_ctx=None):
|
326
310
|
"""visit a CallFunc node by returning a fresh instance of it"""
|
327
|
-
newnode = new.
|
328
|
-
_lineno_parent(node, newnode, parent)
|
329
|
-
newnode.func = self.visit(node.func, newnode)
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
311
|
+
newnode = new.Call()
|
312
|
+
_lineno_parent(node, newnode, parent)
|
313
|
+
newnode.func = self.visit(node.func, newnode, assign_ctx)
|
314
|
+
args = [self.visit(child, newnode, assign_ctx)
|
315
|
+
for child in node.args]
|
316
|
+
|
317
|
+
starargs = _visit_or_none(node, 'starargs', self, newnode,
|
318
|
+
assign_ctx)
|
319
|
+
kwargs = _visit_or_none(node, 'kwargs', self, newnode,
|
320
|
+
assign_ctx)
|
321
|
+
keywords = None
|
322
|
+
if node.keywords:
|
323
|
+
keywords = [self.visit(child, newnode, assign_ctx)
|
324
|
+
for child in node.keywords]
|
325
|
+
|
326
|
+
if starargs:
|
327
|
+
new_starargs = new.Starred()
|
328
|
+
new_starargs.col_offset = starargs.col_offset
|
329
|
+
new_starargs.lineno = starargs.lineno
|
330
|
+
new_starargs.parent = starargs.parent
|
331
|
+
new_starargs.value = starargs
|
332
|
+
args.append(new_starargs)
|
333
|
+
if kwargs:
|
334
|
+
new_kwargs = new.Keyword()
|
335
|
+
new_kwargs.arg = None
|
336
|
+
new_kwargs.col_offset = kwargs.col_offset
|
337
|
+
new_kwargs.lineno = kwargs.lineno
|
338
|
+
new_kwargs.parent = kwargs.parent
|
339
|
+
new_kwargs.value = kwargs
|
340
|
+
if keywords:
|
341
|
+
keywords.append(new_kwargs)
|
342
|
+
else:
|
343
|
+
keywords = [new_kwargs]
|
344
|
+
|
345
|
+
newnode.args = args
|
346
|
+
newnode.keywords = keywords
|
337
347
|
return newnode
|
338
348
|
|
339
|
-
def
|
349
|
+
def visit_classdef(self, node, parent, assign_ctx=None):
|
340
350
|
"""visit a Class node to become astroid"""
|
341
|
-
newnode = new.
|
351
|
+
newnode = new.ClassDef(node.name, None)
|
342
352
|
_lineno_parent(node, newnode, parent)
|
343
353
|
_init_set_doc(node, newnode)
|
344
|
-
newnode.bases = [self.visit(child, newnode)
|
345
|
-
|
346
|
-
|
347
|
-
|
354
|
+
newnode.bases = [self.visit(child, newnode, assign_ctx)
|
355
|
+
for child in node.bases]
|
356
|
+
newnode.body = [self.visit(child, newnode, assign_ctx)
|
357
|
+
for child in node.body]
|
358
|
+
if node.decorator_list:
|
359
|
+
newnode.decorators = self.visit_decorators(node, newnode, assign_ctx)
|
348
360
|
newnode.parent.frame().set_local(newnode.name, newnode)
|
349
361
|
return newnode
|
350
362
|
|
351
|
-
def visit_const(self, node, parent):
|
363
|
+
def visit_const(self, node, parent, assign_ctx=None):
|
352
364
|
"""visit a Const node by returning a fresh instance of it"""
|
353
365
|
newnode = new.Const(node.value)
|
354
366
|
_set_infos(node, newnode, parent)
|
355
367
|
return newnode
|
356
368
|
|
357
|
-
def visit_continue(self, node, parent):
|
369
|
+
def visit_continue(self, node, parent, assign_ctx=None):
|
358
370
|
"""visit a Continue node by returning a fresh instance of it"""
|
359
371
|
newnode = new.Continue()
|
360
372
|
_set_infos(node, newnode, parent)
|
361
373
|
return newnode
|
362
374
|
|
363
|
-
def visit_compare(self, node, parent):
|
375
|
+
def visit_compare(self, node, parent, assign_ctx=None):
|
364
376
|
"""visit a Compare node by returning a fresh instance of it"""
|
365
377
|
newnode = new.Compare()
|
366
378
|
_lineno_parent(node, newnode, parent)
|
367
|
-
newnode.left = self.visit(node.left, newnode)
|
368
|
-
newnode.ops = [(_CMP_OP_CLASSES[op.__class__], self.visit(expr, newnode))
|
379
|
+
newnode.left = self.visit(node.left, newnode, assign_ctx)
|
380
|
+
newnode.ops = [(_CMP_OP_CLASSES[op.__class__], self.visit(expr, newnode, assign_ctx))
|
369
381
|
for (op, expr) in zip(node.ops, node.comparators)]
|
370
382
|
return newnode
|
371
383
|
|
372
|
-
def visit_comprehension(self, node, parent):
|
384
|
+
def visit_comprehension(self, node, parent, assign_ctx=None):
|
373
385
|
"""visit a Comprehension node by returning a fresh instance of it"""
|
374
386
|
newnode = new.Comprehension()
|
375
387
|
newnode.parent = parent
|
376
|
-
|
377
|
-
newnode.
|
378
|
-
|
379
|
-
|
380
|
-
newnode.ifs = [self.visit(child, newnode) for child in node.ifs]
|
388
|
+
newnode.target = self.visit(node.target, newnode, 'Assign')
|
389
|
+
newnode.iter = self.visit(node.iter, newnode, None)
|
390
|
+
newnode.ifs = [self.visit(child, newnode, None)
|
391
|
+
for child in node.ifs]
|
381
392
|
return newnode
|
382
393
|
|
383
|
-
def visit_decorators(self, node, parent):
|
394
|
+
def visit_decorators(self, node, parent, assign_ctx=None):
|
384
395
|
"""visit a Decorators node by returning a fresh instance of it"""
|
385
396
|
# /!\ node is actually a _ast.Function node while
|
386
397
|
# parent is a astroid.nodes.Function node
|
387
398
|
newnode = new.Decorators()
|
388
399
|
_lineno_parent(node, newnode, parent)
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
decorators = node.decorator_list
|
393
|
-
newnode.nodes = [self.visit(child, newnode) for child in decorators]
|
400
|
+
decorators = node.decorator_list
|
401
|
+
newnode.nodes = [self.visit(child, newnode, assign_ctx)
|
402
|
+
for child in decorators]
|
394
403
|
return newnode
|
395
404
|
|
396
|
-
def visit_delete(self, node, parent):
|
405
|
+
def visit_delete(self, node, parent, assign_ctx=None):
|
397
406
|
"""visit a Delete node by returning a fresh instance of it"""
|
398
407
|
newnode = new.Delete()
|
399
408
|
_lineno_parent(node, newnode, parent)
|
400
|
-
|
401
|
-
|
402
|
-
self.asscontext = None
|
409
|
+
newnode.targets = [self.visit(child, newnode, 'Del')
|
410
|
+
for child in node.targets]
|
403
411
|
return newnode
|
404
412
|
|
405
|
-
def
|
413
|
+
def _visit_dict_items(self, node, parent, newnode, assign_ctx):
|
414
|
+
for key, value in zip(node.keys, node.values):
|
415
|
+
rebuilt_value = self.visit(value, newnode, assign_ctx)
|
416
|
+
if not key:
|
417
|
+
# Python 3.5 and extended unpacking
|
418
|
+
rebuilt_key = new.DictUnpack()
|
419
|
+
rebuilt_key.lineno = rebuilt_value.lineno
|
420
|
+
rebuilt_key.col_offset = rebuilt_value.col_offset
|
421
|
+
rebuilt_key.parent = rebuilt_value.parent
|
422
|
+
else:
|
423
|
+
rebuilt_key = self.visit(key, newnode, assign_ctx)
|
424
|
+
yield rebuilt_key, rebuilt_value
|
425
|
+
|
426
|
+
def visit_dict(self, node, parent, assign_ctx=None):
|
406
427
|
"""visit a Dict node by returning a fresh instance of it"""
|
407
428
|
newnode = new.Dict()
|
408
429
|
_lineno_parent(node, newnode, parent)
|
409
|
-
newnode.items =
|
410
|
-
for key, value in zip(node.keys, node.values)]
|
430
|
+
newnode.items = list(self._visit_dict_items(node, parent, newnode, assign_ctx))
|
411
431
|
return newnode
|
412
432
|
|
413
|
-
def visit_dictcomp(self, node, parent):
|
433
|
+
def visit_dictcomp(self, node, parent, assign_ctx=None):
|
414
434
|
"""visit a DictComp node by returning a fresh instance of it"""
|
415
435
|
newnode = new.DictComp()
|
416
436
|
_lineno_parent(node, newnode, parent)
|
417
|
-
newnode.key = self.visit(node.key, newnode)
|
418
|
-
newnode.value = self.visit(node.value, newnode)
|
419
|
-
newnode.generators = [self.visit(child, newnode)
|
437
|
+
newnode.key = self.visit(node.key, newnode, assign_ctx)
|
438
|
+
newnode.value = self.visit(node.value, newnode, assign_ctx)
|
439
|
+
newnode.generators = [self.visit(child, newnode, assign_ctx)
|
420
440
|
for child in node.generators]
|
421
441
|
return newnode
|
422
442
|
|
423
|
-
def
|
443
|
+
def visit_expr(self, node, parent, assign_ctx=None):
|
424
444
|
"""visit a Discard node by returning a fresh instance of it"""
|
425
|
-
newnode = new.
|
445
|
+
newnode = new.Expr()
|
426
446
|
_lineno_parent(node, newnode, parent)
|
427
|
-
newnode.value = self.visit(node.value, newnode)
|
447
|
+
newnode.value = self.visit(node.value, newnode, assign_ctx)
|
428
448
|
return newnode
|
429
449
|
|
430
|
-
def visit_ellipsis(self, node, parent):
|
450
|
+
def visit_ellipsis(self, node, parent, assign_ctx=None):
|
431
451
|
"""visit an Ellipsis node by returning a fresh instance of it"""
|
432
452
|
newnode = new.Ellipsis()
|
433
453
|
_set_infos(node, newnode, parent)
|
434
454
|
return newnode
|
435
455
|
|
436
|
-
def visit_emptynode(self, node, parent):
|
456
|
+
def visit_emptynode(self, node, parent, assign_ctx=None):
|
437
457
|
"""visit an EmptyNode node by returning a fresh instance of it"""
|
438
458
|
newnode = new.EmptyNode()
|
439
459
|
_set_infos(node, newnode, parent)
|
440
460
|
return newnode
|
441
461
|
|
442
|
-
def visit_excepthandler(self, node, parent):
|
462
|
+
def visit_excepthandler(self, node, parent, assign_ctx=None):
|
443
463
|
"""visit an ExceptHandler node by returning a fresh instance of it"""
|
444
464
|
newnode = new.ExceptHandler()
|
445
465
|
_lineno_parent(node, newnode, parent)
|
446
466
|
if node.type is not None:
|
447
|
-
newnode.type = self.visit(node.type, newnode)
|
467
|
+
newnode.type = self.visit(node.type, newnode, assign_ctx)
|
448
468
|
if node.name is not None:
|
449
469
|
# /!\ node.name can be a tuple
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
newnode.body = [self.visit(child, newnode) for child in node.body]
|
470
|
+
newnode.name = self.visit(node.name, newnode, 'Assign')
|
471
|
+
newnode.body = [self.visit(child, newnode, None)
|
472
|
+
for child in node.body]
|
454
473
|
return newnode
|
455
474
|
|
456
|
-
def visit_exec(self, node, parent):
|
475
|
+
def visit_exec(self, node, parent, assign_ctx=None):
|
457
476
|
"""visit an Exec node by returning a fresh instance of it"""
|
458
477
|
newnode = new.Exec()
|
459
478
|
_lineno_parent(node, newnode, parent)
|
460
479
|
newnode.expr = self.visit(node.body, newnode)
|
461
480
|
if node.globals is not None:
|
462
|
-
newnode.globals = self.visit(node.globals, newnode
|
481
|
+
newnode.globals = self.visit(node.globals, newnode,
|
482
|
+
assign_ctx)
|
463
483
|
if node.locals is not None:
|
464
|
-
newnode.locals = self.visit(node.locals, newnode
|
484
|
+
newnode.locals = self.visit(node.locals, newnode,
|
485
|
+
assign_ctx)
|
465
486
|
return newnode
|
466
487
|
|
467
|
-
def visit_extslice(self, node, parent):
|
488
|
+
def visit_extslice(self, node, parent, assign_ctx=None):
|
468
489
|
"""visit an ExtSlice node by returning a fresh instance of it"""
|
469
490
|
newnode = new.ExtSlice()
|
470
491
|
newnode.parent = parent
|
471
|
-
newnode.dims = [self.visit(dim, newnode)
|
492
|
+
newnode.dims = [self.visit(dim, newnode, assign_ctx)
|
493
|
+
for dim in node.dims]
|
472
494
|
return newnode
|
473
495
|
|
474
|
-
def
|
496
|
+
def _visit_for(self, cls, node, parent, assign_ctx=None):
|
475
497
|
"""visit a For node by returning a fresh instance of it"""
|
476
|
-
newnode =
|
498
|
+
newnode = cls()
|
477
499
|
_lineno_parent(node, newnode, parent)
|
478
|
-
|
479
|
-
newnode.
|
480
|
-
|
481
|
-
|
482
|
-
newnode.
|
483
|
-
|
500
|
+
newnode.target = self.visit(node.target, newnode, "Assign")
|
501
|
+
newnode.iter = self.visit(node.iter, newnode, None)
|
502
|
+
newnode.body = [self.visit(child, newnode, None)
|
503
|
+
for child in node.body]
|
504
|
+
newnode.orelse = [self.visit(child, newnode, None)
|
505
|
+
for child in node.orelse]
|
484
506
|
return newnode
|
485
507
|
|
486
|
-
def
|
508
|
+
def visit_for(self, node, parent, assign_ctx=None):
|
509
|
+
return self._visit_for(new.For, node, parent,
|
510
|
+
assign_ctx=assign_ctx)
|
511
|
+
def visit_importfrom(self, node, parent, assign_ctx=None):
|
487
512
|
"""visit a From node by returning a fresh instance of it"""
|
488
513
|
names = [(alias.name, alias.asname) for alias in node.names]
|
489
|
-
newnode = new.
|
514
|
+
newnode = new.ImportFrom(node.module or '', names, node.level or None)
|
490
515
|
_set_infos(node, newnode, parent)
|
491
516
|
# store From names to add them to locals after building
|
492
|
-
self.
|
517
|
+
self._import_from_nodes.append(newnode)
|
493
518
|
return newnode
|
494
519
|
|
495
|
-
def
|
496
|
-
"""visit an
|
520
|
+
def _visit_functiondef(self, cls, node, parent, assign_ctx=None):
|
521
|
+
"""visit an FunctionDef node to become astroid"""
|
497
522
|
self._global_names.append({})
|
498
|
-
newnode =
|
523
|
+
newnode = cls(node.name, None)
|
499
524
|
_lineno_parent(node, newnode, parent)
|
500
525
|
_init_set_doc(node, newnode)
|
501
|
-
newnode.args = self.visit(node.args, newnode)
|
502
|
-
newnode.body = [self.visit(child, newnode)
|
503
|
-
|
504
|
-
|
505
|
-
else:
|
506
|
-
attr = 'decorator_list'
|
507
|
-
decorators = getattr(node, attr)
|
526
|
+
newnode.args = self.visit(node.args, newnode, assign_ctx)
|
527
|
+
newnode.body = [self.visit(child, newnode, assign_ctx)
|
528
|
+
for child in node.body]
|
529
|
+
decorators = node.decorator_list
|
508
530
|
if decorators:
|
509
|
-
newnode.decorators = self.visit_decorators(
|
531
|
+
newnode.decorators = self.visit_decorators(
|
532
|
+
node, newnode, assign_ctx)
|
510
533
|
if PY3K and node.returns:
|
511
|
-
newnode.returns = self.visit(node.returns, newnode
|
534
|
+
newnode.returns = self.visit(node.returns, newnode,
|
535
|
+
assign_ctx)
|
512
536
|
self._global_names.pop()
|
513
537
|
frame = newnode.parent.frame()
|
514
|
-
if isinstance(frame, new.Class):
|
515
|
-
if newnode.name == '__new__':
|
516
|
-
newnode._type = 'classmethod'
|
517
|
-
else:
|
518
|
-
newnode._type = 'method'
|
519
|
-
if newnode.decorators is not None:
|
520
|
-
for decorator_expr in newnode.decorators.nodes:
|
521
|
-
if isinstance(decorator_expr, new.Name):
|
522
|
-
if decorator_expr.name in ('classmethod', 'staticmethod'):
|
523
|
-
newnode._type = decorator_expr.name
|
524
|
-
elif decorator_expr.name == 'classproperty':
|
525
|
-
newnode._type = 'classmethod'
|
526
538
|
frame.set_local(newnode.name, newnode)
|
527
539
|
return newnode
|
528
540
|
|
529
|
-
def
|
541
|
+
def visit_functiondef(self, node, parent, assign_ctx=None):
|
542
|
+
return self._visit_functiondef(new.FunctionDef, node, parent,
|
543
|
+
assign_ctx=assign_ctx)
|
544
|
+
|
545
|
+
def visit_generatorexp(self, node, parent, assign_ctx=None):
|
530
546
|
"""visit a GenExpr node by returning a fresh instance of it"""
|
531
|
-
newnode = new.
|
547
|
+
newnode = new.GeneratorExp()
|
532
548
|
_lineno_parent(node, newnode, parent)
|
533
|
-
newnode.elt = self.visit(node.elt, newnode)
|
534
|
-
newnode.generators = [self.visit(child, newnode)
|
549
|
+
newnode.elt = self.visit(node.elt, newnode, assign_ctx)
|
550
|
+
newnode.generators = [self.visit(child, newnode, assign_ctx)
|
551
|
+
for child in node.generators]
|
535
552
|
return newnode
|
536
553
|
|
537
|
-
def
|
554
|
+
def visit_attribute(self, node, parent, assign_ctx=None):
|
538
555
|
"""visit a Getattr node by returning a fresh instance of it"""
|
539
|
-
|
556
|
+
# pylint: disable=redefined-variable-type
|
557
|
+
if assign_ctx == "Del":
|
540
558
|
# FIXME : maybe we should reintroduce and visit_delattr ?
|
541
559
|
# for instance, deactivating asscontext
|
542
560
|
newnode = new.DelAttr()
|
543
|
-
elif
|
561
|
+
elif assign_ctx == "Assign":
|
544
562
|
# FIXME : maybe we should call visit_assattr ?
|
545
|
-
|
546
|
-
|
563
|
+
# Prohibit a local save if we are in an ExceptHandler.
|
564
|
+
newnode = new.AssignAttr()
|
565
|
+
if not isinstance(parent, new.ExceptHandler):
|
566
|
+
self._delayed_assattr.append(newnode)
|
547
567
|
else:
|
548
|
-
newnode = new.
|
568
|
+
newnode = new.Attribute()
|
549
569
|
_lineno_parent(node, newnode, parent)
|
550
|
-
|
551
|
-
newnode.expr = self.visit(node.value, newnode)
|
552
|
-
self.asscontext = asscontext
|
570
|
+
newnode.expr = self.visit(node.value, newnode, None)
|
553
571
|
newnode.attrname = node.attr
|
554
572
|
return newnode
|
555
573
|
|
556
|
-
def visit_global(self, node, parent):
|
574
|
+
def visit_global(self, node, parent, assign_ctx=None):
|
557
575
|
"""visit an Global node to become astroid"""
|
558
576
|
newnode = new.Global(node.names)
|
559
577
|
_set_infos(node, newnode, parent)
|
@@ -562,25 +580,27 @@ class TreeRebuilder(object):
|
|
562
580
|
self._global_names[-1].setdefault(name, []).append(newnode)
|
563
581
|
return newnode
|
564
582
|
|
565
|
-
def visit_if(self, node, parent):
|
583
|
+
def visit_if(self, node, parent, assign_ctx=None):
|
566
584
|
"""visit a If node by returning a fresh instance of it"""
|
567
585
|
newnode = new.If()
|
568
586
|
_lineno_parent(node, newnode, parent)
|
569
|
-
newnode.test = self.visit(node.test, newnode)
|
570
|
-
newnode.body = [self.visit(child, newnode)
|
571
|
-
|
587
|
+
newnode.test = self.visit(node.test, newnode, assign_ctx)
|
588
|
+
newnode.body = [self.visit(child, newnode, assign_ctx)
|
589
|
+
for child in node.body]
|
590
|
+
newnode.orelse = [self.visit(child, newnode, assign_ctx)
|
591
|
+
for child in node.orelse]
|
572
592
|
return newnode
|
573
593
|
|
574
|
-
def visit_ifexp(self, node, parent):
|
594
|
+
def visit_ifexp(self, node, parent, assign_ctx=None):
|
575
595
|
"""visit a IfExp node by returning a fresh instance of it"""
|
576
596
|
newnode = new.IfExp()
|
577
597
|
_lineno_parent(node, newnode, parent)
|
578
|
-
newnode.test = self.visit(node.test, newnode)
|
579
|
-
newnode.body = self.visit(node.body, newnode)
|
580
|
-
newnode.orelse = self.visit(node.orelse, newnode)
|
598
|
+
newnode.test = self.visit(node.test, newnode, assign_ctx)
|
599
|
+
newnode.body = self.visit(node.body, newnode, assign_ctx)
|
600
|
+
newnode.orelse = self.visit(node.orelse, newnode, assign_ctx)
|
581
601
|
return newnode
|
582
602
|
|
583
|
-
def visit_import(self, node, parent):
|
603
|
+
def visit_import(self, node, parent, assign_ctx=None):
|
584
604
|
"""visit a Import node by returning a fresh instance of it"""
|
585
605
|
newnode = new.Import()
|
586
606
|
_set_infos(node, newnode, parent)
|
@@ -591,53 +611,54 @@ class TreeRebuilder(object):
|
|
591
611
|
newnode.parent.set_local(name.split('.')[0], newnode)
|
592
612
|
return newnode
|
593
613
|
|
594
|
-
def visit_index(self, node, parent):
|
614
|
+
def visit_index(self, node, parent, assign_ctx=None):
|
595
615
|
"""visit a Index node by returning a fresh instance of it"""
|
596
616
|
newnode = new.Index()
|
597
617
|
newnode.parent = parent
|
598
|
-
newnode.value = self.visit(node.value, newnode)
|
618
|
+
newnode.value = self.visit(node.value, newnode, assign_ctx)
|
599
619
|
return newnode
|
600
620
|
|
601
|
-
def visit_keyword(self, node, parent):
|
621
|
+
def visit_keyword(self, node, parent, assign_ctx=None):
|
602
622
|
"""visit a Keyword node by returning a fresh instance of it"""
|
603
623
|
newnode = new.Keyword()
|
604
624
|
newnode.parent = parent
|
605
625
|
newnode.arg = node.arg
|
606
|
-
newnode.value = self.visit(node.value, newnode)
|
626
|
+
newnode.value = self.visit(node.value, newnode, assign_ctx)
|
607
627
|
return newnode
|
608
628
|
|
609
|
-
def visit_lambda(self, node, parent):
|
629
|
+
def visit_lambda(self, node, parent, assign_ctx=None):
|
610
630
|
"""visit a Lambda node by returning a fresh instance of it"""
|
611
631
|
newnode = new.Lambda()
|
612
632
|
_lineno_parent(node, newnode, parent)
|
613
|
-
newnode.args = self.visit(node.args, newnode)
|
614
|
-
newnode.body = self.visit(node.body, newnode)
|
633
|
+
newnode.args = self.visit(node.args, newnode, assign_ctx)
|
634
|
+
newnode.body = self.visit(node.body, newnode, assign_ctx)
|
615
635
|
return newnode
|
616
636
|
|
617
|
-
def visit_list(self, node, parent):
|
637
|
+
def visit_list(self, node, parent, assign_ctx=None):
|
618
638
|
"""visit a List node by returning a fresh instance of it"""
|
619
639
|
newnode = new.List()
|
620
640
|
_lineno_parent(node, newnode, parent)
|
621
|
-
newnode.elts = [self.visit(child, newnode)
|
641
|
+
newnode.elts = [self.visit(child, newnode, assign_ctx)
|
642
|
+
for child in node.elts]
|
622
643
|
return newnode
|
623
644
|
|
624
|
-
def visit_listcomp(self, node, parent):
|
645
|
+
def visit_listcomp(self, node, parent, assign_ctx=None):
|
625
646
|
"""visit a ListComp node by returning a fresh instance of it"""
|
626
647
|
newnode = new.ListComp()
|
627
648
|
_lineno_parent(node, newnode, parent)
|
628
|
-
newnode.elt = self.visit(node.elt, newnode)
|
629
|
-
newnode.generators = [self.visit(child, newnode)
|
649
|
+
newnode.elt = self.visit(node.elt, newnode, assign_ctx)
|
650
|
+
newnode.generators = [self.visit(child, newnode, assign_ctx)
|
630
651
|
for child in node.generators]
|
631
652
|
return newnode
|
632
653
|
|
633
|
-
def visit_name(self, node, parent):
|
654
|
+
def visit_name(self, node, parent, assign_ctx=None):
|
634
655
|
"""visit a Name node by returning a fresh instance of it"""
|
635
656
|
# True and False can be assigned to something in py2x, so we have to
|
636
657
|
# check first the asscontext
|
637
|
-
|
658
|
+
# pylint: disable=redefined-variable-type
|
659
|
+
if assign_ctx == "Del":
|
638
660
|
newnode = new.DelName()
|
639
|
-
elif
|
640
|
-
assert self.asscontext == "Ass"
|
661
|
+
elif assign_ctx is not None: # Ass
|
641
662
|
newnode = new.AssName()
|
642
663
|
elif node.id in CONST_NAME_TRANSFORMS:
|
643
664
|
newnode = new.Const(CONST_NAME_TRANSFORMS[node.id])
|
@@ -648,279 +669,321 @@ class TreeRebuilder(object):
|
|
648
669
|
_lineno_parent(node, newnode, parent)
|
649
670
|
newnode.name = node.id
|
650
671
|
# XXX REMOVE me :
|
651
|
-
if
|
672
|
+
if assign_ctx in ('Del', 'Assign'): # 'Aug' ??
|
652
673
|
self._save_assignment(newnode)
|
653
674
|
return newnode
|
654
675
|
|
655
|
-
def visit_bytes(self, node, parent):
|
676
|
+
def visit_bytes(self, node, parent, assign_ctx=None):
|
656
677
|
"""visit a Bytes node by returning a fresh instance of Const"""
|
657
678
|
newnode = new.Const(node.s)
|
658
679
|
_set_infos(node, newnode, parent)
|
659
680
|
return newnode
|
660
681
|
|
661
|
-
def visit_num(self, node, parent):
|
682
|
+
def visit_num(self, node, parent, assign_ctx=None):
|
662
683
|
"""visit a Num node by returning a fresh instance of Const"""
|
663
684
|
newnode = new.Const(node.n)
|
664
685
|
_set_infos(node, newnode, parent)
|
665
686
|
return newnode
|
666
687
|
|
667
|
-
def visit_pass(self, node, parent):
|
688
|
+
def visit_pass(self, node, parent, assign_ctx=None):
|
668
689
|
"""visit a Pass node by returning a fresh instance of it"""
|
669
690
|
newnode = new.Pass()
|
670
691
|
_set_infos(node, newnode, parent)
|
671
692
|
return newnode
|
672
693
|
|
673
|
-
def visit_str(self, node, parent):
|
694
|
+
def visit_str(self, node, parent, assign_ctx=None):
|
674
695
|
"""visit a Str node by returning a fresh instance of Const"""
|
675
696
|
newnode = new.Const(node.s)
|
676
697
|
_set_infos(node, newnode, parent)
|
677
698
|
return newnode
|
678
699
|
|
679
|
-
def visit_print(self, node, parent):
|
700
|
+
def visit_print(self, node, parent, assign_ctx=None):
|
680
701
|
"""visit a Print node by returning a fresh instance of it"""
|
681
702
|
newnode = new.Print()
|
682
703
|
_lineno_parent(node, newnode, parent)
|
683
704
|
newnode.nl = node.nl
|
684
705
|
if node.dest is not None:
|
685
|
-
newnode.dest = self.visit(node.dest, newnode)
|
686
|
-
newnode.values = [self.visit(child, newnode)
|
706
|
+
newnode.dest = self.visit(node.dest, newnode, assign_ctx)
|
707
|
+
newnode.values = [self.visit(child, newnode, assign_ctx)
|
708
|
+
for child in node.values]
|
687
709
|
return newnode
|
688
710
|
|
689
|
-
def visit_raise(self, node, parent):
|
711
|
+
def visit_raise(self, node, parent, assign_ctx=None):
|
690
712
|
"""visit a Raise node by returning a fresh instance of it"""
|
691
713
|
newnode = new.Raise()
|
692
714
|
_lineno_parent(node, newnode, parent)
|
693
715
|
if node.type is not None:
|
694
|
-
newnode.exc = self.visit(node.type, newnode)
|
716
|
+
newnode.exc = self.visit(node.type, newnode, assign_ctx)
|
695
717
|
if node.inst is not None:
|
696
|
-
newnode.inst = self.visit(node.inst, newnode)
|
718
|
+
newnode.inst = self.visit(node.inst, newnode, assign_ctx)
|
697
719
|
if node.tback is not None:
|
698
|
-
newnode.tback = self.visit(node.tback, newnode)
|
720
|
+
newnode.tback = self.visit(node.tback, newnode, assign_ctx)
|
699
721
|
return newnode
|
700
722
|
|
701
|
-
def visit_return(self, node, parent):
|
723
|
+
def visit_return(self, node, parent, assign_ctx=None):
|
702
724
|
"""visit a Return node by returning a fresh instance of it"""
|
703
725
|
newnode = new.Return()
|
704
726
|
_lineno_parent(node, newnode, parent)
|
705
727
|
if node.value is not None:
|
706
|
-
newnode.value = self.visit(node.value, newnode)
|
728
|
+
newnode.value = self.visit(node.value, newnode, assign_ctx)
|
707
729
|
return newnode
|
708
730
|
|
709
|
-
def visit_set(self, node, parent):
|
731
|
+
def visit_set(self, node, parent, assign_ctx=None):
|
710
732
|
"""visit a Set node by returning a fresh instance of it"""
|
711
733
|
newnode = new.Set()
|
712
734
|
_lineno_parent(node, newnode, parent)
|
713
|
-
newnode.elts = [self.visit(child, newnode)
|
735
|
+
newnode.elts = [self.visit(child, newnode, assign_ctx)
|
736
|
+
for child in node.elts]
|
714
737
|
return newnode
|
715
738
|
|
716
|
-
def visit_setcomp(self, node, parent):
|
739
|
+
def visit_setcomp(self, node, parent, assign_ctx=None):
|
717
740
|
"""visit a SetComp node by returning a fresh instance of it"""
|
718
741
|
newnode = new.SetComp()
|
719
742
|
_lineno_parent(node, newnode, parent)
|
720
|
-
newnode.elt = self.visit(node.elt, newnode)
|
721
|
-
newnode.generators = [self.visit(child, newnode)
|
743
|
+
newnode.elt = self.visit(node.elt, newnode, assign_ctx)
|
744
|
+
newnode.generators = [self.visit(child, newnode, assign_ctx)
|
722
745
|
for child in node.generators]
|
723
746
|
return newnode
|
724
747
|
|
725
|
-
def visit_slice(self, node, parent):
|
748
|
+
def visit_slice(self, node, parent, assign_ctx=None):
|
726
749
|
"""visit a Slice node by returning a fresh instance of it"""
|
727
750
|
newnode = new.Slice()
|
728
751
|
newnode.parent = parent
|
729
752
|
if node.lower is not None:
|
730
|
-
newnode.lower = self.visit(node.lower, newnode)
|
753
|
+
newnode.lower = self.visit(node.lower, newnode, assign_ctx)
|
731
754
|
if node.upper is not None:
|
732
|
-
newnode.upper = self.visit(node.upper, newnode)
|
755
|
+
newnode.upper = self.visit(node.upper, newnode, assign_ctx)
|
733
756
|
if node.step is not None:
|
734
|
-
newnode.step = self.visit(node.step, newnode)
|
757
|
+
newnode.step = self.visit(node.step, newnode, assign_ctx)
|
735
758
|
return newnode
|
736
759
|
|
737
|
-
def visit_subscript(self, node, parent):
|
760
|
+
def visit_subscript(self, node, parent, assign_ctx=None):
|
738
761
|
"""visit a Subscript node by returning a fresh instance of it"""
|
739
762
|
newnode = new.Subscript()
|
740
763
|
_lineno_parent(node, newnode, parent)
|
741
|
-
|
742
|
-
newnode.
|
743
|
-
newnode.slice = self.visit(node.slice, newnode)
|
744
|
-
self.asscontext = subcontext
|
764
|
+
newnode.value = self.visit(node.value, newnode, None)
|
765
|
+
newnode.slice = self.visit(node.slice, newnode, None)
|
745
766
|
return newnode
|
746
767
|
|
747
|
-
def visit_tryexcept(self, node, parent):
|
768
|
+
def visit_tryexcept(self, node, parent, assign_ctx=None):
|
748
769
|
"""visit a TryExcept node by returning a fresh instance of it"""
|
749
770
|
newnode = new.TryExcept()
|
750
771
|
_lineno_parent(node, newnode, parent)
|
751
|
-
newnode.body = [self.visit(child, newnode)
|
752
|
-
|
753
|
-
newnode.
|
772
|
+
newnode.body = [self.visit(child, newnode, assign_ctx)
|
773
|
+
for child in node.body]
|
774
|
+
newnode.handlers = [self.visit(child, newnode, assign_ctx)
|
775
|
+
for child in node.handlers]
|
776
|
+
newnode.orelse = [self.visit(child, newnode, assign_ctx)
|
777
|
+
for child in node.orelse]
|
754
778
|
return newnode
|
755
779
|
|
756
|
-
def visit_tryfinally(self, node, parent):
|
780
|
+
def visit_tryfinally(self, node, parent, assign_ctx=None):
|
757
781
|
"""visit a TryFinally node by returning a fresh instance of it"""
|
758
782
|
newnode = new.TryFinally()
|
759
783
|
_lineno_parent(node, newnode, parent)
|
760
|
-
newnode.body = [self.visit(child, newnode)
|
761
|
-
|
784
|
+
newnode.body = [self.visit(child, newnode, assign_ctx)
|
785
|
+
for child in node.body]
|
786
|
+
newnode.finalbody = [self.visit(n, newnode, assign_ctx)
|
787
|
+
for n in node.finalbody]
|
762
788
|
return newnode
|
763
789
|
|
764
|
-
def visit_tuple(self, node, parent):
|
790
|
+
def visit_tuple(self, node, parent, assign_ctx=None):
|
765
791
|
"""visit a Tuple node by returning a fresh instance of it"""
|
766
792
|
newnode = new.Tuple()
|
767
793
|
_lineno_parent(node, newnode, parent)
|
768
|
-
newnode.elts = [self.visit(child, newnode)
|
794
|
+
newnode.elts = [self.visit(child, newnode, assign_ctx)
|
795
|
+
for child in node.elts]
|
769
796
|
return newnode
|
770
797
|
|
771
|
-
def visit_unaryop(self, node, parent):
|
798
|
+
def visit_unaryop(self, node, parent, assign_ctx=None):
|
772
799
|
"""visit a UnaryOp node by returning a fresh instance of it"""
|
773
800
|
newnode = new.UnaryOp()
|
774
801
|
_lineno_parent(node, newnode, parent)
|
775
|
-
newnode.operand = self.visit(node.operand, newnode)
|
802
|
+
newnode.operand = self.visit(node.operand, newnode, assign_ctx)
|
776
803
|
newnode.op = _UNARY_OP_CLASSES[node.op.__class__]
|
777
804
|
return newnode
|
778
805
|
|
779
|
-
def visit_while(self, node, parent):
|
806
|
+
def visit_while(self, node, parent, assign_ctx=None):
|
780
807
|
"""visit a While node by returning a fresh instance of it"""
|
781
808
|
newnode = new.While()
|
782
809
|
_lineno_parent(node, newnode, parent)
|
783
|
-
newnode.test = self.visit(node.test, newnode)
|
784
|
-
newnode.body = [self.visit(child, newnode)
|
785
|
-
|
810
|
+
newnode.test = self.visit(node.test, newnode, assign_ctx)
|
811
|
+
newnode.body = [self.visit(child, newnode, assign_ctx)
|
812
|
+
for child in node.body]
|
813
|
+
newnode.orelse = [self.visit(child, newnode, assign_ctx)
|
814
|
+
for child in node.orelse]
|
786
815
|
return newnode
|
787
816
|
|
788
|
-
def visit_with(self, node, parent):
|
817
|
+
def visit_with(self, node, parent, assign_ctx=None):
|
789
818
|
newnode = new.With()
|
790
819
|
_lineno_parent(node, newnode, parent)
|
791
|
-
expr = self.visit(node.context_expr, newnode)
|
792
|
-
self.asscontext = "Ass"
|
820
|
+
expr = self.visit(node.context_expr, newnode, assign_ctx)
|
793
821
|
if node.optional_vars is not None:
|
794
|
-
vars = self.visit(node.optional_vars, newnode)
|
822
|
+
vars = self.visit(node.optional_vars, newnode, 'Assign')
|
795
823
|
else:
|
796
824
|
vars = None
|
797
825
|
self.asscontext = None
|
798
826
|
newnode.items = [(expr, vars)]
|
799
|
-
newnode.body = [self.visit(child, newnode)
|
827
|
+
newnode.body = [self.visit(child, newnode, assign_ctx)
|
828
|
+
for child in node.body]
|
800
829
|
return newnode
|
801
830
|
|
802
|
-
def visit_yield(self, node, parent):
|
831
|
+
def visit_yield(self, node, parent, assign_ctx=None):
|
803
832
|
"""visit a Yield node by returning a fresh instance of it"""
|
804
833
|
return _create_yield_node(node, parent, self, new.Yield)
|
805
834
|
|
806
835
|
class TreeRebuilder3k(TreeRebuilder):
|
807
836
|
"""extend and overwrite TreeRebuilder for python3k"""
|
808
837
|
|
809
|
-
def visit_arg(self, node, parent):
|
838
|
+
def visit_arg(self, node, parent, assign_ctx=None):
|
810
839
|
"""visit a arg node by returning a fresh AssName instance"""
|
811
|
-
#
|
812
|
-
|
813
|
-
return self.visit_assname(node, parent, node.arg)
|
840
|
+
# TODO(cpopa): introduce an Arg node instead of using AssignName.
|
841
|
+
return self.visit_assignname(node, parent, assign_ctx, node.arg)
|
814
842
|
|
815
|
-
def visit_nameconstant(self, node, parent):
|
843
|
+
def visit_nameconstant(self, node, parent, assign_ctx=None):
|
816
844
|
# in Python 3.4 we have NameConstant for True / False / None
|
817
845
|
newnode = new.Const(node.value)
|
818
846
|
_set_infos(node, newnode, parent)
|
819
847
|
return newnode
|
820
848
|
|
821
|
-
def visit_arguments(self, node, parent):
|
822
|
-
newnode = super(TreeRebuilder3k, self).visit_arguments(node, parent)
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
849
|
+
def visit_arguments(self, node, parent, assign_ctx=None):
|
850
|
+
newnode = super(TreeRebuilder3k, self).visit_arguments(node, parent, assign_ctx)
|
851
|
+
newnode.kwonlyargs = [self.visit(child, newnode, 'Assign')
|
852
|
+
for child in node.kwonlyargs]
|
853
|
+
newnode.kw_defaults = [self.visit(child, newnode, None)
|
854
|
+
if child else None for child in node.kw_defaults]
|
827
855
|
newnode.annotations = [
|
828
|
-
self.visit(arg.annotation, newnode) if arg.annotation else None
|
856
|
+
self.visit(arg.annotation, newnode, None) if arg.annotation else None
|
829
857
|
for arg in node.args]
|
830
858
|
return newnode
|
831
859
|
|
832
|
-
def visit_excepthandler(self, node, parent):
|
860
|
+
def visit_excepthandler(self, node, parent, assign_ctx=None):
|
833
861
|
"""visit an ExceptHandler node by returning a fresh instance of it"""
|
834
862
|
newnode = new.ExceptHandler()
|
835
863
|
_lineno_parent(node, newnode, parent)
|
836
864
|
if node.type is not None:
|
837
|
-
newnode.type = self.visit(node.type, newnode)
|
865
|
+
newnode.type = self.visit(node.type, newnode, assign_ctx)
|
838
866
|
if node.name is not None:
|
839
|
-
newnode.name = self.
|
840
|
-
newnode.body = [self.visit(child, newnode)
|
867
|
+
newnode.name = self.visit_assignname(node, newnode, 'Assign', node.name)
|
868
|
+
newnode.body = [self.visit(child, newnode, None)
|
869
|
+
for child in node.body]
|
841
870
|
return newnode
|
842
871
|
|
843
|
-
def visit_nonlocal(self, node, parent):
|
872
|
+
def visit_nonlocal(self, node, parent, assign_ctx=None):
|
844
873
|
"""visit a Nonlocal node and return a new instance of it"""
|
845
874
|
newnode = new.Nonlocal(node.names)
|
846
875
|
_set_infos(node, newnode, parent)
|
847
876
|
return newnode
|
848
877
|
|
849
|
-
def visit_raise(self, node, parent):
|
878
|
+
def visit_raise(self, node, parent, assign_ctx=None):
|
850
879
|
"""visit a Raise node by returning a fresh instance of it"""
|
851
880
|
newnode = new.Raise()
|
852
881
|
_lineno_parent(node, newnode, parent)
|
853
882
|
# no traceback; anyway it is not used in Pylint
|
854
883
|
if node.exc is not None:
|
855
|
-
newnode.exc = self.visit(node.exc, newnode)
|
884
|
+
newnode.exc = self.visit(node.exc, newnode, assign_ctx)
|
856
885
|
if node.cause is not None:
|
857
|
-
newnode.cause = self.visit(node.cause, newnode)
|
886
|
+
newnode.cause = self.visit(node.cause, newnode, assign_ctx)
|
858
887
|
return newnode
|
859
888
|
|
860
|
-
def visit_starred(self, node, parent):
|
889
|
+
def visit_starred(self, node, parent, assign_ctx=None):
|
861
890
|
"""visit a Starred node and return a new instance of it"""
|
862
891
|
newnode = new.Starred()
|
863
892
|
_lineno_parent(node, newnode, parent)
|
864
|
-
newnode.value = self.visit(node.value, newnode)
|
893
|
+
newnode.value = self.visit(node.value, newnode, assign_ctx)
|
865
894
|
return newnode
|
866
895
|
|
867
|
-
def visit_try(self, node, parent):
|
896
|
+
def visit_try(self, node, parent, assign_ctx=None):
|
868
897
|
# python 3.3 introduce a new Try node replacing TryFinally/TryExcept nodes
|
898
|
+
# pylint: disable=redefined-variable-type
|
869
899
|
if node.finalbody:
|
870
900
|
newnode = new.TryFinally()
|
871
901
|
_lineno_parent(node, newnode, parent)
|
872
|
-
newnode.finalbody = [self.visit(n, newnode)
|
902
|
+
newnode.finalbody = [self.visit(n, newnode, assign_ctx)
|
903
|
+
for n in node.finalbody]
|
873
904
|
if node.handlers:
|
874
905
|
excnode = new.TryExcept()
|
875
906
|
_lineno_parent(node, excnode, newnode)
|
876
|
-
excnode.body = [self.visit(child, excnode)
|
877
|
-
|
878
|
-
excnode.
|
907
|
+
excnode.body = [self.visit(child, excnode, assign_ctx)
|
908
|
+
for child in node.body]
|
909
|
+
excnode.handlers = [self.visit(child, excnode, assign_ctx)
|
910
|
+
for child in node.handlers]
|
911
|
+
excnode.orelse = [self.visit(child, excnode, assign_ctx)
|
912
|
+
for child in node.orelse]
|
879
913
|
newnode.body = [excnode]
|
880
914
|
else:
|
881
|
-
newnode.body = [self.visit(child, newnode)
|
915
|
+
newnode.body = [self.visit(child, newnode, assign_ctx)
|
916
|
+
for child in node.body]
|
882
917
|
elif node.handlers:
|
883
918
|
newnode = new.TryExcept()
|
884
919
|
_lineno_parent(node, newnode, parent)
|
885
|
-
newnode.body = [self.visit(child, newnode)
|
886
|
-
|
887
|
-
newnode.
|
920
|
+
newnode.body = [self.visit(child, newnode, assign_ctx)
|
921
|
+
for child in node.body]
|
922
|
+
newnode.handlers = [self.visit(child, newnode, assign_ctx)
|
923
|
+
for child in node.handlers]
|
924
|
+
newnode.orelse = [self.visit(child, newnode, assign_ctx)
|
925
|
+
for child in node.orelse]
|
888
926
|
return newnode
|
889
927
|
|
890
|
-
def
|
928
|
+
def _visit_with(self, cls, node, parent, assign_ctx=None):
|
891
929
|
if 'items' not in node._fields:
|
892
930
|
# python < 3.3
|
893
|
-
return super(TreeRebuilder3k, self).visit_with(node, parent
|
931
|
+
return super(TreeRebuilder3k, self).visit_with(node, parent,
|
932
|
+
assign_ctx)
|
894
933
|
|
895
|
-
newnode =
|
934
|
+
newnode = cls()
|
896
935
|
_lineno_parent(node, newnode, parent)
|
897
936
|
def visit_child(child):
|
898
937
|
expr = self.visit(child.context_expr, newnode)
|
899
|
-
self.asscontext = 'Ass'
|
900
938
|
if child.optional_vars:
|
901
|
-
var = self.visit(child.optional_vars, newnode
|
939
|
+
var = self.visit(child.optional_vars, newnode,
|
940
|
+
'Assign')
|
902
941
|
else:
|
903
942
|
var = None
|
904
|
-
self.asscontext = None
|
905
943
|
return expr, var
|
906
944
|
newnode.items = [visit_child(child)
|
907
945
|
for child in node.items]
|
908
|
-
newnode.body = [self.visit(child, newnode)
|
946
|
+
newnode.body = [self.visit(child, newnode, None)
|
947
|
+
for child in node.body]
|
909
948
|
return newnode
|
910
949
|
|
911
|
-
def
|
950
|
+
def visit_with(self, node, parent, assign_ctx=None):
|
951
|
+
return self._visit_with(new.With, node, parent, assign_ctx=assign_ctx)
|
952
|
+
|
953
|
+
def visit_yieldfrom(self, node, parent, assign_ctx=None):
|
912
954
|
return _create_yield_node(node, parent, self, new.YieldFrom)
|
913
955
|
|
914
|
-
def
|
915
|
-
newnode = super(TreeRebuilder3k, self).
|
956
|
+
def visit_classdef(self, node, parent, assign_ctx=None):
|
957
|
+
newnode = super(TreeRebuilder3k, self).visit_classdef(node, parent, assign_ctx)
|
916
958
|
newnode._newstyle = True
|
917
959
|
for keyword in node.keywords:
|
918
960
|
if keyword.arg == 'metaclass':
|
919
|
-
newnode._metaclass = self.visit(keyword, newnode).value
|
961
|
+
newnode._metaclass = self.visit(keyword, newnode, assign_ctx).value
|
920
962
|
break
|
921
963
|
return newnode
|
922
964
|
|
923
|
-
|
924
|
-
|
965
|
+
# Async structs added in Python 3.5
|
966
|
+
def visit_asyncfunctiondef(self, node, parent, assign_ctx=None):
|
967
|
+
return self._visit_functiondef(new.AsyncFunctionDef, node, parent,
|
968
|
+
assign_ctx=assign_ctx)
|
925
969
|
|
926
970
|
|
971
|
+
def visit_asyncfor(self, node, parent, assign_ctx=None):
|
972
|
+
return self._visit_for(new.AsyncFor, node, parent,
|
973
|
+
assign_ctx=assign_ctx)
|
974
|
+
|
975
|
+
def visit_await(self, node, parent, assign_ctx=None):
|
976
|
+
newnode = new.Await()
|
977
|
+
newnode.lineno = node.lineno
|
978
|
+
newnode.col_offset = node.col_offset
|
979
|
+
newnode.parent = parent
|
980
|
+
newnode.value = self.visit(node.value, newnode, None)
|
981
|
+
return newnode
|
982
|
+
|
983
|
+
def visit_asyncwith(self, node, parent, assign_ctx=None):
|
984
|
+
return self._visit_with(new.AsyncWith, node, parent,
|
985
|
+
assign_ctx=assign_ctx)
|
986
|
+
|
987
|
+
|
988
|
+
if sys.version_info >= (3, 0):
|
989
|
+
TreeRebuilder = TreeRebuilder3k
|