mt-lang 0.2.11 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 440292bdf9bb8c311ff6172c6b063defbae416862b2f3369b70c4249bcc09f37
4
- data.tar.gz: 4793a630eff4f1672659c682e3fb9df769e6d7aaf20facc3742216b7af8fe388
3
+ metadata.gz: 28dc7f8c8824f11189bdd3cf704d10eefa2e144d466b218b5b34b1693531fe94
4
+ data.tar.gz: 73dcea75aeb6fb9c460e6b574e0bb64dc118ca9cd0a028586bd526d7b00acb49
5
5
  SHA512:
6
- metadata.gz: ba82f455b038f4bfcf2b3d2748db4327fec835bf676f854578aca8c21f5614836b693385c70679cbece42917a7a2093a405029f4e6b7a7fa9dcb2c0a1af13257
7
- data.tar.gz: 51f8316e7466ae58c141168a3f350c2104fc61a859d41e1a21316a7d56c11d7ea0ca49113f7c6aa69fe9bf2a06c055ff6d6d94fa0d931096d76ddc1e38610ccd
6
+ metadata.gz: c3286442bbca94bd51b9c7aa4166f2b854d9f6bd48da3f6860648f303c30c90e39f2ac531315a5f13a148f3591eab1a5a02dabfd935f6ea136dfe0018012db9d
7
+ data.tar.gz: 53cc3240a7b226d152f831775e508a1db5c030f533d4fb6a88084f6564fcffa86954614e86b37f2c0b7650ae5ef27486e9aea05a6eaffe14b2aa5b2be9be0c8a
data/lib/milk_tea/base.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require "pathname"
4
4
 
5
5
  module MilkTea
6
- VERSION = "0.2.11"
6
+ VERSION = "0.2.12"
7
7
 
8
8
  def self.root
9
9
  @root ||= Pathname.new(File.expand_path("../..", __dir__))
@@ -272,6 +272,28 @@ module MilkTea
272
272
  'Subscription' => 'Opaque handle returned by `event.subscribe`. Pass to `event.unsubscribe` to remove a listener.',
273
273
  }.freeze
274
274
 
275
+ BUILTIN_TYPE_METHOD_SIGNATURES = {
276
+ 'atomic' => {
277
+ 'load' => 'function load() -> T',
278
+ 'store' => 'static function store(value: T) -> void',
279
+ 'add' => 'static function add(value: T) -> T',
280
+ 'sub' => 'static function sub(value: T) -> T',
281
+ 'exchange' => 'static function exchange(value: T) -> T',
282
+ 'compare_exchange' => 'static function compare_exchange(expected: T, desired: T) -> bool',
283
+ },
284
+ 'str_buffer' => {
285
+ 'assign' => 'static function assign(value: str) -> void',
286
+ 'append' => 'static function append(value: str) -> void',
287
+ 'assign_format' => 'static function assign_format(fmt: str) -> void',
288
+ 'append_format' => 'static function append_format(fmt: str) -> void',
289
+ 'clear' => 'static function clear() -> void',
290
+ 'len' => 'static function len() -> ptr_uint',
291
+ 'capacity' => 'static function capacity() -> ptr_uint',
292
+ 'as_str' => 'static function as_str() -> str',
293
+ 'as_cstr' => 'static function as_cstr() -> cstr',
294
+ },
295
+ }.freeze
296
+
275
297
  def handle_hover(params)
276
298
  stages = new_perf_stages
277
299
  total_start = stages ? monotonic_time : nil
@@ -465,6 +487,27 @@ module MilkTea
465
487
  end
466
488
  end
467
489
 
490
+ unless signature
491
+ if dot_receiver
492
+ receiver_name = dot_receiver
493
+ receiver_binding = resolve_local_hover_binding(facts, receiver_name, lsp_line + 1, lsp_char + 1) ||
494
+ facts.values[receiver_name] ||
495
+ facts.functions[receiver_name]
496
+ if receiver_binding && receiver_binding.type
497
+ receiver_type = receiver_binding.respond_to?(:storage_type) ? receiver_binding.storage_type : receiver_binding.type
498
+ methods = methods_for_receiver_type(facts, receiver_type)
499
+ if (method_binding = methods[name])
500
+ signature = method_signature(method_binding)
501
+ else
502
+ type_base = receiver_type.to_s[/^([a-z_]+)/, 1]
503
+ if type_base && (method_sigs = BUILTIN_TYPE_METHOD_SIGNATURES[type_base])
504
+ signature = method_sigs[name]
505
+ end
506
+ end
507
+ end
508
+ end
509
+ end
510
+
468
511
  unless signature
469
512
  if token_index && (builtin_info = builtin_hover_info(name, tokens, token_index))
470
513
  signature = builtin_info[:signature]
@@ -473,14 +516,16 @@ module MilkTea
473
516
  end
474
517
 
475
518
  unless signature
476
- local_def = @workspace.find_definition_token_global(
477
- name,
478
- preferred_uri: uri,
479
- before_line: lsp_line + 1,
480
- before_char: lsp_char + 1,
481
- )
482
- if local_def
483
- signature = resolve_lexical_local_hover_signature(local_def[:uri], name, local_def[:token])
519
+ unless token_index && tokens && tokens[previous_non_trivia_token_index(tokens, token_index)]&.type == :dot
520
+ local_def = @workspace.find_definition_token_global(
521
+ name,
522
+ preferred_uri: uri,
523
+ before_line: lsp_line + 1,
524
+ before_char: lsp_char + 1,
525
+ )
526
+ if local_def
527
+ signature = resolve_lexical_local_hover_signature(local_def[:uri], name, local_def[:token])
528
+ end
484
529
  end
485
530
  end
486
531
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mt-lang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.11
4
+ version: 0.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Long (Teefan) Tran
@@ -583,7 +583,7 @@ metadata:
583
583
  homepage_uri: https://teefan.github.io/mt-lang/
584
584
  source_code_uri: https://github.com/teefan/mt-lang
585
585
  post_install_message: |
586
- Milk Tea 0.2.11 installed!
586
+ Milk Tea 0.2.12 installed!
587
587
 
588
588
  System requirements:
589
589
  - A C compiler (gcc or clang) must be available on PATH