yoda-language-server 0.7.2 → 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/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 +10 -1
- 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 +6 -5
- 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 +53 -10
- 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 +2 -83
- data/lib/yoda/store/query/associators/associate_methods.rb +2 -2
- data/lib/yoda/store/query/constant_member_set.rb +33 -0
- data/lib/yoda/store/query/find_constant.rb +22 -4
- data/lib/yoda/store/query/find_meta_class.rb +1 -1
- data/lib/yoda/store/query/find_method.rb +9 -2
- 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 → registry/cache.rb} +26 -1
- 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 -97
- 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 +13 -13
- data/lib/yoda/store.rb +15 -2
- 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 -111
- 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,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
|
|
@@ -15,21 +15,12 @@ module Yoda
|
|
15
15
|
@registry = (contents || []).map { |content| [content.address.to_sym, content] }.to_h
|
16
16
|
end
|
17
17
|
|
18
|
-
# @param addressable [Addressable]
|
19
|
-
# @return [void]
|
20
|
-
def register(addressable)
|
21
|
-
if el = @registry[addressable.address.to_sym]
|
22
|
-
@registry[addressable.address.to_sym] = el.merge(addressable)
|
23
|
-
else
|
24
|
-
@registry[addressable.address.to_sym] = addressable
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
18
|
# @param address [String, Symbol]
|
29
19
|
# @return [Addressable, nil]
|
30
20
|
def find(address)
|
31
21
|
@registry[address.to_sym]
|
32
22
|
end
|
23
|
+
alias get find
|
33
24
|
|
34
25
|
# @param address [String, Symbol]
|
35
26
|
# @return [true, false]
|
@@ -41,6 +32,58 @@ module Yoda
|
|
41
32
|
def keys
|
42
33
|
@registry.keys
|
43
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
|
44
87
|
end
|
45
88
|
end
|
46
89
|
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
|
|
@@ -2,6 +2,10 @@ module Yoda
|
|
2
2
|
module Store
|
3
3
|
module Objects
|
4
4
|
class ValueObject < Base
|
5
|
+
class Connected < Base::Connected
|
6
|
+
delegate_to_object :value
|
7
|
+
end
|
8
|
+
|
5
9
|
# @return [String]
|
6
10
|
attr_reader :value
|
7
11
|
|
@@ -13,7 +17,7 @@ module Yoda
|
|
13
17
|
# @param path [String]
|
14
18
|
# @param value [String]
|
15
19
|
def initialize(value: nil, **kwargs)
|
16
|
-
super(kwargs)
|
20
|
+
super(**kwargs)
|
17
21
|
@value = value
|
18
22
|
end
|
19
23
|
|
data/lib/yoda/store/objects.rb
CHANGED
@@ -8,6 +8,7 @@ module Yoda
|
|
8
8
|
require 'yoda/store/objects/addressable'
|
9
9
|
require 'yoda/store/objects/patchable'
|
10
10
|
require 'yoda/store/objects/base'
|
11
|
+
require 'yoda/store/objects/connected_delegation'
|
11
12
|
require 'yoda/store/objects/namespace_object'
|
12
13
|
require 'yoda/store/objects/class_object'
|
13
14
|
require 'yoda/store/objects/value_object'
|
@@ -19,7 +20,10 @@ module Yoda
|
|
19
20
|
require 'yoda/store/objects/patch'
|
20
21
|
require 'yoda/store/objects/patch_set'
|
21
22
|
require 'yoda/store/objects/tag'
|
22
|
-
require 'yoda/store/objects/
|
23
|
+
require 'yoda/store/objects/libraries_status'
|
24
|
+
require 'yoda/store/objects/library'
|
25
|
+
require 'yoda/store/objects/serializable_set'
|
26
|
+
require 'yoda/store/objects/map'
|
23
27
|
|
24
28
|
class << self
|
25
29
|
# @param hsh [Hash]
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
module Yoda
|
4
|
+
module Store
|
5
|
+
class Project
|
6
|
+
class Dependency
|
7
|
+
attr_reader :project
|
8
|
+
|
9
|
+
# @param project [Project]
|
10
|
+
def initialize(project)
|
11
|
+
@project = project
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [Array<Objects::Library::Gem>]
|
15
|
+
def gems
|
16
|
+
builder.gems
|
17
|
+
end
|
18
|
+
|
19
|
+
# @param name [String]
|
20
|
+
# @param version [String]
|
21
|
+
# @return [Library, nil]
|
22
|
+
def gem_dependency(name:, version:)
|
23
|
+
libraries.find { |library| library.name == name && library.version == version }
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [Objects::Library::Core]
|
27
|
+
def core
|
28
|
+
@core ||= Objects::Library.core
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [Objects::Library::Std]
|
32
|
+
def std
|
33
|
+
@std ||= Objects::Library.std
|
34
|
+
end
|
35
|
+
|
36
|
+
def builder
|
37
|
+
@builder ||= Builder.new(project)
|
38
|
+
end
|
39
|
+
|
40
|
+
class Builder
|
41
|
+
# @return [Project]
|
42
|
+
attr_reader :project
|
43
|
+
|
44
|
+
# @param project [Project]
|
45
|
+
def initialize(project)
|
46
|
+
@project = project
|
47
|
+
end
|
48
|
+
|
49
|
+
# @return [Array<Objects::Library::Gem>]
|
50
|
+
def gems
|
51
|
+
@gems ||= begin
|
52
|
+
dependencies
|
53
|
+
.map { |attrs| Objects::Library::Gem.new(**attrs) }
|
54
|
+
.reject { |spec| project.config.ignored_gems.include?(spec.name) }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
# @return [Array<Hash>]
|
61
|
+
def dependencies
|
62
|
+
analyzed_deps[:dependencies] || []
|
63
|
+
end
|
64
|
+
|
65
|
+
# @return [Hash]
|
66
|
+
def analyzed_deps
|
67
|
+
@analyzed_deps ||= begin
|
68
|
+
return {} unless project.root_path
|
69
|
+
|
70
|
+
# Bundler pollutes environment variables in the current process, so analyze in another process.
|
71
|
+
stdout, stderr, status = Open3.capture3(Yoda::Cli.yoda_exe, "analyze-deps", project.root_path)
|
72
|
+
|
73
|
+
fail stderr unless status.success?
|
74
|
+
|
75
|
+
Logger.trace("Analysis Result: #{stdout}")
|
76
|
+
JSON.parse(stdout, symbolize_names: true)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'tmpdir'
|
3
|
+
|
4
|
+
module Yoda
|
5
|
+
module Store
|
6
|
+
class Project
|
7
|
+
# Find registry file for the current project settings.
|
8
|
+
class FileFinder
|
9
|
+
# @return [Project]
|
10
|
+
attr_reader :project
|
11
|
+
|
12
|
+
# @param project [Project]
|
13
|
+
def initialize(project)
|
14
|
+
@project = project
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [true, false]
|
18
|
+
def present?
|
19
|
+
File.exist?(cache_path)
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [String, nil]
|
23
|
+
def yoda_dir_path
|
24
|
+
expand_path('.yoda')
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [String, nil]
|
28
|
+
def cache_dir_path
|
29
|
+
expand_path('.yoda/cache')
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [String, nil]
|
33
|
+
def library_registry_dir_path
|
34
|
+
expand_path(File.join('.yoda', 'library_registry'))
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [String, nil]
|
38
|
+
def library_local_yardoc_dir_path
|
39
|
+
expand_path(File.join('.yoda', 'yardoc', RUBY_VERSION))
|
40
|
+
end
|
41
|
+
|
42
|
+
# @return [String, nil]
|
43
|
+
def gemfile_lock_path
|
44
|
+
expand_path('Gemfile.lock')
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [String, nil]
|
48
|
+
def config_file_path
|
49
|
+
expand_path('.yoda.yml')
|
50
|
+
end
|
51
|
+
|
52
|
+
# @return [String, nil]
|
53
|
+
def readable_config_file_path
|
54
|
+
path = config_file_path
|
55
|
+
path && File.readable?(config_file_path) ? path : nil
|
56
|
+
end
|
57
|
+
|
58
|
+
# @param name [String]
|
59
|
+
# @param version [String]
|
60
|
+
# @return [String, nil]
|
61
|
+
def library_local_yardoc_path(name:, version:)
|
62
|
+
expand_path("#{name}-#{version}.yardoc", library_local_yardoc_dir_path)
|
63
|
+
end
|
64
|
+
|
65
|
+
# @param name [String]
|
66
|
+
# @param version [String]
|
67
|
+
# @return [String, nil]
|
68
|
+
def library_registry_path(name:, version:)
|
69
|
+
expand_path(Registry.registry_name, library_registry_dir_path)
|
70
|
+
end
|
71
|
+
|
72
|
+
# @return [String, nil]
|
73
|
+
def project_registry_path
|
74
|
+
expand_path(Registry.registry_name, cache_dir_path)
|
75
|
+
end
|
76
|
+
|
77
|
+
def make_dir
|
78
|
+
make_dir_at(cache_dir_path)
|
79
|
+
make_dir_at(library_local_yardoc_dir_path)
|
80
|
+
make_dir_at(library_registry_dir_path)
|
81
|
+
end
|
82
|
+
|
83
|
+
def clear_dir
|
84
|
+
yoda_dir_path && File.exist?(yoda_dir_path) && FileUtils.rm_rf(yoda_dir_path)
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def expand_path(relative_path, base_path = project.root_path)
|
90
|
+
return nil unless base_path
|
91
|
+
File.expand_path(relative_path, base_path)
|
92
|
+
end
|
93
|
+
|
94
|
+
# @param dir_path [String]
|
95
|
+
def make_dir_at(dir_path)
|
96
|
+
dir_path && (File.exist?(dir_path) || FileUtils.mkdir_p(dir_path))
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rbs'
|
2
|
+
|
3
|
+
module Yoda
|
4
|
+
module Store
|
5
|
+
class Project
|
6
|
+
# Find registry file for the current project settings.
|
7
|
+
class RbsLoader
|
8
|
+
# @return [Project]
|
9
|
+
attr_reader :project
|
10
|
+
|
11
|
+
# @param project [Project]
|
12
|
+
def initialize(project)
|
13
|
+
@project = project
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [RBS::Environment]
|
17
|
+
def rbs_environment
|
18
|
+
@rbs_environment ||= begin
|
19
|
+
repository = RBS::Repository.new
|
20
|
+
project.config.rbs_repository_paths.each do |repo_path|
|
21
|
+
pathname = Pathname(repo_path).expand_path(project.root_path)
|
22
|
+
repository.add(pathname)
|
23
|
+
end
|
24
|
+
|
25
|
+
loader = RBS::EnvironmentLoader.new(repository: repository)
|
26
|
+
project.config.rbs_signature_paths.each do |sig_path|
|
27
|
+
pathname = Pathname(sig_path).expand_path(project.root_path)
|
28
|
+
loader.add(path: pathname)
|
29
|
+
end
|
30
|
+
|
31
|
+
project.config.rbs_libraries.each do |library|
|
32
|
+
loader.add(library: library)
|
33
|
+
end
|
34
|
+
|
35
|
+
RBS::Environment.from_loader(loader).resolve_type_names
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|