yoda-language-server 0.7.2 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (405) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +23 -0
  3. data/.gitignore +1 -1
  4. data/.rspec +1 -0
  5. data/CHANGELOG.md +14 -0
  6. data/Gemfile +2 -0
  7. data/README.md +23 -11
  8. data/Rakefile +32 -0
  9. data/bin/bench +12 -0
  10. data/bin/local +7 -0
  11. data/client/atom/.gitignore +1 -0
  12. data/{package.json → client/atom/package.json} +1 -1
  13. data/{yarn.lock → client/atom/yarn.lock} +0 -0
  14. data/client/vscode/.gitignore +1 -1
  15. data/client/vscode/.vscode/launch.json +0 -11
  16. data/client/vscode/.vscode/settings.json +5 -1
  17. data/client/vscode/LICENSE.txt +21 -0
  18. data/client/vscode/README.md +4 -55
  19. data/client/vscode/package-lock.json +4299 -1373
  20. data/client/vscode/package.json +40 -15
  21. data/client/vscode/src/check-versions.ts +49 -0
  22. data/client/vscode/src/config.ts +20 -0
  23. data/client/vscode/src/extension.ts +12 -27
  24. data/client/vscode/src/install-tools.ts +109 -0
  25. data/client/vscode/src/language-server.ts +59 -0
  26. data/client/vscode/src/status.ts +3 -0
  27. data/client/vscode/src/test/runTest.ts +30 -0
  28. data/client/vscode/src/test/{completion.test.ts → suite/completion.test.ts} +2 -1
  29. data/client/vscode/src/test/suite/hover.test.ts +31 -0
  30. data/client/vscode/src/test/suite/index.ts +26 -0
  31. data/client/vscode/src/utils.ts +11 -0
  32. data/client/vscode/tsconfig.json +4 -1
  33. data/exe/yoda +1 -1
  34. data/lib/yoda/ast/array_node.rb +10 -0
  35. data/lib/yoda/ast/assignment_node.rb +15 -0
  36. data/lib/yoda/ast/block_call_node.rb +20 -0
  37. data/lib/yoda/ast/block_node.rb +10 -0
  38. data/lib/yoda/ast/case_node.rb +20 -0
  39. data/lib/yoda/ast/center_operator_node.rb +20 -0
  40. data/lib/yoda/ast/class_node.rb +22 -0
  41. data/lib/yoda/ast/comment_block/base_part.rb +12 -0
  42. data/lib/yoda/ast/comment_block/range_calculation.rb +58 -0
  43. data/lib/yoda/ast/comment_block/tag_part.rb +88 -0
  44. data/lib/yoda/ast/comment_block/tag_text_name_part.rb +35 -0
  45. data/lib/yoda/ast/comment_block/tag_text_type_part.rb +52 -0
  46. data/lib/yoda/ast/comment_block/text_part.rb +28 -0
  47. data/lib/yoda/ast/comment_block/token.rb +44 -0
  48. data/lib/yoda/ast/comment_block.rb +119 -0
  49. data/lib/yoda/ast/conditional_loop_node.rb +15 -0
  50. data/lib/yoda/ast/constant_assignment_node.rb +20 -0
  51. data/lib/yoda/ast/constant_base_node.rb +42 -0
  52. data/lib/yoda/ast/constant_node.rb +53 -0
  53. data/lib/yoda/ast/def_node.rb +27 -0
  54. data/lib/yoda/ast/def_singleton_node.rb +32 -0
  55. data/lib/yoda/ast/empty_vnode.rb +24 -0
  56. data/lib/yoda/ast/ensure_node.rb +15 -0
  57. data/lib/yoda/ast/for_node.rb +20 -0
  58. data/lib/yoda/ast/hash_node.rb +10 -0
  59. data/lib/yoda/ast/if_node.rb +20 -0
  60. data/lib/yoda/ast/interpolation_text_node.rb +10 -0
  61. data/lib/yoda/ast/kwsplat_node.rb +10 -0
  62. data/lib/yoda/ast/left_operator_node.rb +15 -0
  63. data/lib/yoda/ast/literal_node.rb +18 -0
  64. data/lib/yoda/ast/method_traversable.rb +22 -0
  65. data/lib/yoda/ast/module_node.rb +17 -0
  66. data/lib/yoda/ast/multiple_left_hand_side_node.rb +31 -0
  67. data/lib/yoda/ast/name_vnode.rb +28 -0
  68. data/lib/yoda/ast/namespace.rb +36 -0
  69. data/lib/yoda/ast/namespace_traversable.rb +39 -0
  70. data/lib/yoda/ast/node.rb +52 -0
  71. data/lib/yoda/ast/optional_parameter_node.rb +20 -0
  72. data/lib/yoda/ast/pair_node.rb +15 -0
  73. data/lib/yoda/ast/parameter_node.rb +25 -0
  74. data/lib/yoda/ast/parameters_node.rb +62 -0
  75. data/lib/yoda/ast/rescue_clause_node.rb +20 -0
  76. data/lib/yoda/ast/rescue_node.rb +20 -0
  77. data/lib/yoda/ast/root_vnode.rb +48 -0
  78. data/lib/yoda/ast/send_node.rb +100 -0
  79. data/lib/yoda/ast/singleton_class_node.rb +17 -0
  80. data/lib/yoda/ast/special_call_node.rb +10 -0
  81. data/lib/yoda/ast/traversable.rb +34 -0
  82. data/lib/yoda/ast/value_vnode.rb +28 -0
  83. data/lib/yoda/ast/variable_node.rb +15 -0
  84. data/lib/yoda/ast/vnode.rb +170 -0
  85. data/lib/yoda/ast/when_node.rb +15 -0
  86. data/lib/yoda/ast.rb +140 -0
  87. data/lib/yoda/cli/analyze_deps.rb +123 -0
  88. data/lib/yoda/{commands → cli}/base.rb +1 -1
  89. data/lib/yoda/{commands → cli}/complete.rb +12 -9
  90. data/lib/yoda/cli/console.rb +17 -0
  91. data/lib/yoda/{commands → cli}/file_cursor_parsable.rb +1 -1
  92. data/lib/yoda/{commands → cli}/infer.rb +4 -4
  93. data/lib/yoda/cli.rb +117 -0
  94. data/lib/yoda/has_services.rb +40 -0
  95. data/lib/yoda/id_mask.rb +84 -0
  96. data/lib/yoda/instrument.rb +21 -5
  97. data/lib/yoda/logger.rb +4 -2
  98. data/lib/yoda/missing_delegatable.rb +34 -0
  99. data/lib/yoda/model/completion_item.rb +43 -11
  100. data/lib/yoda/model/descriptions/base.rb +11 -0
  101. data/lib/yoda/model/descriptions/comment_token_description.rb +46 -0
  102. data/lib/yoda/model/descriptions/function_description.rb +19 -2
  103. data/lib/yoda/model/descriptions/node_description.rb +19 -8
  104. data/lib/yoda/model/descriptions/require_path_description.rb +45 -0
  105. data/lib/yoda/model/descriptions/variable_description.rb +41 -0
  106. data/lib/yoda/model/descriptions.rb +3 -0
  107. data/lib/yoda/model/environment/accessor_interface.rb +43 -0
  108. data/lib/yoda/model/environment/instance_accessor.rb +121 -0
  109. data/lib/yoda/model/environment/namespace_members.rb +104 -0
  110. data/lib/yoda/model/environment/singleton_accessor.rb +66 -0
  111. data/lib/yoda/model/environment/value_factory.rb +151 -0
  112. data/lib/yoda/model/environment/value_resolve_context.rb +62 -0
  113. data/lib/yoda/model/environment/with_cache.rb +14 -0
  114. data/lib/yoda/model/environment.rb +122 -0
  115. data/lib/yoda/model/function_signatures/base.rb +22 -2
  116. data/lib/yoda/model/function_signatures/constructor.rb +17 -1
  117. data/lib/yoda/model/function_signatures/method.rb +18 -2
  118. data/lib/yoda/model/function_signatures/overload.rb +17 -1
  119. data/lib/yoda/model/function_signatures/parameter_list.rb +17 -0
  120. data/lib/yoda/model/function_signatures/rbs_method.rb +91 -0
  121. data/lib/yoda/model/function_signatures/type_builder.rb +63 -31
  122. data/lib/yoda/model/function_signatures/wrapper.rb +46 -0
  123. data/lib/yoda/model/function_signatures.rb +2 -0
  124. data/lib/yoda/model/lexical_context.rb +40 -0
  125. data/lib/yoda/model/node_signatures/base.rb +42 -0
  126. data/lib/yoda/model/node_signatures/const.rb +20 -0
  127. data/lib/yoda/model/node_signatures/method_definition.rb +20 -0
  128. data/lib/yoda/model/node_signatures/node.rb +19 -0
  129. data/lib/yoda/model/node_signatures/send.rb +20 -0
  130. data/lib/yoda/model/node_signatures.rb +35 -0
  131. data/lib/yoda/model/parameters/base.rb +14 -0
  132. data/lib/yoda/model/parameters/binder.rb +148 -0
  133. data/lib/yoda/model/parameters/multiple.rb +36 -0
  134. data/lib/yoda/model/parameters/named.rb +20 -0
  135. data/lib/yoda/model/parameters/unnamed.rb +12 -0
  136. data/lib/yoda/model/parameters.rb +11 -0
  137. data/lib/yoda/model/path.rb +16 -0
  138. data/lib/yoda/model/primary_source_inferencer.rb +34 -0
  139. data/lib/yoda/model/scoped_path.rb +13 -2
  140. data/lib/yoda/model/{types → type_expressions}/any_type.rb +7 -3
  141. data/lib/yoda/model/{types → type_expressions}/base.rb +10 -3
  142. data/lib/yoda/model/{types → type_expressions}/duck_type.rb +8 -2
  143. data/lib/yoda/model/type_expressions/function_type/parameter.rb +95 -0
  144. data/lib/yoda/model/{types → type_expressions}/function_type.rb +61 -70
  145. data/lib/yoda/model/type_expressions/generator.rb +28 -0
  146. data/lib/yoda/model/{types → type_expressions}/generic_type.rb +17 -2
  147. data/lib/yoda/model/{types → type_expressions}/instance_type.rb +10 -2
  148. data/lib/yoda/model/{types → type_expressions}/module_type.rb +7 -1
  149. data/lib/yoda/model/type_expressions/self_type.rb +38 -0
  150. data/lib/yoda/model/{types → type_expressions}/sequence_type.rb +6 -1
  151. data/lib/yoda/model/{types → type_expressions}/union_type.rb +7 -3
  152. data/lib/yoda/model/{types → type_expressions}/unknown_type.rb +6 -1
  153. data/lib/yoda/model/{types → type_expressions}/value_type.rb +17 -1
  154. data/lib/yoda/model/type_expressions/void_type.rb +37 -0
  155. data/lib/yoda/model/type_expressions.rb +40 -0
  156. data/lib/yoda/model/values/base.rb +23 -8
  157. data/lib/yoda/model/values/empty_value.rb +39 -0
  158. data/lib/yoda/model/values/instance_value.rb +24 -43
  159. data/lib/yoda/model/values/intersection_value.rb +48 -0
  160. data/lib/yoda/model/values/literal_value.rb +26 -0
  161. data/lib/yoda/model/values/union_value.rb +50 -0
  162. data/lib/yoda/model/values.rb +5 -1
  163. data/lib/yoda/model/yard_type_parser.rb +35 -0
  164. data/lib/yoda/model.rb +7 -2
  165. data/lib/yoda/parsing/comment_tokenizer.rb +21 -4
  166. data/lib/yoda/parsing/location.rb +9 -0
  167. data/lib/yoda/parsing/node_objects/args_node.rb +85 -0
  168. data/lib/yoda/parsing/node_objects/const_node.rb +3 -3
  169. data/lib/yoda/parsing/node_objects/mlhs_node.rb +31 -0
  170. data/lib/yoda/parsing/node_objects.rb +2 -0
  171. data/lib/yoda/parsing/parser.rb +44 -5
  172. data/lib/yoda/parsing/query/current_comment_token_query.rb +4 -3
  173. data/lib/yoda/parsing/query/current_commenting_node_query.rb +7 -7
  174. data/lib/yoda/parsing/scopes/base.rb +1 -1
  175. data/lib/yoda/parsing/scopes/builder.rb +1 -1
  176. data/lib/yoda/parsing/source_cutter.rb +6 -2
  177. data/lib/yoda/parsing/traverser/matcher.rb +65 -0
  178. data/lib/yoda/parsing/traverser/query_interface.rb +68 -0
  179. data/lib/yoda/parsing/traverser/result_set.rb +37 -0
  180. data/lib/yoda/parsing/traverser.rb +29 -0
  181. data/lib/yoda/parsing/type_parser.rb +24 -20
  182. data/lib/yoda/parsing.rb +27 -1
  183. data/lib/yoda/presentation/code_completion/constant.rb +27 -0
  184. data/lib/yoda/server/concurrent_writer.rb +1 -1
  185. data/lib/yoda/server/lifecycle_handler.rb +125 -25
  186. data/lib/yoda/server/notifier.rb +79 -1
  187. data/lib/yoda/server/providers/completion.rb +31 -17
  188. data/lib/yoda/server/providers/definition.rb +38 -10
  189. data/lib/yoda/server/providers/hover.rb +26 -10
  190. data/lib/yoda/server/providers/reportable_progress.rb +75 -0
  191. data/lib/yoda/server/providers/signature.rb +20 -7
  192. data/lib/yoda/server/providers/text_document_did_change.rb +1 -1
  193. data/lib/yoda/server/providers/text_document_did_open.rb +1 -1
  194. data/lib/yoda/server/providers/with_timeout.rb +36 -0
  195. data/lib/yoda/server/providers/workspace_did_change_workspace_folders.rb +33 -0
  196. data/lib/yoda/server/providers/workspace_did_create_files.rb +21 -0
  197. data/lib/yoda/server/providers/workspace_did_delete_files.rb +21 -0
  198. data/lib/yoda/server/providers/workspace_did_rename_files.rb +22 -0
  199. data/lib/yoda/server/providers/workspace_symbol.rb +82 -0
  200. data/lib/yoda/server/providers.rb +12 -0
  201. data/lib/yoda/server/root_handler.rb +27 -23
  202. data/lib/yoda/server/rootless_workspace.rb +62 -0
  203. data/lib/yoda/server/scheduler.rb +50 -0
  204. data/lib/yoda/server/session.rb +71 -25
  205. data/lib/yoda/server/uri_decoder.rb +16 -0
  206. data/lib/yoda/server/workspace.rb +117 -0
  207. data/lib/yoda/server.rb +9 -2
  208. data/lib/yoda/services/code_completion/base_provider.rb +52 -0
  209. data/lib/yoda/{evaluation → services}/code_completion/const_provider.rb +35 -25
  210. data/lib/yoda/services/code_completion/keyword_provider.rb +67 -0
  211. data/lib/yoda/services/code_completion/local_variable_provider.rb +51 -0
  212. data/lib/yoda/{evaluation → services}/code_completion/method_provider.rb +14 -32
  213. data/lib/yoda/services/code_completion.rb +74 -0
  214. data/lib/yoda/{evaluation → services}/comment_completion/base_provider.rb +11 -6
  215. data/lib/yoda/{evaluation → services}/comment_completion/param_provider.rb +1 -1
  216. data/lib/yoda/{evaluation → services}/comment_completion/tag_provider.rb +1 -1
  217. data/lib/yoda/{evaluation → services}/comment_completion/type_provider.rb +6 -5
  218. data/lib/yoda/{evaluation → services}/comment_completion.rb +13 -13
  219. data/lib/yoda/services/current_node_explain/comment_signature.rb +77 -0
  220. data/lib/yoda/services/current_node_explain.rb +72 -0
  221. data/lib/yoda/services/evaluator.rb +44 -0
  222. data/lib/yoda/services/loadable_path_resolver.rb +33 -0
  223. data/lib/yoda/services/signature_discovery.rb +74 -0
  224. data/lib/yoda/services.rb +10 -0
  225. data/lib/yoda/store/actions/build_core_index.rb +38 -9
  226. data/lib/yoda/store/actions/import_core_library.rb +14 -19
  227. data/lib/yoda/store/actions/import_gem.rb +65 -33
  228. data/lib/yoda/store/actions/import_project_dependencies.rb +47 -0
  229. data/lib/yoda/store/actions/import_std_library.rb +13 -18
  230. data/lib/yoda/store/actions/read_file.rb +21 -6
  231. data/lib/yoda/store/actions/read_project_files.rb +13 -5
  232. data/lib/yoda/store/actions.rb +1 -0
  233. data/lib/yoda/store/adapters/base.rb +39 -0
  234. data/lib/yoda/store/adapters/gdbm_adapter/namespace_accessor.rb +152 -0
  235. data/lib/yoda/store/adapters/gdbm_adapter.rb +56 -0
  236. data/lib/yoda/store/adapters/lazy_adapter.rb +34 -0
  237. data/lib/yoda/store/adapters/memory_adapter.rb +22 -1
  238. data/lib/yoda/store/adapters.rb +12 -4
  239. data/lib/yoda/store/config.rb +43 -0
  240. data/lib/yoda/store/file_tree.rb +131 -0
  241. data/lib/yoda/store/objects/base.rb +73 -4
  242. data/lib/yoda/store/objects/class_object.rb +10 -1
  243. data/lib/yoda/store/objects/connected_delegation.rb +25 -0
  244. data/lib/yoda/store/objects/libraries_status.rb +67 -0
  245. data/lib/yoda/store/objects/library/core.rb +80 -0
  246. data/lib/yoda/store/objects/library/gem.rb +152 -0
  247. data/lib/yoda/store/objects/library/path_resolvable.rb +29 -0
  248. data/lib/yoda/store/objects/library/std.rb +81 -0
  249. data/lib/yoda/store/objects/library/with_registry.rb +28 -0
  250. data/lib/yoda/store/objects/library.rb +25 -0
  251. data/lib/yoda/store/objects/map.rb +61 -0
  252. data/lib/yoda/store/objects/merger.rb +6 -5
  253. data/lib/yoda/store/objects/meta_class_object.rb +28 -1
  254. data/lib/yoda/store/objects/method_object.rb +39 -6
  255. data/lib/yoda/store/objects/module_object.rb +3 -0
  256. data/lib/yoda/store/objects/namespace_object.rb +38 -1
  257. data/lib/yoda/store/objects/overload.rb +1 -1
  258. data/lib/yoda/store/objects/patch.rb +54 -11
  259. data/lib/yoda/store/objects/patch_set.rb +2 -2
  260. data/lib/yoda/store/objects/serializable.rb +17 -2
  261. data/lib/yoda/store/objects/serializable_set.rb +23 -0
  262. data/lib/yoda/store/objects/tag.rb +1 -1
  263. data/lib/yoda/store/objects/value_object.rb +5 -1
  264. data/lib/yoda/store/objects.rb +5 -1
  265. data/lib/yoda/store/project/dependency.rb +101 -0
  266. data/lib/yoda/store/project/file_finder.rb +121 -0
  267. data/lib/yoda/store/project/rbs_loader.rb +41 -0
  268. data/lib/yoda/store/project/setuper.rb +68 -0
  269. data/lib/yoda/store/project.rb +101 -41
  270. data/lib/yoda/store/query/ancestor_tree.rb +126 -0
  271. data/lib/yoda/store/query/associators/associate_ancestors.rb +2 -83
  272. data/lib/yoda/store/query/associators/associate_methods.rb +2 -2
  273. data/lib/yoda/store/query/constant_member_set.rb +33 -0
  274. data/lib/yoda/store/query/find_constant.rb +22 -4
  275. data/lib/yoda/store/query/find_meta_class.rb +1 -1
  276. data/lib/yoda/store/query/find_method.rb +9 -2
  277. data/lib/yoda/store/query/find_signature.rb +11 -3
  278. data/lib/yoda/store/query/find_workspace_objects.rb +36 -0
  279. data/lib/yoda/store/query/method_member_set.rb +50 -0
  280. data/lib/yoda/store/query.rb +4 -0
  281. data/lib/yoda/store/{registry_cache.rb → registry/cache.rb} +26 -1
  282. data/lib/yoda/store/registry/composer.rb +49 -0
  283. data/lib/yoda/store/registry/index.rb +120 -0
  284. data/lib/yoda/store/registry/library_registry.rb +71 -0
  285. data/lib/yoda/store/registry/library_registry_set.rb +133 -0
  286. data/lib/yoda/store/registry/local_store.rb +38 -0
  287. data/lib/yoda/store/registry/project_registry.rb +72 -0
  288. data/lib/yoda/store/registry.rb +25 -97
  289. data/lib/yoda/store/transformers/core_visibility.rb +61 -0
  290. data/lib/yoda/store/transformers.rb +7 -0
  291. data/lib/yoda/store/version_store.rb +71 -0
  292. data/lib/yoda/store/yard_importer.rb +13 -13
  293. data/lib/yoda/store.rb +15 -2
  294. data/lib/yoda/typing/constant_resolver/cbase_query.rb +14 -0
  295. data/lib/yoda/typing/constant_resolver/code_query.rb +25 -0
  296. data/lib/yoda/typing/constant_resolver/member_query.rb +27 -0
  297. data/lib/yoda/typing/constant_resolver/node_tracer.rb +36 -0
  298. data/lib/yoda/typing/constant_resolver/query.rb +70 -0
  299. data/lib/yoda/typing/constant_resolver/relative_base_query.rb +14 -0
  300. data/lib/yoda/typing/constant_resolver.rb +110 -0
  301. data/lib/yoda/typing/contexts/base_context.rb +83 -0
  302. data/lib/yoda/typing/contexts/block_context.rb +14 -0
  303. data/lib/yoda/typing/contexts/context_derivation.rb +59 -0
  304. data/lib/yoda/typing/contexts/method_context.rb +14 -0
  305. data/lib/yoda/typing/contexts/namespace_block_context.rb +29 -0
  306. data/lib/yoda/typing/contexts/namespace_context.rb +14 -0
  307. data/lib/yoda/typing/contexts.rb +25 -0
  308. data/lib/yoda/typing/environment.rb +1 -1
  309. data/lib/yoda/typing/inferencer/arguments.rb +38 -0
  310. data/lib/yoda/typing/inferencer/arguments_binder.rb +24 -0
  311. data/lib/yoda/typing/inferencer/load_resolver.rb +37 -0
  312. data/lib/yoda/typing/inferencer/method_resolver.rb +81 -0
  313. data/lib/yoda/typing/inferencer/object_resolver.rb +55 -0
  314. data/lib/yoda/typing/inferencer/parameter_binder.rb +176 -0
  315. data/lib/yoda/typing/inferencer/tracer.rb +209 -0
  316. data/lib/yoda/typing/inferencer/type_binding.rb +46 -0
  317. data/lib/yoda/typing/inferencer.rb +53 -0
  318. data/lib/yoda/typing/node_info.rb +83 -0
  319. data/lib/yoda/typing/relation.rb +2 -2
  320. data/lib/yoda/typing/traces/base.rb +2 -2
  321. data/lib/yoda/typing/traces/normal.rb +3 -3
  322. data/lib/yoda/typing/traces/send.rb +4 -4
  323. data/lib/yoda/typing/tree/ask_defined.rb +12 -0
  324. data/lib/yoda/typing/tree/base.rb +91 -0
  325. data/lib/yoda/typing/tree/begin.rb +15 -0
  326. data/lib/yoda/typing/tree/block_call.rb +26 -0
  327. data/lib/yoda/typing/tree/case.rb +18 -0
  328. data/lib/yoda/typing/tree/class_tree.rb +23 -0
  329. data/lib/yoda/typing/tree/conditional_loop.rb +15 -0
  330. data/lib/yoda/typing/tree/constant.rb +19 -0
  331. data/lib/yoda/typing/tree/constant_assignment.rb +12 -0
  332. data/lib/yoda/typing/tree/ensure.rb +17 -0
  333. data/lib/yoda/typing/tree/for.rb +15 -0
  334. data/lib/yoda/typing/tree/hash_tree.rb +32 -0
  335. data/lib/yoda/typing/tree/if.rb +22 -0
  336. data/lib/yoda/typing/tree/interpolation_text.rb +21 -0
  337. data/lib/yoda/typing/tree/literal.rb +18 -0
  338. data/lib/yoda/typing/tree/literal_inferable.rb +48 -0
  339. data/lib/yoda/typing/tree/local_exit.rb +15 -0
  340. data/lib/yoda/typing/tree/logical_assignment.rb +16 -0
  341. data/lib/yoda/typing/tree/logical_operator.rb +16 -0
  342. data/lib/yoda/typing/tree/method_def.rb +41 -0
  343. data/lib/yoda/typing/tree/method_inferable.rb +51 -0
  344. data/lib/yoda/typing/tree/module_tree.rb +18 -0
  345. data/lib/yoda/typing/tree/multiple_assignment.rb +16 -0
  346. data/lib/yoda/typing/tree/namespace_inferable.rb +20 -0
  347. data/lib/yoda/typing/tree/rescue.rb +18 -0
  348. data/lib/yoda/typing/tree/rescue_clause.rb +42 -0
  349. data/lib/yoda/typing/tree/self.rb +12 -0
  350. data/lib/yoda/typing/tree/send.rb +19 -0
  351. data/lib/yoda/typing/tree/send_inferable.rb +89 -0
  352. data/lib/yoda/typing/tree/singleton_class_tree.rb +24 -0
  353. data/lib/yoda/typing/tree/singleton_method_def.rb +41 -0
  354. data/lib/yoda/typing/tree/super.rb +19 -0
  355. data/lib/yoda/typing/tree/variable.rb +15 -0
  356. data/lib/yoda/typing/tree/variable_assignment.rb +23 -0
  357. data/lib/yoda/typing/tree/yield.rb +19 -0
  358. data/lib/yoda/typing/tree.rb +129 -0
  359. data/lib/yoda/typing/types/any.rb +15 -0
  360. data/lib/yoda/typing/types/associative_array.rb +28 -0
  361. data/lib/yoda/typing/types/base.rb +25 -0
  362. data/lib/yoda/typing/types/converter.rb +67 -0
  363. data/lib/yoda/typing/types/function.rb +68 -0
  364. data/lib/yoda/typing/types/generator.rb +306 -0
  365. data/lib/yoda/typing/types/generic.rb +29 -0
  366. data/lib/yoda/typing/types/instance.rb +30 -0
  367. data/lib/yoda/typing/types/instance_type.rb +74 -0
  368. data/lib/yoda/typing/types/method.rb +39 -0
  369. data/lib/yoda/typing/types/rbs_type_wrapper_interface.rb +44 -0
  370. data/lib/yoda/typing/types/singleton_type.rb +75 -0
  371. data/lib/yoda/typing/types/tuple.rb +24 -0
  372. data/lib/yoda/typing/types/type.rb +60 -0
  373. data/lib/yoda/typing/types/union.rb +38 -0
  374. data/lib/yoda/typing/types/var.rb +38 -0
  375. data/lib/yoda/typing/types.rb +24 -0
  376. data/lib/yoda/typing.rb +6 -2
  377. data/lib/yoda/version.rb +1 -1
  378. data/lib/yoda.rb +7 -2
  379. data/scripts/benchmark.rb +1 -1
  380. data/yoda-language-server.gemspec +16 -15
  381. metadata +349 -111
  382. data/.travis.yml +0 -8
  383. data/client/vscode/src/test/index.ts +0 -24
  384. data/lib/yoda/commands/setup.rb +0 -51
  385. data/lib/yoda/commands.rb +0 -69
  386. data/lib/yoda/evaluation/code_completion/base_provider.rb +0 -57
  387. data/lib/yoda/evaluation/code_completion/variable_provider.rb +0 -18
  388. data/lib/yoda/evaluation/code_completion.rb +0 -65
  389. data/lib/yoda/evaluation/current_node_explain.rb +0 -71
  390. data/lib/yoda/evaluation/evaluator.rb +0 -105
  391. data/lib/yoda/evaluation/signature_discovery.rb +0 -85
  392. data/lib/yoda/evaluation.rb +0 -9
  393. data/lib/yoda/model/node_signature.rb +0 -43
  394. data/lib/yoda/model/types.rb +0 -84
  395. data/lib/yoda/model/values/module_value.rb +0 -72
  396. data/lib/yoda/parsing/source_analyzer.rb +0 -59
  397. data/lib/yoda/server/file_store.rb +0 -57
  398. data/lib/yoda/store/adapters/leveldb_adapter.rb +0 -80
  399. data/lib/yoda/store/adapters/lmdb_adapter.rb +0 -113
  400. data/lib/yoda/store/objects/project_status.rb +0 -169
  401. data/lib/yoda/store/project/cache.rb +0 -78
  402. data/lib/yoda/store/project/library_doc_loader.rb +0 -114
  403. data/lib/yoda/typing/context.rb +0 -96
  404. data/lib/yoda/typing/evaluator.rb +0 -259
  405. data/scripts/build_core_index.sh +0 -16
@@ -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
- path.slice(0, (path.rindex(/[#.]/) || 0))
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
- path.slice((path.rindex(/[#.]/) || -1) + 1, path.length)
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
- path.slice(path.rindex(/[#.]/))
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 [TagList, nil]
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
@@ -2,6 +2,9 @@ module Yoda
2
2
  module Store
3
3
  module Objects
4
4
  class ModuleObject < NamespaceObject
5
+ class Connected < NamespaceObject::Connected
6
+ end
7
+
5
8
  def kind
6
9
  :module
7
10
  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
- def find(address)
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
@@ -13,7 +13,7 @@ module Yoda
13
13
 
14
14
  # @param address [Symbol]
15
15
  # @return [Set<Symbol>]
16
- def get(address)
16
+ def get(address, **)
17
17
  index[address] ||= Set.new
18
18
  end
19
19
 
@@ -73,7 +73,7 @@ module Yoda
73
73
 
74
74
  # @param address [String, Symbol]
75
75
  # @return [Addressable, nil]
76
- def find(address)
76
+ def find(address, **)
77
77
  if (patches = get_patches(address)).empty?
78
78
  nil
79
79
  else
@@ -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
 
@@ -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/project_status'
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,101 @@
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 loadable_gems
16
+ builder.loadable_gems
17
+ end
18
+
19
+ # @return [Array<Objects::Library::Gem>]
20
+ def autoload_gems
21
+ builder.autoload_gems
22
+ end
23
+
24
+ # @param name [String]
25
+ # @param version [String]
26
+ # @return [Library, nil]
27
+ def gem_dependency(name:, version:)
28
+ libraries.find { |library| library.name == name && library.version == version }
29
+ end
30
+
31
+ # @return [Objects::Library::Core]
32
+ def core
33
+ @core ||= Objects::Library.core
34
+ end
35
+
36
+ # @return [Objects::Library::Std]
37
+ def std
38
+ @std ||= Objects::Library.std
39
+ end
40
+
41
+ # @return [Builder]
42
+ def builder
43
+ @builder ||= Builder.new(project)
44
+ end
45
+
46
+ class Builder
47
+ # @return [Project]
48
+ attr_reader :project
49
+
50
+ # @param project [Project]
51
+ def initialize(project)
52
+ @project = project
53
+ end
54
+
55
+ # @return [Array<Objects::Library::Gem>]
56
+ def loadable_gems
57
+ @loadable_gems ||= begin
58
+ dependencies
59
+ .map { |attrs| Objects::Library::Gem.new(**attrs) }
60
+ .reject { |spec| project.config.ignored_gems.include?(spec.name) }
61
+ end
62
+ end
63
+
64
+ # @return [Array<Objects::Library::Gem>]
65
+ def autoload_gems
66
+ @autoload_gems ||= begin
67
+ loadable_gems.select { |gem| autoload_dependency_ids.include?(gem.id) }
68
+ end
69
+ end
70
+
71
+ private
72
+
73
+ # @return [Array<Hash>]
74
+ def dependencies
75
+ analyzed_deps[:dependencies] || []
76
+ end
77
+
78
+ # @return [Array<String>]
79
+ def autoload_dependency_ids
80
+ analyzed_deps[:autoload_dependency_ids] || []
81
+ end
82
+
83
+ # @return [Hash]
84
+ def analyzed_deps
85
+ @analyzed_deps ||= begin
86
+ return {} unless project.root_path
87
+
88
+ # Bundler pollutes environment variables in the current process, so analyze in another process.
89
+ stdout, stderr, status = Open3.capture3(Yoda::Cli.yoda_exe, "analyze-deps", project.root_path)
90
+
91
+ fail stderr unless status.success?
92
+
93
+ Logger.trace("Analysis Result: #{stdout}")
94
+ JSON.parse(stdout, symbolize_names: true)
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,121 @@
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 [Array<String>]
53
+ def project_source_paths
54
+ glob(["{lib,app}/**/*.rb", "ext/**/*.c", ".yoda/*.rb"])
55
+ end
56
+
57
+ # @return [Array<String>]
58
+ def project_load_paths
59
+ ["lib", "app", "ext"].map { |path| expand_path(path) }.compact
60
+ end
61
+
62
+ # @return [String, nil]
63
+ def readable_config_file_path
64
+ path = config_file_path
65
+ path && File.readable?(config_file_path) ? path : nil
66
+ end
67
+
68
+ # @param name [String]
69
+ # @param version [String]
70
+ # @return [String, nil]
71
+ def library_local_yardoc_path(name:, version:)
72
+ expand_path("#{name}-#{version}.yardoc", library_local_yardoc_dir_path)
73
+ end
74
+
75
+ # @param name [String]
76
+ # @param version [String]
77
+ # @return [String, nil]
78
+ def library_registry_path(name:, version:)
79
+ expand_path(Registry.registry_name, library_registry_dir_path)
80
+ end
81
+
82
+ # @return [String, nil]
83
+ def project_registry_path
84
+ expand_path(Registry.registry_name, cache_dir_path)
85
+ end
86
+
87
+ def make_dir
88
+ make_dir_at(cache_dir_path)
89
+ make_dir_at(library_local_yardoc_dir_path)
90
+ make_dir_at(library_registry_dir_path)
91
+ end
92
+
93
+ def clear_dir
94
+ yoda_dir_path && File.exist?(yoda_dir_path) && FileUtils.rm_rf(yoda_dir_path)
95
+ end
96
+
97
+ private
98
+
99
+ def expand_path(relative_path, base_path = project.root_path)
100
+ return nil unless base_path
101
+ File.expand_path(relative_path, base_path)
102
+ end
103
+
104
+ # @param dir_path [String]
105
+ def make_dir_at(dir_path)
106
+ dir_path && (File.exist?(dir_path) || FileUtils.mkdir_p(dir_path))
107
+ end
108
+
109
+ # @param pattern [String, Array<String>]
110
+ # @return [Array<String>]
111
+ def glob(pattern, base_path = project.root_path)
112
+ if project.root_path
113
+ Dir.glob(pattern, base: base_path).map { |path| File.expand_path(path, base_path) }
114
+ else
115
+ []
116
+ end
117
+ end
118
+ end
119
+ end
120
+ end
121
+ 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