solargraph 0.37.2 → 0.38.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/solargraph.rb +2 -7
- data/lib/solargraph/api_map.rb +2 -0
- data/lib/solargraph/api_map/store.rb +8 -1
- data/lib/solargraph/complex_type.rb +1 -0
- data/lib/solargraph/converters/dd.rb +12 -0
- data/lib/solargraph/converters/dl.rb +12 -0
- data/lib/solargraph/converters/dt.rb +12 -0
- data/lib/solargraph/converters/misc.rb +1 -0
- data/lib/solargraph/diagnostics/rubocop.rb +0 -11
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +11 -0
- data/lib/solargraph/language_server/message.rb +31 -31
- data/lib/solargraph/language_server/message/text_document/formatting.rb +24 -13
- data/lib/solargraph/language_server/message/text_document/hover.rb +1 -1
- data/lib/solargraph/language_server/transport/data_reader.rb +2 -0
- data/lib/solargraph/page.rb +1 -2
- data/lib/solargraph/pin.rb +2 -0
- data/lib/solargraph/pin/base.rb +1 -1
- data/lib/solargraph/pin/documenting.rb +74 -17
- data/lib/solargraph/pin/method.rb +1 -1
- data/lib/solargraph/pin/yard_pin/yard_mixin.rb +1 -1
- data/lib/solargraph/shell.rb +3 -2
- data/lib/solargraph/source/node_methods.rb +8 -8
- data/lib/solargraph/source_map.rb +2 -0
- data/lib/solargraph/source_map/mapper.rb +3 -3
- data/lib/solargraph/type_checker.rb +9 -2
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/yard_map.rb +7 -1
- data/solargraph.gemspec +1 -1
- metadata +18 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b51cc5aaad5a07e4b7a5f6d2678b3fa42ffba42e7eb5aef0a9dca1834fe3b32
|
4
|
+
data.tar.gz: eef096fe46ea782d8d1b747f4bf1faa80c3cac9caf80b6f212face3ae8d45392
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47f9cdd2ef911ab8ace7de207503c53bc518aaa1b303bb2bc097b86cca229d73886ad8fa0bd7d502794cc8ec67c4c9a9077bd75b2c06e9e9bb39e3879a102eef
|
7
|
+
data.tar.gz: 698d1343b2843767c9a51d7330f0af2c4202018b1e9cd3e78179f3dd709d1a4a48b5b01ada8d867b8107c4b297a5bc34305989f4adaa7e9057732f1298b54975
|
data/lib/solargraph.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'yard'
|
3
|
+
# require 'yard'
|
4
4
|
require 'solargraph/version'
|
5
|
-
require '
|
6
|
-
require 'yard-solargraph'
|
5
|
+
# require 'yard-solargraph'
|
7
6
|
|
8
7
|
# The top-level namespace for the Solargraph code mapping, documentation,
|
9
8
|
# static analysis, and language server libraries.
|
@@ -53,7 +52,3 @@ module Solargraph
|
|
53
52
|
Solargraph::Logging.logger
|
54
53
|
end
|
55
54
|
end
|
56
|
-
|
57
|
-
Solargraph::YardMap::CoreDocs.require_minimum
|
58
|
-
# Change YARD log IO to avoid sending unexpected messages to STDOUT
|
59
|
-
YARD::Logger.instance.io = File.new(File::NULL, 'w')
|
data/lib/solargraph/api_map.rb
CHANGED
@@ -147,7 +147,14 @@ module Solargraph
|
|
147
147
|
base = ''
|
148
148
|
name = fqns
|
149
149
|
end
|
150
|
-
|
150
|
+
fqns_pins_map[[base, name]]
|
151
|
+
end
|
152
|
+
|
153
|
+
def fqns_pins_map
|
154
|
+
@fqns_pins_map ||= Hash.new do |h, (base, name)|
|
155
|
+
value = namespace_children(base).select { |pin| pin.name == name && pin.is_a?(Pin::Namespace) }
|
156
|
+
h[[base, name]] = value
|
157
|
+
end
|
151
158
|
end
|
152
159
|
|
153
160
|
# @return [Array<Solargraph::Pin::Symbol>]
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module ReverseMarkdown
|
2
|
+
module Converters
|
3
|
+
class Dd < Base
|
4
|
+
def convert node, state = {}
|
5
|
+
content = treat_children(node, state)
|
6
|
+
": #{content.strip}\n"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
ReverseMarkdown::Converters.register :dd, ReverseMarkdown::Converters::Dd.new
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module ReverseMarkdown
|
2
|
+
module Converters
|
3
|
+
class Dl < Base
|
4
|
+
def convert node, state = {}
|
5
|
+
content = treat_children(node, state).strip
|
6
|
+
"\n\n#{content}\n"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
ReverseMarkdown::Converters.register :dl, ReverseMarkdown::Converters::Dl.new
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module ReverseMarkdown
|
2
|
+
module Converters
|
3
|
+
class Dt < Base
|
4
|
+
def convert node, state = {}
|
5
|
+
content = treat_children(node, state)
|
6
|
+
"\n#{content.strip}\n"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
ReverseMarkdown::Converters.register :dt, ReverseMarkdown::Converters::Dt.new
|
@@ -0,0 +1 @@
|
|
1
|
+
ReverseMarkdown::Converters.register :tt, ReverseMarkdown::Converters::Code.new
|
@@ -35,17 +35,6 @@ module Solargraph
|
|
35
35
|
|
36
36
|
private
|
37
37
|
|
38
|
-
# @todo This is a smelly way to redirect output, but the RuboCop specs do
|
39
|
-
# the same thing.
|
40
|
-
# @return [String]
|
41
|
-
def redirect_stdout
|
42
|
-
redir = StringIO.new
|
43
|
-
$stdout = redir
|
44
|
-
yield if block_given?
|
45
|
-
$stdout = STDOUT
|
46
|
-
redir.string
|
47
|
-
end
|
48
|
-
|
49
38
|
# @param resp [Hash]
|
50
39
|
# @return [Array<Hash>]
|
51
40
|
def make_array resp
|
@@ -45,6 +45,17 @@ module Solargraph
|
|
45
45
|
return path unless path.match(/^[a-z]:/)
|
46
46
|
path[0].upcase + path[1..-1]
|
47
47
|
end
|
48
|
+
|
49
|
+
# @todo This is a smelly way to redirect output, but the RuboCop specs do
|
50
|
+
# the same thing.
|
51
|
+
# @return [String]
|
52
|
+
def redirect_stdout
|
53
|
+
redir = StringIO.new
|
54
|
+
$stdout = redir
|
55
|
+
yield if block_given?
|
56
|
+
$stdout = STDOUT
|
57
|
+
redir.string
|
58
|
+
end
|
48
59
|
end
|
49
60
|
end
|
50
61
|
end
|
@@ -56,38 +56,38 @@ module Solargraph
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
register 'initialize',
|
60
|
-
register 'initialized',
|
61
|
-
register 'textDocument/completion',
|
62
|
-
register 'completionItem/resolve',
|
63
|
-
register 'textDocument/signatureHelp',
|
64
|
-
register 'textDocument/didOpen',
|
65
|
-
register 'textDocument/didChange',
|
66
|
-
register 'textDocument/didSave',
|
67
|
-
register 'textDocument/didClose',
|
68
|
-
register 'textDocument/hover',
|
69
|
-
register 'textDocument/definition',
|
70
|
-
register 'textDocument/formatting',
|
71
|
-
register 'textDocument/onTypeFormatting',
|
72
|
-
register 'textDocument/documentSymbol',
|
73
|
-
register 'textDocument/references',
|
74
|
-
register 'textDocument/rename',
|
75
|
-
register 'textDocument/prepareRename',
|
76
|
-
register 'textDocument/foldingRange',
|
77
|
-
register 'textDocument/codeAction',
|
78
|
-
register 'workspace/didChangeWatchedFiles',
|
79
|
-
register 'workspace/didChangeConfiguration',
|
59
|
+
register 'initialize', Initialize
|
60
|
+
register 'initialized', Initialized
|
61
|
+
register 'textDocument/completion', TextDocument::Completion
|
62
|
+
register 'completionItem/resolve', CompletionItem::Resolve
|
63
|
+
register 'textDocument/signatureHelp', TextDocument::SignatureHelp
|
64
|
+
register 'textDocument/didOpen', TextDocument::DidOpen
|
65
|
+
register 'textDocument/didChange', TextDocument::DidChange
|
66
|
+
register 'textDocument/didSave', TextDocument::DidSave
|
67
|
+
register 'textDocument/didClose', TextDocument::DidClose
|
68
|
+
register 'textDocument/hover', TextDocument::Hover
|
69
|
+
register 'textDocument/definition', TextDocument::Definition
|
70
|
+
register 'textDocument/formatting', TextDocument::Formatting
|
71
|
+
register 'textDocument/onTypeFormatting', TextDocument::OnTypeFormatting
|
72
|
+
register 'textDocument/documentSymbol', TextDocument::DocumentSymbol
|
73
|
+
register 'textDocument/references', TextDocument::References
|
74
|
+
register 'textDocument/rename', TextDocument::Rename
|
75
|
+
register 'textDocument/prepareRename', TextDocument::PrepareRename
|
76
|
+
register 'textDocument/foldingRange', TextDocument::FoldingRange
|
77
|
+
register 'textDocument/codeAction', TextDocument::CodeAction
|
78
|
+
register 'workspace/didChangeWatchedFiles', Workspace::DidChangeWatchedFiles
|
79
|
+
register 'workspace/didChangeConfiguration', Workspace::DidChangeConfiguration
|
80
80
|
register 'workspace/didChangeWorkspaceFolders', Workspace::DidChangeWorkspaceFolders
|
81
|
-
register 'workspace/symbol',
|
82
|
-
register '$/cancelRequest',
|
83
|
-
register '$/solargraph/document',
|
84
|
-
register '$/solargraph/search',
|
85
|
-
register '$/solargraph/checkGemVersion',
|
86
|
-
register '$/solargraph/documentGems',
|
87
|
-
register '$/solargraph/downloadCore',
|
88
|
-
register '$/solargraph/environment',
|
89
|
-
register 'shutdown',
|
90
|
-
register 'exit',
|
81
|
+
register 'workspace/symbol', Workspace::WorkspaceSymbol
|
82
|
+
register '$/cancelRequest', CancelRequest
|
83
|
+
register '$/solargraph/document', Extended::Document
|
84
|
+
register '$/solargraph/search', Extended::Search
|
85
|
+
register '$/solargraph/checkGemVersion', Extended::CheckGemVersion
|
86
|
+
register '$/solargraph/documentGems', Extended::DocumentGems
|
87
|
+
register '$/solargraph/downloadCore', Extended::DownloadCore
|
88
|
+
register '$/solargraph/environment', Extended::Environment
|
89
|
+
register 'shutdown', Shutdown
|
90
|
+
register 'exit', ExitNotification
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
@@ -1,29 +1,40 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require '
|
3
|
+
require 'rubocop'
|
4
|
+
require 'securerandom'
|
5
5
|
|
6
6
|
module Solargraph
|
7
7
|
module LanguageServer
|
8
8
|
module Message
|
9
9
|
module TextDocument
|
10
10
|
class Formatting < Base
|
11
|
+
include Solargraph::Diagnostics::RubocopHelpers
|
12
|
+
|
11
13
|
def process
|
12
14
|
filename = uri_to_file(params['textDocument']['uri'])
|
13
|
-
|
15
|
+
# Make the temp file in the original file's directory so RuboCop
|
16
|
+
# detects the correct configuration
|
17
|
+
tempfile = File.join(File.dirname(filename), "_tmp_#{SecureRandom.hex(8)}_#{File.basename(filename)}")
|
14
18
|
original = host.read_text(params['textDocument']['uri'])
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
+
File.write tempfile, original
|
20
|
+
begin
|
21
|
+
options, paths = RuboCop::Options.new.parse(['-a', '-f', 'fi', tempfile])
|
22
|
+
redirect_stdout { RuboCop::Runner.new(options, RuboCop::ConfigStore.new).run(paths) }
|
23
|
+
result = File.read(tempfile)
|
24
|
+
File.unlink tempfile
|
25
|
+
format original, result
|
26
|
+
rescue RuboCop::ValidationError, RuboCop::ConfigNotFoundError => e
|
27
|
+
set_error(Solargraph::LanguageServer::ErrorCodes::INTERNAL_ERROR, "[#{e.class}] #{e.message}")
|
28
|
+
File.unlink tempfile
|
29
|
+
end
|
19
30
|
end
|
20
31
|
|
32
|
+
private
|
33
|
+
|
34
|
+
# @param original [String]
|
35
|
+
# @param result [String]
|
36
|
+
# @return [void]
|
21
37
|
def format original, result
|
22
|
-
lines = result.lines
|
23
|
-
index = lines.index{|l| l.start_with?('====================')}
|
24
|
-
formatted = lines[index+1..-1].join
|
25
|
-
# The response is required to send an explicit range. Text edits
|
26
|
-
# with null ranges get ignored. See castwide/vscode-solargraph#83
|
27
38
|
if original.end_with?("\n")
|
28
39
|
ending = {
|
29
40
|
line: original.lines.length,
|
@@ -45,7 +56,7 @@ module Solargraph
|
|
45
56
|
},
|
46
57
|
end: ending
|
47
58
|
},
|
48
|
-
newText:
|
59
|
+
newText: result
|
49
60
|
}
|
50
61
|
]
|
51
62
|
)
|
@@ -19,7 +19,7 @@ module Solargraph
|
|
19
19
|
if !this_link.nil? && this_link != last_link
|
20
20
|
parts.push this_link
|
21
21
|
end
|
22
|
-
parts.push pin.detail unless pin.is_a?(Pin::Namespace) || pin.detail.nil?
|
22
|
+
parts.push pin.detail.gsub(':', '\\:') unless pin.is_a?(Pin::Namespace) || pin.detail.nil?
|
23
23
|
parts.push pin.documentation unless pin.documentation.nil? or pin.documentation.empty?
|
24
24
|
contents.push parts.join("\n\n") unless parts.empty?
|
25
25
|
last_link = this_link unless this_link.nil?
|
data/lib/solargraph/page.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require 'ostruct'
|
4
4
|
require 'tilt'
|
5
5
|
require 'yard'
|
6
|
-
require 'htmlentities'
|
7
6
|
require 'cgi'
|
8
7
|
|
9
8
|
module Solargraph
|
@@ -30,7 +29,7 @@ module Solargraph
|
|
30
29
|
# @param text [String]
|
31
30
|
# @return [String]
|
32
31
|
def escape text
|
33
|
-
|
32
|
+
CGI.escapeHTML(text)
|
34
33
|
end
|
35
34
|
|
36
35
|
# @param code [String]
|
data/lib/solargraph/pin.rb
CHANGED
data/lib/solargraph/pin/base.rb
CHANGED
@@ -237,7 +237,7 @@ module Solargraph
|
|
237
237
|
# @return [void]
|
238
238
|
def parse_comments
|
239
239
|
# HACK: Avoid a NoMethodError on nil with empty overload tags
|
240
|
-
if comments.empty? || comments.strip.end_with?('@overload')
|
240
|
+
if comments.nil? || comments.empty? || comments.strip.end_with?('@overload')
|
241
241
|
@docstring = nil
|
242
242
|
@directives = []
|
243
243
|
else
|
@@ -1,25 +1,91 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'maruku'
|
4
|
+
require 'yard'
|
3
5
|
require 'reverse_markdown'
|
6
|
+
require 'solargraph/converters/dl'
|
7
|
+
require 'solargraph/converters/dt'
|
8
|
+
require 'solargraph/converters/dd'
|
9
|
+
require 'solargraph/converters/misc'
|
10
|
+
|
11
|
+
# HACK: Setting :html_parser through `Maruku.new` does not work
|
12
|
+
MaRuKu::Globals[:html_parser] = 'nokogiri'
|
4
13
|
|
5
14
|
module Solargraph
|
6
15
|
module Pin
|
7
16
|
# A module to add the Pin::Base#documentation method.
|
8
17
|
#
|
9
18
|
module Documenting
|
19
|
+
# A documentation formatter that either performs Markdown conversion for
|
20
|
+
# text, or applies backticks for code blocks.
|
21
|
+
#
|
22
|
+
class DocSection
|
23
|
+
# @return [String]
|
24
|
+
attr_reader :plaintext
|
25
|
+
|
26
|
+
# @param code [Boolean] True if this section is a code block
|
27
|
+
def initialize code
|
28
|
+
@plaintext = String.new('')
|
29
|
+
@code = code
|
30
|
+
end
|
31
|
+
|
32
|
+
def code?
|
33
|
+
@code
|
34
|
+
end
|
35
|
+
|
36
|
+
# @param text [String]
|
37
|
+
# @return [String]
|
38
|
+
def concat text
|
39
|
+
@plaintext.concat text
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_s
|
43
|
+
return "\n```ruby\n#{@plaintext}#{@plaintext.end_with?("\n") ? '' : "\n"}```\n\n" if code?
|
44
|
+
ReverseMarkdown.convert unescape_brackets(Maruku.new(escape_brackets(@plaintext), on_error: :raise).to_html)
|
45
|
+
rescue MaRuKu::Exception
|
46
|
+
# Maruku exceptions usually indicate that the documentation is in
|
47
|
+
# RDoc syntax.
|
48
|
+
ReverseMarkdown.convert YARD::Templates::Helpers::Markup::RDocMarkup.new(@plaintext).to_html
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
# @param text [String]
|
54
|
+
# @return [String]
|
55
|
+
def escape_brackets text
|
56
|
+
text.gsub(/(\[[^\]]*\])([^\(]|\z)/, '!!!`\1`!!!\2')
|
57
|
+
end
|
58
|
+
|
59
|
+
# @param text [String]
|
60
|
+
# @return [String]
|
61
|
+
def unescape_brackets text
|
62
|
+
text.gsub('!!!`[', '[').gsub(']`!!!', ']')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
10
66
|
# @return [String]
|
11
67
|
def documentation
|
12
68
|
@documentation ||= begin
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
69
|
+
# Using DocSections allows for code blocks that start with an empty
|
70
|
+
# line and at least two spaces of indentation. This is a common
|
71
|
+
# convention in Ruby core documentation, e.g., String#split.
|
72
|
+
sections = [DocSection.new(false)]
|
73
|
+
normalize_indentation(docstring.to_s).gsub(/\t/, ' ').lines.each do |l|
|
74
|
+
if l.strip.empty?
|
75
|
+
sections.last.concat l
|
18
76
|
else
|
19
|
-
|
20
|
-
|
77
|
+
if (l =~ /^ [^\s]/ && sections.last.plaintext =~ /(\r?\n[ \t]*?){2,}$/) || (l.start_with?(' ') && sections.last.code?)
|
78
|
+
# Code block
|
79
|
+
sections.push DocSection.new(true) unless sections.last.code?
|
80
|
+
sections.last.concat l[2..-1]
|
81
|
+
else
|
82
|
+
# Regular documentation
|
83
|
+
sections.push DocSection.new(false) if sections.last.code?
|
84
|
+
sections.last.concat l
|
85
|
+
end
|
21
86
|
end
|
22
|
-
|
87
|
+
end
|
88
|
+
sections.map(&:to_s).join
|
23
89
|
end
|
24
90
|
end
|
25
91
|
|
@@ -39,15 +105,6 @@ module Solargraph
|
|
39
105
|
return line unless spaces.odd?
|
40
106
|
line[1..-1]
|
41
107
|
end
|
42
|
-
|
43
|
-
# @todo This was tested as a simple way to convert some of the more
|
44
|
-
# common markup in documentation to Markdown. We should still look
|
45
|
-
# for a solution, but it'll have to be more robust than this.
|
46
|
-
def unhtml text
|
47
|
-
text.gsub(/\<\/?(code|tt)\>/, '`')
|
48
|
-
.gsub(/\<\/?(em|i)\>/, '*')
|
49
|
-
.gsub(/\<\/?(strong|b)\>/, '**')
|
50
|
-
end
|
51
108
|
end
|
52
109
|
end
|
53
110
|
end
|
data/lib/solargraph/shell.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'thor'
|
4
|
-
require 'backport'
|
5
|
-
require 'benchmark'
|
6
4
|
|
7
5
|
module Solargraph
|
8
6
|
class Shell < Thor
|
@@ -20,6 +18,7 @@ module Solargraph
|
|
20
18
|
option :host, type: :string, aliases: :h, desc: 'The server host', default: '127.0.0.1'
|
21
19
|
option :port, type: :numeric, aliases: :p, desc: 'The server port', default: 7658
|
22
20
|
def socket
|
21
|
+
require 'backport'
|
23
22
|
port = options[:port]
|
24
23
|
port = available_port if port.zero?
|
25
24
|
Backport.run do
|
@@ -36,6 +35,7 @@ module Solargraph
|
|
36
35
|
|
37
36
|
desc 'stdio', 'Run a Solargraph stdio server'
|
38
37
|
def stdio
|
38
|
+
require 'backport'
|
39
39
|
Backport.run do
|
40
40
|
Signal.trap("INT") do
|
41
41
|
Backport.stop
|
@@ -159,6 +159,7 @@ module Solargraph
|
|
159
159
|
option :directory, type: :string, aliases: :d, desc: 'The workspace directory', default: '.'
|
160
160
|
option :verbose, type: :boolean, aliases: :v, desc: 'Verbose output', default: false
|
161
161
|
def scan
|
162
|
+
require 'benchmark'
|
162
163
|
directory = File.realpath(options[:directory])
|
163
164
|
api_map = nil
|
164
165
|
time = Benchmark.measure {
|
@@ -55,21 +55,21 @@ module Solargraph
|
|
55
55
|
def infer_literal_node_type node
|
56
56
|
return nil unless node.is_a?(AST::Node)
|
57
57
|
if node.type == :str || node.type == :dstr
|
58
|
-
return 'String'
|
58
|
+
return '::String'
|
59
59
|
elsif node.type == :array
|
60
|
-
return 'Array'
|
60
|
+
return '::Array'
|
61
61
|
elsif node.type == :hash
|
62
|
-
return 'Hash'
|
62
|
+
return '::Hash'
|
63
63
|
elsif node.type == :int
|
64
|
-
return 'Integer'
|
64
|
+
return '::Integer'
|
65
65
|
elsif node.type == :float
|
66
|
-
return 'Float'
|
66
|
+
return '::Float'
|
67
67
|
elsif node.type == :sym
|
68
|
-
return 'Symbol'
|
68
|
+
return '::Symbol'
|
69
69
|
elsif node.type == :regexp
|
70
|
-
return 'Regexp'
|
70
|
+
return '::Regexp'
|
71
71
|
elsif node.type == :irange
|
72
|
-
return 'Range'
|
72
|
+
return '::Range'
|
73
73
|
# @todo Support `nil` keyword in types
|
74
74
|
# elsif node.type == :nil
|
75
75
|
# return 'NilClass'
|
@@ -104,7 +104,7 @@ module Solargraph
|
|
104
104
|
gen_pin = Solargraph::SourceMap::NodeProcessor.process(src_node, region).first.last
|
105
105
|
return if gen_pin.nil?
|
106
106
|
# @todo: Smelly instance variable access
|
107
|
-
gen_pin.instance_variable_set(:@comments, docstring.all)
|
107
|
+
gen_pin.instance_variable_set(:@comments, docstring.all.to_s)
|
108
108
|
@pins.push gen_pin
|
109
109
|
when 'attribute'
|
110
110
|
return if directive.tag.name.nil?
|
@@ -115,7 +115,7 @@ module Solargraph
|
|
115
115
|
location: location,
|
116
116
|
closure: namespace,
|
117
117
|
name: directive.tag.name,
|
118
|
-
comments: docstring.all,
|
118
|
+
comments: docstring.all.to_s,
|
119
119
|
access: :reader,
|
120
120
|
scope: namespace.is_a?(Pin::Singleton) ? :class : :instance,
|
121
121
|
visibility: :public
|
@@ -126,7 +126,7 @@ module Solargraph
|
|
126
126
|
location: location,
|
127
127
|
closure: namespace,
|
128
128
|
name: "#{directive.tag.name}=",
|
129
|
-
comments: docstring.all,
|
129
|
+
comments: docstring.all.to_s,
|
130
130
|
access: :writer,
|
131
131
|
scope: namespace.is_a?(Pin::Singleton) ? :class : :instance,
|
132
132
|
visibility: :public
|
@@ -231,8 +231,15 @@ module Solargraph
|
|
231
231
|
else
|
232
232
|
argtype = arg.infer(api_map, block, locals)
|
233
233
|
if !arg_to_duck(argtype, partype)
|
234
|
-
|
235
|
-
|
234
|
+
match = false
|
235
|
+
partype.each do |pt|
|
236
|
+
if argtype.tag == pt.tag || api_map.super_and_sub?(pt.tag.to_s, argtype.tag.to_s)
|
237
|
+
match = true
|
238
|
+
break
|
239
|
+
end
|
240
|
+
end
|
241
|
+
unless match
|
242
|
+
result.push Problem.new(Solargraph::Location.new(filename, Solargraph::Range.from_node(node)), "Wrong parameter type for #{pin.path}: #{pin.parameter_names[index]} expected [#{partype}], received [#{argtype.tag}]")
|
236
243
|
end
|
237
244
|
end
|
238
245
|
end
|
data/lib/solargraph/version.rb
CHANGED
data/lib/solargraph/yard_map.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'yard'
|
4
|
+
require 'yard-solargraph'
|
5
|
+
require 'rubygems/package'
|
4
6
|
|
5
7
|
module Solargraph
|
6
8
|
# The YardMap provides access to YARD documentation for the Ruby core, the
|
@@ -18,7 +20,7 @@ module Solargraph
|
|
18
20
|
@@stdlib_paths = {}
|
19
21
|
YARD::Registry.load! @@stdlib_yardoc
|
20
22
|
YARD::Registry.all(:class, :module).each do |ns|
|
21
|
-
next if ns.file.nil?
|
23
|
+
next if ns.nil? || ns.file.nil?
|
22
24
|
path = ns.file.sub(/^(ext|lib)\//, '').sub(/\.(rb|c)$/, '')
|
23
25
|
next if path.start_with?('-')
|
24
26
|
@@stdlib_paths[path] ||= []
|
@@ -291,3 +293,7 @@ module Solargraph
|
|
291
293
|
end
|
292
294
|
end
|
293
295
|
end
|
296
|
+
|
297
|
+
Solargraph::YardMap::CoreDocs.require_minimum
|
298
|
+
# Change YARD log IO to avoid sending unexpected messages to STDOUT
|
299
|
+
YARD::Logger.instance.io = File.new(File::NULL, 'w')
|
data/solargraph.gemspec
CHANGED
@@ -21,8 +21,8 @@ Gem::Specification.new do |s|
|
|
21
21
|
|
22
22
|
s.add_runtime_dependency 'backport', '~> 1.1'
|
23
23
|
s.add_runtime_dependency 'bundler', '>= 1.17.2'
|
24
|
-
s.add_runtime_dependency 'htmlentities', '~> 4.3', '>= 4.3.4'
|
25
24
|
s.add_runtime_dependency 'jaro_winkler', '~> 1.5'
|
25
|
+
s.add_runtime_dependency 'maruku', '~> 0.7', '>= 0.7.3'
|
26
26
|
s.add_runtime_dependency 'nokogiri', '~> 1.9', '>= 1.9.1'
|
27
27
|
s.add_runtime_dependency 'parser', '~> 2.3'
|
28
28
|
s.add_runtime_dependency 'reverse_markdown', '~> 1.0', '>= 1.0.5'
|
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.
|
4
|
+
version: 0.38.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backport
|
@@ -39,39 +39,39 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.17.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: jaro_winkler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
-
- - ">="
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: 4.3.4
|
47
|
+
version: '1.5'
|
51
48
|
type: :runtime
|
52
49
|
prerelease: false
|
53
50
|
version_requirements: !ruby/object:Gem::Requirement
|
54
51
|
requirements:
|
55
52
|
- - "~>"
|
56
53
|
- !ruby/object:Gem::Version
|
57
|
-
version: '
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: 4.3.4
|
54
|
+
version: '1.5'
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
56
|
+
name: maruku
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
64
58
|
requirements:
|
65
59
|
- - "~>"
|
66
60
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
61
|
+
version: '0.7'
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 0.7.3
|
68
65
|
type: :runtime
|
69
66
|
prerelease: false
|
70
67
|
version_requirements: !ruby/object:Gem::Requirement
|
71
68
|
requirements:
|
72
69
|
- - "~>"
|
73
70
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
71
|
+
version: '0.7'
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.7.3
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: nokogiri
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -283,6 +283,10 @@ files:
|
|
283
283
|
- lib/solargraph/convention/gemfile.rb
|
284
284
|
- lib/solargraph/convention/gemspec.rb
|
285
285
|
- lib/solargraph/convention/rspec.rb
|
286
|
+
- lib/solargraph/converters/dd.rb
|
287
|
+
- lib/solargraph/converters/dl.rb
|
288
|
+
- lib/solargraph/converters/dt.rb
|
289
|
+
- lib/solargraph/converters/misc.rb
|
286
290
|
- lib/solargraph/core_fills.rb
|
287
291
|
- lib/solargraph/diagnostics.rb
|
288
292
|
- lib/solargraph/diagnostics/base.rb
|