yoda-language-server 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +23 -0
- data/.gitignore +1 -1
- data/.rspec +1 -0
- data/Gemfile +2 -0
- data/README.md +23 -11
- data/Rakefile +32 -0
- data/bin/bench +12 -0
- data/bin/local +7 -0
- data/client/atom/.gitignore +1 -0
- data/{package.json → client/atom/package.json} +1 -1
- data/{yarn.lock → client/atom/yarn.lock} +0 -0
- data/client/vscode/.gitignore +1 -1
- data/client/vscode/.vscode/launch.json +0 -11
- data/client/vscode/.vscode/settings.json +5 -1
- data/client/vscode/LICENSE.txt +21 -0
- data/client/vscode/README.md +4 -55
- data/client/vscode/package-lock.json +4195 -1360
- data/client/vscode/package.json +30 -15
- data/client/vscode/src/config.ts +13 -0
- data/client/vscode/src/extension.ts +11 -27
- data/client/vscode/src/install-tools.ts +69 -0
- data/client/vscode/src/language-server.ts +54 -0
- data/client/vscode/src/status.ts +3 -0
- data/client/vscode/src/test/runTest.ts +30 -0
- data/client/vscode/src/test/{completion.test.ts → suite/completion.test.ts} +2 -1
- data/client/vscode/src/test/suite/hover.test.ts +43 -0
- data/client/vscode/src/test/suite/index.ts +27 -0
- data/client/vscode/tsconfig.json +4 -1
- data/exe/yoda +1 -1
- data/lib/yoda/ast/array_node.rb +10 -0
- data/lib/yoda/ast/assignment_node.rb +15 -0
- data/lib/yoda/ast/block_call_node.rb +20 -0
- data/lib/yoda/ast/block_node.rb +10 -0
- data/lib/yoda/ast/case_node.rb +20 -0
- data/lib/yoda/ast/center_operator_node.rb +20 -0
- data/lib/yoda/ast/class_node.rb +22 -0
- data/lib/yoda/ast/comment_block/base_part.rb +12 -0
- data/lib/yoda/ast/comment_block/range_calculation.rb +58 -0
- data/lib/yoda/ast/comment_block/tag_part.rb +88 -0
- data/lib/yoda/ast/comment_block/tag_text_name_part.rb +35 -0
- data/lib/yoda/ast/comment_block/tag_text_type_part.rb +52 -0
- data/lib/yoda/ast/comment_block/text_part.rb +28 -0
- data/lib/yoda/ast/comment_block/token.rb +44 -0
- data/lib/yoda/ast/comment_block.rb +119 -0
- data/lib/yoda/ast/conditional_loop_node.rb +15 -0
- data/lib/yoda/ast/constant_assignment_node.rb +20 -0
- data/lib/yoda/ast/constant_base_node.rb +42 -0
- data/lib/yoda/ast/constant_node.rb +53 -0
- data/lib/yoda/ast/def_node.rb +27 -0
- data/lib/yoda/ast/def_singleton_node.rb +32 -0
- data/lib/yoda/ast/empty_vnode.rb +24 -0
- data/lib/yoda/ast/ensure_node.rb +15 -0
- data/lib/yoda/ast/for_node.rb +20 -0
- data/lib/yoda/ast/hash_node.rb +10 -0
- data/lib/yoda/ast/if_node.rb +20 -0
- data/lib/yoda/ast/interpolation_text_node.rb +10 -0
- data/lib/yoda/ast/kwsplat_node.rb +10 -0
- data/lib/yoda/ast/left_operator_node.rb +15 -0
- data/lib/yoda/ast/literal_node.rb +18 -0
- data/lib/yoda/ast/method_traversable.rb +22 -0
- data/lib/yoda/ast/module_node.rb +17 -0
- data/lib/yoda/ast/multiple_left_hand_side_node.rb +31 -0
- data/lib/yoda/ast/name_vnode.rb +28 -0
- data/lib/yoda/ast/namespace.rb +36 -0
- data/lib/yoda/ast/namespace_traversable.rb +39 -0
- data/lib/yoda/ast/node.rb +52 -0
- data/lib/yoda/ast/optional_parameter_node.rb +20 -0
- data/lib/yoda/ast/pair_node.rb +15 -0
- data/lib/yoda/ast/parameter_node.rb +25 -0
- data/lib/yoda/ast/parameters_node.rb +62 -0
- data/lib/yoda/ast/rescue_clause_node.rb +20 -0
- data/lib/yoda/ast/rescue_node.rb +20 -0
- data/lib/yoda/ast/root_vnode.rb +48 -0
- data/lib/yoda/ast/send_node.rb +100 -0
- data/lib/yoda/ast/singleton_class_node.rb +17 -0
- data/lib/yoda/ast/special_call_node.rb +10 -0
- data/lib/yoda/ast/traversable.rb +34 -0
- data/lib/yoda/ast/value_vnode.rb +28 -0
- data/lib/yoda/ast/variable_node.rb +15 -0
- data/lib/yoda/ast/vnode.rb +170 -0
- data/lib/yoda/ast/when_node.rb +15 -0
- data/lib/yoda/ast.rb +140 -0
- data/lib/yoda/cli/analyze_deps.rb +102 -0
- data/lib/yoda/{commands → cli}/base.rb +1 -1
- data/lib/yoda/{commands → cli}/complete.rb +12 -9
- data/lib/yoda/cli/console.rb +17 -0
- data/lib/yoda/{commands → cli}/file_cursor_parsable.rb +1 -1
- data/lib/yoda/{commands → cli}/infer.rb +4 -4
- data/lib/yoda/cli.rb +117 -0
- data/lib/yoda/has_services.rb +40 -0
- data/lib/yoda/instrument.rb +14 -5
- data/lib/yoda/logger.rb +4 -2
- data/lib/yoda/missing_delegatable.rb +34 -0
- data/lib/yoda/model/completion_item.rb +43 -11
- data/lib/yoda/model/descriptions/base.rb +11 -0
- data/lib/yoda/model/descriptions/comment_token_description.rb +46 -0
- data/lib/yoda/model/descriptions/function_description.rb +19 -2
- data/lib/yoda/model/descriptions/node_description.rb +19 -8
- data/lib/yoda/model/descriptions/variable_description.rb +41 -0
- data/lib/yoda/model/descriptions.rb +2 -0
- data/lib/yoda/model/environment/accessor_interface.rb +43 -0
- data/lib/yoda/model/environment/instance_accessor.rb +121 -0
- data/lib/yoda/model/environment/namespace_members.rb +104 -0
- data/lib/yoda/model/environment/singleton_accessor.rb +66 -0
- data/lib/yoda/model/environment/value_factory.rb +151 -0
- data/lib/yoda/model/environment/value_resolve_context.rb +62 -0
- data/lib/yoda/model/environment/with_cache.rb +14 -0
- data/lib/yoda/model/environment.rb +122 -0
- data/lib/yoda/model/function_signatures/base.rb +22 -2
- data/lib/yoda/model/function_signatures/constructor.rb +17 -1
- data/lib/yoda/model/function_signatures/method.rb +18 -2
- data/lib/yoda/model/function_signatures/overload.rb +17 -1
- data/lib/yoda/model/function_signatures/parameter_list.rb +17 -0
- data/lib/yoda/model/function_signatures/rbs_method.rb +91 -0
- data/lib/yoda/model/function_signatures/type_builder.rb +63 -31
- data/lib/yoda/model/function_signatures/wrapper.rb +46 -0
- data/lib/yoda/model/function_signatures.rb +2 -0
- data/lib/yoda/model/lexical_context.rb +40 -0
- data/lib/yoda/model/node_signatures/base.rb +42 -0
- data/lib/yoda/model/node_signatures/const.rb +20 -0
- data/lib/yoda/model/node_signatures/method_definition.rb +20 -0
- data/lib/yoda/model/node_signatures/node.rb +11 -0
- data/lib/yoda/model/node_signatures/send.rb +20 -0
- data/lib/yoda/model/node_signatures.rb +35 -0
- data/lib/yoda/model/parameters/base.rb +14 -0
- data/lib/yoda/model/parameters/binder.rb +148 -0
- data/lib/yoda/model/parameters/multiple.rb +36 -0
- data/lib/yoda/model/parameters/named.rb +20 -0
- data/lib/yoda/model/parameters/unnamed.rb +12 -0
- data/lib/yoda/model/parameters.rb +11 -0
- data/lib/yoda/model/path.rb +16 -0
- data/lib/yoda/model/primary_source_inferencer.rb +34 -0
- data/lib/yoda/model/scoped_path.rb +13 -2
- data/lib/yoda/model/{types → type_expressions}/any_type.rb +7 -3
- data/lib/yoda/model/{types → type_expressions}/base.rb +10 -3
- data/lib/yoda/model/{types → type_expressions}/duck_type.rb +8 -2
- data/lib/yoda/model/type_expressions/function_type/parameter.rb +95 -0
- data/lib/yoda/model/{types → type_expressions}/function_type.rb +61 -70
- data/lib/yoda/model/type_expressions/generator.rb +28 -0
- data/lib/yoda/model/{types → type_expressions}/generic_type.rb +17 -2
- data/lib/yoda/model/{types → type_expressions}/instance_type.rb +10 -2
- data/lib/yoda/model/{types → type_expressions}/module_type.rb +7 -1
- data/lib/yoda/model/type_expressions/self_type.rb +38 -0
- data/lib/yoda/model/{types → type_expressions}/sequence_type.rb +6 -1
- data/lib/yoda/model/{types → type_expressions}/union_type.rb +7 -3
- data/lib/yoda/model/{types → type_expressions}/unknown_type.rb +6 -1
- data/lib/yoda/model/{types → type_expressions}/value_type.rb +17 -1
- data/lib/yoda/model/type_expressions/void_type.rb +37 -0
- data/lib/yoda/model/type_expressions.rb +40 -0
- data/lib/yoda/model/values/base.rb +23 -8
- data/lib/yoda/model/values/empty_value.rb +39 -0
- data/lib/yoda/model/values/instance_value.rb +24 -43
- data/lib/yoda/model/values/intersection_value.rb +48 -0
- data/lib/yoda/model/values/literal_value.rb +23 -0
- data/lib/yoda/model/values/union_value.rb +50 -0
- data/lib/yoda/model/values.rb +5 -1
- data/lib/yoda/model/yard_type_parser.rb +35 -0
- data/lib/yoda/model.rb +7 -2
- data/lib/yoda/parsing/comment_tokenizer.rb +21 -4
- data/lib/yoda/parsing/location.rb +1 -1
- data/lib/yoda/parsing/node_objects/args_node.rb +85 -0
- data/lib/yoda/parsing/node_objects/const_node.rb +3 -3
- data/lib/yoda/parsing/node_objects/mlhs_node.rb +31 -0
- data/lib/yoda/parsing/node_objects.rb +2 -0
- data/lib/yoda/parsing/parser.rb +44 -5
- data/lib/yoda/parsing/query/current_comment_token_query.rb +4 -3
- data/lib/yoda/parsing/query/current_commenting_node_query.rb +7 -7
- data/lib/yoda/parsing/scopes/base.rb +1 -1
- data/lib/yoda/parsing/scopes/builder.rb +1 -1
- data/lib/yoda/parsing/source_cutter.rb +6 -2
- data/lib/yoda/parsing/traverser/matcher.rb +65 -0
- data/lib/yoda/parsing/traverser/query_interface.rb +68 -0
- data/lib/yoda/parsing/traverser/result_set.rb +37 -0
- data/lib/yoda/parsing/traverser.rb +29 -0
- data/lib/yoda/parsing/type_parser.rb +24 -20
- data/lib/yoda/parsing.rb +27 -1
- data/lib/yoda/presentation/code_completion/constant.rb +27 -0
- data/lib/yoda/server/lifecycle_handler.rb +81 -4
- data/lib/yoda/server/notifier.rb +131 -0
- data/lib/yoda/server/providers/completion.rb +31 -17
- data/lib/yoda/server/providers/definition.rb +38 -10
- data/lib/yoda/server/providers/hover.rb +26 -10
- data/lib/yoda/server/providers/reportable_progress.rb +75 -0
- data/lib/yoda/server/providers/signature.rb +20 -7
- data/lib/yoda/server/providers/text_document_did_change.rb +1 -1
- data/lib/yoda/server/providers/text_document_did_open.rb +1 -1
- data/lib/yoda/server/providers/with_timeout.rb +36 -0
- data/lib/yoda/server/providers/workspace_did_change_workspace_folders.rb +33 -0
- data/lib/yoda/server/providers/workspace_did_create_files.rb +21 -0
- data/lib/yoda/server/providers/workspace_did_delete_files.rb +21 -0
- data/lib/yoda/server/providers/workspace_did_rename_files.rb +22 -0
- data/lib/yoda/server/providers/workspace_symbol.rb +82 -0
- data/lib/yoda/server/providers.rb +12 -0
- data/lib/yoda/server/root_handler.rb +27 -23
- data/lib/yoda/server/rootless_workspace.rb +62 -0
- data/lib/yoda/server/scheduler.rb +50 -0
- data/lib/yoda/server/session.rb +71 -25
- data/lib/yoda/server/uri_decoder.rb +16 -0
- data/lib/yoda/server/workspace.rb +117 -0
- data/lib/yoda/server.rb +9 -2
- data/lib/yoda/services/code_completion/base_provider.rb +52 -0
- data/lib/yoda/{evaluation → services}/code_completion/const_provider.rb +35 -25
- data/lib/yoda/services/code_completion/keyword_provider.rb +67 -0
- data/lib/yoda/services/code_completion/local_variable_provider.rb +51 -0
- data/lib/yoda/{evaluation → services}/code_completion/method_provider.rb +14 -32
- data/lib/yoda/services/code_completion.rb +74 -0
- data/lib/yoda/{evaluation → services}/comment_completion/base_provider.rb +11 -6
- data/lib/yoda/{evaluation → services}/comment_completion/param_provider.rb +1 -1
- data/lib/yoda/{evaluation → services}/comment_completion/tag_provider.rb +1 -1
- data/lib/yoda/{evaluation → services}/comment_completion/type_provider.rb +6 -5
- data/lib/yoda/{evaluation → services}/comment_completion.rb +13 -13
- data/lib/yoda/services/current_node_explain/comment_signature.rb +77 -0
- data/lib/yoda/services/current_node_explain.rb +72 -0
- data/lib/yoda/services/evaluator.rb +44 -0
- data/lib/yoda/services/signature_discovery.rb +74 -0
- data/lib/yoda/services.rb +9 -0
- data/lib/yoda/store/actions/build_core_index.rb +38 -9
- data/lib/yoda/store/actions/import_core_library.rb +14 -19
- data/lib/yoda/store/actions/import_gem.rb +65 -33
- data/lib/yoda/store/actions/import_project_dependencies.rb +47 -0
- data/lib/yoda/store/actions/import_std_library.rb +13 -18
- data/lib/yoda/store/actions/read_file.rb +21 -6
- data/lib/yoda/store/actions/read_project_files.rb +7 -1
- data/lib/yoda/store/actions.rb +1 -0
- data/lib/yoda/store/adapters/base.rb +39 -0
- data/lib/yoda/store/adapters/gdbm_adapter/namespace_accessor.rb +152 -0
- data/lib/yoda/store/adapters/gdbm_adapter.rb +56 -0
- data/lib/yoda/store/adapters/lazy_adapter.rb +34 -0
- data/lib/yoda/store/adapters/memory_adapter.rb +21 -0
- data/lib/yoda/store/adapters.rb +12 -4
- data/lib/yoda/store/config.rb +43 -0
- data/lib/yoda/store/file_tree.rb +131 -0
- data/lib/yoda/store/objects/base.rb +73 -4
- data/lib/yoda/store/objects/class_object.rb +16 -7
- data/lib/yoda/store/objects/connected_delegation.rb +25 -0
- data/lib/yoda/store/objects/libraries_status.rb +67 -0
- data/lib/yoda/store/objects/library/core.rb +72 -0
- data/lib/yoda/store/objects/library/gem.rb +141 -0
- data/lib/yoda/store/objects/library/std.rb +72 -0
- data/lib/yoda/store/objects/library/with_registry.rb +28 -0
- data/lib/yoda/store/objects/library.rb +24 -0
- data/lib/yoda/store/objects/map.rb +61 -0
- data/lib/yoda/store/objects/merger.rb +96 -12
- data/lib/yoda/store/objects/meta_class_object.rb +28 -1
- data/lib/yoda/store/objects/method_object.rb +39 -6
- data/lib/yoda/store/objects/module_object.rb +3 -0
- data/lib/yoda/store/objects/namespace_object.rb +38 -1
- data/lib/yoda/store/objects/overload.rb +1 -1
- data/lib/yoda/store/objects/patch.rb +56 -12
- data/lib/yoda/store/objects/patch_set.rb +58 -26
- data/lib/yoda/store/objects/serializable.rb +17 -2
- data/lib/yoda/store/objects/serializable_set.rb +23 -0
- data/lib/yoda/store/objects/tag.rb +1 -1
- data/lib/yoda/store/objects/value_object.rb +5 -1
- data/lib/yoda/store/objects.rb +5 -1
- data/lib/yoda/store/project/dependency.rb +83 -0
- data/lib/yoda/store/project/file_finder.rb +101 -0
- data/lib/yoda/store/project/rbs_loader.rb +41 -0
- data/lib/yoda/store/project/setuper.rb +68 -0
- data/lib/yoda/store/project.rb +99 -41
- data/lib/yoda/store/query/ancestor_tree.rb +126 -0
- data/lib/yoda/store/query/associators/associate_ancestors.rb +5 -78
- data/lib/yoda/store/query/associators/associate_methods.rb +11 -8
- data/lib/yoda/store/query/constant_member_set.rb +33 -0
- data/lib/yoda/store/query/find_constant.rb +23 -6
- data/lib/yoda/store/query/find_meta_class.rb +1 -1
- data/lib/yoda/store/query/find_method.rb +12 -25
- data/lib/yoda/store/query/find_signature.rb +11 -3
- data/lib/yoda/store/query/find_workspace_objects.rb +36 -0
- data/lib/yoda/store/query/method_member_set.rb +50 -0
- data/lib/yoda/store/query.rb +4 -0
- data/lib/yoda/store/registry/cache.rb +65 -0
- data/lib/yoda/store/registry/composer.rb +47 -0
- data/lib/yoda/store/registry/index.rb +116 -0
- data/lib/yoda/store/registry/library_registry.rb +69 -0
- data/lib/yoda/store/registry/library_registry_set.rb +133 -0
- data/lib/yoda/store/registry/local_store.rb +38 -0
- data/lib/yoda/store/registry/project_registry.rb +72 -0
- data/lib/yoda/store/registry.rb +25 -89
- data/lib/yoda/store/transformers/core_visibility.rb +61 -0
- data/lib/yoda/store/transformers.rb +7 -0
- data/lib/yoda/store/version_store.rb +71 -0
- data/lib/yoda/store/yard_importer.rb +22 -20
- data/lib/yoda/store.rb +15 -1
- data/lib/yoda/typing/constant_resolver/cbase_query.rb +14 -0
- data/lib/yoda/typing/constant_resolver/member_query.rb +27 -0
- data/lib/yoda/typing/constant_resolver/node_tracer.rb +36 -0
- data/lib/yoda/typing/constant_resolver/query.rb +59 -0
- data/lib/yoda/typing/constant_resolver/relative_base_query.rb +14 -0
- data/lib/yoda/typing/constant_resolver.rb +105 -0
- data/lib/yoda/typing/contexts/base_context.rb +83 -0
- data/lib/yoda/typing/contexts/block_context.rb +14 -0
- data/lib/yoda/typing/contexts/context_derivation.rb +59 -0
- data/lib/yoda/typing/contexts/method_context.rb +14 -0
- data/lib/yoda/typing/contexts/namespace_block_context.rb +29 -0
- data/lib/yoda/typing/contexts/namespace_context.rb +14 -0
- data/lib/yoda/typing/contexts.rb +25 -0
- data/lib/yoda/typing/environment.rb +1 -1
- data/lib/yoda/typing/inferencer/arguments.rb +38 -0
- data/lib/yoda/typing/inferencer/arguments_binder.rb +24 -0
- data/lib/yoda/typing/inferencer/ast_traverser.rb +408 -0
- data/lib/yoda/typing/inferencer/method_resolver.rb +81 -0
- data/lib/yoda/typing/inferencer/object_resolver.rb +55 -0
- data/lib/yoda/typing/inferencer/parameter_binder.rb +176 -0
- data/lib/yoda/typing/inferencer/tracer.rb +177 -0
- data/lib/yoda/typing/inferencer/type_binding.rb +46 -0
- data/lib/yoda/typing/inferencer.rb +52 -0
- data/lib/yoda/typing/node_info.rb +78 -0
- data/lib/yoda/typing/relation.rb +2 -2
- data/lib/yoda/typing/traces/base.rb +2 -2
- data/lib/yoda/typing/traces/normal.rb +3 -3
- data/lib/yoda/typing/traces/send.rb +4 -4
- data/lib/yoda/typing/tree/base.rb +46 -0
- data/lib/yoda/typing/tree/begin.rb +15 -0
- data/lib/yoda/typing/tree/block.rb +12 -0
- data/lib/yoda/typing/tree/case.rb +29 -0
- data/lib/yoda/typing/tree/class_tree.rb +31 -0
- data/lib/yoda/typing/tree/const.rb +12 -0
- data/lib/yoda/typing/tree/constant_assignment.rb +12 -0
- data/lib/yoda/typing/tree/defined.rb +11 -0
- data/lib/yoda/typing/tree/escape.rb +12 -0
- data/lib/yoda/typing/tree/for.rb +8 -0
- data/lib/yoda/typing/tree/hash_body.rb +36 -0
- data/lib/yoda/typing/tree/if.rb +17 -0
- data/lib/yoda/typing/tree/literal.rb +46 -0
- data/lib/yoda/typing/tree/literal_with_interpolation.rb +21 -0
- data/lib/yoda/typing/tree/logical_assignment.rb +16 -0
- data/lib/yoda/typing/tree/logical_operator.rb +15 -0
- data/lib/yoda/typing/tree/method.rb +43 -0
- data/lib/yoda/typing/tree/module_tree.rb +31 -0
- data/lib/yoda/typing/tree/multiple_assignment.rb +20 -0
- data/lib/yoda/typing/tree/rescue_body.rb +12 -0
- data/lib/yoda/typing/tree/self.rb +11 -0
- data/lib/yoda/typing/tree/send.rb +71 -0
- data/lib/yoda/typing/tree/singleton_method.rb +47 -0
- data/lib/yoda/typing/tree/super.rb +12 -0
- data/lib/yoda/typing/tree/variable.rb +20 -0
- data/lib/yoda/typing/tree/variable_assignment.rb +20 -0
- data/lib/yoda/typing/tree/while.rb +12 -0
- data/lib/yoda/typing/tree/yield.rb +12 -0
- data/lib/yoda/typing/tree.rb +96 -0
- data/lib/yoda/typing/types/any.rb +15 -0
- data/lib/yoda/typing/types/associative_array.rb +28 -0
- data/lib/yoda/typing/types/base.rb +25 -0
- data/lib/yoda/typing/types/converter.rb +67 -0
- data/lib/yoda/typing/types/function.rb +68 -0
- data/lib/yoda/typing/types/generator.rb +306 -0
- data/lib/yoda/typing/types/generic.rb +29 -0
- data/lib/yoda/typing/types/instance.rb +30 -0
- data/lib/yoda/typing/types/instance_type.rb +74 -0
- data/lib/yoda/typing/types/method.rb +39 -0
- data/lib/yoda/typing/types/rbs_type_wrapper_interface.rb +44 -0
- data/lib/yoda/typing/types/singleton_type.rb +75 -0
- data/lib/yoda/typing/types/tuple.rb +24 -0
- data/lib/yoda/typing/types/type.rb +60 -0
- data/lib/yoda/typing/types/union.rb +38 -0
- data/lib/yoda/typing/types/var.rb +38 -0
- data/lib/yoda/typing/types.rb +24 -0
- data/lib/yoda/typing.rb +5 -2
- data/lib/yoda/version.rb +1 -1
- data/lib/yoda.rb +6 -2
- data/scripts/benchmark.rb +1 -1
- data/yoda-language-server.gemspec +16 -15
- metadata +334 -110
- data/.travis.yml +0 -8
- data/client/vscode/src/test/index.ts +0 -24
- data/lib/yoda/commands/setup.rb +0 -51
- data/lib/yoda/commands.rb +0 -69
- data/lib/yoda/evaluation/code_completion/base_provider.rb +0 -57
- data/lib/yoda/evaluation/code_completion/variable_provider.rb +0 -18
- data/lib/yoda/evaluation/code_completion.rb +0 -65
- data/lib/yoda/evaluation/current_node_explain.rb +0 -71
- data/lib/yoda/evaluation/evaluator.rb +0 -105
- data/lib/yoda/evaluation/signature_discovery.rb +0 -85
- data/lib/yoda/evaluation.rb +0 -9
- data/lib/yoda/model/node_signature.rb +0 -43
- data/lib/yoda/model/types.rb +0 -84
- data/lib/yoda/model/values/module_value.rb +0 -72
- data/lib/yoda/parsing/source_analyzer.rb +0 -59
- data/lib/yoda/server/file_store.rb +0 -57
- data/lib/yoda/store/adapters/leveldb_adapter.rb +0 -80
- data/lib/yoda/store/adapters/lmdb_adapter.rb +0 -113
- data/lib/yoda/store/objects/project_status.rb +0 -169
- data/lib/yoda/store/project/cache.rb +0 -78
- data/lib/yoda/store/project/library_doc_loader.rb +0 -114
- data/lib/yoda/typing/context.rb +0 -96
- data/lib/yoda/typing/evaluator.rb +0 -259
- data/scripts/build_core_index.sh +0 -16
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'set'
|
2
|
+
require 'forwardable'
|
3
|
+
|
1
4
|
module Yoda
|
2
5
|
module Store
|
3
6
|
module Objects
|
@@ -7,12 +10,13 @@ module Yoda
|
|
7
10
|
|
8
11
|
# @param instances [Array<Base>]
|
9
12
|
def initialize(instances)
|
13
|
+
fail ArgumentError, 'instances must not be an empty array' if instances.empty?
|
10
14
|
@instances = instances
|
11
15
|
end
|
12
16
|
|
13
17
|
# @return [Base]
|
14
18
|
def merged_instance
|
15
|
-
class_to_generate.new(attributes.select { |k, v| class_to_generate.attr_names.include?(k) }
|
19
|
+
class_to_generate.new(**attributes.select { |k, v| class_to_generate.attr_names.include?(k) })
|
16
20
|
end
|
17
21
|
|
18
22
|
private
|
@@ -20,13 +24,13 @@ module Yoda
|
|
20
24
|
# @return [Base.class]
|
21
25
|
def class_to_generate
|
22
26
|
@class_to_generate ||= begin
|
23
|
-
if instances.any? { |el| el.
|
27
|
+
if instances.any? { |el| el.kind == :meta_class }
|
24
28
|
MetaClassObject
|
25
|
-
elsif instances.any? { |el| el.
|
29
|
+
elsif instances.any? { |el| el.kind == :class }
|
26
30
|
ClassObject
|
27
|
-
elsif instances.any? { |el| el.
|
31
|
+
elsif instances.any? { |el| el.kind == :module }
|
28
32
|
ModuleObject
|
29
|
-
elsif instances.any? { |el| el.
|
33
|
+
elsif instances.any? { |el| el.kind == :method }
|
30
34
|
MethodObject
|
31
35
|
else
|
32
36
|
ValueObject
|
@@ -36,7 +40,7 @@ module Yoda
|
|
36
40
|
|
37
41
|
# @return [Hash{ Symbol => Object }]
|
38
42
|
def attributes
|
39
|
-
@attributes ||= instances.map { |i| default_attributes.merge(i.to_h) }.reduce { |a, b| merge_attributes(a, b) }
|
43
|
+
@attributes ||= normalize_attributes(instances.map { |i| default_attributes.merge(i.to_h) }.reduce { |a, b| merge_attributes(a, b) })
|
40
44
|
end
|
41
45
|
|
42
46
|
# @param one [Hash{ Symbol => Object }]
|
@@ -45,15 +49,15 @@ module Yoda
|
|
45
49
|
{
|
46
50
|
path: one[:path] || another[:path],
|
47
51
|
document: one[:document] + (one[:document].empty? || another[:document].empty? ? '' : "\n") + another[:document],
|
48
|
-
tag_list: one[:tag_list]
|
49
|
-
sources: one[:sources]
|
52
|
+
tag_list: PendingArray.append(one[:tag_list], another[:tag_list]),
|
53
|
+
sources: PendingSet.merge(one[:sources], another[:sources]),
|
50
54
|
primary_source: one[:primary_source] || another[:primary_source],
|
51
|
-
instance_method_addresses: (one[:instance_method_addresses]
|
52
|
-
mixin_addresses: (one[:mixin_addresses]
|
53
|
-
constant_addresses: (one[:constant_addresses]
|
55
|
+
instance_method_addresses: PendingSet.merge(one[:instance_method_addresses], another[:instance_method_addresses]),
|
56
|
+
mixin_addresses: PendingSet.merge(one[:mixin_addresses], another[:mixin_addresses]),
|
57
|
+
constant_addresses: PendingSet.merge(one[:constant_addresses], another[:constant_addresses]),
|
54
58
|
visibility: one[:visibility] || another[:visibility],
|
55
59
|
parameters: one[:parameters].empty? ? another[:parameters] : one[:parameters],
|
56
|
-
overloads: one[:overloads]
|
60
|
+
overloads: PendingArray.append(one[:overloads], another[:overloads]),
|
57
61
|
superclass_path: select_superclass(one, another),
|
58
62
|
value: one[:value] || another[:value],
|
59
63
|
}
|
@@ -78,6 +82,26 @@ module Yoda
|
|
78
82
|
}
|
79
83
|
end
|
80
84
|
|
85
|
+
# @param attrs [Hash{ Symbol => Object }]
|
86
|
+
# @return [Hash{ Symbol => Object }]
|
87
|
+
def normalize_attributes(attrs)
|
88
|
+
{
|
89
|
+
path: attrs[:path],
|
90
|
+
document: attrs[:document],
|
91
|
+
tag_list: attrs[:tag_list].to_a,
|
92
|
+
sources: attrs[:sources].to_a,
|
93
|
+
primary_source: attrs[:primary_source],
|
94
|
+
instance_method_addresses: attrs[:instance_method_addresses].to_a,
|
95
|
+
mixin_addresses: attrs[:mixin_addresses].to_a,
|
96
|
+
constant_addresses: attrs[:constant_addresses].to_a,
|
97
|
+
visibility: attrs[:visibility],
|
98
|
+
parameters: attrs[:parameters].to_a,
|
99
|
+
overloads: attrs[:overloads].to_a,
|
100
|
+
superclass_path: attrs[:superclass_path],
|
101
|
+
value: attrs[:value],
|
102
|
+
}
|
103
|
+
end
|
104
|
+
|
81
105
|
# @param one [Hash{ Symbol => Object }]
|
82
106
|
# @param another [Hash{ Symbol => Object }]
|
83
107
|
# @return [ScopedPath]
|
@@ -88,6 +112,66 @@ module Yoda
|
|
88
112
|
another[:superclass_path] || one[:superclass_path]
|
89
113
|
end
|
90
114
|
end
|
115
|
+
|
116
|
+
class PendingArray
|
117
|
+
extend Forwardable
|
118
|
+
|
119
|
+
# @param els1 [Array<Object>, PendingArray]
|
120
|
+
# @param others [Array<Array<Object>, PendingArray>]
|
121
|
+
def self.append(els, *others)
|
122
|
+
if els.is_a?(PendingArray)
|
123
|
+
others.reduce(els) { |array, item| array.append(item) }
|
124
|
+
else
|
125
|
+
append(PendingArray.new(els), *others)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# @return [Array<Object>]
|
130
|
+
attr_reader :array
|
131
|
+
|
132
|
+
delegate %i(to_a each) => :array
|
133
|
+
|
134
|
+
# @param els [Array<Object>]
|
135
|
+
def initialize(els)
|
136
|
+
@array = els.dup
|
137
|
+
end
|
138
|
+
|
139
|
+
# @param els [Array<Object>]
|
140
|
+
def append(els)
|
141
|
+
array.push(*els)
|
142
|
+
self
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
class PendingSet
|
147
|
+
extend Forwardable
|
148
|
+
|
149
|
+
# @param els1 [Array<Object>, PendingSet]
|
150
|
+
# @param els2 [Array<Object>, PendingSet]
|
151
|
+
def self.merge(els1, els2)
|
152
|
+
if els1.is_a?(PendingSet)
|
153
|
+
els1.merge(els2)
|
154
|
+
else
|
155
|
+
PendingSet.new(els1).merge(els2)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
# @return [Set<Object>]
|
160
|
+
attr_reader :set
|
161
|
+
|
162
|
+
delegate %i(to_a each) => :set
|
163
|
+
|
164
|
+
# @param els [Array<Object>]
|
165
|
+
def initialize(els)
|
166
|
+
@set = Set.new(els)
|
167
|
+
end
|
168
|
+
|
169
|
+
# @param els [Array<Object>]
|
170
|
+
def merge(els)
|
171
|
+
set.merge(els)
|
172
|
+
self
|
173
|
+
end
|
174
|
+
end
|
91
175
|
end
|
92
176
|
end
|
93
177
|
end
|
@@ -1,20 +1,47 @@
|
|
1
1
|
module Yoda
|
2
2
|
module Store
|
3
3
|
module Objects
|
4
|
+
# @todo Rename to SingletonClassObject
|
4
5
|
class MetaClassObject < NamespaceObject
|
6
|
+
class Connected < NamespaceObject::Connected
|
7
|
+
delegate_to_object :base_class_address
|
8
|
+
|
9
|
+
# @return [NamespaceObject::Connected]
|
10
|
+
def superclass
|
11
|
+
ancestor_tree.superclass.with_connection(**connection_options)
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [Base::Connected, nil]
|
15
|
+
def instance
|
16
|
+
registry.get(path)&.with_connection(**connection_options)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
5
20
|
# @param path [String]
|
6
21
|
# @return [String]
|
7
22
|
def self.address_of(path)
|
8
23
|
"#{path}%class"
|
9
24
|
end
|
10
25
|
|
26
|
+
# @param address [String]
|
27
|
+
# @return [true, false]
|
28
|
+
def self.meta_class_address?(address)
|
29
|
+
address.end_with?('%class')
|
30
|
+
end
|
31
|
+
|
32
|
+
# @param address [String]
|
33
|
+
# @return [String]
|
34
|
+
def self.path_of(address)
|
35
|
+
address.sub(/%class$/, '')
|
36
|
+
end
|
37
|
+
|
11
38
|
# @param path [String]
|
12
39
|
# @param document [Document, nil]
|
13
40
|
# @param tag_list [TagList, nil]
|
14
41
|
# @param instance_method_paths [Array<String>]
|
15
42
|
# @param instance_mixin_paths [Array<String>]
|
16
43
|
def initialize(**kwargs)
|
17
|
-
super(kwargs)
|
44
|
+
super(**kwargs)
|
18
45
|
end
|
19
46
|
|
20
47
|
# @return [String]
|
@@ -2,6 +2,10 @@ module Yoda
|
|
2
2
|
module Store
|
3
3
|
module Objects
|
4
4
|
class MethodObject < Base
|
5
|
+
class Connected < Base::Connected
|
6
|
+
delegate_to_object :parameters, :visibility, :overloads, :sep, :namespace_path, :parent_address, :namespace_path
|
7
|
+
end
|
8
|
+
|
5
9
|
# @return [Array<(String, String)>]
|
6
10
|
attr_reader :parameters
|
7
11
|
|
@@ -12,38 +16,53 @@ module Yoda
|
|
12
16
|
attr_reader :overloads
|
13
17
|
|
14
18
|
class << self
|
19
|
+
METHOD_SEPARATOR_PATTERN = /[#.]|(::)/
|
20
|
+
|
15
21
|
# @param path [String]
|
16
22
|
# @return [String]
|
17
23
|
def namespace_of_path(path)
|
18
|
-
|
24
|
+
divide_by_separator(path)&.at(0)
|
19
25
|
end
|
20
26
|
|
21
27
|
# @param path [String]
|
22
28
|
# @return [String]
|
23
29
|
def name_of_path(path)
|
24
|
-
|
30
|
+
divide_by_separator(path)&.at(2)
|
25
31
|
end
|
26
32
|
|
27
33
|
# @param path [String]
|
28
|
-
# @return [String]
|
34
|
+
# @return [String, nil]
|
29
35
|
def sep_of_path(path)
|
30
|
-
|
36
|
+
divide_by_separator(path)&.at(1)
|
31
37
|
end
|
32
38
|
|
33
39
|
# @return [Array<Symbol>]
|
34
40
|
def attr_names
|
35
41
|
super + %i(parameters visibility overloads)
|
36
42
|
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
# @param path [String]
|
47
|
+
# @return [(String, String, String), nil]
|
48
|
+
def divide_by_separator(path)
|
49
|
+
rev_path = path.reverse
|
50
|
+
if match_data = rev_path.match(METHOD_SEPARATOR_PATTERN)
|
51
|
+
[match_data.post_match.reverse, match_data.to_s, match_data.pre_match.reverse]
|
52
|
+
else
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
end
|
37
56
|
end
|
38
57
|
|
39
58
|
# @param path [String]
|
40
59
|
# @param document [Document, nil]
|
41
|
-
# @param tag_list [
|
60
|
+
# @param tag_list [Array<Tag>, nil]
|
42
61
|
# @param visibility [Symbol]
|
43
62
|
# @param overloads [Array<Overload>]
|
44
63
|
# @param parameters [Array<(String, String)>, nil]
|
45
64
|
def initialize(parameters: [], visibility: :public, overloads: [], **kwargs)
|
46
|
-
super(kwargs)
|
65
|
+
super(**kwargs)
|
47
66
|
fail ArgumentError, visibility unless %i(public private protected)
|
48
67
|
@visibility = visibility.to_sym
|
49
68
|
@parameters = parameters
|
@@ -65,6 +84,20 @@ module Yoda
|
|
65
84
|
@namespace_path ||= MethodObject.namespace_of_path(path)
|
66
85
|
end
|
67
86
|
|
87
|
+
# @return [String]
|
88
|
+
def parent_address
|
89
|
+
@parent_address ||= begin
|
90
|
+
case MethodObject.sep_of_path(path)
|
91
|
+
when '#'
|
92
|
+
namespace_path
|
93
|
+
when '.', '::'
|
94
|
+
MetaClassObject.address_of(namespace_path)
|
95
|
+
else
|
96
|
+
fail TypeError
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
68
101
|
def kind
|
69
102
|
:method
|
70
103
|
end
|
@@ -3,6 +3,36 @@ module Yoda
|
|
3
3
|
module Objects
|
4
4
|
# @abstract
|
5
5
|
class NamespaceObject < Base
|
6
|
+
class Connected < Base::Connected
|
7
|
+
delegate_to_object :instance_method_addresses, :mixin_addresses, :constant_addresses, :ancestors, :methods
|
8
|
+
|
9
|
+
# @return [Enumerator<NamespaceObject::Connected>]
|
10
|
+
def ancestors
|
11
|
+
ancestor_tree.ancestors.map { |object| object.with_connection(**connection_options) }
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [Enumerator<NamespaceObject::Connected>]
|
15
|
+
def mixins
|
16
|
+
ancestor_tree.mixins.map { |object| object.with_connection(**connection_options) }
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [Query::MethodMemberSet]
|
20
|
+
def method_members
|
21
|
+
@method_members ||= Query::MethodMemberSet.new(registry: registry, object: object)
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [Query::ConstantMemberSet]
|
25
|
+
def constant_members
|
26
|
+
@constant_members ||= Query::ConstantMemberSet.new(registry: registry, object: object)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def ancestor_tree
|
32
|
+
@ancestor_tree ||= Query::AncestorTree.new(registry: registry, object: object)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
6
36
|
# @return [Array<String>]
|
7
37
|
attr_reader :instance_method_addresses
|
8
38
|
|
@@ -30,18 +60,20 @@ module Yoda
|
|
30
60
|
# @param constant_addresses [Array<String>]
|
31
61
|
# @param mixin_addresses [Array<String>]
|
32
62
|
def initialize(instance_method_addresses: [], mixin_addresses: [], constant_addresses: [], **kwargs)
|
33
|
-
super(kwargs)
|
63
|
+
super(**kwargs)
|
34
64
|
@instance_method_addresses = instance_method_addresses
|
35
65
|
@mixin_addresses = mixin_addresses
|
36
66
|
@constant_addresses = constant_addresses
|
37
67
|
@ancestors ||= []
|
38
68
|
end
|
39
69
|
|
70
|
+
# @note Override of {Base#name}
|
40
71
|
# @return [String]
|
41
72
|
def name
|
42
73
|
@name ||= path.match(MODULE_TAIL_PATTERN) { |md| md[1] || md[2] }
|
43
74
|
end
|
44
75
|
|
76
|
+
# @note Override of {Base#to_h}
|
45
77
|
def to_h
|
46
78
|
super.merge(
|
47
79
|
instance_method_addresses: instance_method_addresses,
|
@@ -50,6 +82,11 @@ module Yoda
|
|
50
82
|
)
|
51
83
|
end
|
52
84
|
|
85
|
+
# @note Override of {Base#namespace?}
|
86
|
+
def namespace?
|
87
|
+
true
|
88
|
+
end
|
89
|
+
|
53
90
|
private
|
54
91
|
|
55
92
|
# @param another [self]
|
@@ -9,7 +9,7 @@ module Yoda
|
|
9
9
|
|
10
10
|
# @param params [Hash]
|
11
11
|
def json_create(params)
|
12
|
-
new(params.map { |k, v| [k.to_sym, v] }.select { |(k, v)| %i(name tag_list document parameters).include?(k) }.to_h)
|
12
|
+
new(**params.map { |k, v| [k.to_sym, v] }.select { |(k, v)| %i(name tag_list document parameters).include?(k) }.to_h)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -9,19 +9,10 @@ module Yoda
|
|
9
9
|
attr_reader :registry
|
10
10
|
|
11
11
|
# @param id [String]
|
12
|
-
|
12
|
+
# @param [Array[Addressable], nil]
|
13
|
+
def initialize(id, contents = nil)
|
13
14
|
@id = id
|
14
|
-
@registry =
|
15
|
-
end
|
16
|
-
|
17
|
-
# @param addressable [Addressable]
|
18
|
-
# @return [void]
|
19
|
-
def register(addressable)
|
20
|
-
if el = @registry[addressable.address.to_sym]
|
21
|
-
@registry[addressable.address.to_sym] = el.merge(addressable)
|
22
|
-
else
|
23
|
-
@registry[addressable.address.to_sym] = addressable
|
24
|
-
end
|
15
|
+
@registry = (contents || []).map { |content| [content.address.to_sym, content] }.to_h
|
25
16
|
end
|
26
17
|
|
27
18
|
# @param address [String, Symbol]
|
@@ -29,6 +20,7 @@ module Yoda
|
|
29
20
|
def find(address)
|
30
21
|
@registry[address.to_sym]
|
31
22
|
end
|
23
|
+
alias get find
|
32
24
|
|
33
25
|
# @param address [String, Symbol]
|
34
26
|
# @return [true, false]
|
@@ -40,6 +32,58 @@ module Yoda
|
|
40
32
|
def keys
|
41
33
|
@registry.keys
|
42
34
|
end
|
35
|
+
|
36
|
+
# @param addressable [Addressable]
|
37
|
+
# @return [void]
|
38
|
+
def register(addressable)
|
39
|
+
parent_modifier.add_address_to_parent(addressable)
|
40
|
+
|
41
|
+
if el = @registry[addressable.address.to_sym]
|
42
|
+
@registry[addressable.address.to_sym] = el.merge(addressable)
|
43
|
+
else
|
44
|
+
@registry[addressable.address.to_sym] = addressable
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def parent_modifier
|
51
|
+
@parent_modifier ||= ParentModifier.new(self)
|
52
|
+
end
|
53
|
+
|
54
|
+
class ParentModifier
|
55
|
+
attr_reader :patch
|
56
|
+
|
57
|
+
# @param patch [Patch]
|
58
|
+
def initialize(patch)
|
59
|
+
@patch = patch
|
60
|
+
end
|
61
|
+
|
62
|
+
# @param code_object [Base]
|
63
|
+
# @return [void]
|
64
|
+
def add_address_to_parent(code_object)
|
65
|
+
parent_module = patch.find(code_object.parent_address) || create_parent_module(code_object)
|
66
|
+
return unless parent_module.namespace?
|
67
|
+
patch.register(parent_module) if !patch.has_key?(parent_module.address) && parent_module.address != code_object.address
|
68
|
+
|
69
|
+
case code_object.kind
|
70
|
+
when :method
|
71
|
+
parent_module.instance_method_addresses.push(code_object.address) unless parent_module.instance_method_addresses.include?(code_object.address)
|
72
|
+
when :class, :module, :value
|
73
|
+
parent_module.constant_addresses.push(code_object.address) unless parent_module.constant_addresses.include?(code_object.address)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def create_parent_module(code_object)
|
78
|
+
if code_object.address == code_object.parent_address
|
79
|
+
code_object
|
80
|
+
elsif MetaClassObject.meta_class_address?(code_object.parent_address)
|
81
|
+
MetaClassObject.new(path: MetaClassObject.path_of(code_object.parent_address))
|
82
|
+
else
|
83
|
+
ModuleObject.new(path: code_object.parent_address)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
43
87
|
end
|
44
88
|
end
|
45
89
|
end
|
@@ -1,78 +1,110 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
1
3
|
module Yoda
|
2
4
|
module Store
|
3
5
|
module Objects
|
4
6
|
# PatchSet manages patch updates and patch outdates.
|
5
7
|
# Besides, this class provides api to modify objects by using owning patches.
|
6
8
|
class PatchSet
|
7
|
-
|
8
|
-
|
9
|
+
class AddressIndex
|
10
|
+
def initialize
|
11
|
+
@index = Hash.new
|
12
|
+
end
|
9
13
|
|
10
|
-
|
11
|
-
|
14
|
+
# @param address [Symbol]
|
15
|
+
# @return [Set<Symbol>]
|
16
|
+
def get(address)
|
17
|
+
index[address] ||= Set.new
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [Set<Symbol>]
|
21
|
+
def keys
|
22
|
+
index.keys
|
23
|
+
end
|
24
|
+
|
25
|
+
# @param patch [Patch]
|
26
|
+
# @return [void]
|
27
|
+
def register(patch)
|
28
|
+
patch.keys.each do |key|
|
29
|
+
index[key.to_sym] ||= Set.new
|
30
|
+
index[key.to_sym].add(patch.id.to_sym)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# @param patch [Patch]
|
35
|
+
# @return [void]
|
36
|
+
def delete(patch)
|
37
|
+
patch.keys.each do |key|
|
38
|
+
(index[key.to_sym] || []).delete(patch.id.to_sym)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
# @return [{ Symbol => Array<Symbol> }]
|
44
|
+
attr_reader :index
|
45
|
+
end
|
12
46
|
|
13
47
|
def initialize
|
14
48
|
@patches = Hash.new
|
15
|
-
@address_index =
|
49
|
+
@address_index = AddressIndex.new
|
16
50
|
end
|
17
51
|
|
18
52
|
# @param patch [Patch]
|
19
53
|
# @return [void]
|
20
54
|
def register(patch)
|
21
|
-
|
55
|
+
address_index.register(patch)
|
22
56
|
patches[patch.id.to_sym] = patch
|
23
57
|
end
|
24
58
|
|
25
59
|
# @param id [String, Symbol]
|
26
60
|
def delete(id)
|
61
|
+
if patch = patches[id.to_sym]
|
62
|
+
address_index.delete(patch)
|
63
|
+
end
|
27
64
|
patches.delete(id.to_sym)
|
28
65
|
end
|
29
66
|
|
30
67
|
# @param object [Addressable]
|
31
68
|
# @return [Addressable]
|
32
69
|
def patch(object)
|
33
|
-
|
34
|
-
objects_in_patch = (address_index[object.address.to_sym] || []).map { |patch_id| patches[patch_id].find(object.address.to_sym) }
|
70
|
+
objects_in_patch = get_patches(object.address)
|
35
71
|
Merger.new([object, *objects_in_patch]).merged_instance
|
36
72
|
end
|
37
73
|
|
38
74
|
# @param address [String, Symbol]
|
39
75
|
# @return [Addressable, nil]
|
40
76
|
def find(address)
|
41
|
-
|
42
|
-
if (patch_ids = address_index[address.to_sym] || []).empty?
|
77
|
+
if (patches = get_patches(address)).empty?
|
43
78
|
nil
|
44
79
|
else
|
45
|
-
|
46
|
-
Merger.new(objects).merged_instance
|
80
|
+
Merger.new(patches).merged_instance
|
47
81
|
end
|
48
82
|
end
|
49
83
|
|
50
84
|
# @return [Array<Symbol>]
|
51
85
|
def keys
|
52
|
-
address_index.keys
|
86
|
+
address_index.keys.to_a
|
53
87
|
end
|
54
88
|
|
55
89
|
# @param address [String, Symbol]
|
56
90
|
# @return [true, false]
|
57
91
|
def has_key?(address)
|
58
|
-
|
59
|
-
address_index[address.to_sym] && !address_index[address.to_sym].empty?
|
92
|
+
!address_index.get(address.to_sym).empty?
|
60
93
|
end
|
61
94
|
|
62
95
|
private
|
63
96
|
|
64
|
-
# @
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
address_index[key.to_sym].push(patch.id.to_sym)
|
70
|
-
end
|
71
|
-
end
|
97
|
+
# @return [AddressIndex]
|
98
|
+
attr_reader :address_index
|
99
|
+
|
100
|
+
# @return [{ Symbol => Patch }]
|
101
|
+
attr_reader :patches
|
72
102
|
|
73
|
-
# @param address [Symbol]
|
74
|
-
|
75
|
-
|
103
|
+
# @param address [String, Symbol]
|
104
|
+
# @return [Array<Patch>]
|
105
|
+
def get_patches(address)
|
106
|
+
patch_ids = address_index.get(address.to_sym)
|
107
|
+
patch_ids.map { |id| patches[id].find(address.to_sym) }
|
76
108
|
end
|
77
109
|
end
|
78
110
|
end
|
@@ -9,7 +9,7 @@ module Yoda
|
|
9
9
|
|
10
10
|
# @param params [Hash]
|
11
11
|
def json_create(params)
|
12
|
-
new(params.reject { |k, _v| k.to_sym == :json_class }.map { |k, v| [k.to_sym, v] }.to_h)
|
12
|
+
new(**params.reject { |k, _v| k.to_sym == :json_class }.map { |k, v| [k.to_sym, v] }.to_h)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -31,7 +31,22 @@ module Yoda
|
|
31
31
|
# Create a new instance which has the original parameters and overrided parameters.
|
32
32
|
# @param params [Hash{Symbol => Object}] parameters to override
|
33
33
|
def derive(params = {})
|
34
|
-
self.class.new(to_h.merge(params))
|
34
|
+
self.class.new(**to_h.merge(params))
|
35
|
+
end
|
36
|
+
|
37
|
+
def eql?(another)
|
38
|
+
return object.eql?(another) if respond_to?(:object) && !object.respond_to?(:object)
|
39
|
+
return eql?(another.object) if another.respond_to?(:object) && !another.object.respond_to?(:object)
|
40
|
+
return false unless self.class.name == another.class.name
|
41
|
+
to_h.eql?(another.to_h)
|
42
|
+
end
|
43
|
+
|
44
|
+
def ==(another)
|
45
|
+
eql?(another)
|
46
|
+
end
|
47
|
+
|
48
|
+
def hash
|
49
|
+
to_h.hash
|
35
50
|
end
|
36
51
|
end
|
37
52
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Yoda
|
2
|
+
module Store
|
3
|
+
module Objects
|
4
|
+
class SerializableSet
|
5
|
+
include MissingDelegatable
|
6
|
+
include Serializable
|
7
|
+
|
8
|
+
delegate_missing :set
|
9
|
+
|
10
|
+
# @return [Set]
|
11
|
+
attr_reader :set
|
12
|
+
|
13
|
+
def initialize(els = nil, elements: nil)
|
14
|
+
@set = Set.new(els || elements)
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_h
|
18
|
+
{ elements: set.to_a }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -9,7 +9,7 @@ module Yoda
|
|
9
9
|
|
10
10
|
# @param params [Hash]
|
11
11
|
def json_create(params)
|
12
|
-
new(params.map { |k, v| [k.to_sym, v] }.select { |(k, v)| %i(tag_name name yard_types text lexical_scope).include?(k) }.to_h)
|
12
|
+
new(**params.map { |k, v| [k.to_sym, v] }.select { |(k, v)| %i(tag_name name yard_types text lexical_scope).include?(k) }.to_h)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|