ruby-lsp 0.3.4 → 0.3.6
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 +4 -4
 - data/VERSION +1 -1
 - data/lib/ruby_lsp/document.rb +3 -2
 - data/lib/ruby_lsp/requests/document_highlight.rb +5 -2
 - data/lib/ruby_lsp/requests/document_link.rb +3 -3
 - data/lib/ruby_lsp/requests/hover.rb +0 -2
 - data/lib/ruby_lsp/requests/semantic_highlighting.rb +38 -11
 - data/lib/ruby_lsp/requests/support/rails_document_client.rb +1 -1
 - data/lib/ruby_lsp/requests.rb +1 -0
 - metadata +10 -4
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 59e3f670a003f565c001d00333a727d8cf4080eb274d4ebdf248bc0ad76b9c16
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 5010473614d96f47ba10a267844448d6b5985b469cdfec752489be268ba95510
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: '0853a29d497f7befc9bcbbd0387c3e456293728788b0067b91026f4c61c5013240284adc913471b5c015184b19752ecac5e958ab021f301e41c24ce55ed876e2'
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: c2ee016b997013590cad9c575b1461d50f833d3fc06a7b22aa953aa73d6163feb5d821fe443c4ba20b0ac25cf686f32ed26c34348016408f6118f45261cce8a9
         
     | 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0.3. 
     | 
| 
      
 1 
     | 
    
         
            +
            0.3.6
         
     | 
    
        data/lib/ruby_lsp/document.rb
    CHANGED
    
    | 
         @@ -96,8 +96,9 @@ module RubyLsp 
     | 
|
| 
       96 
96 
     | 
    
         
             
                  end
         
     | 
| 
       97 
97 
     | 
    
         | 
| 
       98 
98 
     | 
    
         
             
                  @tree = SyntaxTree.parse(@parsable_source)
         
     | 
| 
       99 
     | 
    
         
            -
                rescue  
     | 
| 
       100 
     | 
    
         
            -
                  #  
     | 
| 
      
 99 
     | 
    
         
            +
                rescue StandardError
         
     | 
| 
      
 100 
     | 
    
         
            +
                  # Trying to maintain a parsable source when there are syntax errors is a best effort. If we fail to apply edits or
         
     | 
| 
      
 101 
     | 
    
         
            +
                  # parse, just ignore it
         
     | 
| 
       101 
102 
     | 
    
         
             
                end
         
     | 
| 
       102 
103 
     | 
    
         | 
| 
       103 
104 
     | 
    
         
             
                sig { params(source: String, range: RangeShape, text: String).void }
         
     | 
| 
         @@ -27,11 +27,14 @@ module RubyLsp 
     | 
|
| 
       27 
27 
     | 
    
         | 
| 
       28 
28 
     | 
    
         
             
                  sig { params(document: Document, position: Document::PositionShape).void }
         
     | 
| 
       29 
29 
     | 
    
         
             
                  def initialize(document, position)
         
     | 
| 
      
 30 
     | 
    
         
            +
                    super(document)
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
       30 
32 
     | 
    
         
             
                    @highlights = T.let([], T::Array[LanguageServer::Protocol::Interface::DocumentHighlight])
         
     | 
| 
       31 
33 
     | 
    
         
             
                    position = Document::Scanner.new(document.source).find_position(position)
         
     | 
| 
       32 
     | 
    
         
            -
                    @target = T.let(find(T.must(document.tree), position), T.nilable(Support::HighlightTarget))
         
     | 
| 
       33 
34 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
                     
     | 
| 
      
 35 
     | 
    
         
            +
                    return unless document.parsed?
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                    @target = T.let(find(T.must(document.tree), position), T.nilable(Support::HighlightTarget))
         
     | 
| 
       35 
38 
     | 
    
         
             
                  end
         
     | 
| 
       36 
39 
     | 
    
         | 
| 
       37 
40 
     | 
    
         
             
                  sig { override.returns(T.all(T::Array[LanguageServer::Protocol::Interface::DocumentHighlight], Object)) }
         
     | 
| 
         @@ -31,7 +31,7 @@ module RubyLsp 
     | 
|
| 
       31 
31 
     | 
    
         
             
                  class << self
         
     | 
| 
       32 
32 
     | 
    
         
             
                    extend T::Sig
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
                    sig { returns(T::Hash[String, T:: 
     | 
| 
      
 34 
     | 
    
         
            +
                    sig { returns(T::Hash[String, T::Hash[String, T::Hash[String, String]]]) }
         
     | 
| 
       35 
35 
     | 
    
         
             
                    def gem_paths
         
     | 
| 
       36 
36 
     | 
    
         
             
                      @gem_paths ||= T.let(begin
         
     | 
| 
       37 
37 
     | 
    
         
             
                        lookup = {}
         
     | 
| 
         @@ -61,7 +61,7 @@ module RubyLsp 
     | 
|
| 
       61 
61 
     | 
    
         
             
                        end
         
     | 
| 
       62 
62 
     | 
    
         | 
| 
       63 
63 
     | 
    
         
             
                        lookup
         
     | 
| 
       64 
     | 
    
         
            -
                      end, T.nilable(T::Hash[String, T:: 
     | 
| 
      
 64 
     | 
    
         
            +
                      end, T.nilable(T::Hash[String, T::Hash[String, T::Hash[String, String]]]))
         
     | 
| 
       65 
65 
     | 
    
         
             
                    end
         
     | 
| 
       66 
66 
     | 
    
         
             
                  end
         
     | 
| 
       67 
67 
     | 
    
         | 
| 
         @@ -88,7 +88,7 @@ module RubyLsp 
     | 
|
| 
       88 
88 
     | 
    
         
             
                    return unless match
         
     | 
| 
       89 
89 
     | 
    
         | 
| 
       90 
90 
     | 
    
         
             
                    uri = T.cast(URI(match[0]), URI::Source)
         
     | 
| 
       91 
     | 
    
         
            -
                    gem_version = resolve_version(uri)
         
     | 
| 
      
 91 
     | 
    
         
            +
                    gem_version = T.must(resolve_version(uri))
         
     | 
| 
       92 
92 
     | 
    
         
             
                    file_path = self.class.gem_paths.dig(uri.gem_name, gem_version, uri.path)
         
     | 
| 
       93 
93 
     | 
    
         
             
                    return if file_path.nil?
         
     | 
| 
       94 
94 
     | 
    
         | 
| 
         @@ -20,6 +20,7 @@ module RubyLsp 
     | 
|
| 
       20 
20 
     | 
    
         
             
                # ```
         
     | 
| 
       21 
21 
     | 
    
         
             
                class SemanticHighlighting < BaseRequest
         
     | 
| 
       22 
22 
     | 
    
         
             
                  extend T::Sig
         
     | 
| 
      
 23 
     | 
    
         
            +
                  include SyntaxTree::WithEnvironment
         
     | 
| 
       23 
24 
     | 
    
         | 
| 
       24 
25 
     | 
    
         
             
                  TOKEN_TYPES = T.let({
         
     | 
| 
       25 
26 
     | 
    
         
             
                    namespace: 0,
         
     | 
| 
         @@ -172,37 +173,52 @@ module RubyLsp 
     | 
|
| 
       172 
173 
     | 
    
         
             
                  def visit_params(node)
         
     | 
| 
       173 
174 
     | 
    
         
             
                    node.keywords.each do |keyword,|
         
     | 
| 
       174 
175 
     | 
    
         
             
                      location = keyword.location
         
     | 
| 
       175 
     | 
    
         
            -
                      add_token(location_without_colon(location), : 
     | 
| 
      
 176 
     | 
    
         
            +
                      add_token(location_without_colon(location), :parameter)
         
     | 
| 
       176 
177 
     | 
    
         
             
                    end
         
     | 
| 
       177 
178 
     | 
    
         | 
| 
       178 
179 
     | 
    
         
             
                    node.requireds.each do |required|
         
     | 
| 
       179 
     | 
    
         
            -
                      add_token(required.location, : 
     | 
| 
      
 180 
     | 
    
         
            +
                      add_token(required.location, :parameter)
         
     | 
| 
       180 
181 
     | 
    
         
             
                    end
         
     | 
| 
       181 
182 
     | 
    
         | 
| 
       182 
183 
     | 
    
         
             
                    rest = node.keyword_rest
         
     | 
| 
       183 
     | 
    
         
            -
                     
     | 
| 
      
 184 
     | 
    
         
            +
                    if rest && !rest.is_a?(SyntaxTree::ArgsForward)
         
     | 
| 
      
 185 
     | 
    
         
            +
                      name = rest.name
         
     | 
| 
      
 186 
     | 
    
         
            +
                      add_token(name.location, :parameter) if name
         
     | 
| 
      
 187 
     | 
    
         
            +
                    end
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
                    super
         
     | 
| 
      
 190 
     | 
    
         
            +
                  end
         
     | 
| 
      
 191 
     | 
    
         
            +
             
     | 
| 
      
 192 
     | 
    
         
            +
                  sig { override.params(node: SyntaxTree::Field).void }
         
     | 
| 
      
 193 
     | 
    
         
            +
                  def visit_field(node)
         
     | 
| 
      
 194 
     | 
    
         
            +
                    add_token(node.name.location, :method)
         
     | 
| 
       184 
195 
     | 
    
         | 
| 
       185 
     | 
    
         
            -
                     
     | 
| 
       186 
     | 
    
         
            -
                    add_token(name.location, :variable) if name
         
     | 
| 
      
 196 
     | 
    
         
            +
                    super
         
     | 
| 
       187 
197 
     | 
    
         
             
                  end
         
     | 
| 
       188 
198 
     | 
    
         | 
| 
       189 
199 
     | 
    
         
             
                  sig { override.params(node: SyntaxTree::VarField).void }
         
     | 
| 
       190 
200 
     | 
    
         
             
                  def visit_var_field(node)
         
     | 
| 
       191 
     | 
    
         
            -
                     
     | 
| 
      
 201 
     | 
    
         
            +
                    value = node.value
         
     | 
| 
      
 202 
     | 
    
         
            +
             
     | 
| 
      
 203 
     | 
    
         
            +
                    case value
         
     | 
| 
       192 
204 
     | 
    
         
             
                    when SyntaxTree::Ident
         
     | 
| 
       193 
     | 
    
         
            -
                       
     | 
| 
      
 205 
     | 
    
         
            +
                      type = type_for_local(value)
         
     | 
| 
      
 206 
     | 
    
         
            +
                      add_token(value.location, type)
         
     | 
| 
       194 
207 
     | 
    
         
             
                    else
         
     | 
| 
       195 
     | 
    
         
            -
                      visit( 
     | 
| 
      
 208 
     | 
    
         
            +
                      visit(value)
         
     | 
| 
       196 
209 
     | 
    
         
             
                    end
         
     | 
| 
       197 
210 
     | 
    
         
             
                  end
         
     | 
| 
       198 
211 
     | 
    
         | 
| 
       199 
212 
     | 
    
         
             
                  sig { override.params(node: SyntaxTree::VarRef).void }
         
     | 
| 
       200 
213 
     | 
    
         
             
                  def visit_var_ref(node)
         
     | 
| 
       201 
     | 
    
         
            -
                     
     | 
| 
      
 214 
     | 
    
         
            +
                    value = node.value
         
     | 
| 
      
 215 
     | 
    
         
            +
             
     | 
| 
      
 216 
     | 
    
         
            +
                    case value
         
     | 
| 
       202 
217 
     | 
    
         
             
                    when SyntaxTree::Ident
         
     | 
| 
       203 
     | 
    
         
            -
                       
     | 
| 
      
 218 
     | 
    
         
            +
                      type = type_for_local(value)
         
     | 
| 
      
 219 
     | 
    
         
            +
                      add_token(value.location, type)
         
     | 
| 
       204 
220 
     | 
    
         
             
                    else
         
     | 
| 
       205 
     | 
    
         
            -
                      visit( 
     | 
| 
      
 221 
     | 
    
         
            +
                      visit(value)
         
     | 
| 
       206 
222 
     | 
    
         
             
                    end
         
     | 
| 
       207 
223 
     | 
    
         
             
                  end
         
     | 
| 
       208 
224 
     | 
    
         | 
| 
         @@ -263,6 +279,17 @@ module RubyLsp 
     | 
|
| 
       263 
279 
     | 
    
         
             
                  def special_method?(method_name)
         
     | 
| 
       264 
280 
     | 
    
         
             
                    SPECIAL_RUBY_METHODS.include?(method_name)
         
     | 
| 
       265 
281 
     | 
    
         
             
                  end
         
     | 
| 
      
 282 
     | 
    
         
            +
             
     | 
| 
      
 283 
     | 
    
         
            +
                  sig { params(value: SyntaxTree::Ident).returns(Symbol) }
         
     | 
| 
      
 284 
     | 
    
         
            +
                  def type_for_local(value)
         
     | 
| 
      
 285 
     | 
    
         
            +
                    local = current_environment.find_local(value.value)
         
     | 
| 
      
 286 
     | 
    
         
            +
             
     | 
| 
      
 287 
     | 
    
         
            +
                    if local.nil? || local.type == :variable
         
     | 
| 
      
 288 
     | 
    
         
            +
                      :variable
         
     | 
| 
      
 289 
     | 
    
         
            +
                    else
         
     | 
| 
      
 290 
     | 
    
         
            +
                      :parameter
         
     | 
| 
      
 291 
     | 
    
         
            +
                    end
         
     | 
| 
      
 292 
     | 
    
         
            +
                  end
         
     | 
| 
       266 
293 
     | 
    
         
             
                end
         
     | 
| 
       267 
294 
     | 
    
         
             
              end
         
     | 
| 
       268 
295 
     | 
    
         
             
            end
         
     | 
    
        data/lib/ruby_lsp/requests.rb
    CHANGED
    
    | 
         @@ -39,6 +39,7 @@ module RubyLsp 
     | 
|
| 
       39 
39 
     | 
    
         
             
                  autoload :SemanticTokenEncoder, "ruby_lsp/requests/support/semantic_token_encoder"
         
     | 
| 
       40 
40 
     | 
    
         
             
                  autoload :SyntaxErrorDiagnostic, "ruby_lsp/requests/support/syntax_error_diagnostic"
         
     | 
| 
       41 
41 
     | 
    
         
             
                  autoload :HighlightTarget, "ruby_lsp/requests/support/highlight_target"
         
     | 
| 
      
 42 
     | 
    
         
            +
                  autoload :RailsDocumentClient, "ruby_lsp/requests/support/rails_document_client"
         
     | 
| 
       42 
43 
     | 
    
         
             
                end
         
     | 
| 
       43 
44 
     | 
    
         
             
              end
         
     | 
| 
       44 
45 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: ruby-lsp
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.3. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.3.6
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Shopify
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2022- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2022-11-11 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: language_server-protocol
         
     | 
| 
         @@ -44,14 +44,20 @@ dependencies: 
     | 
|
| 
       44 
44 
     | 
    
         
             
                requirements:
         
     | 
| 
       45 
45 
     | 
    
         
             
                - - ">="
         
     | 
| 
       46 
46 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       47 
     | 
    
         
            -
                    version:  
     | 
| 
      
 47 
     | 
    
         
            +
                    version: 4.0.2
         
     | 
| 
      
 48 
     | 
    
         
            +
                - - "<"
         
     | 
| 
      
 49 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 50 
     | 
    
         
            +
                    version: 5.0.0
         
     | 
| 
       48 
51 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       49 
52 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       50 
53 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       51 
54 
     | 
    
         
             
                requirements:
         
     | 
| 
       52 
55 
     | 
    
         
             
                - - ">="
         
     | 
| 
       53 
56 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       54 
     | 
    
         
            -
                    version:  
     | 
| 
      
 57 
     | 
    
         
            +
                    version: 4.0.2
         
     | 
| 
      
 58 
     | 
    
         
            +
                - - "<"
         
     | 
| 
      
 59 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 60 
     | 
    
         
            +
                    version: 5.0.0
         
     | 
| 
       55 
61 
     | 
    
         
             
            description: An opinionated language server for Ruby
         
     | 
| 
       56 
62 
     | 
    
         
             
            email:
         
     | 
| 
       57 
63 
     | 
    
         
             
            - ruby@shopify.com
         
     |