jsii-rosetta 1.76.0 → 4.9.0-dev.1
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/LICENSE +202 -0
- package/NOTICE +1 -0
- package/README.md +287 -388
- package/bin/jsii-rosetta +1 -1
- package/lib/ambient/semver-intersect.d.ts +13 -0
- package/lib/ambient/semver-intersect.js +2 -0
- package/lib/ambient/semver-intersect.js.map +1 -0
- package/lib/commands/convert.js.map +1 -0
- package/lib/commands/coverage.js.map +1 -0
- package/lib/commands/extract.js +2 -2
- package/lib/commands/extract.js.map +1 -0
- package/lib/commands/infuse.js +2 -2
- package/lib/commands/infuse.js.map +1 -0
- package/lib/commands/read.js +6 -6
- package/lib/commands/read.js.map +1 -0
- package/lib/commands/transliterate.js +4 -4
- package/lib/commands/transliterate.js.map +1 -0
- package/lib/commands/trim-cache.js.map +1 -0
- package/lib/find-utils.js +4 -4
- package/lib/find-utils.js.map +1 -0
- package/lib/fixtures.js +2 -2
- package/lib/fixtures.js.map +1 -0
- package/lib/index.js.map +1 -0
- package/lib/jsii/assemblies.d.ts +1 -1
- package/lib/jsii/assemblies.js +14 -11
- package/lib/jsii/assemblies.js.map +1 -0
- package/lib/jsii/fingerprinting.js +9 -9
- package/lib/jsii/fingerprinting.js.map +1 -0
- package/lib/jsii/jsii-types.d.ts +4 -4
- package/lib/jsii/jsii-types.js +9 -4
- package/lib/jsii/jsii-types.js.map +1 -0
- package/lib/jsii/jsii-utils.d.ts +1 -1
- package/lib/jsii/jsii-utils.js +2 -2
- package/lib/jsii/jsii-utils.js.map +1 -0
- package/lib/jsii/packages.js.map +1 -0
- package/lib/languages/csharp.d.ts +3 -3
- package/lib/languages/csharp.js +2 -2
- package/lib/languages/csharp.js.map +1 -0
- package/lib/languages/default.d.ts +2 -2
- package/lib/languages/default.js.map +1 -0
- package/lib/languages/go.d.ts +3 -3
- package/lib/languages/go.js +33 -23
- package/lib/languages/go.js.map +1 -0
- package/lib/languages/index.d.ts +1 -1
- package/lib/languages/index.js +4 -4
- package/lib/languages/index.js.map +1 -0
- package/lib/languages/java.d.ts +2 -2
- package/lib/languages/java.js +2 -2
- package/lib/languages/java.js.map +1 -0
- package/lib/languages/python.d.ts +3 -3
- package/lib/languages/python.js +1 -1
- package/lib/languages/python.js.map +1 -0
- package/lib/languages/record-references-version.d.ts +2 -0
- package/lib/languages/record-references-version.js +6 -0
- package/lib/languages/record-references-version.js.map +1 -0
- package/lib/languages/record-references.d.ts +2 -2
- package/lib/languages/record-references.js +3 -2
- package/lib/languages/record-references.js.map +1 -0
- package/lib/languages/target-language.d.ts +0 -2
- package/lib/languages/target-language.js +2 -1
- package/lib/languages/target-language.js.map +1 -0
- package/lib/languages/visualize.d.ts +1 -1
- package/lib/languages/visualize.js +1 -1
- package/lib/languages/visualize.js.map +1 -0
- package/lib/logging.js +1 -1
- package/lib/logging.js.map +1 -0
- package/lib/main.d.ts +2 -0
- package/{bin/jsii-rosetta.js → lib/main.js} +21 -21
- package/lib/main.js.map +1 -0
- package/lib/markdown/escapes.js.map +1 -0
- package/lib/markdown/extract-snippets.d.ts +2 -2
- package/lib/markdown/extract-snippets.js +1 -1
- package/lib/markdown/extract-snippets.js.map +1 -0
- package/lib/markdown/index.js.map +1 -0
- package/lib/markdown/javadoc-renderer.js.map +1 -0
- package/lib/markdown/markdown-renderer.js.map +1 -0
- package/lib/markdown/markdown.js.map +1 -0
- package/lib/markdown/replace-code-renderer.d.ts +1 -1
- package/lib/markdown/replace-code-renderer.js.map +1 -0
- package/lib/markdown/replace-typescript-transform.d.ts +2 -2
- package/lib/markdown/replace-typescript-transform.js +1 -1
- package/lib/markdown/replace-typescript-transform.js.map +1 -0
- package/lib/markdown/structure-renderer.js.map +1 -0
- package/lib/markdown/types.js.map +1 -0
- package/lib/markdown/xml-comment-renderer.js.map +1 -0
- package/lib/o-tree.js +3 -3
- package/lib/o-tree.js.map +1 -0
- package/lib/renderer.js.map +1 -0
- package/lib/rosetta-reader.js.map +1 -0
- package/lib/rosetta-translator.d.ts +1 -1
- package/lib/rosetta-translator.js +2 -2
- package/lib/rosetta-translator.js.map +1 -0
- package/lib/snippet-dependencies.js +12 -12
- package/lib/snippet-dependencies.js.map +1 -0
- package/lib/snippet-selectors.d.ts +1 -1
- package/lib/snippet-selectors.js +2 -2
- package/lib/snippet-selectors.js.map +1 -0
- package/lib/snippet.d.ts +3 -3
- package/lib/snippet.js +5 -5
- package/lib/snippet.js.map +1 -0
- package/lib/strict.js.map +1 -0
- package/lib/submodule-reference.d.ts +1 -1
- package/lib/submodule-reference.js +11 -11
- package/lib/submodule-reference.js.map +1 -0
- package/lib/tablets/key.js +3 -3
- package/lib/tablets/key.js.map +1 -0
- package/lib/tablets/schema.js.map +1 -0
- package/lib/tablets/tablets.d.ts +1 -1
- package/lib/tablets/tablets.js +13 -13
- package/lib/tablets/tablets.js.map +1 -0
- package/lib/translate.d.ts +1 -1
- package/lib/translate.js +9 -7
- package/lib/translate.js.map +1 -0
- package/lib/translate_all.js +2 -2
- package/lib/translate_all.js.map +1 -0
- package/lib/translate_all_worker.js.map +1 -0
- package/lib/typescript/ast-utils.d.ts +2 -2
- package/lib/typescript/ast-utils.js +2 -4
- package/lib/typescript/ast-utils.js.map +1 -0
- package/lib/typescript/imports.d.ts +2 -2
- package/lib/typescript/imports.js +3 -3
- package/lib/typescript/imports.js.map +1 -0
- package/lib/typescript/syntax-kind-counter.d.ts +1 -1
- package/lib/typescript/syntax-kind-counter.js +1 -2
- package/lib/typescript/syntax-kind-counter.js.map +1 -0
- package/lib/typescript/ts-compiler.js.map +1 -0
- package/lib/typescript/types.d.ts +2 -2
- package/lib/typescript/types.js +1 -1
- package/lib/typescript/types.js.map +1 -0
- package/lib/typescript/visible-spans.js +6 -6
- package/lib/typescript/visible-spans.js.map +1 -0
- package/lib/util.d.ts +1 -1
- package/lib/util.js +2 -2
- package/lib/util.js.map +1 -0
- package/package.json +68 -37
- package/temp.tabl.json +48 -0
- package/bin/jsii-rosetta.d.ts +0 -2
- package/jest.config.mjs +0 -8
- package/jestsetup.js +0 -4
- package/test/commands/extract.test.d.ts +0 -2
- package/test/commands/extract.test.js +0 -698
- package/test/commands/infuse.test.d.ts +0 -2
- package/test/commands/infuse.test.js +0 -165
- package/test/commands/transliterate.test.d.ts +0 -2
- package/test/commands/transliterate.test.js +0 -1636
- package/test/commands/trim-cache.test.d.ts +0 -2
- package/test/commands/trim-cache.test.js +0 -85
- package/test/fixtures.test.d.ts +0 -2
- package/test/fixtures.test.js +0 -49
- package/test/jsii/assemblies.test.d.ts +0 -2
- package/test/jsii/assemblies.test.js +0 -230
- package/test/jsii/fake-assembly.d.ts +0 -3
- package/test/jsii/fake-assembly.js +0 -21
- package/test/jsii/fixtures/rosetta/explicit.ts-fixture +0 -7
- package/test/jsii/visible-spans.test.d.ts +0 -2
- package/test/jsii/visible-spans.test.js +0 -40
- package/test/jsii-imports.test.d.ts +0 -2
- package/test/jsii-imports.test.js +0 -438
- package/test/markdown/javadoc.test.d.ts +0 -2
- package/test/markdown/javadoc.test.js +0 -110
- package/test/markdown/roundtrip.test.d.ts +0 -2
- package/test/markdown/roundtrip.test.js +0 -126
- package/test/markdown/xmldoccomments.test.d.ts +0 -2
- package/test/markdown/xmldoccomments.test.js +0 -89
- package/test/otree.test.d.ts +0 -2
- package/test/otree.test.js +0 -36
- package/test/record-references.test.d.ts +0 -2
- package/test/record-references.test.js +0 -88
- package/test/rosetta/default.ts-fixture +0 -1
- package/test/rosetta-translator.test.d.ts +0 -2
- package/test/rosetta-translator.test.js +0 -33
- package/test/rosetta.test.d.ts +0 -2
- package/test/rosetta.test.js +0 -221
- package/test/snippet-selectors.test.d.ts +0 -2
- package/test/snippet-selectors.test.js +0 -57
- package/test/snippet.test.d.ts +0 -2
- package/test/snippet.test.js +0 -18
- package/test/syntax-counter.test.d.ts +0 -2
- package/test/syntax-counter.test.js +0 -60
- package/test/testutil.d.ts +0 -64
- package/test/testutil.js +0 -104
- package/test/translate.test.d.ts +0 -2
- package/test/translate.test.js +0 -175
- package/test/translations/calls/declaring_default_arguments.cs +0 -4
- package/test/translations/calls/declaring_default_arguments.go +0 -6
- package/test/translations/calls/declaring_default_arguments.java +0 -11
- package/test/translations/calls/declaring_default_arguments.py +0 -2
- package/test/translations/calls/default_struct_fields.cs +0 -9
- package/test/translations/calls/default_struct_fields.go +0 -7
- package/test/translations/calls/default_struct_fields.java +0 -21
- package/test/translations/calls/default_struct_fields.py +0 -2
- package/test/translations/calls/function_call.cs +0 -1
- package/test/translations/calls/function_call.go +0 -1
- package/test/translations/calls/function_call.java +0 -1
- package/test/translations/calls/function_call.py +0 -1
- package/test/translations/calls/list_of_anonymous_structs.cs +0 -9
- package/test/translations/calls/list_of_anonymous_structs.go +0 -12
- package/test/translations/calls/list_of_anonymous_structs.java +0 -6
- package/test/translations/calls/list_of_anonymous_structs.py +0 -9
- package/test/translations/calls/literal_map_argument.cs +0 -5
- package/test/translations/calls/literal_map_argument.go +0 -7
- package/test/translations/calls/literal_map_argument.java +0 -4
- package/test/translations/calls/literal_map_argument.py +0 -4
- package/test/translations/calls/method_call.cs +0 -1
- package/test/translations/calls/method_call.go +0 -1
- package/test/translations/calls/method_call.java +0 -1
- package/test/translations/calls/method_call.py +0 -1
- package/test/translations/calls/self_method_call.cs +0 -1
- package/test/translations/calls/self_method_call.go +0 -1
- package/test/translations/calls/self_method_call.java +0 -1
- package/test/translations/calls/self_method_call.py +0 -1
- package/test/translations/calls/shorthand_property.cs +0 -2
- package/test/translations/calls/shorthand_property.go +0 -4
- package/test/translations/calls/shorthand_property.java +0 -2
- package/test/translations/calls/shorthand_property.py +0 -2
- package/test/translations/calls/static_function_call.cs +0 -1
- package/test/translations/calls/static_function_call.go +0 -1
- package/test/translations/calls/static_function_call.java +0 -1
- package/test/translations/calls/static_function_call.py +0 -1
- package/test/translations/calls/this_argument.cs +0 -1
- package/test/translations/calls/this_argument.go +0 -1
- package/test/translations/calls/this_argument.java +0 -1
- package/test/translations/calls/this_argument.py +0 -1
- package/test/translations/calls/translate_object_literals_in_function_call.cs +0 -1
- package/test/translations/calls/translate_object_literals_in_function_call.go +0 -4
- package/test/translations/calls/translate_object_literals_in_function_call.java +0 -1
- package/test/translations/calls/translate_object_literals_in_function_call.py +0 -1
- package/test/translations/calls/translate_object_literals_only_one_level_deep.cs +0 -1
- package/test/translations/calls/translate_object_literals_only_one_level_deep.go +0 -7
- package/test/translations/calls/translate_object_literals_only_one_level_deep.java +0 -1
- package/test/translations/calls/translate_object_literals_only_one_level_deep.py +0 -1
- package/test/translations/calls/translate_object_literals_second_level_with_newlines.cs +0 -4
- package/test/translations/calls/translate_object_literals_second_level_with_newlines.go +0 -7
- package/test/translations/calls/translate_object_literals_second_level_with_newlines.java +0 -3
- package/test/translations/calls/translate_object_literals_second_level_with_newlines.py +0 -4
- package/test/translations/calls/translate_object_literals_with_multiple_newlines.cs +0 -5
- package/test/translations/calls/translate_object_literals_with_multiple_newlines.go +0 -5
- package/test/translations/calls/translate_object_literals_with_multiple_newlines.java +0 -4
- package/test/translations/calls/translate_object_literals_with_multiple_newlines.py +0 -5
- package/test/translations/calls/translate_object_literals_with_newlines.cs +0 -4
- package/test/translations/calls/translate_object_literals_with_newlines.go +0 -4
- package/test/translations/calls/translate_object_literals_with_newlines.java +0 -3
- package/test/translations/calls/translate_object_literals_with_newlines.py +0 -4
- package/test/translations/calls/will_type_deep_structs_directly_if_type_info_is_available.cs +0 -24
- package/test/translations/calls/will_type_deep_structs_directly_if_type_info_is_available.go +0 -24
- package/test/translations/calls/will_type_deep_structs_directly_if_type_info_is_available.java +0 -48
- package/test/translations/calls/will_type_deep_structs_directly_if_type_info_is_available.py +0 -7
- package/test/translations/classes/class_declaration_with_private_fields_and_constructor.cs +0 -9
- package/test/translations/classes/class_declaration_with_private_fields_and_constructor.go +0 -9
- package/test/translations/classes/class_declaration_with_private_fields_and_constructor.java +0 -7
- package/test/translations/classes/class_declaration_with_private_fields_and_constructor.py +0 -4
- package/test/translations/classes/class_declaration_with_public_fields_and_constructor.cs +0 -9
- package/test/translations/classes/class_declaration_with_public_fields_and_constructor.go +0 -9
- package/test/translations/classes/class_declaration_with_public_fields_and_constructor.java +0 -7
- package/test/translations/classes/class_declaration_with_public_fields_and_constructor.py +0 -4
- package/test/translations/classes/class_implementing_jsii_interface.cs +0 -7
- package/test/translations/classes/class_implementing_jsii_interface.go +0 -6
- package/test/translations/classes/class_implementing_jsii_interface.java +0 -5
- package/test/translations/classes/class_implementing_jsii_interface.py +0 -4
- package/test/translations/classes/class_with_different_name.cs +0 -6
- package/test/translations/classes/class_with_different_name.go +0 -7
- package/test/translations/classes/class_with_different_name.java +0 -4
- package/test/translations/classes/class_with_different_name.py +0 -3
- package/test/translations/classes/class_with_extends_and_implements.cs +0 -3
- package/test/translations/classes/class_with_extends_and_implements.go +0 -3
- package/test/translations/classes/class_with_extends_and_implements.java +0 -2
- package/test/translations/classes/class_with_inheritance.cs +0 -3
- package/test/translations/classes/class_with_inheritance.go +0 -3
- package/test/translations/classes/class_with_inheritance.java +0 -2
- package/test/translations/classes/class_with_inheritance.py +0 -2
- package/test/translations/classes/class_with_inheritance_and_super_class.cs +0 -6
- package/test/translations/classes/class_with_inheritance_and_super_class.go +0 -9
- package/test/translations/classes/class_with_inheritance_and_super_class.java +0 -5
- package/test/translations/classes/class_with_inheritance_and_super_class.py +0 -3
- package/test/translations/classes/class_with_method.cs +0 -7
- package/test/translations/classes/class_with_method.go +0 -7
- package/test/translations/classes/class_with_method.java +0 -5
- package/test/translations/classes/class_with_method.py +0 -3
- package/test/translations/classes/class_with_props_argument.cs +0 -14
- package/test/translations/classes/class_with_props_argument.go +0 -16
- package/test/translations/classes/class_with_props_argument.java +0 -26
- package/test/translations/classes/class_with_props_argument.py +0 -5
- package/test/translations/classes/constructor_with_optional_params.go +0 -10
- package/test/translations/classes/constructor_with_optional_params.java +0 -12
- package/test/translations/classes/empty_class.cs +0 -3
- package/test/translations/classes/empty_class.go +0 -2
- package/test/translations/classes/empty_class.java +0 -2
- package/test/translations/classes/empty_class.py +0 -2
- package/test/translations/classes/invisible_interfaces_do_not_affect_whitespace.cs +0 -11
- package/test/translations/classes/invisible_interfaces_do_not_affect_whitespace.go +0 -8
- package/test/translations/classes/invisible_interfaces_do_not_affect_whitespace.java +0 -8
- package/test/translations/classes/invisible_interfaces_do_not_affect_whitespace.py +0 -5
- package/test/translations/classes/whitespace_between_multiple_empty_members.cs +0 -15
- package/test/translations/classes/whitespace_between_multiple_empty_members.go +0 -12
- package/test/translations/classes/whitespace_between_multiple_empty_members.java +0 -11
- package/test/translations/classes/whitespace_between_multiple_empty_members.py +0 -9
- package/test/translations/classes/whitespace_between_multiple_members.cs +0 -17
- package/test/translations/classes/whitespace_between_multiple_members.go +0 -16
- package/test/translations/classes/whitespace_between_multiple_members.java +0 -13
- package/test/translations/classes/whitespace_between_multiple_members.py +0 -9
- package/test/translations/comments/empty_lines_in_comments.cs +0 -4
- package/test/translations/comments/empty_lines_in_comments.go +0 -4
- package/test/translations/comments/empty_lines_in_comments.java +0 -4
- package/test/translations/comments/empty_lines_in_comments.py +0 -4
- package/test/translations/comments/interleave_multiline_comments_with_function_call.cs +0 -7
- package/test/translations/comments/interleave_multiline_comments_with_function_call.go +0 -7
- package/test/translations/comments/interleave_multiline_comments_with_function_call.java +0 -6
- package/test/translations/comments/interleave_multiline_comments_with_function_call.py +0 -7
- package/test/translations/comments/interleave_single_line_comments_with_function_call.cs +0 -7
- package/test/translations/comments/interleave_single_line_comments_with_function_call.go +0 -7
- package/test/translations/comments/interleave_single_line_comments_with_function_call.java +0 -6
- package/test/translations/comments/interleave_single_line_comments_with_function_call.py +0 -7
- package/test/translations/comments/no_duplication_of_comments.cs +0 -2
- package/test/translations/comments/no_duplication_of_comments.go +0 -2
- package/test/translations/comments/no_duplication_of_comments.java +0 -2
- package/test/translations/comments/no_duplication_of_comments.py +0 -2
- package/test/translations/expressions/array_index.cs +0 -3
- package/test/translations/expressions/array_index.go +0 -3
- package/test/translations/expressions/array_index.java +0 -3
- package/test/translations/expressions/array_index.py +0 -3
- package/test/translations/expressions/as_expression.cs +0 -1
- package/test/translations/expressions/as_expression.go +0 -1
- package/test/translations/expressions/as_expression.java +0 -1
- package/test/translations/expressions/as_expression.py +0 -1
- package/test/translations/expressions/await.cs +0 -1
- package/test/translations/expressions/await.go +0 -1
- package/test/translations/expressions/await.java +0 -1
- package/test/translations/expressions/await.py +0 -1
- package/test/translations/expressions/backtick_string_w_o_substitutions.cs +0 -1
- package/test/translations/expressions/backtick_string_w_o_substitutions.go +0 -1
- package/test/translations/expressions/backtick_string_w_o_substitutions.java +0 -1
- package/test/translations/expressions/backtick_string_w_o_substitutions.py +0 -1
- package/test/translations/expressions/computed_key.cs +0 -4
- package/test/translations/expressions/computed_key.go +0 -8
- package/test/translations/expressions/computed_key.java +0 -4
- package/test/translations/expressions/computed_key.py +0 -4
- package/test/translations/expressions/double_quoted_dict_keys.cs +0 -1
- package/test/translations/expressions/double_quoted_dict_keys.go +0 -3
- package/test/translations/expressions/double_quoted_dict_keys.java +0 -1
- package/test/translations/expressions/double_quoted_dict_keys.py +0 -1
- package/test/translations/expressions/ellipsis_at_a_random_place.cs +0 -1
- package/test/translations/expressions/ellipsis_at_a_random_place.go +0 -1
- package/test/translations/expressions/ellipsis_at_a_random_place.java +0 -1
- package/test/translations/expressions/ellipsis_at_a_random_place.py +0 -1
- package/test/translations/expressions/enum_access.cs +0 -1
- package/test/translations/expressions/enum_access.go +0 -1
- package/test/translations/expressions/enum_access.java +0 -1
- package/test/translations/expressions/enum_access.py +0 -1
- package/test/translations/expressions/enum_like_access.cs +0 -1
- package/test/translations/expressions/enum_like_access.go +0 -1
- package/test/translations/expressions/enum_like_access.java +0 -1
- package/test/translations/expressions/enum_like_access.py +0 -1
- package/test/translations/expressions/map-literal.cs +0 -3
- package/test/translations/expressions/map-literal.go +0 -3
- package/test/translations/expressions/map-literal.java +0 -2
- package/test/translations/expressions/map-literal.py +0 -3
- package/test/translations/expressions/non_null_expression.cs +0 -1
- package/test/translations/expressions/non_null_expression.go +0 -1
- package/test/translations/expressions/non_null_expression.java +0 -1
- package/test/translations/expressions/non_null_expression.py +0 -1
- package/test/translations/expressions/string_interpolation.cs +0 -10
- package/test/translations/expressions/string_interpolation.go +0 -6
- package/test/translations/expressions/string_interpolation.java +0 -6
- package/test/translations/expressions/string_interpolation.py +0 -10
- package/test/translations/expressions/string_literal.cs +0 -9
- package/test/translations/expressions/string_literal.go +0 -9
- package/test/translations/expressions/string_literal.java +0 -1
- package/test/translations/expressions/string_literal.py +0 -9
- package/test/translations/expressions/struct_assignment.cs +0 -6
- package/test/translations/expressions/struct_assignment.go +0 -7
- package/test/translations/expressions/struct_assignment.java +0 -12
- package/test/translations/expressions/struct_assignment.py +0 -1
- package/test/translations/expressions/unary_and_binary_operators.cs +0 -3
- package/test/translations/expressions/unary_and_binary_operators.go +0 -3
- package/test/translations/expressions/unary_and_binary_operators.java +0 -3
- package/test/translations/expressions/unary_and_binary_operators.py +0 -3
- package/test/translations/hiding/hide_block_level_statements_using_void_directive.cs +0 -6
- package/test/translations/hiding/hide_block_level_statements_using_void_directive.go +0 -5
- package/test/translations/hiding/hide_block_level_statements_using_void_directive.java +0 -5
- package/test/translations/hiding/hide_block_level_statements_using_void_directive.py +0 -4
- package/test/translations/hiding/hide_expression_with_explicit_ellipsis.cs +0 -1
- package/test/translations/hiding/hide_expression_with_explicit_ellipsis.go +0 -1
- package/test/translations/hiding/hide_expression_with_explicit_ellipsis.java +0 -1
- package/test/translations/hiding/hide_expression_with_explicit_ellipsis.py +0 -1
- package/test/translations/hiding/hide_halfway_into_class_using_comments.cs +0 -3
- package/test/translations/hiding/hide_halfway_into_class_using_comments.go +0 -3
- package/test/translations/hiding/hide_halfway_into_class_using_comments.java +0 -3
- package/test/translations/hiding/hide_halfway_into_class_using_comments.py +0 -3
- package/test/translations/hiding/hide_parameter_sequence.cs +0 -1
- package/test/translations/hiding/hide_parameter_sequence.go +0 -1
- package/test/translations/hiding/hide_parameter_sequence.java +0 -1
- package/test/translations/hiding/hide_parameter_sequence.py +0 -1
- package/test/translations/hiding/hide_statements_with_explicit_ellipsis.cs +0 -3
- package/test/translations/hiding/hide_statements_with_explicit_ellipsis.go +0 -3
- package/test/translations/hiding/hide_statements_with_explicit_ellipsis.java +0 -3
- package/test/translations/hiding/hide_statements_with_explicit_ellipsis.py +0 -3
- package/test/translations/hiding/hide_top_level_statements_using_void_directive.cs +0 -1
- package/test/translations/hiding/hide_top_level_statements_using_void_directive.go +0 -1
- package/test/translations/hiding/hide_top_level_statements_using_void_directive.java +0 -1
- package/test/translations/hiding/hide_top_level_statements_using_void_directive.py +0 -1
- package/test/translations/identifiers/keyword.cs +0 -4
- package/test/translations/identifiers/keyword.go +0 -4
- package/test/translations/identifiers/keyword.java +0 -4
- package/test/translations/identifiers/keyword.py +0 -4
- package/test/translations/imports/import_require.cs +0 -2
- package/test/translations/imports/import_require.go +0 -2
- package/test/translations/imports/import_require.java +0 -2
- package/test/translations/imports/import_require.py +0 -2
- package/test/translations/imports/import_star_as.cs +0 -2
- package/test/translations/imports/import_star_as.go +0 -2
- package/test/translations/imports/import_star_as.java +0 -2
- package/test/translations/imports/import_star_as.py +0 -2
- package/test/translations/imports/multiple-imports.cs +0 -2
- package/test/translations/imports/multiple-imports.go +0 -2
- package/test/translations/imports/multiple-imports.java +0 -3
- package/test/translations/imports/multiple-imports.py +0 -2
- package/test/translations/imports/selective_import.cs +0 -4
- package/test/translations/imports/selective_import.go +0 -3
- package/test/translations/imports/selective_import.java +0 -6
- package/test/translations/imports/selective_import.py +0 -3
- package/test/translations/imports/submodule-import.cs +0 -15
- package/test/translations/imports/submodule-import.go +0 -23
- package/test/translations/imports/submodule-import.java +0 -17
- package/test/translations/imports/submodule-import.py +0 -15
- package/test/translations/interfaces/interface_with_method.cs +0 -4
- package/test/translations/interfaces/interface_with_method.go +0 -3
- package/test/translations/interfaces/interface_with_method.java +0 -3
- package/test/translations/interfaces/interface_with_props.cs +0 -4
- package/test/translations/interfaces/interface_with_props.go +0 -3
- package/test/translations/interfaces/interface_with_props.java +0 -3
- package/test/translations/misc/booleans_render_to_right_primitives.cs +0 -1
- package/test/translations/misc/booleans_render_to_right_primitives.go +0 -1
- package/test/translations/misc/booleans_render_to_right_primitives.java +0 -1
- package/test/translations/misc/booleans_render_to_right_primitives.py +0 -1
- package/test/translations/statements/block_without_braces.cs +0 -1
- package/test/translations/statements/block_without_braces.go +0 -3
- package/test/translations/statements/block_without_braces.java +0 -1
- package/test/translations/statements/block_without_braces.py +0 -1
- package/test/translations/statements/declare_var.cs +0 -1
- package/test/translations/statements/declare_var.go +0 -1
- package/test/translations/statements/declare_var.java +0 -1
- package/test/translations/statements/declare_var.py +0 -1
- package/test/translations/statements/empty_control_block.cs +0 -3
- package/test/translations/statements/empty_control_block.go +0 -1
- package/test/translations/statements/empty_control_block.java +0 -2
- package/test/translations/statements/empty_control_block.py +0 -2
- package/test/translations/statements/for_of_loop.cs +0 -4
- package/test/translations/statements/for_of_loop.go +0 -3
- package/test/translations/statements/for_of_loop.java +0 -3
- package/test/translations/statements/for_of_loop.py +0 -2
- package/test/translations/statements/if.cs +0 -4
- package/test/translations/statements/if.go +0 -3
- package/test/translations/statements/if.java +0 -3
- package/test/translations/statements/if.py +0 -2
- package/test/translations/statements/if_then_else.cs +0 -8
- package/test/translations/statements/if_then_else.go +0 -5
- package/test/translations/statements/if_then_else.java +0 -5
- package/test/translations/statements/if_then_else.py +0 -4
- package/test/translations/statements/initialize_object_literal.cs +0 -5
- package/test/translations/statements/initialize_object_literal.go +0 -8
- package/test/translations/statements/initialize_object_literal.java +0 -4
- package/test/translations/statements/initialize_object_literal.py +0 -5
- package/test/translations/statements/multiline_if_then_else.cs +0 -9
- package/test/translations/statements/multiline_if_then_else.go +0 -6
- package/test/translations/statements/multiline_if_then_else.java +0 -6
- package/test/translations/statements/multiline_if_then_else.py +0 -5
- package/test/translations/statements/statements_and_newlines.cs +0 -26
- package/test/translations/statements/statements_and_newlines.go +0 -21
- package/test/translations/statements/statements_and_newlines.java +0 -21
- package/test/translations/statements/statements_and_newlines.py +0 -16
- package/test/translations/statements/vararg_any_call.cs +0 -7
- package/test/translations/statements/vararg_any_call.go +0 -13
- package/test/translations/statements/vararg_any_call.java +0 -6
- package/test/translations/statements/vararg_any_call.py +0 -6
- package/test/translations/statements/whitespace_between_statements.cs +0 -3
- package/test/translations/statements/whitespace_between_statements.go +0 -3
- package/test/translations/statements/whitespace_between_statements.java +0 -3
- package/test/translations/statements/whitespace_between_statements.py +0 -3
- package/test/translations/statements/whitespace_between_statements_in_a_block.cs +0 -6
- package/test/translations/statements/whitespace_between_statements_in_a_block.go +0 -5
- package/test/translations/statements/whitespace_between_statements_in_a_block.java +0 -5
- package/test/translations/statements/whitespace_between_statements_in_a_block.py +0 -4
- package/test/translations/structs/any_type_never_a_struct.cs +0 -3
- package/test/translations/structs/any_type_never_a_struct.go +0 -3
- package/test/translations/structs/any_type_never_a_struct.java +0 -2
- package/test/translations/structs/any_type_never_a_struct.py +0 -3
- package/test/translations/structs/infer_struct_from_union.cs +0 -6
- package/test/translations/structs/infer_struct_from_union.go +0 -8
- package/test/translations/structs/infer_struct_from_union.java +0 -6
- package/test/translations/structs/infer_struct_from_union.py +0 -6
- package/test/translations/structs/optional_known_struct.cs +0 -3
- package/test/translations/structs/optional_known_struct.go +0 -3
- package/test/translations/structs/optional_known_struct.java +0 -3
- package/test/translations/structs/optional_known_struct.py +0 -3
- package/test/translations/structs/struct_starting_with_i.cs +0 -3
- package/test/translations/structs/struct_starting_with_i.go +0 -3
- package/test/translations/structs/struct_starting_with_i.java +0 -3
- package/test/translations/structs/struct_starting_with_i.py +0 -3
- package/test/translations/structs/var_new_class_known_struct.cs +0 -3
- package/test/translations/structs/var_new_class_known_struct.go +0 -3
- package/test/translations/structs/var_new_class_known_struct.java +0 -3
- package/test/translations/structs/var_new_class_known_struct.py +0 -3
- package/test/translations/structs/var_new_class_unknown_struct.cs +0 -3
- package/test/translations/structs/var_new_class_unknown_struct.go +0 -3
- package/test/translations/structs/var_new_class_unknown_struct.java +0 -3
- package/test/translations/structs/var_new_class_unknown_struct.py +0 -3
- package/test/translations.test.d.ts +0 -9
- package/test/translations.test.js +0 -112
- package/test/util.test.d.ts +0 -2
- package/test/util.test.js +0 -25
- package/vendor/semver-intersect.d.ts +0 -13
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const lib_1 = require("../../lib");
|
|
4
|
-
const DEBUG = false;
|
|
5
|
-
test('emphasis and lists', () => {
|
|
6
|
-
expectOutput(`
|
|
7
|
-
# Hello
|
|
8
|
-
## Bye
|
|
9
|
-
|
|
10
|
-
This is *very* **cool**.
|
|
11
|
-
|
|
12
|
-
* Yes
|
|
13
|
-
* Really
|
|
14
|
-
`, `
|
|
15
|
-
<h1>Hello</h1>
|
|
16
|
-
|
|
17
|
-
<h2>Bye</h2>
|
|
18
|
-
|
|
19
|
-
This is <em>very</em> <strong>cool</strong>.
|
|
20
|
-
|
|
21
|
-
<list type="bullet">
|
|
22
|
-
<description>Yes</description>
|
|
23
|
-
<description>Really</description>
|
|
24
|
-
</list>
|
|
25
|
-
`);
|
|
26
|
-
});
|
|
27
|
-
test('special characters are escaped', () => {
|
|
28
|
-
expectOutput(`
|
|
29
|
-
Escape this & and this < and this >
|
|
30
|
-
|
|
31
|
-
` +
|
|
32
|
-
'```' +
|
|
33
|
-
`
|
|
34
|
-
if (x < 3) {
|
|
35
|
-
System.Console.WriteLn("bloep");
|
|
36
|
-
}
|
|
37
|
-
` +
|
|
38
|
-
'```', `
|
|
39
|
-
Escape this & and this < and this >
|
|
40
|
-
|
|
41
|
-
<code><![CDATA[
|
|
42
|
-
if (x < 3) {
|
|
43
|
-
System.Console.WriteLn("bloep");
|
|
44
|
-
}
|
|
45
|
-
]]></code>
|
|
46
|
-
`);
|
|
47
|
-
});
|
|
48
|
-
test('quotes are escaped inside attributes', () => {
|
|
49
|
-
expectOutput(`
|
|
50
|
-
['tis but a "scratch"](http://bla.ck/"kni"gh&t)
|
|
51
|
-
|
|
52
|
-

|
|
53
|
-
`, `
|
|
54
|
-
<a href="http://bla.ck/%22kni%22gh&t">'tis but a "scratch"</a>
|
|
55
|
-
|
|
56
|
-
<img alt="nay merely a "flesh wound" &cet" src="http://bla.ck/%22kni%22gh&t.jpg" />
|
|
57
|
-
`);
|
|
58
|
-
});
|
|
59
|
-
test('convert header properly', () => {
|
|
60
|
-
expectOutput(`
|
|
61
|
-
<!--BEGIN STABILITY BANNER-->
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-

|
|
66
|
-
|
|
67
|
-
---
|
|
68
|
-
<!--END STABILITY BANNER-->
|
|
69
|
-
`, `
|
|
70
|
-
<!--BEGIN STABILITY BANNER-->
|
|
71
|
-
|
|
72
|
-
<hr />
|
|
73
|
-
|
|
74
|
-
<img alt="Stability: Stable" src="https://img.shields.io/badge/stability-Stable-success.svg?style=for-the-badge" />
|
|
75
|
-
|
|
76
|
-
<hr />
|
|
77
|
-
|
|
78
|
-
<!--END STABILITY BANNER-->
|
|
79
|
-
`);
|
|
80
|
-
});
|
|
81
|
-
function expectOutput(source, expected) {
|
|
82
|
-
if (DEBUG) {
|
|
83
|
-
// tslint:disable-next-line:no-console
|
|
84
|
-
console.log((0, lib_1.markDownToStructure)(source));
|
|
85
|
-
}
|
|
86
|
-
const output = (0, lib_1.markDownToXmlDoc)(source);
|
|
87
|
-
expect(output.trim()).toEqual(expected.trim());
|
|
88
|
-
}
|
|
89
|
-
//# sourceMappingURL=xmldoccomments.test.js.map
|
package/test/otree.test.d.ts
DELETED
package/test/otree.test.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const o_tree_1 = require("../lib/o-tree");
|
|
4
|
-
test('test indentation', () => {
|
|
5
|
-
const tree = new o_tree_1.OTree(['{'], ['\na', '\nb', '\nc'], {
|
|
6
|
-
separator: ', ',
|
|
7
|
-
indent: 4,
|
|
8
|
-
suffix: '\n}',
|
|
9
|
-
});
|
|
10
|
-
expect((0, o_tree_1.renderTree)(tree)).toEqual('{\n a,\n b,\n c\n}');
|
|
11
|
-
});
|
|
12
|
-
test('collapse subsequent unused indentation', () => {
|
|
13
|
-
const tree = new o_tree_1.OTree(['{'], [new o_tree_1.OTree([], ['\na', '\nb', '\nc'], { indent: 4, separator: ', ' })], {
|
|
14
|
-
separator: ', ',
|
|
15
|
-
indent: 4,
|
|
16
|
-
suffix: '\n}',
|
|
17
|
-
});
|
|
18
|
-
expect((0, o_tree_1.renderTree)(tree)).toEqual('{\n a,\n b,\n c\n}');
|
|
19
|
-
});
|
|
20
|
-
test('don not collapse subsequent USED indentation', () => {
|
|
21
|
-
const tree = new o_tree_1.OTree(['{'], [
|
|
22
|
-
'\na',
|
|
23
|
-
new o_tree_1.OTree(['\n{'], ['\na', '\nb', '\nc'], {
|
|
24
|
-
indent: 4,
|
|
25
|
-
separator: ', ',
|
|
26
|
-
suffix: '\n}',
|
|
27
|
-
}),
|
|
28
|
-
'\nb',
|
|
29
|
-
], {
|
|
30
|
-
separator: ', ',
|
|
31
|
-
indent: 4,
|
|
32
|
-
suffix: '\n}',
|
|
33
|
-
});
|
|
34
|
-
expect((0, o_tree_1.renderTree)(tree)).toEqual(['{', ' a,', ' {', ' a,', ' b,', ' c', ' },', ' b', '}'].join('\n'));
|
|
35
|
-
});
|
|
36
|
-
//# sourceMappingURL=otree.test.js.map
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const testutil_1 = require("./testutil");
|
|
4
|
-
let assembly;
|
|
5
|
-
beforeAll(() => {
|
|
6
|
-
assembly = testutil_1.TestJsiiModule.fromSource({
|
|
7
|
-
'index.ts': `
|
|
8
|
-
export class ClassA {
|
|
9
|
-
public someMethod() {
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export class ClassB {
|
|
13
|
-
public argumentMethod(args: BeeArgs) {
|
|
14
|
-
Array.isArray(args);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface BeeArgs { readonly value: string; readonly nested?: NestedType; }
|
|
19
|
-
|
|
20
|
-
export interface NestedType { readonly x: number; }
|
|
21
|
-
|
|
22
|
-
export * as submod from './submodule';
|
|
23
|
-
`,
|
|
24
|
-
'submodule.ts': `
|
|
25
|
-
export class SubmoduleClass {
|
|
26
|
-
}
|
|
27
|
-
`,
|
|
28
|
-
}, {
|
|
29
|
-
name: 'my_assembly',
|
|
30
|
-
jsii: testutil_1.DUMMY_JSII_CONFIG,
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
afterAll(() => assembly.cleanup());
|
|
34
|
-
test('detect class instantiations', () => {
|
|
35
|
-
const translator = assembly.successfullyCompile(`
|
|
36
|
-
import * as ass from 'my_assembly';
|
|
37
|
-
const a = new ass.ClassA();
|
|
38
|
-
`);
|
|
39
|
-
expect(translator.fqnsReferenced()).toEqual(['my_assembly.ClassA']);
|
|
40
|
-
});
|
|
41
|
-
test("don't detect hidden class instantiations", () => {
|
|
42
|
-
const translator = assembly.successfullyCompile(`
|
|
43
|
-
/// !hide
|
|
44
|
-
import * as ass from 'my_assembly';
|
|
45
|
-
const a = new ass.ClassA();
|
|
46
|
-
/// !show
|
|
47
|
-
const b = new ass.ClassB();
|
|
48
|
-
`);
|
|
49
|
-
expect(translator.fqnsReferenced()).toEqual(['my_assembly.ClassB']);
|
|
50
|
-
});
|
|
51
|
-
test('detect method calls', () => {
|
|
52
|
-
const translator = assembly.successfullyCompile(`
|
|
53
|
-
/// !hide
|
|
54
|
-
import * as ass from 'my_assembly';
|
|
55
|
-
const a = new ass.ClassA();
|
|
56
|
-
/// !show
|
|
57
|
-
a.someMethod();
|
|
58
|
-
`);
|
|
59
|
-
expect(translator.fqnsReferenced()).toEqual(['my_assembly.ClassA#someMethod']);
|
|
60
|
-
});
|
|
61
|
-
test('detect types of parameter used in method calls', () => {
|
|
62
|
-
const translator = assembly.successfullyCompile(`
|
|
63
|
-
/// !hide
|
|
64
|
-
import * as ass from 'my_assembly';
|
|
65
|
-
const b = new ass.ClassB();
|
|
66
|
-
/// !show
|
|
67
|
-
b.argumentMethod({ value: 'hello' });
|
|
68
|
-
`);
|
|
69
|
-
expect(translator.fqnsReferenced()).toEqual(['my_assembly.BeeArgs', 'my_assembly.ClassB#argumentMethod']);
|
|
70
|
-
});
|
|
71
|
-
test('detect nested types of parameter used in method calls', () => {
|
|
72
|
-
const translator = assembly.successfullyCompile(`
|
|
73
|
-
/// !hide
|
|
74
|
-
import * as ass from 'my_assembly';
|
|
75
|
-
const b = new ass.ClassB();
|
|
76
|
-
/// !show
|
|
77
|
-
b.argumentMethod({ value: 'hello', nested: { x: 3 } });
|
|
78
|
-
`);
|
|
79
|
-
expect(translator.fqnsReferenced()).toContain('my_assembly.NestedType');
|
|
80
|
-
});
|
|
81
|
-
test('detect types in submodules', () => {
|
|
82
|
-
const translator = assembly.successfullyCompile(`
|
|
83
|
-
import { submod as subby } from 'my_assembly';
|
|
84
|
-
const b = new subby.SubmoduleClass();
|
|
85
|
-
`);
|
|
86
|
-
expect(translator.fqnsReferenced()).toContain('my_assembly.submod.SubmoduleClass');
|
|
87
|
-
});
|
|
88
|
-
//# sourceMappingURL=record-references.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// here
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const lib_1 = require("../lib");
|
|
4
|
-
const testutil_1 = require("./testutil");
|
|
5
|
-
const location = { api: { api: 'file', fileName: 'test.ts' } };
|
|
6
|
-
jest.setTimeout(60000);
|
|
7
|
-
test('translator can translate', async () => {
|
|
8
|
-
const translator = new lib_1.RosettaTranslator({
|
|
9
|
-
includeCompilerDiagnostics: true,
|
|
10
|
-
});
|
|
11
|
-
const snippet = (0, lib_1.typeScriptSnippetFromVisibleSource)('console.log("hello world");', location, true);
|
|
12
|
-
const { translatedSnippets } = await translator.translateAll([snippet]);
|
|
13
|
-
expect(translatedSnippets).toHaveLength(1);
|
|
14
|
-
expect(translatedSnippets[0].get(lib_1.TargetLanguage.PYTHON)?.source).toEqual('print("hello world")');
|
|
15
|
-
expect(translator.tablet.snippetKeys).toHaveLength(1);
|
|
16
|
-
});
|
|
17
|
-
test('translator can read from cache', async () => {
|
|
18
|
-
await (0, testutil_1.withTemporaryDirectory)(async () => {
|
|
19
|
-
// GIVEN: prepare cache
|
|
20
|
-
const cacheBuilder = new lib_1.RosettaTranslator({ includeCompilerDiagnostics: true });
|
|
21
|
-
const snippet = (0, lib_1.typeScriptSnippetFromVisibleSource)('console.log("hello world");', location, true);
|
|
22
|
-
await cacheBuilder.translateAll([snippet]);
|
|
23
|
-
await cacheBuilder.tablet.save('temp.tabl.json');
|
|
24
|
-
// WHEN: new translatro
|
|
25
|
-
const translator = new lib_1.RosettaTranslator({ includeCompilerDiagnostics: true });
|
|
26
|
-
await translator.loadCache('temp.tabl.json');
|
|
27
|
-
const cached = translator.readFromCache([snippet]);
|
|
28
|
-
expect(cached.translations).toHaveLength(1);
|
|
29
|
-
expect(cached.remaining).toHaveLength(0);
|
|
30
|
-
expect(translator.tablet.snippetKeys).toHaveLength(1);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
//# sourceMappingURL=rosetta-translator.test.js.map
|
package/test/rosetta.test.d.ts
DELETED
package/test/rosetta.test.js
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const mockfs = require("mock-fs");
|
|
4
|
-
const lib_1 = require("../lib");
|
|
5
|
-
const languages_1 = require("../lib/languages");
|
|
6
|
-
const fake_assembly_1 = require("./jsii/fake-assembly");
|
|
7
|
-
const testutil_1 = require("./testutil");
|
|
8
|
-
const SAMPLE_CODE = {
|
|
9
|
-
visibleSource: 'callThisFunction();',
|
|
10
|
-
location: (0, testutil_1.testSnippetLocation)('sample'),
|
|
11
|
-
};
|
|
12
|
-
const SAMPLE_CODE_COMPILING = {
|
|
13
|
-
visibleSource: 'console.log("hello");',
|
|
14
|
-
location: (0, testutil_1.testSnippetLocation)('sample'),
|
|
15
|
-
};
|
|
16
|
-
describe('Rosetta object can do live translation', () => {
|
|
17
|
-
let rosetta;
|
|
18
|
-
let translated;
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
// GIVEN
|
|
21
|
-
rosetta = new lib_1.Rosetta({
|
|
22
|
-
unknownSnippets: lib_1.UnknownSnippetMode.TRANSLATE,
|
|
23
|
-
targetLanguages: [languages_1.TargetLanguage.PYTHON],
|
|
24
|
-
});
|
|
25
|
-
// WHEN
|
|
26
|
-
translated = rosetta.translateSnippet(SAMPLE_CODE, languages_1.TargetLanguage.PYTHON);
|
|
27
|
-
});
|
|
28
|
-
test('output is correct', () => {
|
|
29
|
-
expect(translated).toMatchObject({
|
|
30
|
-
source: 'call_this_function()',
|
|
31
|
-
language: 'python',
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
test('translations are added to liveTablet', () => {
|
|
35
|
-
expect(rosetta.liveTablet.count).toEqual(1);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
test('Can use preloaded tablet', () => {
|
|
39
|
-
// GIVEN
|
|
40
|
-
const rosetta = new lib_1.Rosetta();
|
|
41
|
-
const tablet = new lib_1.LanguageTablet();
|
|
42
|
-
tablet.addSnippet(makeSnippet(SAMPLE_CODE, {
|
|
43
|
-
python: 'Not Really Translated',
|
|
44
|
-
csharp: 'Not Really Translated C#',
|
|
45
|
-
java: 'Not Really Translated Java',
|
|
46
|
-
go: 'Not Really Translated Go',
|
|
47
|
-
}));
|
|
48
|
-
rosetta.addTablet(tablet);
|
|
49
|
-
// WHEN
|
|
50
|
-
const translated = rosetta.translateSnippet(SAMPLE_CODE, languages_1.TargetLanguage.PYTHON);
|
|
51
|
-
// THEN
|
|
52
|
-
expect(translated).toMatchObject({
|
|
53
|
-
source: 'Not Really Translated',
|
|
54
|
-
language: 'python',
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
test('Rosetta object can do live translation', () => {
|
|
58
|
-
// GIVEN
|
|
59
|
-
const rosetta = new lib_1.Rosetta({
|
|
60
|
-
unknownSnippets: lib_1.UnknownSnippetMode.TRANSLATE,
|
|
61
|
-
targetLanguages: [languages_1.TargetLanguage.PYTHON],
|
|
62
|
-
});
|
|
63
|
-
// WHEN
|
|
64
|
-
const translated = rosetta.translateSnippet(SAMPLE_CODE, languages_1.TargetLanguage.PYTHON);
|
|
65
|
-
// THEN
|
|
66
|
-
expect(translated).toMatchObject({
|
|
67
|
-
source: 'call_this_function()',
|
|
68
|
-
language: 'python',
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
test('Rosetta object can fail on untranslated snippet', () => {
|
|
72
|
-
// GIVEN
|
|
73
|
-
const rosetta = new lib_1.Rosetta({
|
|
74
|
-
unknownSnippets: lib_1.UnknownSnippetMode.FAIL,
|
|
75
|
-
targetLanguages: [languages_1.TargetLanguage.PYTHON],
|
|
76
|
-
});
|
|
77
|
-
// WHEN
|
|
78
|
-
expect(() => {
|
|
79
|
-
rosetta.translateSnippet(SAMPLE_CODE, languages_1.TargetLanguage.PYTHON);
|
|
80
|
-
}).toThrow(/snippet was not found/);
|
|
81
|
-
});
|
|
82
|
-
test('Rosetta can give you an untranslated snippet back', () => {
|
|
83
|
-
// GIVEN
|
|
84
|
-
const rosetta = new lib_1.Rosetta({
|
|
85
|
-
unknownSnippets: lib_1.UnknownSnippetMode.VERBATIM,
|
|
86
|
-
targetLanguages: [languages_1.TargetLanguage.PYTHON],
|
|
87
|
-
});
|
|
88
|
-
// WHEN
|
|
89
|
-
const translated = rosetta.translateSnippet(SAMPLE_CODE, languages_1.TargetLanguage.PYTHON);
|
|
90
|
-
expect(translated?.source).toEqual('callThisFunction();');
|
|
91
|
-
});
|
|
92
|
-
test('Rosetta object can do translation and annotation of snippets in MarkDown', () => {
|
|
93
|
-
// GIVEN
|
|
94
|
-
const rosetta = new lib_1.Rosetta({
|
|
95
|
-
unknownSnippets: lib_1.UnknownSnippetMode.TRANSLATE,
|
|
96
|
-
targetLanguages: [languages_1.TargetLanguage.PYTHON],
|
|
97
|
-
});
|
|
98
|
-
// WHEN
|
|
99
|
-
const translated = rosetta.translateSnippetsInMarkdown({ api: 'file', fileName: 'markdown' }, [
|
|
100
|
-
'# MarkDown Translation',
|
|
101
|
-
'',
|
|
102
|
-
'Now follows a snippet:',
|
|
103
|
-
'```ts',
|
|
104
|
-
SAMPLE_CODE.visibleSource,
|
|
105
|
-
'```',
|
|
106
|
-
'That was it, thank you for your attention.',
|
|
107
|
-
].join('\n'), languages_1.TargetLanguage.PYTHON, false, (trans) => {
|
|
108
|
-
return {
|
|
109
|
-
...trans,
|
|
110
|
-
source: `# We translated something!\n${trans.source}`,
|
|
111
|
-
};
|
|
112
|
-
});
|
|
113
|
-
// THEN
|
|
114
|
-
expect(translated).toEqual([
|
|
115
|
-
'# MarkDown Translation',
|
|
116
|
-
'',
|
|
117
|
-
'Now follows a snippet:',
|
|
118
|
-
'',
|
|
119
|
-
'```python',
|
|
120
|
-
'# We translated something!',
|
|
121
|
-
'call_this_function()',
|
|
122
|
-
'```',
|
|
123
|
-
'',
|
|
124
|
-
'That was it, thank you for your attention.',
|
|
125
|
-
].join('\n'));
|
|
126
|
-
});
|
|
127
|
-
describe('Rosetta object with disclaimers', () => {
|
|
128
|
-
let rosetta;
|
|
129
|
-
beforeEach(() => {
|
|
130
|
-
// GIVEN
|
|
131
|
-
rosetta = new lib_1.Rosetta({
|
|
132
|
-
includeCompilerDiagnostics: true,
|
|
133
|
-
unknownSnippets: lib_1.UnknownSnippetMode.TRANSLATE,
|
|
134
|
-
targetLanguages: [languages_1.TargetLanguage.PYTHON],
|
|
135
|
-
prefixDisclaimer: true,
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
test('compiling source code has no disclaimer', () => {
|
|
139
|
-
// WHEN
|
|
140
|
-
const translated = rosetta.translateSnippet(SAMPLE_CODE_COMPILING, languages_1.TargetLanguage.PYTHON);
|
|
141
|
-
// THEN
|
|
142
|
-
expect(translated).toMatchObject({
|
|
143
|
-
source: 'print("hello")',
|
|
144
|
-
language: 'python',
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
test('noncompiling source code has disclaimer', () => {
|
|
148
|
-
// WHEN
|
|
149
|
-
const translated = rosetta.translateSnippet(SAMPLE_CODE, languages_1.TargetLanguage.PYTHON);
|
|
150
|
-
// THEN
|
|
151
|
-
expect(translated).toMatchObject({
|
|
152
|
-
source: '# Example automatically generated from non-compiling source. May contain errors.\ncall_this_function()',
|
|
153
|
-
language: 'python',
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
test('source with no compilation information has no disclaimer', () => {
|
|
157
|
-
// GIVEN
|
|
158
|
-
const rosettaNoCompile = new lib_1.Rosetta({
|
|
159
|
-
includeCompilerDiagnostics: false,
|
|
160
|
-
unknownSnippets: lib_1.UnknownSnippetMode.TRANSLATE,
|
|
161
|
-
targetLanguages: [languages_1.TargetLanguage.PYTHON],
|
|
162
|
-
prefixDisclaimer: true,
|
|
163
|
-
});
|
|
164
|
-
// WHEN
|
|
165
|
-
const translated = rosettaNoCompile.translateSnippet(SAMPLE_CODE, languages_1.TargetLanguage.PYTHON);
|
|
166
|
-
// THEN
|
|
167
|
-
expect(translated).toMatchObject({
|
|
168
|
-
source: 'call_this_function()',
|
|
169
|
-
language: 'python',
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
describe('with mocked filesystem', () => {
|
|
174
|
-
beforeEach(() => {
|
|
175
|
-
mockfs();
|
|
176
|
-
});
|
|
177
|
-
afterEach(() => {
|
|
178
|
-
mockfs.restore();
|
|
179
|
-
});
|
|
180
|
-
const tablet = new lib_1.LanguageTablet();
|
|
181
|
-
tablet.addSnippet(makeSnippet(SAMPLE_CODE, {
|
|
182
|
-
python: 'My Stored Translation',
|
|
183
|
-
csharp: 'My Stored Translation C#',
|
|
184
|
-
java: 'My Stored Translation Java',
|
|
185
|
-
go: 'My Stored Translation Go',
|
|
186
|
-
}));
|
|
187
|
-
test('Can save language tablet and load it in Rosetta class', async () => {
|
|
188
|
-
// GIVEN
|
|
189
|
-
await tablet.save('/test.tablet');
|
|
190
|
-
// WHEN
|
|
191
|
-
const rosetta = new lib_1.Rosetta();
|
|
192
|
-
await rosetta.loadTabletFromFile('/test.tablet');
|
|
193
|
-
const translated = rosetta.translateSnippet(SAMPLE_CODE, languages_1.TargetLanguage.PYTHON);
|
|
194
|
-
// THEN
|
|
195
|
-
expect(translated).toMatchObject({
|
|
196
|
-
source: 'My Stored Translation',
|
|
197
|
-
language: 'python',
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
test('Rosetta class automatically loads default-named tablets in same directory as assembly', async () => {
|
|
201
|
-
// GIVEN
|
|
202
|
-
await tablet.save(`/${lib_1.DEFAULT_TABLET_NAME}`);
|
|
203
|
-
// WHEN
|
|
204
|
-
const rosetta = new lib_1.Rosetta();
|
|
205
|
-
await rosetta.addAssembly((0, fake_assembly_1.fakeAssembly)({}), '/');
|
|
206
|
-
const translated = rosetta.translateSnippet(SAMPLE_CODE, languages_1.TargetLanguage.PYTHON);
|
|
207
|
-
// THEN
|
|
208
|
-
expect(translated).toMatchObject({
|
|
209
|
-
source: 'My Stored Translation',
|
|
210
|
-
language: 'python',
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
function makeSnippet(original, translations) {
|
|
215
|
-
const snippet = lib_1.TranslatedSnippet.fromTypeScript(original);
|
|
216
|
-
for (const [key, value] of Object.entries(translations)) {
|
|
217
|
-
snippet.addTranslation(key, value, 'x');
|
|
218
|
-
}
|
|
219
|
-
return snippet;
|
|
220
|
-
}
|
|
221
|
-
//# sourceMappingURL=rosetta.test.js.map
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const snippet_1 = require("../lib/snippet");
|
|
4
|
-
const snippet_selectors_1 = require("../lib/snippet-selectors");
|
|
5
|
-
const tablets_1 = require("../lib/tablets/tablets");
|
|
6
|
-
const testutil_1 = require("./testutil");
|
|
7
|
-
const snippets = [];
|
|
8
|
-
const sources = [
|
|
9
|
-
`export class ClassA {
|
|
10
|
-
public someMethod() {
|
|
11
|
-
}
|
|
12
|
-
}`,
|
|
13
|
-
`export class ClassA {
|
|
14
|
-
public someMethod() {
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export interface BeeArgs { readonly value: string; }
|
|
18
|
-
`,
|
|
19
|
-
`export class ClassA {
|
|
20
|
-
public someMethod() {
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export class ClassB {
|
|
24
|
-
public argumentMethod(args: BeeArgs) {
|
|
25
|
-
Array.isArray(args);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export interface BeeArgs { readonly value: string; }
|
|
29
|
-
`,
|
|
30
|
-
];
|
|
31
|
-
beforeAll(() => {
|
|
32
|
-
for (const source of sources) {
|
|
33
|
-
const snippet = tablets_1.TranslatedSnippet.fromTypeScript((0, snippet_1.typeScriptSnippetFromSource)(source, (0, testutil_1.testSnippetLocation)('selectors'), false));
|
|
34
|
-
snippets.push(snippet);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
test('longest', () => {
|
|
38
|
-
const result = (0, snippet_selectors_1.longest)(snippets);
|
|
39
|
-
expect(result).toEqual(snippets[2]);
|
|
40
|
-
});
|
|
41
|
-
test('meanLength', () => {
|
|
42
|
-
const result = (0, snippet_selectors_1.meanLength)(snippets);
|
|
43
|
-
expect(result).toEqual(snippets[1]);
|
|
44
|
-
});
|
|
45
|
-
test('shortest', () => {
|
|
46
|
-
const result = (0, snippet_selectors_1.shortest)(snippets);
|
|
47
|
-
expect(result).toEqual(snippets[0]);
|
|
48
|
-
});
|
|
49
|
-
test('mean', () => {
|
|
50
|
-
// Add fake syntax counters to ensure that snippets[1] is the closest euclidean distance.
|
|
51
|
-
snippets[0].addSyntaxKindCounter({ 1: 1, 2: 5, 3: 1 });
|
|
52
|
-
snippets[1].addSyntaxKindCounter({ 1: 1, 2: 3, 3: 2 });
|
|
53
|
-
snippets[2].addSyntaxKindCounter({ 1: 1, 2: 1, 3: 4 });
|
|
54
|
-
const result = (0, snippet_selectors_1.mean)(snippets);
|
|
55
|
-
expect(result).toEqual(snippets[1]);
|
|
56
|
-
});
|
|
57
|
-
//# sourceMappingURL=snippet-selectors.test.js.map
|
package/test/snippet.test.d.ts
DELETED
package/test/snippet.test.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const lib_1 = require("../lib");
|
|
4
|
-
describe('construct TypeScriptSnippets', () => {
|
|
5
|
-
const source = ['a', '/// !show', 'b', '/// !hide', 'c'].join('\n');
|
|
6
|
-
const location = { api: { api: 'file', fileName: 'x' } };
|
|
7
|
-
test('using typeScriptSnippetFromVisibleSource', () => {
|
|
8
|
-
const snippet = (0, lib_1.typeScriptSnippetFromVisibleSource)(source, location, true);
|
|
9
|
-
expect(snippet.visibleSource).toEqual(source);
|
|
10
|
-
expect(snippet.completeSource).toEqual(undefined);
|
|
11
|
-
});
|
|
12
|
-
test('using typeScriptSnippetFromCompleteSource', () => {
|
|
13
|
-
const snippet = (0, lib_1.typeScriptSnippetFromCompleteSource)(source, location, true);
|
|
14
|
-
expect(snippet.visibleSource).toEqual('b');
|
|
15
|
-
expect(snippet.completeSource).toEqual(source);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
//# sourceMappingURL=snippet.test.js.map
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const testutil_1 = require("./testutil");
|
|
4
|
-
let assembly;
|
|
5
|
-
beforeAll(() => {
|
|
6
|
-
assembly = testutil_1.TestJsiiModule.fromSource(`
|
|
7
|
-
export class ClassA {
|
|
8
|
-
public someMethod() {
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
export class ClassB {
|
|
12
|
-
public argumentMethod(args: BeeArgs) {
|
|
13
|
-
Array.isArray(args);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export interface BeeArgs { readonly value: string; readonly nested?: NestedType; }
|
|
17
|
-
export interface NestedType { readonly x: number; }
|
|
18
|
-
`, {
|
|
19
|
-
name: 'my_assembly',
|
|
20
|
-
jsii: testutil_1.DUMMY_JSII_CONFIG,
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
afterAll(() => assembly.cleanup());
|
|
24
|
-
test('generate syntax counter', () => {
|
|
25
|
-
const translator = assembly.successfullyCompile(`
|
|
26
|
-
import * as ass from 'my_assembly';
|
|
27
|
-
const a = new ass.ClassA();
|
|
28
|
-
`);
|
|
29
|
-
expect(translator.syntaxKindCounter()).toEqual({
|
|
30
|
-
10: 1,
|
|
31
|
-
75: 4,
|
|
32
|
-
194: 1,
|
|
33
|
-
197: 1,
|
|
34
|
-
225: 1,
|
|
35
|
-
242: 1,
|
|
36
|
-
243: 1,
|
|
37
|
-
254: 1,
|
|
38
|
-
255: 1,
|
|
39
|
-
256: 1,
|
|
40
|
-
290: 1, // SourceFile
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
test('do not count syntax in hidden lines', () => {
|
|
44
|
-
const translator = assembly.successfullyCompile(`
|
|
45
|
-
/// !hide
|
|
46
|
-
import * as ass from 'my_assembly';
|
|
47
|
-
const a = new ass.ClassA();
|
|
48
|
-
/// !show
|
|
49
|
-
const b = new ass.ClassB();
|
|
50
|
-
`);
|
|
51
|
-
expect(translator.syntaxKindCounter()).toEqual({
|
|
52
|
-
75: 3,
|
|
53
|
-
194: 1,
|
|
54
|
-
197: 1,
|
|
55
|
-
225: 1,
|
|
56
|
-
242: 1,
|
|
57
|
-
243: 1, // VariableDeclarationList
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
//# sourceMappingURL=syntax-counter.test.js.map
|