solargraph 0.7.3 → 0.7.4
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/lib/solargraph/api_map.rb +2 -2
 - data/lib/solargraph/code_map.rb +29 -4
 - data/lib/solargraph/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 8b663346a935bf7a364c828edc3eddfcdeab1702
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 28e58c55f6d542b5a3b4bff0da3f7ce619d8df0c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 441b66f057a2ec97b41bc7a76b71c1869a483e61c2494cc2a93e4f9faac4d0e350b4b78096242a2f87ef001454c397447d422c0fba2fd5bbe2caa1ecb3cd2aba
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 2d44127c944bd074ec315dd5e1043eebe5b9b706ef950468318228922655569a42fc2e641771f8e4b497209cff0b9a8852ce7ac49091be424ec9dfd476936846
         
     | 
    
        data/lib/solargraph/api_map.rb
    CHANGED
    
    | 
         @@ -10,7 +10,7 @@ module Solargraph 
     | 
|
| 
       10 
10 
     | 
    
         
             
                  'begin', 'break', 'case', 'class', 'def', 'defined?', 'do', 'else',
         
     | 
| 
       11 
11 
     | 
    
         
             
                  'elsif', 'end', 'ensure', 'false', 'for', 'if', 'in', 'module', 'next',
         
     | 
| 
       12 
12 
     | 
    
         
             
                  'nil', 'not', 'or', 'redo', 'rescue', 'retry', 'return', 'self', 'super',
         
     | 
| 
       13 
     | 
    
         
            -
                  'then', 'true', 'undef', 'unless', 'until', 'when', 'while', 'yield'
         
     | 
| 
      
 13 
     | 
    
         
            +
                  'then', 'true', 'undef', 'unless', 'until', 'when', 'while', 'yield',
         
     | 
| 
       14 
14 
     | 
    
         
             
                ]
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
                MAPPABLE_METHODS = [
         
     | 
| 
         @@ -99,7 +99,7 @@ module Solargraph 
     | 
|
| 
       99 
99 
     | 
    
         | 
| 
       100 
100 
     | 
    
         
             
                def self.get_keywords
         
     | 
| 
       101 
101 
     | 
    
         
             
                  result = []
         
     | 
| 
       102 
     | 
    
         
            -
                  keywords = KEYWORDS
         
     | 
| 
      
 102 
     | 
    
         
            +
                  keywords = KEYWORDS + MAPPABLE_METHODS
         
     | 
| 
       103 
103 
     | 
    
         
             
                  keywords.each { |k|
         
     | 
| 
       104 
104 
     | 
    
         
             
                    result.push Suggestion.new(k, kind: Suggestion::KEYWORD, detail: 'Keyword')
         
     | 
| 
       105 
105 
     | 
    
         
             
                  }
         
     | 
    
        data/lib/solargraph/code_map.rb
    CHANGED
    
    | 
         @@ -4,6 +4,8 @@ module Solargraph 
     | 
|
| 
       4 
4 
     | 
    
         
             
              class CodeMap
         
     | 
| 
       5 
5 
     | 
    
         
             
                attr_accessor :node
         
     | 
| 
       6 
6 
     | 
    
         
             
                attr_accessor :api_map
         
     | 
| 
      
 7 
     | 
    
         
            +
                attr_reader :code
         
     | 
| 
      
 8 
     | 
    
         
            +
                attr_reader :parsed
         
     | 
| 
       7 
9 
     | 
    
         | 
| 
       8 
10 
     | 
    
         
             
                include NodeMethods
         
     | 
| 
       9 
11 
     | 
    
         | 
| 
         @@ -20,20 +22,37 @@ module Solargraph 
     | 
|
| 
       20 
22 
     | 
    
         
             
                  if @api_map.nil?
         
     | 
| 
       21 
23 
     | 
    
         
             
                    @api_map = ApiMap.new(workspace)
         
     | 
| 
       22 
24 
     | 
    
         
             
                  end
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
25 
     | 
    
         
             
                  @code = code.gsub(/\r/, '')
         
     | 
| 
       25 
26 
     | 
    
         
             
                  tries = 0
         
     | 
| 
       26 
27 
     | 
    
         
             
                  # Hide incomplete code to avoid syntax errors
         
     | 
| 
       27 
     | 
    
         
            -
                   
     | 
| 
      
 28 
     | 
    
         
            +
                  # @todo This might not be necessary given the corrected character
         
     | 
| 
      
 29 
     | 
    
         
            +
                  #   replacement in retries.
         
     | 
| 
      
 30 
     | 
    
         
            +
                  #tmp = "#{@code}\nX".gsub(/[\.@]([\s])/, '#\1').gsub(/([\A\s]?)def([\s]*?[\n\Z])/, '\1#ef\2')
         
     | 
| 
      
 31 
     | 
    
         
            +
                  tmp = @code
         
     | 
| 
       28 
32 
     | 
    
         
             
                  begin
         
     | 
| 
       29 
33 
     | 
    
         
             
                    node, comments = Parser::CurrentRuby.parse_with_comments(tmp)
         
     | 
| 
       30 
34 
     | 
    
         
             
                    @node = @api_map.append_node(node, comments, filename)
         
     | 
| 
      
 35 
     | 
    
         
            +
                    @parsed = tmp
         
     | 
| 
      
 36 
     | 
    
         
            +
                    @code.freeze
         
     | 
| 
      
 37 
     | 
    
         
            +
                    @parsed.freeze
         
     | 
| 
       31 
38 
     | 
    
         
             
                  rescue Parser::SyntaxError => e
         
     | 
| 
       32 
39 
     | 
    
         
             
                    if tries < 10
         
     | 
| 
      
 40 
     | 
    
         
            +
                      STDERR.puts "Error parsing #{filename}: #{e.message}"
         
     | 
| 
      
 41 
     | 
    
         
            +
                      STDERR.puts "Retrying..."
         
     | 
| 
       33 
42 
     | 
    
         
             
                      tries += 1
         
     | 
| 
       34 
43 
     | 
    
         
             
                      spot = e.diagnostic.location.begin_pos
         
     | 
| 
       35 
     | 
    
         
            -
                      if spot == tmp 
     | 
| 
       36 
     | 
    
         
            -
                         
     | 
| 
      
 44 
     | 
    
         
            +
                      if tmp[spot] == '@' or tmp[spot] == ':'
         
     | 
| 
      
 45 
     | 
    
         
            +
                        # Stub unfinished instance variables and symbols
         
     | 
| 
      
 46 
     | 
    
         
            +
                        spot -= 1
         
     | 
| 
      
 47 
     | 
    
         
            +
                      elsif tmp[spot - 1] == '.'
         
     | 
| 
      
 48 
     | 
    
         
            +
                        # Stub unfinished method calls
         
     | 
| 
      
 49 
     | 
    
         
            +
                        spot -= 2
         
     | 
| 
      
 50 
     | 
    
         
            +
                      else
         
     | 
| 
      
 51 
     | 
    
         
            +
                        # Stub the whole line
         
     | 
| 
      
 52 
     | 
    
         
            +
                        spot = beginning_of_line_from(spot)
         
     | 
| 
      
 53 
     | 
    
         
            +
                      end
         
     | 
| 
      
 54 
     | 
    
         
            +
                      if spot == 0
         
     | 
| 
      
 55 
     | 
    
         
            +
                        tmp = '#' + tmp[1..-1]
         
     | 
| 
       37 
56 
     | 
    
         
             
                      else
         
     | 
| 
       38 
57 
     | 
    
         
             
                        tmp = tmp[0..spot] + '#' + tmp[spot+2..-1].to_s
         
     | 
| 
       39 
58 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -413,5 +432,11 @@ module Solargraph 
     | 
|
| 
       413 
432 
     | 
    
         
             
                  nil
         
     | 
| 
       414 
433 
     | 
    
         
             
                end
         
     | 
| 
       415 
434 
     | 
    
         | 
| 
      
 435 
     | 
    
         
            +
                def beginning_of_line_from i
         
     | 
| 
      
 436 
     | 
    
         
            +
                  while i > 0 and @code[i] != "\n"
         
     | 
| 
      
 437 
     | 
    
         
            +
                    i -= 1
         
     | 
| 
      
 438 
     | 
    
         
            +
                  end
         
     | 
| 
      
 439 
     | 
    
         
            +
                  i
         
     | 
| 
      
 440 
     | 
    
         
            +
                end
         
     | 
| 
       416 
441 
     | 
    
         
             
              end
         
     | 
| 
       417 
442 
     | 
    
         
             
            end
         
     | 
    
        data/lib/solargraph/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: solargraph
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.7. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.7.4
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Fred Snyder
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2017-05- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-05-11 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: parser
         
     |