ttsc 0.33.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/cmd/ttsc/api_compile.go +3 -2
- package/cmd/ttsc/api_transform.go +1 -1
- package/cmd/ttsc/build.go +5 -4
- package/cmd/ttsc-cache/account.go +16 -0
- package/cmd/ttsc-cache/account_test.go +91 -0
- package/cmd/ttsc-cache/main.go +1 -1
- package/cmd/ttsc-cache/protocol_test.go +2 -2
- package/cmd/ttsc-cache/publisher_seal_test.go +1 -1
- package/cmd/ttsc-cache/stock_go_failure_test.go +1 -1
- package/cmd/ttsc-cache/stock_go_test.go +2 -2
- package/cmd/ttsc-cache/store.go +5 -0
- package/cmd/ttsc-cache/tuple.go +6 -2
- package/cmd/ttsc-cache/tuple_test.go +1 -1
- package/cmd/ttscgraph/main.go +6 -1
- package/cmd/ttscgraph/run_help_version_and_bad_flags_exit_codes_test.go +6 -1
- package/cmd/ttscgraph/serve.go +22 -20
- package/cmd/ttscgraph/serve_alternative_members_and_reads_refresh_test.go +95 -0
- package/cmd/ttscgraph/serve_shards.go +26 -15
- package/cmd/ttscgraph/serve_shards_abandoned_generation_converges_on_retry_test.go +2 -2
- package/cmd/ttscgraph/serve_shards_delete_removed_source_test.go +3 -3
- package/cmd/ttscgraph/serve_shards_prune_unreferenced_external_endpoints_test.go +1 -1
- package/cmd/ttscgraph/serve_shards_publish_created_source_test.go +3 -3
- package/cmd/ttscgraph/serve_shards_refresh_cross_file_implementation_test.go +2 -2
- package/cmd/ttscgraph/serve_shards_refresh_dependent_diagnostics_test.go +3 -3
- package/cmd/ttscgraph/serve_shards_rename_moves_source_identity_test.go +5 -5
- package/cmd/ttscgraph/serve_shards_reuse_unaffected_sources_test.go +8 -8
- package/cmd/ttscgraph/serve_source_encoding_test.go +2 -2
- package/driver/build_information_uses_selected_output_identity_test.go +5 -4
- package/driver/check_observations.go +1 -1
- package/driver/config_discovery.go +5 -1
- package/driver/declaration_shape.go +15 -21
- package/driver/diagnostics_preamble.go +2 -2
- package/driver/emit_containment.go +11 -14
- package/driver/emit_plugin.go +51 -43
- package/driver/emit_plugin_output.go +6 -5
- package/driver/emit_provenance.go +12 -15
- package/driver/graph.go +8 -8
- package/driver/host.go +15 -5
- package/driver/input_observation.go +22 -21
- package/driver/input_observation_test.go +11 -10
- package/driver/overlay.go +11 -11
- package/driver/program.go +102 -51
- package/driver/resolution_candidates.go +50 -32
- package/driver/resolution_candidates_test.go +18 -5
- package/driver/rewrite.go +11 -13
- package/driver/session.go +13 -7
- package/driver/target_ts70.go +85 -0
- package/driver/target_ts71.go +97 -0
- package/driver/transform_dependencies.go +1 -1
- package/driver/transform_source_map.go +21 -20
- package/go.mod +3 -3
- package/go.sum +4 -4
- package/internal/graph/alternative_member_declarations_resolve_uses_test.go +145 -0
- package/internal/graph/assigned_implementations_of_declaration_file_symbols_leave_no_edge_source_test.go +2 -2
- package/internal/graph/assigned_implementations_of_node_modules_symbols_leave_no_edge_source_test.go +2 -2
- package/internal/graph/build.go +75 -33
- package/internal/graph/build_files_reuses_committed_cross_file_endpoints_test.go +4 -4
- package/internal/graph/build_records_a_node_per_top_level_declaration_test.go +1 -1
- package/internal/graph/declaration_members.go +143 -0
- package/internal/graph/decorators_capture_name_and_literal_arguments_test.go +3 -3
- package/internal/graph/doc_tags.go +2 -2
- package/internal/graph/dump_paths.go +6 -5
- package/internal/graph/duplicate_variable_object_members_keep_first_declaration_test.go +1 -1
- package/internal/graph/edges.go +151 -68
- package/internal/graph/edges_cover_class_level_references_test.go +5 -5
- package/internal/graph/enum_initializer_calls_are_edges_test.go +2 -2
- package/internal/graph/enum_members_carry_their_names_on_the_enum_node_test.go +6 -6
- package/internal/graph/exports.go +6 -6
- package/internal/graph/file_diagnostics_match_tsgo_code_and_location_test.go +2 -2
- package/internal/graph/file_diagnostics_report_code_column_and_message_test.go +1 -1
- package/internal/graph/function_locals_do_not_collide_test.go +3 -3
- package/internal/graph/heritage_edges_cover_implements_and_interface_extends_test.go +5 -5
- package/internal/graph/heritage_edges_keep_extends_and_implements_to_same_base_test.go +2 -2
- package/internal/graph/heritage_edges_record_extends_versus_implements_origin_test.go +3 -3
- package/internal/graph/heritage_edges_traverse_barrels_and_stop_at_external_leaves_test.go +3 -3
- package/internal/graph/literals.go +3 -3
- package/internal/graph/literals_are_absent_when_the_type_admits_more_than_it_can_name_test.go +2 -2
- package/internal/graph/literals_cover_enum_members_the_graph_has_no_nodes_for_test.go +4 -4
- package/internal/graph/literals_do_not_depend_on_declaration_line_wrapping_test.go +2 -2
- package/internal/graph/literals_render_every_value_in_typescript_source_form_test.go +1 -1
- package/internal/graph/literals_resolve_through_alias_indirection_test.go +3 -3
- package/internal/graph/member_relation_edges_follow_checker_validity_test.go +7 -7
- package/internal/graph/member_relation_edges_preserve_checker_boundaries_test.go +19 -19
- package/internal/graph/member_relation_edges_reject_checker_invalid_pairs_test.go +11 -11
- package/internal/graph/namespace_dotted_form_qualifies_deeply_test.go +2 -2
- package/internal/graph/namespace_members_become_qualified_nodes_and_edges_test.go +7 -7
- package/internal/graph/namespace_private_declarations_keep_lexical_identity_test.go +85 -0
- package/internal/graph/nodes_are_marked_exported_through_the_export_table_test.go +2 -2
- package/internal/graph/object_literal_declarations_resolve_calls_test.go +9 -9
- package/internal/graph/object_literal_members_ride_on_the_snapshot_test.go +1 -1
- package/internal/graph/overload_implementation_replaces_signature_test.go +2 -2
- package/internal/graph/property_member_edges_remain_owner_visible_test.go +6 -6
- package/internal/graph/resolve.go +37 -12
- package/internal/graph/resolve_unwraps_barrel_reexport_to_real_declaration_test.go +6 -6
- package/internal/graph/source.go +1 -1
- package/internal/graph/type_ref_edges_cover_typeof_as_satisfies_test.go +7 -7
- package/internal/graph/type_ref_edges_resolve_named_types_across_files_test.go +2 -2
- package/internal/graph/value_access_edges_cover_properties_test.go +5 -5
- package/internal/graph/value_call_edges_attribute_function_assignments_to_members_test.go +3 -3
- package/internal/graph/value_call_edges_cover_jsx_components_test.go +2 -2
- package/internal/graph/value_call_edges_cover_methods_and_constructors_test.go +3 -3
- package/internal/graph/value_call_edges_cover_variable_bound_callables_test.go +2 -2
- package/internal/graph/value_call_edges_do_not_double_record_invoked_member_access_test.go +4 -4
- package/internal/graph/value_call_edges_record_construct_versus_call_origin_test.go +3 -3
- package/internal/graph/value_call_edges_resolve_across_files_and_dedupe_test.go +2 -2
- package/internal/graph/value_call_edges_skip_self_and_unresolved_test.go +4 -4
- package/internal/graph/value_reads_cover_expression_positions_test.go +88 -0
- package/lib/compiler/internal/buildNativeCompiler.d.ts +5 -2
- package/lib/compiler/internal/buildNativeCompiler.js +12 -4
- package/lib/compiler/internal/buildNativeCompiler.js.map +1 -1
- package/lib/flags/COMPILER_ENUM_WHITESPACE.js +1 -1
- package/lib/flags/COMPILER_ENUM_WHITESPACE.js.map +1 -1
- package/lib/flags/COMPILER_OPTIONS.js +1079 -149
- package/lib/flags/COMPILER_OPTIONS.js.map +1 -1
- package/lib/flags/COMPILER_OPTION_ASCII_FOLDS.js +1 -1
- package/lib/flags/COMPILER_OPTION_ASCII_FOLDS.js.map +1 -1
- package/lib/flags/COMPILER_OPTION_KINDS.js +1 -1
- package/lib/flags/COMPILER_OPTION_KINDS.js.map +1 -1
- package/lib/flags/CompilerOptionSpec.d.ts +9 -2
- package/lib/internal/pluginSource.d.ts +1 -0
- package/lib/internal/pluginSource.js +1 -0
- package/lib/internal/pluginSource.js.map +1 -1
- package/lib/launcher/internal/TypeScriptSyncApi.d.ts +140 -0
- package/lib/launcher/internal/TypeScriptSyncApi.js +99 -0
- package/lib/launcher/internal/TypeScriptSyncApi.js.map +1 -0
- package/lib/launcher/internal/buildSingleRootInMemory.d.ts +80 -0
- package/lib/launcher/internal/buildSingleRootInMemory.js +253 -0
- package/lib/launcher/internal/buildSingleRootInMemory.js.map +1 -0
- package/lib/launcher/internal/buildSingleRootProject.d.ts +22 -18
- package/lib/launcher/internal/buildSingleRootProject.js +27 -18
- package/lib/launcher/internal/buildSingleRootProject.js.map +1 -1
- package/lib/launcher/internal/compilerArgsAsConfigOptions.d.ts +39 -0
- package/lib/launcher/internal/compilerArgsAsConfigOptions.js +115 -0
- package/lib/launcher/internal/compilerArgsAsConfigOptions.js.map +1 -0
- package/lib/plugin/CapabilityPluginResolver.js +3 -0
- package/lib/plugin/CapabilityPluginResolver.js.map +1 -1
- package/lib/plugin/internal/load/loadProjectPlugins.js +6 -2
- package/lib/plugin/internal/load/loadProjectPlugins.js.map +1 -1
- package/lib/plugin/internal/source/CompilerTarget.d.ts +127 -0
- package/lib/plugin/internal/source/CompilerTarget.js +231 -0
- package/lib/plugin/internal/source/CompilerTarget.js.map +1 -0
- package/lib/plugin/internal/source/NativeSourcePackages.js +6 -5
- package/lib/plugin/internal/source/NativeSourcePackages.js.map +1 -1
- package/lib/plugin/internal/source/SourcePluginAdmission.d.ts +18 -1
- package/lib/plugin/internal/source/SourcePluginAdmission.js +24 -2
- package/lib/plugin/internal/source/SourcePluginAdmission.js.map +1 -1
- package/lib/plugin/internal/source/SourcePluginWorkspace.d.ts +6 -3
- package/lib/plugin/internal/source/SourcePluginWorkspace.js +31 -13
- package/lib/plugin/internal/source/SourcePluginWorkspace.js.map +1 -1
- package/lib/plugin/internal/source/buildSourcePlugin.js +3 -1
- package/lib/plugin/internal/source/buildSourcePlugin.js.map +1 -1
- package/lib/plugin/internal/source/hashPluginBuildEnvironment.d.ts +1 -1
- package/lib/plugin/internal/source/hashPluginBuildEnvironment.js +9 -1
- package/lib/plugin/internal/source/hashPluginBuildEnvironment.js.map +1 -1
- package/package.json +14 -9
- package/shim/ast/enums_gen.go +1 -0
- package/shim/ast/go.mod +2 -2
- package/shim/ast/go.sum +4 -4
- package/shim/ast/neutral.go +141 -0
- package/shim/astnav/go.mod +2 -2
- package/shim/astnav/go.sum +4 -4
- package/shim/bundled/go.mod +2 -2
- package/shim/bundled/go.sum +4 -4
- package/shim/checker/go.mod +2 -2
- package/shim/checker/go.sum +4 -4
- package/shim/compiler/go.mod +2 -2
- package/shim/compiler/go.sum +4 -4
- package/shim/compiler/neutral.go +213 -0
- package/shim/core/go.mod +2 -2
- package/shim/core/go.sum +4 -4
- package/shim/diagnosticwriter/go.mod +2 -2
- package/shim/diagnosticwriter/go.sum +4 -4
- package/shim/lsp/go.mod +2 -2
- package/shim/lsp/go.sum +4 -4
- package/shim/parser/go.mod +2 -2
- package/shim/parser/go.sum +4 -4
- package/shim/printer/go.mod +2 -2
- package/shim/printer/go.sum +4 -4
- package/shim/scanner/go.mod +2 -2
- package/shim/scanner/go.sum +4 -4
- package/shim/stringutil/go.mod +1 -1
- package/shim/stringutil/go.sum +2 -2
- package/shim/stringutil/shim.go +15 -0
- package/shim/transformers/go.mod +2 -2
- package/shim/transformers/go.sum +4 -4
- package/shim/tsoptions/go.mod +2 -2
- package/shim/tsoptions/go.sum +4 -4
- package/shim/tsoptions/neutral.go +56 -0
- package/shim/tspath/go.mod +1 -1
- package/shim/tspath/go.sum +2 -2
- package/shim/tspath/neutral.go +150 -0
- package/shim/tspath/typed_paths.go +266 -0
- package/shim/vfs/cachedvfs/go.mod +2 -2
- package/shim/vfs/cachedvfs/go.sum +4 -4
- package/shim/vfs/go.mod +2 -2
- package/shim/vfs/go.sum +4 -4
- package/shim/vfs/neutral.go +20 -0
- package/shim/vfs/osvfs/go.mod +2 -2
- package/shim/vfs/osvfs/go.sum +4 -4
- package/src/compiler/internal/buildNativeCompiler.ts +13 -4
- package/src/flags/COMPILER_ENUM_WHITESPACE.ts +1 -1
- package/src/flags/COMPILER_OPTIONS.ts +1080 -150
- package/src/flags/COMPILER_OPTION_ASCII_FOLDS.ts +1 -1
- package/src/flags/COMPILER_OPTION_KINDS.ts +1 -1
- package/src/flags/CompilerOptionSpec.ts +11 -2
- package/src/internal/pluginSource.ts +1 -0
- package/src/launcher/internal/TypeScriptSyncApi.ts +186 -0
- package/src/launcher/internal/buildSingleRootInMemory.ts +319 -0
- package/src/launcher/internal/buildSingleRootProject.ts +26 -18
- package/src/launcher/internal/compilerArgsAsConfigOptions.ts +112 -0
- package/src/plugin/CapabilityPluginResolver.ts +4 -1
- package/src/plugin/internal/load/loadProjectPlugins.ts +12 -2
- package/src/plugin/internal/source/CompilerTarget.ts +249 -0
- package/src/plugin/internal/source/NativeSourcePackages.ts +10 -4
- package/src/plugin/internal/source/SourcePluginAdmission.ts +28 -2
- package/src/plugin/internal/source/SourcePluginWorkspace.ts +45 -19
- package/src/plugin/internal/source/buildSourcePlugin.ts +3 -1
- package/src/plugin/internal/source/hashPluginBuildEnvironment.ts +9 -1
- package/targets/7.1/bridge/ast/enums_gen.go +174 -0
- package/targets/7.1/bridge/ast/extra-shim.json +4 -0
- package/targets/7.1/bridge/ast/go.mod +14 -0
- package/targets/7.1/bridge/ast/go.sum +20 -0
- package/targets/7.1/bridge/ast/lint.go +1412 -0
- package/targets/7.1/bridge/ast/neutral.go +141 -0
- package/targets/7.1/bridge/ast/parent.go +60 -0
- package/targets/7.1/bridge/ast/safe_text.go +108 -0
- package/targets/7.1/bridge/ast/shim.go +1656 -0
- package/targets/7.1/bridge/ast/surface.go +686 -0
- package/targets/7.1/bridge/ast/test/next_jsdoc_comment_location_reaches_variable_statement_test.go +51 -0
- package/targets/7.1/bridge/ast/test/node_text_joins_multi_hop_qualified_name_test.go +47 -0
- package/targets/7.1/bridge/ast/test/node_text_joins_one_hop_qualified_name_test.go +35 -0
- package/targets/7.1/bridge/ast/test/node_text_returns_empty_for_nil_test.go +31 -0
- package/targets/7.1/bridge/ast/test/node_text_returns_identifier_text_test.go +34 -0
- package/targets/7.1/bridge/ast/test/node_text_skips_empty_qualified_left_test.go +60 -0
- package/targets/7.1/bridge/astnav/go.mod +14 -0
- package/targets/7.1/bridge/astnav/go.sum +22 -0
- package/targets/7.1/bridge/astnav/shim.go +24 -0
- package/targets/7.1/bridge/bundled/extra-shim.json +1 -0
- package/targets/7.1/bridge/bundled/go.mod +10 -0
- package/targets/7.1/bridge/bundled/go.sum +10 -0
- package/targets/7.1/bridge/bundled/shim.go +24 -0
- package/targets/7.1/bridge/checker/enums_gen.go +150 -0
- package/targets/7.1/bridge/checker/extra-shim.json +37 -0
- package/targets/7.1/bridge/checker/go.mod +15 -0
- package/targets/7.1/bridge/checker/go.sum +24 -0
- package/targets/7.1/bridge/checker/node_builder_fields_gen.go +19 -0
- package/targets/7.1/bridge/checker/shim.go +1390 -0
- package/targets/7.1/bridge/compiler/contentmapper_process.go +70 -0
- package/targets/7.1/bridge/compiler/emit_sourcemap.go +296 -0
- package/targets/7.1/bridge/compiler/emitassemble.go +81 -0
- package/targets/7.1/bridge/compiler/emithook.go +44 -0
- package/targets/7.1/bridge/compiler/extra-shim.json +4 -0
- package/targets/7.1/bridge/compiler/go.mod +15 -0
- package/targets/7.1/bridge/compiler/go.sum +24 -0
- package/targets/7.1/bridge/compiler/incremental.go +185 -0
- package/targets/7.1/bridge/compiler/neutral.go +256 -0
- package/targets/7.1/bridge/compiler/resolution.go +571 -0
- package/targets/7.1/bridge/compiler/shim.go +70 -0
- package/targets/7.1/bridge/core/enums_gen.go +15 -0
- package/targets/7.1/bridge/core/extra-shim.json +4 -0
- package/targets/7.1/bridge/core/go.mod +7 -0
- package/targets/7.1/bridge/core/go.sum +8 -0
- package/targets/7.1/bridge/core/modulekind.go +19 -0
- package/targets/7.1/bridge/core/shim.go +272 -0
- package/targets/7.1/bridge/diagnosticwriter/go.mod +14 -0
- package/targets/7.1/bridge/diagnosticwriter/go.sum +20 -0
- package/targets/7.1/bridge/diagnosticwriter/lint.go +411 -0
- package/targets/7.1/bridge/diagnosticwriter/shim.go +56 -0
- package/targets/7.1/bridge/lsp/extra-shim.json +4 -0
- package/targets/7.1/bridge/lsp/go.mod +16 -0
- package/targets/7.1/bridge/lsp/go.sum +26 -0
- package/targets/7.1/bridge/lsp/shim.go +112 -0
- package/targets/7.1/bridge/parser/extra-shim.json +4 -0
- package/targets/7.1/bridge/parser/go.mod +14 -0
- package/targets/7.1/bridge/parser/go.sum +24 -0
- package/targets/7.1/bridge/parser/shim.go +61 -0
- package/targets/7.1/bridge/printer/emithost.go +69 -0
- package/targets/7.1/bridge/printer/go.mod +15 -0
- package/targets/7.1/bridge/printer/go.sum +24 -0
- package/targets/7.1/bridge/printer/shim.go +168 -0
- package/targets/7.1/bridge/printer/sourcemap.go +49 -0
- package/targets/7.1/bridge/scanner/extra-shim.json +4 -0
- package/targets/7.1/bridge/scanner/go.mod +14 -0
- package/targets/7.1/bridge/scanner/go.sum +20 -0
- package/targets/7.1/bridge/scanner/regexp.go +42 -0
- package/targets/7.1/bridge/scanner/shim.go +137 -0
- package/targets/7.1/bridge/stringutil/extra-shim.json +1 -0
- package/targets/7.1/bridge/stringutil/go.mod +5 -0
- package/targets/7.1/bridge/stringutil/go.sum +2 -0
- package/targets/7.1/bridge/stringutil/shim.go +131 -0
- package/targets/7.1/bridge/transformers/go.mod +15 -0
- package/targets/7.1/bridge/transformers/go.sum +24 -0
- package/targets/7.1/bridge/transformers/shim.go +24 -0
- package/targets/7.1/bridge/tsoptions/command_line_raw.go +44 -0
- package/targets/7.1/bridge/tsoptions/extra-shim.json +4 -0
- package/targets/7.1/bridge/tsoptions/go.mod +15 -0
- package/targets/7.1/bridge/tsoptions/go.sum +24 -0
- package/targets/7.1/bridge/tsoptions/neutral.go +47 -0
- package/targets/7.1/bridge/tsoptions/shim.go +193 -0
- package/targets/7.1/bridge/tspath/extra-shim.json +4 -0
- package/targets/7.1/bridge/tspath/go.mod +5 -0
- package/targets/7.1/bridge/tspath/go.sum +6 -0
- package/targets/7.1/bridge/tspath/neutral.go +142 -0
- package/targets/7.1/bridge/tspath/shim.go +382 -0
- package/targets/7.1/bridge/vfs/cachedvfs/extra-shim.json +4 -0
- package/targets/7.1/bridge/vfs/cachedvfs/go.mod +5 -0
- package/targets/7.1/bridge/vfs/cachedvfs/go.sum +10 -0
- package/targets/7.1/bridge/vfs/cachedvfs/shim.go +12 -0
- package/targets/7.1/bridge/vfs/decode.go +26 -0
- package/targets/7.1/bridge/vfs/decode_test.go +42 -0
- package/targets/7.1/bridge/vfs/extra-shim.json +4 -0
- package/targets/7.1/bridge/vfs/go.mod +10 -0
- package/targets/7.1/bridge/vfs/go.sum +10 -0
- package/targets/7.1/bridge/vfs/neutral.go +23 -0
- package/targets/7.1/bridge/vfs/osvfs/extra-shim.json +4 -0
- package/targets/7.1/bridge/vfs/osvfs/go.mod +10 -0
- package/targets/7.1/bridge/vfs/osvfs/go.sum +10 -0
- package/targets/7.1/bridge/vfs/osvfs/shim.go +14 -0
- package/targets/7.1/bridge/vfs/shim.go +27 -0
- package/targets/7.1/facade/ast/facade_gen.go +2691 -0
- package/targets/7.1/facade/ast/go.mod +20 -0
- package/targets/7.1/facade/ast/go.sum +20 -0
- package/targets/7.1/facade/astnav/facade_gen.go +15 -0
- package/targets/7.1/facade/astnav/go.mod +22 -0
- package/targets/7.1/facade/astnav/go.sum +22 -0
- package/targets/7.1/facade/bundled/facade_gen.go +32 -0
- package/targets/7.1/facade/bundled/go.mod +21 -0
- package/targets/7.1/facade/bundled/go.sum +10 -0
- package/targets/7.1/facade/checker/facade_gen.go +563 -0
- package/targets/7.1/facade/checker/go.mod +26 -0
- package/targets/7.1/facade/checker/go.sum +24 -0
- package/targets/7.1/facade/compiler/facade_gen.go +198 -0
- package/targets/7.1/facade/compiler/go.mod +41 -0
- package/targets/7.1/facade/compiler/go.sum +24 -0
- package/targets/7.1/facade/core/facade_gen.go +130 -0
- package/targets/7.1/facade/core/go.mod +12 -0
- package/targets/7.1/facade/core/go.sum +8 -0
- package/targets/7.1/facade/diagnosticwriter/facade_gen.go +36 -0
- package/targets/7.1/facade/diagnosticwriter/go.mod +22 -0
- package/targets/7.1/facade/diagnosticwriter/go.sum +20 -0
- package/targets/7.1/facade/lsp/facade_gen.go +31 -0
- package/targets/7.1/facade/lsp/go.mod +19 -0
- package/targets/7.1/facade/lsp/go.sum +26 -0
- package/targets/7.1/facade/parser/facade_gen.go +102 -0
- package/targets/7.1/facade/parser/go.mod +25 -0
- package/targets/7.1/facade/parser/go.sum +24 -0
- package/targets/7.1/facade/printer/facade_gen.go +74 -0
- package/targets/7.1/facade/printer/go.mod +26 -0
- package/targets/7.1/facade/printer/go.sum +24 -0
- package/targets/7.1/facade/scanner/facade_gen.go +191 -0
- package/targets/7.1/facade/scanner/go.mod +25 -0
- package/targets/7.1/facade/scanner/go.sum +20 -0
- package/targets/7.1/facade/stringutil/facade_gen.go +176 -0
- package/targets/7.1/facade/stringutil/go.mod +9 -0
- package/targets/7.1/facade/stringutil/go.sum +2 -0
- package/targets/7.1/facade/transformers/facade_gen.go +12 -0
- package/targets/7.1/facade/transformers/go.mod +18 -0
- package/targets/7.1/facade/transformers/go.sum +24 -0
- package/targets/7.1/facade/tsoptions/facade_gen.go +274 -0
- package/targets/7.1/facade/tsoptions/go.mod +32 -0
- package/targets/7.1/facade/tsoptions/go.sum +24 -0
- package/targets/7.1/facade/tspath/facade_gen.go +550 -0
- package/targets/7.1/facade/tspath/go.mod +9 -0
- package/targets/7.1/facade/tspath/go.sum +6 -0
- package/targets/7.1/facade/vfs/cachedvfs/facade_gen.go +17 -0
- package/targets/7.1/facade/vfs/cachedvfs/go.mod +18 -0
- package/targets/7.1/facade/vfs/cachedvfs/go.sum +10 -0
- package/targets/7.1/facade/vfs/facade_gen.go +47 -0
- package/targets/7.1/facade/vfs/go.mod +18 -0
- package/targets/7.1/facade/vfs/go.sum +10 -0
- package/targets/7.1/facade/vfs/osvfs/facade_gen.go +20 -0
- package/targets/7.1/facade/vfs/osvfs/go.mod +21 -0
- package/targets/7.1/facade/vfs/osvfs/go.sum +10 -0
- package/tools/gen_facade/committed_facades_match_their_bridges_test.go +57 -0
- package/tools/gen_facade/facade_manifest_points_into_the_bridge_root_test.go +75 -0
- package/tools/gen_facade/facade_spells_internal_types_through_bridge_aliases_test.go +75 -0
- package/tools/gen_facade/facade_types_are_their_bridge_types_test.go +99 -0
- package/tools/gen_facade/go.mod +10 -0
- package/tools/gen_facade/go.sum +8 -0
- package/tools/gen_facade/main.go +734 -0
- package/tools/gen_shims/go.mod +4 -4
- package/tools/gen_shims/go.sum +6 -6
- package/tools/gen_shims/main.go +124 -66
- package/tools/gen_shims/mirror_structs_terminate_on_unexported_cycles_test.go +101 -0
- package/tools/shim_audit/baseline-7.1.json +720 -0
- package/tools/shim_audit/baseline.json +5 -4
- package/tools/shim_audit/go.mod +4 -4
- package/tools/shim_audit/go.sum +6 -6
- package/tools/shim_audit/linkname_signatures.go +178 -0
- package/tools/shim_audit/linkname_signatures_match_their_targets_test.go +64 -0
- package/tools/shim_audit/linkname_targets_follow_the_audited_compiler_test.go +38 -0
- package/tools/shim_audit/main.go +29 -4
- package/tools/shim_audit/neutral_api.go +160 -0
- package/tools/shim_audit/neutral_api_must_match_across_targets_test.go +74 -0
- package/utility/host.go +5 -4
- package/utility/preamble_output.go +15 -15
- package/utility/serve.go +1 -1
package/internal/graph/edges.go
CHANGED
|
@@ -24,7 +24,7 @@ func (g *Graph) addEdges(prog *driver.Program, selected map[string]bool, partial
|
|
|
24
24
|
if !IsWorkspaceSourceFile(file) {
|
|
25
25
|
continue
|
|
26
26
|
}
|
|
27
|
-
if partial && !selected[file.FileName()] {
|
|
27
|
+
if partial && !selected[string(file.FileName())] {
|
|
28
28
|
continue
|
|
29
29
|
}
|
|
30
30
|
g.markExports(checker, file)
|
|
@@ -34,7 +34,7 @@ func (g *Graph) addEdges(prog *driver.Program, selected map[string]bool, partial
|
|
|
34
34
|
g.collectDocRefs(checker, file)
|
|
35
35
|
g.collectLiterals(checker, file)
|
|
36
36
|
if file.Statements != nil {
|
|
37
|
-
g.collectDecorators(file.FileName(), file.Statements.Nodes)
|
|
37
|
+
g.collectDecorators(string(file.FileName()), file.Statements.Nodes)
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -72,7 +72,7 @@ func (g *Graph) collectHeritage(checker *shimchecker.Checker, file *shimast.Sour
|
|
|
72
72
|
if file.Statements == nil {
|
|
73
73
|
return
|
|
74
74
|
}
|
|
75
|
-
g.collectHeritageIn(checker, file.FileName(), file.Statements.Nodes)
|
|
75
|
+
g.collectHeritageIn(checker, string(file.FileName()), file.Statements.Nodes)
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
// collectHeritageIn adds heritage edges for the class/interface statements in a
|
|
@@ -90,6 +90,17 @@ func (g *Graph) collectHeritageIn(checker *shimchecker.Checker, path string, sta
|
|
|
90
90
|
if decl != nil && decl.HeritageClauses != nil {
|
|
91
91
|
g.heritageEdges(checker, path, statement, NodeInterface, decl.HeritageClauses.Nodes)
|
|
92
92
|
}
|
|
93
|
+
case shimast.KindVariableStatement:
|
|
94
|
+
variables := statement.AsVariableStatement().DeclarationList
|
|
95
|
+
if variables != nil && variables.AsVariableDeclarationList().Declarations != nil {
|
|
96
|
+
for _, binding := range variables.AsVariableDeclarationList().Declarations.Nodes {
|
|
97
|
+
if expression := boundClassExpression(binding); expression != nil {
|
|
98
|
+
if clauses := expression.AsClassExpression().HeritageClauses; clauses != nil {
|
|
99
|
+
g.heritageEdges(checker, path, expression, NodeClass, clauses.Nodes)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
93
104
|
case shimast.KindModuleDeclaration:
|
|
94
105
|
g.collectHeritageIn(checker, path, moduleStatements(statement))
|
|
95
106
|
}
|
|
@@ -100,10 +111,17 @@ func (g *Graph) collectHeritageIn(checker *shimchecker.Checker, path string, sta
|
|
|
100
111
|
// records a heritage edge from node to the resolved base node.
|
|
101
112
|
func (g *Graph) heritageEdges(checker *shimchecker.Checker, path string, node *shimast.Node, kind NodeKind, clauses []*shimast.Node) {
|
|
102
113
|
symbol := node.Symbol()
|
|
103
|
-
if symbol == nil || symbol
|
|
114
|
+
if symbol == nil || shimast.SymbolNameOf(symbol) == "" {
|
|
104
115
|
return
|
|
105
116
|
}
|
|
106
117
|
from := nodeID(path, qualifiedName(symbol), kind)
|
|
118
|
+
if node.Kind == shimast.KindClassExpression {
|
|
119
|
+
owner := classExpressionOwner(node)
|
|
120
|
+
if owner == "" {
|
|
121
|
+
return
|
|
122
|
+
}
|
|
123
|
+
from = nodeID(path, owner, NodeVariable)
|
|
124
|
+
}
|
|
107
125
|
for _, clauseNode := range clauses {
|
|
108
126
|
clause := clauseNode.AsHeritageClause()
|
|
109
127
|
if clause == nil || clause.Types == nil {
|
|
@@ -117,11 +135,11 @@ func (g *Graph) heritageEdges(checker *shimchecker.Checker, path string, node *s
|
|
|
117
135
|
origin = "extends"
|
|
118
136
|
}
|
|
119
137
|
for _, typeNode := range clause.Types.Nodes {
|
|
120
|
-
|
|
121
|
-
if
|
|
138
|
+
name := heritageElementName(typeNode)
|
|
139
|
+
if name == nil {
|
|
122
140
|
continue
|
|
123
141
|
}
|
|
124
|
-
target := g.resolve(checker,
|
|
142
|
+
target := g.resolve(checker, name)
|
|
125
143
|
if target == nil || target.Symbol == nil {
|
|
126
144
|
continue
|
|
127
145
|
}
|
|
@@ -129,12 +147,23 @@ func (g *Graph) heritageEdges(checker *shimchecker.Checker, path string, node *s
|
|
|
129
147
|
if to == "" {
|
|
130
148
|
continue
|
|
131
149
|
}
|
|
132
|
-
g.addEdgeAt(from, to, EdgeHeritage, origin,
|
|
150
|
+
g.addEdgeAt(from, to, EdgeHeritage, origin, name.Pos(), name.End())
|
|
133
151
|
g.memberRelationEdges(checker, node, kind, typeNode, target, origin)
|
|
134
152
|
}
|
|
135
153
|
}
|
|
136
154
|
}
|
|
137
155
|
|
|
156
|
+
// heritageElementName is the name a heritage clause element refers to. The
|
|
157
|
+
// parser represents an interface's `extends` and a class's `implements`
|
|
158
|
+
// element as a type reference when it is an entity name, and every other
|
|
159
|
+
// element as an expression with type arguments.
|
|
160
|
+
func heritageElementName(element *shimast.Node) *shimast.Node {
|
|
161
|
+
if element.Kind == shimast.KindTypeReference {
|
|
162
|
+
return element.AsTypeReferenceNode().TypeName
|
|
163
|
+
}
|
|
164
|
+
return element.AsExpressionWithTypeArguments().Expression
|
|
165
|
+
}
|
|
166
|
+
|
|
138
167
|
// memberRelationEdges records the directly declared member pairs that a
|
|
139
168
|
// heritage clause makes checker-valid. Inferring them from equal names after the
|
|
140
169
|
// dump was built would make an authoritative edge even when the checker rejects
|
|
@@ -183,8 +212,8 @@ func (g *Graph) memberRelationEdges(
|
|
|
183
212
|
continue
|
|
184
213
|
}
|
|
185
214
|
|
|
186
|
-
derivedProperty := checker.GetPropertyOfType(derivedType, derivedMemberSymbol
|
|
187
|
-
baseProperty := checker.GetPropertyOfType(baseType, derivedMemberSymbol
|
|
215
|
+
derivedProperty := checker.GetPropertyOfType(derivedType, shimast.SymbolNameOf(derivedMemberSymbol))
|
|
216
|
+
baseProperty := checker.GetPropertyOfType(baseType, shimast.SymbolNameOf(derivedMemberSymbol))
|
|
188
217
|
if derivedProperty == nil || baseProperty == nil ||
|
|
189
218
|
!propertyRootsAt(checker, derivedProperty, derivedMemberSymbol) {
|
|
190
219
|
continue
|
|
@@ -233,7 +262,7 @@ func declaredTypeMembers(symbol *shimast.Symbol) []*shimast.Node {
|
|
|
233
262
|
return nil
|
|
234
263
|
}
|
|
235
264
|
var members []*shimast.Node
|
|
236
|
-
for _, declaration := range symbol
|
|
265
|
+
for _, declaration := range shimast.SymbolDeclarationsOf(symbol) {
|
|
237
266
|
members = append(members, classMembers(declaration)...)
|
|
238
267
|
}
|
|
239
268
|
return members
|
|
@@ -259,7 +288,7 @@ func inheritedMemberForProperty(
|
|
|
259
288
|
if root == nil {
|
|
260
289
|
continue
|
|
261
290
|
}
|
|
262
|
-
for _, declaration := range root
|
|
291
|
+
for _, declaration := range shimast.SymbolDeclarationsOf(root) {
|
|
263
292
|
if declaration == nil ||
|
|
264
293
|
shimast.GetCombinedModifierFlags(declaration)&shimast.ModifierFlagsStatic != 0 ||
|
|
265
294
|
declaration.Kind == shimast.KindConstructor {
|
|
@@ -327,17 +356,13 @@ func graphMemberNodeID(g *Graph, member *shimast.Node) string {
|
|
|
327
356
|
if file == nil || name == "" {
|
|
328
357
|
return ""
|
|
329
358
|
}
|
|
330
|
-
id := nodeID(file.FileName(), name, kind)
|
|
359
|
+
id := nodeID(string(file.FileName()), name, kind)
|
|
331
360
|
stored, ok := g.lookupNode(id)
|
|
332
361
|
if !ok {
|
|
333
362
|
return ""
|
|
334
363
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
if declarationFile != nil && declarationFile.FileName() == stored.File &&
|
|
338
|
-
declaration.Pos() == stored.Pos && declaration.End() == stored.End {
|
|
339
|
-
return id
|
|
340
|
-
}
|
|
364
|
+
if nodeDeclaresSymbol(stored, member.Symbol()) {
|
|
365
|
+
return id
|
|
341
366
|
}
|
|
342
367
|
return ""
|
|
343
368
|
}
|
|
@@ -348,7 +373,7 @@ func graphMemberNodeID(g *Graph, member *shimast.Node) string {
|
|
|
348
373
|
// top-level variable binding, or the class itself for a member that is not a
|
|
349
374
|
// method (a property initializer).
|
|
350
375
|
func (g *Graph) collectCalls(checker *shimchecker.Checker, file *shimast.SourceFile) {
|
|
351
|
-
forEachContainer(file.FileName(), file, func(from string, node *shimast.Node) {
|
|
376
|
+
forEachContainer(string(file.FileName()), file, func(from string, node *shimast.Node) {
|
|
352
377
|
g.callsWithin(checker, from, node)
|
|
353
378
|
})
|
|
354
379
|
}
|
|
@@ -382,6 +407,7 @@ func forEachContainerIn(path string, statements []*shimast.Node, fn func(string,
|
|
|
382
407
|
if id := topLevelID(path, statement, NodeTypeAlias); id != "" {
|
|
383
408
|
fn(id, statement)
|
|
384
409
|
}
|
|
410
|
+
forEachMember(path, statement, NodeTypeAlias, fn)
|
|
385
411
|
case shimast.KindEnumDeclaration:
|
|
386
412
|
// An enum is a recorded node (build.go), and a member initializer can call a
|
|
387
413
|
// function (`enum E { A = base() }`) or reference a type, so walk its body
|
|
@@ -420,7 +446,7 @@ func moduleID(path string) string {
|
|
|
420
446
|
// pass recorded.
|
|
421
447
|
func topLevelID(path string, statement *shimast.Node, kind NodeKind) string {
|
|
422
448
|
symbol := statement.Symbol()
|
|
423
|
-
if symbol == nil || symbol
|
|
449
|
+
if symbol == nil || shimast.SymbolNameOf(symbol) == "" {
|
|
424
450
|
return ""
|
|
425
451
|
}
|
|
426
452
|
return nodeID(path, qualifiedName(symbol), kind)
|
|
@@ -433,6 +459,12 @@ func topLevelID(path string, statement *shimast.Node, kind NodeKind) string {
|
|
|
433
459
|
// lose dependency edges the owner node carries.
|
|
434
460
|
func forEachMember(path string, statement *shimast.Node, kind NodeKind, fn func(string, *shimast.Node)) {
|
|
435
461
|
containerID := topLevelID(path, statement, kind)
|
|
462
|
+
if statement.Kind == shimast.KindClassExpression {
|
|
463
|
+
containerID = ""
|
|
464
|
+
if owner := classExpressionOwner(statement); owner != "" {
|
|
465
|
+
containerID = nodeID(path, owner, NodeVariable)
|
|
466
|
+
}
|
|
467
|
+
}
|
|
436
468
|
for _, member := range classMembers(statement) {
|
|
437
469
|
forEachClosureIn(path, member, fn)
|
|
438
470
|
if isMethodMember(member.Kind) {
|
|
@@ -479,6 +511,10 @@ func heritageClauses(statement *shimast.Node) []*shimast.Node {
|
|
|
479
511
|
if decl := statement.AsClassDeclaration(); decl != nil && decl.HeritageClauses != nil {
|
|
480
512
|
return decl.HeritageClauses.Nodes
|
|
481
513
|
}
|
|
514
|
+
case shimast.KindClassExpression:
|
|
515
|
+
if decl := statement.AsClassExpression(); decl != nil && decl.HeritageClauses != nil {
|
|
516
|
+
return decl.HeritageClauses.Nodes
|
|
517
|
+
}
|
|
482
518
|
case shimast.KindInterfaceDeclaration:
|
|
483
519
|
if decl := statement.AsInterfaceDeclaration(); decl != nil && decl.HeritageClauses != nil {
|
|
484
520
|
return decl.HeritageClauses.Nodes
|
|
@@ -501,10 +537,13 @@ func forEachVariable(path string, statement *shimast.Node, fn func(string, *shim
|
|
|
501
537
|
}
|
|
502
538
|
for _, binding := range list.Declarations.Nodes {
|
|
503
539
|
symbol := binding.Symbol()
|
|
504
|
-
if symbol == nil || symbol
|
|
540
|
+
if symbol == nil || shimast.SymbolNameOf(symbol) == "" {
|
|
505
541
|
continue
|
|
506
542
|
}
|
|
507
543
|
fn(nodeID(path, qualifiedName(symbol), NodeVariable), binding)
|
|
544
|
+
if expression := boundClassExpression(binding); expression != nil {
|
|
545
|
+
forEachMember(path, expression, NodeVariable, fn)
|
|
546
|
+
}
|
|
508
547
|
if variable := binding.AsVariableDeclaration(); variable != nil {
|
|
509
548
|
forEachObjectDeclaration(path, variable.Initializer, fn)
|
|
510
549
|
}
|
|
@@ -542,6 +581,11 @@ func closureID(path string, closure *shimast.Node) string {
|
|
|
542
581
|
// value-call edges, and property or element access as value-access edges.
|
|
543
582
|
func (g *Graph) callsWithin(checker *shimchecker.Checker, from string, node *shimast.Node) {
|
|
544
583
|
node.ForEachChild(func(child *shimast.Node) bool {
|
|
584
|
+
// Computed names and typeof inside a type surface are type dependencies,
|
|
585
|
+
// even when the language-service expression predicate accepts their names.
|
|
586
|
+
if shimast.IsPartOfTypeNode(child) || child.Kind == shimast.KindTypeQuery {
|
|
587
|
+
return false
|
|
588
|
+
}
|
|
545
589
|
// The owning callable keeps aggregate body relationships across closures.
|
|
546
590
|
// forEachClosureIn also records each named closure's own relationships.
|
|
547
591
|
switch child.Kind {
|
|
@@ -557,7 +601,6 @@ func (g *Graph) callsWithin(checker *shimchecker.Checker, from string, node *shi
|
|
|
557
601
|
}
|
|
558
602
|
if call := child.AsCallExpression(); call != nil && call.Expression != nil {
|
|
559
603
|
g.callEdge(checker, from, call.Expression, "call")
|
|
560
|
-
g.handedOffValues(checker, from, call)
|
|
561
604
|
}
|
|
562
605
|
case shimast.KindNewExpression:
|
|
563
606
|
if newExpr := child.AsNewExpression(); newExpr != nil && newExpr.Expression != nil {
|
|
@@ -582,6 +625,12 @@ func (g *Graph) callsWithin(checker *shimchecker.Checker, from string, node *shi
|
|
|
582
625
|
if !isInvokedAccess(child) {
|
|
583
626
|
g.accessEdge(checker, from, child)
|
|
584
627
|
}
|
|
628
|
+
case shimast.KindIdentifier:
|
|
629
|
+
if isValueIdentifier(child) {
|
|
630
|
+
g.accessEdge(checker, from, child)
|
|
631
|
+
}
|
|
632
|
+
case shimast.KindShorthandPropertyAssignment, shimast.KindBindingElement, shimast.KindJsxAttribute:
|
|
633
|
+
g.accessEdge(checker, from, child)
|
|
585
634
|
case shimast.KindBinaryExpression:
|
|
586
635
|
if target := g.assignedFunctionTarget(checker, from, child); target != "" {
|
|
587
636
|
file := g.recordImplementation(target, child)
|
|
@@ -652,14 +701,14 @@ func (g *Graph) recordImplementation(id string, assignment *shimast.Node) string
|
|
|
652
701
|
sources = map[string]bool{}
|
|
653
702
|
g.ImplementationSources[id] = sources
|
|
654
703
|
}
|
|
655
|
-
sources[file.FileName()] = true
|
|
704
|
+
sources[string(file.FileName())] = true
|
|
656
705
|
current := g.Nodes[id]
|
|
657
706
|
if current != nil && current.ImplementationFile == "" {
|
|
658
|
-
current.ImplementationFile = file.FileName()
|
|
707
|
+
current.ImplementationFile = string(file.FileName())
|
|
659
708
|
current.ImplementationPos = assignment.Pos()
|
|
660
709
|
current.ImplementationEnd = assignment.End()
|
|
661
710
|
}
|
|
662
|
-
return file.FileName()
|
|
711
|
+
return string(file.FileName())
|
|
663
712
|
}
|
|
664
713
|
|
|
665
714
|
func (g *Graph) withEdgeEvidenceFile(from, file string, visit func()) {
|
|
@@ -707,29 +756,22 @@ func (g *Graph) callEdge(checker *shimchecker.Checker, from string, callee *shim
|
|
|
707
756
|
g.valueUseEdge(checker, from, callee, EdgeValueCall, origin)
|
|
708
757
|
}
|
|
709
758
|
|
|
710
|
-
//
|
|
711
|
-
//
|
|
712
|
-
//
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
// React.memo(ExcalidrawBase)` would reach nothing of the component behind it.
|
|
718
|
-
//
|
|
719
|
-
// A function handed to another function is a use of it, and it is the one the
|
|
720
|
-
// runtime will run. Bounded to argument position: this is the callback, the
|
|
721
|
-
// wrapped component, the registered handler — not every identifier in every
|
|
722
|
-
// expression.
|
|
723
|
-
func (g *Graph) handedOffValues(checker *shimchecker.Checker, from string, call *shimast.CallExpression) {
|
|
724
|
-
if call.Arguments == nil {
|
|
725
|
-
return
|
|
759
|
+
// isValueIdentifier uses the compiler's expression classification and excludes
|
|
760
|
+
// names already represented by their enclosing access, call or JSX expression.
|
|
761
|
+
// Type queries are expressions to the language service but remain type edges here.
|
|
762
|
+
func isValueIdentifier(node *shimast.Node) bool {
|
|
763
|
+
parent := node.Parent
|
|
764
|
+
if parent == nil || !shimast.IsExpressionNode(node) || shimast.IsDeclarationNameOrImportPropertyName(node) || isInvokedAccess(node) {
|
|
765
|
+
return false
|
|
726
766
|
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
767
|
+
switch parent.Kind {
|
|
768
|
+
case shimast.KindPropertyAccessExpression:
|
|
769
|
+
return parent.AsPropertyAccessExpression().Name() != node
|
|
770
|
+
case shimast.KindJsxOpeningElement, shimast.KindJsxSelfClosingElement, shimast.KindJsxClosingElement,
|
|
771
|
+
shimast.KindTypeQuery, shimast.KindQualifiedName:
|
|
772
|
+
return false
|
|
732
773
|
}
|
|
774
|
+
return true
|
|
733
775
|
}
|
|
734
776
|
|
|
735
777
|
// accessEdge resolves a property or element access to its declaration and
|
|
@@ -746,6 +788,17 @@ func (g *Graph) valueUseEdge(checker *shimchecker.Checker, from string, targetEx
|
|
|
746
788
|
if target == nil || target.Symbol == nil {
|
|
747
789
|
return
|
|
748
790
|
}
|
|
791
|
+
// Enum members remain outline facts on their enum rather than separate nodes.
|
|
792
|
+
// Their reads therefore depend on that enum's existing identity.
|
|
793
|
+
if kind == EdgeValueAccess && shimast.SymbolFlagsOf(target.Symbol)&shimast.SymbolFlagsEnumMember != 0 {
|
|
794
|
+
if parent := shimast.SymbolParentOf(target.Symbol); parent != nil {
|
|
795
|
+
if declaration := declarationNode(parent); declaration != nil {
|
|
796
|
+
if file := declarationFile(parent); file != nil {
|
|
797
|
+
target = &Target{Symbol: parent, File: string(file.FileName()), External: !IsWorkspaceSourceFile(file), Pos: declaration.Pos(), End: declaration.End()}
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
}
|
|
749
802
|
to := g.ensureTargetNode(target)
|
|
750
803
|
if to == "" || to == from {
|
|
751
804
|
return
|
|
@@ -760,7 +813,7 @@ func (g *Graph) valueUseEdge(checker *shimchecker.Checker, from string, targetEx
|
|
|
760
813
|
// the unit of truth: an `import type` or annotation-only dependency relates two
|
|
761
814
|
// symbols without any runtime call.
|
|
762
815
|
func (g *Graph) collectTypeRefs(checker *shimchecker.Checker, file *shimast.SourceFile) {
|
|
763
|
-
forEachContainer(file.FileName(), file, func(from string, node *shimast.Node) {
|
|
816
|
+
forEachContainer(string(file.FileName()), file, func(from string, node *shimast.Node) {
|
|
764
817
|
g.typeRefsWithin(checker, from, node)
|
|
765
818
|
})
|
|
766
819
|
}
|
|
@@ -794,7 +847,7 @@ func (g *Graph) typeRefsWithin(checker *shimchecker.Checker, from string, node *
|
|
|
794
847
|
if target := g.assignedFunctionTarget(checker, from, child); target != "" {
|
|
795
848
|
file := ""
|
|
796
849
|
if source := shimast.GetSourceFileOfNode(child); source != nil {
|
|
797
|
-
file = source.FileName()
|
|
850
|
+
file = string(source.FileName())
|
|
798
851
|
}
|
|
799
852
|
g.withEdgeEvidenceFile(target, file, func() {
|
|
800
853
|
g.typeRefsWithin(checker, target, child.AsBinaryExpression().Right)
|
|
@@ -838,6 +891,21 @@ func (g *Graph) ensureTargetNode(target *Target) string {
|
|
|
838
891
|
if target.File == "" {
|
|
839
892
|
return ""
|
|
840
893
|
}
|
|
894
|
+
if kind == NodeClass && !target.External {
|
|
895
|
+
// A named class expression's internal name denotes the same constructor
|
|
896
|
+
// its variable binds. Keep those self-references on the existing value node.
|
|
897
|
+
for _, declaration := range shimast.SymbolDeclarationsOf(target.Symbol) {
|
|
898
|
+
if declaration.Kind != shimast.KindClassExpression {
|
|
899
|
+
continue
|
|
900
|
+
}
|
|
901
|
+
if binding := classExpressionBinding(declaration); binding != nil {
|
|
902
|
+
id := nodeID(target.File, qualifiedName(binding.Symbol()), NodeVariable)
|
|
903
|
+
if stored, exists := g.lookupNode(id); exists && nodeDeclaresSymbol(stored, binding.Symbol()) {
|
|
904
|
+
return id
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
}
|
|
841
909
|
if kind == NodeMethod {
|
|
842
910
|
// A method node is class-qualified and only modeled when it belongs to the
|
|
843
911
|
// workspace (Build recorded it). A call into a dependency's method stops at
|
|
@@ -848,26 +916,28 @@ func (g *Graph) ensureTargetNode(target *Target) string {
|
|
|
848
916
|
return ""
|
|
849
917
|
}
|
|
850
918
|
id := nodeID(target.File, name, NodeMethod)
|
|
851
|
-
if
|
|
919
|
+
if stored, exists := g.lookupNode(id); exists && nodeDeclaresSymbol(stored, target.Symbol) {
|
|
852
920
|
return id
|
|
853
921
|
}
|
|
854
922
|
return ""
|
|
855
923
|
}
|
|
856
|
-
if kind == NodeVariable && target.External && target.Symbol
|
|
924
|
+
if kind == NodeVariable && target.External && shimast.SymbolFlagsOf(target.Symbol)&shimast.SymbolFlagsProperty != 0 {
|
|
857
925
|
return ""
|
|
858
926
|
}
|
|
859
927
|
name := qualifiedName(target.Symbol)
|
|
860
|
-
id := nodeID(target.File, name, kind)
|
|
861
|
-
if _, exists := g.lookupNode(id); exists {
|
|
862
|
-
return id
|
|
863
|
-
}
|
|
864
928
|
if !target.External {
|
|
865
|
-
// A
|
|
866
|
-
// (`baseCreateRenderer.patch`), which the symbol alone does not spell, so
|
|
867
|
-
// resolve it from the declaration the checker pointed at.
|
|
929
|
+
// A scoped callable must resolve before any same-named top-level node.
|
|
868
930
|
if id := g.closureTargetID(target); id != "" {
|
|
869
931
|
return id
|
|
870
932
|
}
|
|
933
|
+
}
|
|
934
|
+
id := nodeID(target.File, name, kind)
|
|
935
|
+
if stored, exists := g.lookupNode(id); exists {
|
|
936
|
+
if nodeDeclaresSymbol(stored, target.Symbol) {
|
|
937
|
+
return id
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
if !target.External {
|
|
871
941
|
// Any other workspace target Build did not record is body-scoped and
|
|
872
942
|
// unnameable without collisions (a local of an anonymous callback), so its
|
|
873
943
|
// name would key the same id as a same-named local of another scope and
|
|
@@ -889,10 +959,23 @@ func (g *Graph) ensureTargetNode(target *Target) string {
|
|
|
889
959
|
return id
|
|
890
960
|
}
|
|
891
961
|
|
|
962
|
+
// nodeDeclaresSymbol verifies the indexed display declaration belongs to the
|
|
963
|
+
// resolved symbol. Names alone cannot distinguish unindexed shadowing locals;
|
|
964
|
+
// overloads and merged symbols may legitimately carry several declarations.
|
|
965
|
+
func nodeDeclaresSymbol(node *Node, symbol *shimast.Symbol) bool {
|
|
966
|
+
for _, declaration := range shimast.SymbolDeclarationsOf(symbol) {
|
|
967
|
+
file := shimast.GetSourceFileOfNode(declaration)
|
|
968
|
+
if file != nil && string(file.FileName()) == node.File && declaration.Pos() == node.Pos && declaration.End() == node.End {
|
|
969
|
+
return true
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
return false
|
|
973
|
+
}
|
|
974
|
+
|
|
892
975
|
// closureTargetID returns the node id of a closure the checker resolved to, or ""
|
|
893
976
|
// when the target is not one Build recorded.
|
|
894
977
|
func (g *Graph) closureTargetID(target *Target) string {
|
|
895
|
-
for _, declaration := range target.Symbol
|
|
978
|
+
for _, declaration := range shimast.SymbolDeclarationsOf(target.Symbol) {
|
|
896
979
|
if !IsClosure(declaration) {
|
|
897
980
|
continue
|
|
898
981
|
}
|
|
@@ -918,7 +1001,7 @@ func (g *Graph) closureTargetID(target *Target) string {
|
|
|
918
1001
|
// resolved as NodeVariable even though Build recorded the getter/setter as a
|
|
919
1002
|
// NodeMethod.
|
|
920
1003
|
func symbolNodeKind(symbol *shimast.Symbol) NodeKind {
|
|
921
|
-
for _, declaration := range symbol
|
|
1004
|
+
for _, declaration := range shimast.SymbolDeclarationsOf(symbol) {
|
|
922
1005
|
switch declaration.Kind {
|
|
923
1006
|
case shimast.KindClassDeclaration:
|
|
924
1007
|
return NodeClass
|
|
@@ -939,21 +1022,21 @@ func symbolNodeKind(symbol *shimast.Symbol) NodeKind {
|
|
|
939
1022
|
}
|
|
940
1023
|
}
|
|
941
1024
|
switch {
|
|
942
|
-
case symbol
|
|
1025
|
+
case shimast.SymbolFlagsOf(symbol)&shimast.SymbolFlagsClass != 0:
|
|
943
1026
|
return NodeClass
|
|
944
|
-
case symbol
|
|
1027
|
+
case shimast.SymbolFlagsOf(symbol)&shimast.SymbolFlagsInterface != 0:
|
|
945
1028
|
return NodeInterface
|
|
946
|
-
case symbol
|
|
1029
|
+
case shimast.SymbolFlagsOf(symbol)&shimast.SymbolFlagsTypeAlias != 0:
|
|
947
1030
|
return NodeTypeAlias
|
|
948
|
-
case symbol
|
|
1031
|
+
case shimast.SymbolFlagsOf(symbol)&shimast.SymbolFlagsEnum != 0:
|
|
949
1032
|
return NodeEnum
|
|
950
|
-
case symbol
|
|
1033
|
+
case shimast.SymbolFlagsOf(symbol)&shimast.SymbolFlagsFunction != 0:
|
|
951
1034
|
return NodeFunction
|
|
952
|
-
case symbol
|
|
1035
|
+
case shimast.SymbolFlagsOf(symbol)&(shimast.SymbolFlagsMethod|shimast.SymbolFlagsConstructor|shimast.SymbolFlagsGetAccessor|shimast.SymbolFlagsSetAccessor) != 0:
|
|
953
1036
|
return NodeMethod
|
|
954
|
-
case symbol
|
|
1037
|
+
case shimast.SymbolFlagsOf(symbol)&shimast.SymbolFlagsProperty != 0:
|
|
955
1038
|
return NodeVariable
|
|
956
|
-
case symbol
|
|
1039
|
+
case shimast.SymbolFlagsOf(symbol)&shimast.SymbolFlagsVariable != 0:
|
|
957
1040
|
return NodeVariable
|
|
958
1041
|
default:
|
|
959
1042
|
return ""
|
|
@@ -65,11 +65,11 @@ export class Service<T extends Constraint> extends Base<Payload> {}
|
|
|
65
65
|
graph := Build(prog)
|
|
66
66
|
path := sourceFile(t, prog, "main.ts").FileName()
|
|
67
67
|
|
|
68
|
-
service := nodeID(path, "Service", NodeClass)
|
|
69
|
-
injectable := nodeID(path, "Injectable", NodeFunction)
|
|
70
|
-
base := nodeID(path, "Base", NodeClass)
|
|
71
|
-
payload := nodeID(path, "Payload", NodeInterface)
|
|
72
|
-
constraint := nodeID(path, "Constraint", NodeInterface)
|
|
68
|
+
service := nodeID(string(path), "Service", NodeClass)
|
|
69
|
+
injectable := nodeID(string(path), "Injectable", NodeFunction)
|
|
70
|
+
base := nodeID(string(path), "Base", NodeClass)
|
|
71
|
+
payload := nodeID(string(path), "Payload", NodeInterface)
|
|
72
|
+
constraint := nodeID(string(path), "Constraint", NodeInterface)
|
|
73
73
|
|
|
74
74
|
// The decorator factory call is a fact, not an edge: no value-call to
|
|
75
75
|
// Injectable, but a recorded decorator on the Service node.
|
|
@@ -54,8 +54,8 @@ export enum E {
|
|
|
54
54
|
|
|
55
55
|
graph := Build(prog)
|
|
56
56
|
path := sourceFile(t, prog, "main.ts").FileName()
|
|
57
|
-
enumID := nodeID(path, "E", NodeEnum)
|
|
58
|
-
baseID := nodeID(path, "base", NodeFunction)
|
|
57
|
+
enumID := nodeID(string(path), "E", NodeEnum)
|
|
58
|
+
baseID := nodeID(string(path), "base", NodeFunction)
|
|
59
59
|
|
|
60
60
|
if _, ok := graph.Nodes[enumID]; !ok {
|
|
61
61
|
t.Fatalf("enum E was not recorded as a node")
|
|
@@ -60,7 +60,7 @@ export class Cls {
|
|
|
60
60
|
graph := Build(prog)
|
|
61
61
|
path := sourceFile(t, prog, "main.ts").FileName()
|
|
62
62
|
|
|
63
|
-
colors, ok := graph.Nodes[nodeID(path, "Colors", NodeEnum)]
|
|
63
|
+
colors, ok := graph.Nodes[nodeID(string(path), "Colors", NodeEnum)]
|
|
64
64
|
if !ok {
|
|
65
65
|
t.Fatalf("missing enum node; nodes: %v", nodeIDSet(graph))
|
|
66
66
|
}
|
|
@@ -76,7 +76,7 @@ export class Cls {
|
|
|
76
76
|
|
|
77
77
|
// The expected numeric values are not written as initializers in the fixture.
|
|
78
78
|
// This result check does not prove which acquisition method produced them.
|
|
79
|
-
implicit := graph.Nodes[nodeID(path, "Implicit", NodeEnum)]
|
|
79
|
+
implicit := graph.Nodes[nodeID(string(path), "Implicit", NodeEnum)]
|
|
80
80
|
if implicit == nil ||
|
|
81
81
|
len(implicit.EnumMembers) != 2 ||
|
|
82
82
|
implicit.EnumMembers[0] != (EnumMember{Name: "First", Value: "0"}) ||
|
|
@@ -85,7 +85,7 @@ export class Cls {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
// Three declared names must remain even when A and B share one value.
|
|
88
|
-
dup := graph.Nodes[nodeID(path, "Dup", NodeEnum)]
|
|
88
|
+
dup := graph.Nodes[nodeID(string(path), "Dup", NodeEnum)]
|
|
89
89
|
if dup == nil {
|
|
90
90
|
t.Fatalf("missing Dup; nodes: %v", nodeIDSet(graph))
|
|
91
91
|
}
|
|
@@ -101,15 +101,15 @@ export class Cls {
|
|
|
101
101
|
|
|
102
102
|
// Reject the two candidate variable-node IDs for the authored Red member.
|
|
103
103
|
for id := range graph.Nodes {
|
|
104
|
-
if id == nodeID(path, "Colors.Red", NodeVariable) ||
|
|
105
|
-
id == nodeID(path, "Red", NodeVariable) {
|
|
104
|
+
if id == nodeID(string(path), "Colors.Red", NodeVariable) ||
|
|
105
|
+
id == nodeID(string(path), "Red", NodeVariable) {
|
|
106
106
|
t.Fatalf("an enum member became a node (%s); it is a fact on the enum", id)
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
// The negative twin: this rides on enums only. A class's fields are member
|
|
111
111
|
// nodes and its outline comes from those.
|
|
112
|
-
if cls := graph.Nodes[nodeID(path, "Cls", NodeClass)]; cls == nil ||
|
|
112
|
+
if cls := graph.Nodes[nodeID(string(path), "Cls", NodeClass)]; cls == nil ||
|
|
113
113
|
len(cls.EnumMembers) != 0 {
|
|
114
114
|
t.Fatalf("a class node carried enum members: %v", cls)
|
|
115
115
|
}
|
|
@@ -42,7 +42,7 @@ func (g *Graph) markExports(checker *shimchecker.Checker, file *shimast.SourceFi
|
|
|
42
42
|
// A re-export is an alias; unwrap it to the declaration it points at so the
|
|
43
43
|
// exported flag lands on the real node, not a re-exporting index file's
|
|
44
44
|
// local alias symbol (which has no node of its own).
|
|
45
|
-
if symbol
|
|
45
|
+
if shimast.SymbolFlagsOf(symbol)&shimast.SymbolFlagsAlias != 0 {
|
|
46
46
|
if aliased := shimchecker.Checker_getAliasedSymbol(checker, symbol); aliased != nil {
|
|
47
47
|
symbol = aliased
|
|
48
48
|
}
|
|
@@ -64,16 +64,16 @@ func (g *Graph) markExports(checker *shimchecker.Checker, file *shimast.SourceFi
|
|
|
64
64
|
// test suite would leave no trace in the graph.
|
|
65
65
|
func (g *Graph) putModuleNode(file *shimast.SourceFile) *Node {
|
|
66
66
|
path := file.FileName()
|
|
67
|
-
id := nodeID(path, path, NodeModule)
|
|
67
|
+
id := nodeID(string(path), string(path), NodeModule)
|
|
68
68
|
if existing, ok := g.Nodes[id]; ok {
|
|
69
69
|
return existing
|
|
70
70
|
}
|
|
71
71
|
node := &Node{
|
|
72
72
|
ID: id,
|
|
73
|
-
Name: path,
|
|
74
|
-
Simple: path,
|
|
73
|
+
Name: string(path),
|
|
74
|
+
Simple: string(path),
|
|
75
75
|
Kind: NodeModule,
|
|
76
|
-
File: path,
|
|
76
|
+
File: string(path),
|
|
77
77
|
// A module that exports is by definition part of some surface; whether it is
|
|
78
78
|
// the package's front door is the package.json's to say, not the graph's.
|
|
79
79
|
Exported: true,
|
|
@@ -106,7 +106,7 @@ func (g *Graph) markExportedSymbol(symbol *shimast.Symbol) (string, bool) {
|
|
|
106
106
|
if name == "" {
|
|
107
107
|
return "", false
|
|
108
108
|
}
|
|
109
|
-
node, ok := g.lookupNode(nodeID(file.FileName(), name, kind))
|
|
109
|
+
node, ok := g.lookupNode(nodeID(string(file.FileName()), name, kind))
|
|
110
110
|
if !ok {
|
|
111
111
|
return "", false
|
|
112
112
|
}
|
|
@@ -40,7 +40,7 @@ func TestFileDiagnosticsMatchTsgoCodeAndLocation(t *testing.T) {
|
|
|
40
40
|
defer func() { _ = prog.Close() }()
|
|
41
41
|
|
|
42
42
|
main := sourceFile(t, prog, "main.ts").FileName()
|
|
43
|
-
got := FileDiagnostics(prog, main)
|
|
43
|
+
got := FileDiagnostics(prog, string(main))
|
|
44
44
|
|
|
45
45
|
var match *driver.Diagnostic
|
|
46
46
|
for i := range got {
|
|
@@ -55,7 +55,7 @@ func TestFileDiagnosticsMatchTsgoCodeAndLocation(t *testing.T) {
|
|
|
55
55
|
if match.Line != 1 {
|
|
56
56
|
t.Fatalf("TS2322 reported on line %d, expected line 1", match.Line)
|
|
57
57
|
}
|
|
58
|
-
if match.File != main {
|
|
58
|
+
if match.File != string(main) {
|
|
59
59
|
t.Fatalf("diagnostic file %q is not the queried file %q", match.File, main)
|
|
60
60
|
}
|
|
61
61
|
if other := FileDiagnostics(prog, filepath.Join(root, "src", "absent.ts")); len(other) != 0 {
|
|
@@ -49,7 +49,7 @@ func TestFileDiagnosticsReportCodeColumnAndMessage(t *testing.T) {
|
|
|
49
49
|
defer func() { _ = prog.Close() }()
|
|
50
50
|
|
|
51
51
|
main := sourceFile(t, prog, "main.ts").FileName()
|
|
52
|
-
got := FileDiagnostics(prog, main)
|
|
52
|
+
got := FileDiagnostics(prog, string(main))
|
|
53
53
|
|
|
54
54
|
var match *driver.Diagnostic
|
|
55
55
|
for i := range got {
|
|
@@ -64,17 +64,17 @@ export function outerB(): number {
|
|
|
64
64
|
path := sourceFile(t, prog, "main.ts").FileName()
|
|
65
65
|
|
|
66
66
|
for _, owner := range []string{"outerA", "outerB"} {
|
|
67
|
-
localID := nodeID(path, owner+".inner", NodeFunction)
|
|
67
|
+
localID := nodeID(string(path), owner+".inner", NodeFunction)
|
|
68
68
|
if local := graph.Nodes[localID]; local == nil || local.Name != owner+".inner" {
|
|
69
69
|
t.Fatalf("missing scoped local %s.inner; nodes: %v", owner, nodeIDSet(graph))
|
|
70
70
|
}
|
|
71
|
-
if !hasEdge(graph, nodeID(path, owner, NodeFunction), localID, EdgeValueCall) {
|
|
71
|
+
if !hasEdge(graph, nodeID(string(path), owner, NodeFunction), localID, EdgeValueCall) {
|
|
72
72
|
t.Fatalf("missing %s -> %s.inner call; edges: %v", owner, owner, graph.Edges)
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
// No unqualified function-local node is minted...
|
|
77
|
-
if _, ok := graph.Nodes[nodeID(path, "inner", NodeFunction)]; ok {
|
|
77
|
+
if _, ok := graph.Nodes[nodeID(string(path), "inner", NodeFunction)]; ok {
|
|
78
78
|
t.Fatalf("a function-local 'inner' was minted as a node (would collide across scopes)")
|
|
79
79
|
}
|
|
80
80
|
// ...so no edge points at a phantom shared 'inner'.
|
|
@@ -58,11 +58,11 @@ export class Unrelated {
|
|
|
58
58
|
graph := Build(prog)
|
|
59
59
|
path := sourceFile(t, prog, "main.ts").FileName()
|
|
60
60
|
|
|
61
|
-
base := nodeID(path, "Base", NodeInterface)
|
|
62
|
-
derived := nodeID(path, "Derived", NodeInterface)
|
|
63
|
-
impl := nodeID(path, "Impl", NodeClass)
|
|
64
|
-
unrelated := nodeID(path, "Unrelated", NodeClass)
|
|
65
|
-
greet := nodeID(path, "Unrelated.greet", NodeMethod)
|
|
61
|
+
base := nodeID(string(path), "Base", NodeInterface)
|
|
62
|
+
derived := nodeID(string(path), "Derived", NodeInterface)
|
|
63
|
+
impl := nodeID(string(path), "Impl", NodeClass)
|
|
64
|
+
unrelated := nodeID(string(path), "Unrelated", NodeClass)
|
|
65
|
+
greet := nodeID(string(path), "Unrelated.greet", NodeMethod)
|
|
66
66
|
|
|
67
67
|
// Interface `extends`: Derived inherits Base.
|
|
68
68
|
if !hasEdge(graph, derived, base, EdgeHeritage) {
|
|
@@ -48,8 +48,8 @@ export class Derived extends Base implements Base {}
|
|
|
48
48
|
graph := Build(prog)
|
|
49
49
|
path := sourceFile(t, prog, "main.ts").FileName()
|
|
50
50
|
|
|
51
|
-
derived := nodeID(path, "Derived", NodeClass)
|
|
52
|
-
base := nodeID(path, "Base", NodeClass)
|
|
51
|
+
derived := nodeID(string(path), "Derived", NodeClass)
|
|
52
|
+
base := nodeID(string(path), "Base", NodeClass)
|
|
53
53
|
|
|
54
54
|
wireKinds := map[string]bool{}
|
|
55
55
|
for _, edge := range graph.Edges {
|