ruby-lsp-typeprof 0.2.0 → 0.4.0

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: 8d6205b59c4d03e2deab702b463991aa376f26105be75ae7c0ffc5d154d9fe2a
4
- data.tar.gz: 0ed3ffed58873686298a87ea548c1a82199da616da97d08955bc328c49f7a127
3
+ metadata.gz: cd458cb056ff5e4f48058e864528f8db6d03a9d7709fb47cd81b387976346d77
4
+ data.tar.gz: fe8d2d2de7862ea0ce8dccf66a0ed6e01e259815d82e3c484f35e8d73f4f3d8f
5
5
  SHA512:
6
- metadata.gz: 63edefab59f8261ef245c61e145d013dd0728acdc1cd79e6bdac2fe6e695ff10bbe3edd0374d2ee854d5488d78b891d0d97ab689ba855330793b8ecee43bd780
7
- data.tar.gz: ffa2d4612940a332550574c8c4bea47efcd64ca6d0b3440abf069df86ebeb9da75e8d171908b0255a21adcc84bf12e1b5dfcb2e1fd45548bba9f54e2e9bb17e3
6
+ metadata.gz: '008e208221b72bb8db5908f01a4f74f30854f54d2a70648c62ad2b39185407014f982b00d52be93ba2a9ac8d47c5a84d1831f217210ec5e4ba49867937eb44e2'
7
+ data.tar.gz: 9e38f9e164764cd93f8da7e877a64262764abba9d74dbbf4221ece9403bbd4cade039daa0dd116f1a6789ab488a57c58be9bd2f9e46b5df406a0192568f91747
data/README.md CHANGED
@@ -26,6 +26,7 @@ Configure them in VS Code's `settings.json`:
26
26
  {
27
27
  "rubyLsp.addonSettings": {
28
28
  "TypeProf": {
29
+ "enabled": false,
29
30
  "enableCodeLens": false
30
31
  }
31
32
  }
@@ -42,7 +43,8 @@ You can place this configuration in either:
42
43
 
43
44
  | Key | Type | Default | Description |
44
45
  | --- | --- | --- | --- |
45
- | `enableCodeLens` | boolean | `true` | Show inferred type signatures as code lens above method definitions. |
46
+ | `enabled` | boolean | `true` | Master switch. When `false`, the add-on skips loading TypeProf entirely and disables every feature. |
47
+ | `enableCodeLens` | boolean | `true` | Show inferred type signatures as code lens above method definitions. Has no effect when `enabled` is `false`. |
46
48
 
47
49
  After changing the setting, restart Ruby LSP via the "Ruby LSP: Restart"
48
50
  command for it to take effect.
@@ -51,7 +53,9 @@ command for it to take effect.
51
53
 
52
54
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
53
55
 
54
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
56
+ To install this gem onto your local machine, run `bundle exec rake install`.
57
+
58
+ To release a new version, run `bin/bump.rb` (pass `--minor` or `--major` to bump those segments) and push the resulting commit to `main`. The release workflow then publishes the gem to [rubygems.org](https://rubygems.org) and creates a GitHub release.
55
59
 
56
60
  ## Contributing
57
61
 
@@ -5,25 +5,32 @@ require "ruby_lsp/addon"
5
5
  require "uri"
6
6
 
7
7
  require_relative "code_lens_listener"
8
+ require_relative "loggable"
8
9
 
9
10
  module RubyLsp
10
11
  module Typeprof
11
12
  class Addon < ::RubyLsp::Addon
13
+ include Loggable
14
+
12
15
  def initialize
13
16
  super
14
17
  @service = nil
15
18
  @mutex = Mutex.new
19
+ @enabled = true
16
20
  @code_lens_enabled = true
17
21
  end
18
22
 
19
- def activate(global_state, _outgoing_queue)
20
- require "typeprof"
23
+ def activate(global_state, outgoing_queue)
24
+ @outgoing_queue = outgoing_queue
25
+ log_message("Activating Ruby LSP TypeProf add-on v#{VERSION}")
21
26
 
22
- settings = global_state.settings_for_addon(name)
23
- @code_lens_enabled = settings&.dig(:enableCodeLens) != false
27
+ load_settings(global_state)
28
+ return unless @enabled
29
+
30
+ require "typeprof"
24
31
  @service = build_service(global_state.workspace_path)
25
32
  rescue StandardError => e
26
- warn "ruby-lsp-typeprof: Failed to activate: #{e.message}"
33
+ log_error("Ruby LSP TypeProf failed to activate: #{e.full_message(highlight: false)}")
27
34
  end
28
35
 
29
36
  def deactivate
@@ -42,7 +49,7 @@ module RubyLsp
42
49
  return unless @service
43
50
  return unless @code_lens_enabled
44
51
 
45
- CodeLensListener.new(response_builder, uri, dispatcher, @service, @mutex)
52
+ CodeLensListener.new(response_builder, uri, dispatcher, @service, @mutex, @outgoing_queue)
46
53
  end
47
54
 
48
55
  def workspace_did_change_watched_files(changes)
@@ -55,6 +62,12 @@ module RubyLsp
55
62
 
56
63
  private
57
64
 
65
+ def load_settings(global_state)
66
+ settings = global_state.settings_for_addon(name)
67
+ @enabled = settings&.dig(:enabled) != false
68
+ @code_lens_enabled = settings&.dig(:enableCodeLens) != false
69
+ end
70
+
58
71
  def build_service(workspace_path)
59
72
  conf = load_typeprof_conf(workspace_path) || default_conf
60
73
  rbs_dir = File.expand_path(conf[:rbs_dir], workspace_path)
@@ -88,7 +101,7 @@ module RubyLsp
88
101
 
89
102
  @service.update_file(path, nil)
90
103
  rescue StandardError => e
91
- warn "ruby-lsp-typeprof: Failed to update file #{path}: #{e.message}"
104
+ log_error("Ruby LSP TypeProf failed to update file #{path}: #{e.full_message(highlight: false)}")
92
105
  end
93
106
  end
94
107
  end
@@ -1,12 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "loggable"
4
+
3
5
  module RubyLsp
4
6
  module Typeprof
5
7
  class CodeLensListener
6
- def initialize(response_builder, uri, dispatcher, service, mutex)
8
+ include Loggable
9
+
10
+ def initialize(response_builder, uri, dispatcher, service, mutex, outgoing_queue)
7
11
  @response_builder = response_builder
8
12
  @path = uri.to_standardized_path
9
13
  @lens_cache = {}
14
+ @outgoing_queue = outgoing_queue
10
15
 
11
16
  cache_code_lens_results(service, mutex)
12
17
  dispatcher.register(self, :on_def_node_enter) unless @lens_cache.empty?
@@ -38,7 +43,7 @@ module RubyLsp
38
43
  end
39
44
  end
40
45
  rescue StandardError => e
41
- warn "ruby-lsp-typeprof: Code lens error: #{e.message}"
46
+ log_error("Ruby LSP TypeProf failed to compute code lens for #{@path}: #{e.full_message(highlight: false)}")
42
47
  end
43
48
  end
44
49
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLsp
4
+ module Typeprof
5
+ module Loggable
6
+ private
7
+
8
+ def log_message(message, type: ::RubyLsp::Constant::MessageType::LOG)
9
+ return if @outgoing_queue.nil? || @outgoing_queue.closed?
10
+
11
+ @outgoing_queue << ::RubyLsp::Notification.window_log_message(message, type: type)
12
+ end
13
+
14
+ def log_error(message)
15
+ log_message(message, type: ::RubyLsp::Constant::MessageType::ERROR)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RubyLsp
4
4
  module Typeprof
5
- VERSION = "0.2.0"
5
+ VERSION = "0.4.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lsp-typeprof
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takumi Shotoku
@@ -44,8 +44,6 @@ executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
- - ".tagpr"
48
- - CHANGELOG.md
49
47
  - CODE_OF_CONDUCT.md
50
48
  - LICENSE.txt
51
49
  - README.md
@@ -53,6 +51,7 @@ files:
53
51
  - lib/ruby-lsp-typeprof.rb
54
52
  - lib/ruby_lsp/ruby_lsp_typeprof/addon.rb
55
53
  - lib/ruby_lsp/ruby_lsp_typeprof/code_lens_listener.rb
54
+ - lib/ruby_lsp/ruby_lsp_typeprof/loggable.rb
56
55
  - lib/ruby_lsp_typeprof/version.rb
57
56
  - sig/ruby_lsp_typeprof/version.rbs
58
57
  homepage: https://github.com/sinsoku/ruby-lsp-typeprof
@@ -60,8 +59,8 @@ licenses:
60
59
  - MIT
61
60
  metadata:
62
61
  homepage_uri: https://github.com/sinsoku/ruby-lsp-typeprof
63
- source_code_uri: https://github.com/sinsoku/ruby-lsp-typeprof/tree/v0.2.0
64
- changelog_uri: https://github.com/sinsoku/ruby-lsp-typeprof/blob/v0.2.0/CHANGELOG.md
62
+ source_code_uri: https://github.com/sinsoku/ruby-lsp-typeprof/tree/v0.4.0
63
+ changelog_uri: https://github.com/sinsoku/ruby-lsp-typeprof/releases
65
64
  rubygems_mfa_required: 'true'
66
65
  rdoc_options: []
67
66
  require_paths:
@@ -77,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
76
  - !ruby/object:Gem::Version
78
77
  version: '0'
79
78
  requirements: []
80
- rubygems_version: 4.0.6
79
+ rubygems_version: 4.0.10
81
80
  specification_version: 4
82
81
  summary: A Ruby LSP addon for TypeProf
83
82
  test_files: []
data/.tagpr DELETED
@@ -1,5 +0,0 @@
1
- [tagpr]
2
- vPrefix = true
3
- releaseBranch = main
4
- versionFile = lib/ruby_lsp_typeprof/version.rb
5
- postVersionCommand = BUNDLE_FROZEN=false bundle install
data/CHANGELOG.md DELETED
@@ -1,8 +0,0 @@
1
- ## [v0.2.0](https://github.com/sinsoku/ruby-lsp-typeprof/compare/v0.1.1...v0.2.0) - 2026-05-03
2
- - feat: Add enableCodeLens setting via addonSettings by @sinsoku in https://github.com/sinsoku/ruby-lsp-typeprof/pull/4
3
-
4
- ## [v0.1.1](https://github.com/sinsoku/ruby-lsp-typeprof/compare/v0.1.0...v0.1.1) - 2026-04-27
5
-
6
- ## [0.1.0] - 2026-04-27
7
-
8
- - feat: Display type declarations using Code Lens