solargraph 0.58.2 → 0.58.3
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/.github/workflows/plugins.yml +3 -2
- data/CHANGELOG.md +3 -0
- data/lib/solargraph/bench.rb +45 -45
- data/lib/solargraph/convention/data_definition/data_assignment_node.rb +61 -61
- data/lib/solargraph/convention/gemfile.rb +15 -15
- data/lib/solargraph/convention/gemspec.rb +23 -23
- data/lib/solargraph/convention/rakefile.rb +17 -17
- data/lib/solargraph/convention.rb +78 -78
- data/lib/solargraph/converters/dd.rb +17 -17
- data/lib/solargraph/converters/dl.rb +15 -15
- data/lib/solargraph/converters/dt.rb +15 -15
- data/lib/solargraph/converters/misc.rb +1 -1
- data/lib/solargraph/diagnostics/update_errors.rb +41 -41
- data/lib/solargraph/language_server/error_codes.rb +20 -20
- data/lib/solargraph/language_server/message/base.rb +97 -97
- data/lib/solargraph/language_server/message/client/register_capability.rb +15 -15
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +60 -60
- data/lib/solargraph/language_server/message/extended/document_gems.rb +32 -32
- data/lib/solargraph/language_server/message/extended/download_core.rb +19 -19
- data/lib/solargraph/language_server/message/extended/search.rb +20 -20
- data/lib/solargraph/language_server/message/initialize.rb +191 -191
- data/lib/solargraph/language_server/message/text_document/document_highlight.rb +16 -16
- data/lib/solargraph/language_server/message/text_document/prepare_rename.rb +11 -11
- data/lib/solargraph/language_server/message/text_document/references.rb +16 -16
- data/lib/solargraph/language_server/message/text_document/rename.rb +19 -19
- data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +35 -35
- data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +40 -40
- data/lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb +26 -26
- data/lib/solargraph/language_server/message.rb +94 -94
- data/lib/solargraph/language_server/request.rb +27 -27
- data/lib/solargraph/language_server/transport/data_reader.rb +74 -74
- data/lib/solargraph/language_server/uri_helpers.rb +49 -49
- data/lib/solargraph/page.rb +92 -92
- data/lib/solargraph/parser/parser_gem/flawed_builder.rb +19 -19
- data/lib/solargraph/parser/parser_gem/node_processors/defs_node.rb +37 -37
- data/lib/solargraph/parser/parser_gem/node_processors/until_node.rb +29 -29
- data/lib/solargraph/parser/parser_gem.rb +12 -12
- data/lib/solargraph/parser.rb +23 -23
- data/lib/solargraph/pin/constant.rb +45 -45
- data/lib/solargraph/rbs_map/core_fills.rb +84 -84
- data/lib/solargraph/server_methods.rb +16 -16
- data/lib/solargraph/shell.rb +14 -3
- data/lib/solargraph/source/chain/array.rb +37 -37
- data/lib/solargraph/source/chain/class_variable.rb +13 -13
- data/lib/solargraph/source/chain/global_variable.rb +13 -13
- data/lib/solargraph/source/chain/link.rb +109 -109
- data/lib/solargraph/source/chain/q_call.rb +11 -11
- data/lib/solargraph/source/chain/variable.rb +13 -13
- data/lib/solargraph/source/chain/z_super.rb +30 -30
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/yard_tags.rb +20 -20
- metadata +2 -2
data/lib/solargraph/page.rb
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'ostruct'
|
|
4
|
-
require 'tilt'
|
|
5
|
-
require 'yard'
|
|
6
|
-
require 'cgi'
|
|
7
|
-
|
|
8
|
-
module Solargraph
|
|
9
|
-
class Page
|
|
10
|
-
# @todo This method directive is necessary because OpenStruct.new confuses
|
|
11
|
-
# the typechecker.
|
|
12
|
-
# @!method self.new(locals, render_method)
|
|
13
|
-
# @param locals[Hash]
|
|
14
|
-
# @param render_method [Proc]
|
|
15
|
-
# @return [Binder]
|
|
16
|
-
class Binder < OpenStruct
|
|
17
|
-
# @param locals [Hash]
|
|
18
|
-
# @param render_method [Proc]
|
|
19
|
-
def initialize locals, render_method
|
|
20
|
-
super(locals)
|
|
21
|
-
define_singleton_method :render do |template, layout: false, locals: {}|
|
|
22
|
-
render_method.call(template, layout: layout, locals: locals)
|
|
23
|
-
end
|
|
24
|
-
define_singleton_method :erb do |template, layout: false, locals: {}|
|
|
25
|
-
render_method.call(template, layout: layout, locals: locals)
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# @param text [String]
|
|
30
|
-
# @return [String]
|
|
31
|
-
def htmlify text
|
|
32
|
-
# @type [String]
|
|
33
|
-
YARD::Templates::Helpers::Markup::RDocMarkup.new(text).to_html
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# @param text [String]
|
|
37
|
-
# @return [String]
|
|
38
|
-
def escape text
|
|
39
|
-
CGI.escapeHTML(text)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# @param code [String]
|
|
43
|
-
# @return [String]
|
|
44
|
-
def ruby_to_html code
|
|
45
|
-
code
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
private_constant :Binder
|
|
49
|
-
|
|
50
|
-
# @param directory [String]
|
|
51
|
-
def initialize directory = VIEWS_PATH
|
|
52
|
-
directory = VIEWS_PATH if directory.nil? or !File.directory?(directory)
|
|
53
|
-
directories = [directory]
|
|
54
|
-
directories.push VIEWS_PATH if directory != VIEWS_PATH
|
|
55
|
-
# @type [Proc]
|
|
56
|
-
# @param template [String]
|
|
57
|
-
# @param layout [Boolean]
|
|
58
|
-
# @param locals [Hash]
|
|
59
|
-
@render_method = proc { |template, layout: false, locals: {}|
|
|
60
|
-
binder = Binder.new(locals, @render_method)
|
|
61
|
-
if layout
|
|
62
|
-
Tilt::ERBTemplate.new(Page.select_template(directories, 'layout')).render(binder) do
|
|
63
|
-
Tilt::ERBTemplate.new(Page.select_template(directories, template)).render(binder)
|
|
64
|
-
end
|
|
65
|
-
else
|
|
66
|
-
Tilt::ERBTemplate.new(Page.select_template(directories, template)).render(binder)
|
|
67
|
-
end
|
|
68
|
-
}
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
# @param template [String]
|
|
72
|
-
# @param layout [Boolean]
|
|
73
|
-
# @param locals [Hash]
|
|
74
|
-
# @sg-ignore
|
|
75
|
-
# @return [String]
|
|
76
|
-
def render template, layout: true, locals: {}
|
|
77
|
-
# @type [String]
|
|
78
|
-
@render_method.call(template, layout: layout, locals: locals)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
# @param directories [Array<String>]
|
|
82
|
-
# @param name [String]
|
|
83
|
-
# @return [String]
|
|
84
|
-
def self.select_template directories, name
|
|
85
|
-
directories.each do |dir|
|
|
86
|
-
path = File.join(dir, "#{name}.erb")
|
|
87
|
-
return path if File.file?(path)
|
|
88
|
-
end
|
|
89
|
-
raise FileNotFoundError, "Template not found: #{name}"
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'ostruct'
|
|
4
|
+
require 'tilt'
|
|
5
|
+
require 'yard'
|
|
6
|
+
require 'cgi'
|
|
7
|
+
|
|
8
|
+
module Solargraph
|
|
9
|
+
class Page
|
|
10
|
+
# @todo This method directive is necessary because OpenStruct.new confuses
|
|
11
|
+
# the typechecker.
|
|
12
|
+
# @!method self.new(locals, render_method)
|
|
13
|
+
# @param locals[Hash]
|
|
14
|
+
# @param render_method [Proc]
|
|
15
|
+
# @return [Binder]
|
|
16
|
+
class Binder < OpenStruct
|
|
17
|
+
# @param locals [Hash]
|
|
18
|
+
# @param render_method [Proc]
|
|
19
|
+
def initialize locals, render_method
|
|
20
|
+
super(locals)
|
|
21
|
+
define_singleton_method :render do |template, layout: false, locals: {}|
|
|
22
|
+
render_method.call(template, layout: layout, locals: locals)
|
|
23
|
+
end
|
|
24
|
+
define_singleton_method :erb do |template, layout: false, locals: {}|
|
|
25
|
+
render_method.call(template, layout: layout, locals: locals)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# @param text [String]
|
|
30
|
+
# @return [String]
|
|
31
|
+
def htmlify text
|
|
32
|
+
# @type [String]
|
|
33
|
+
YARD::Templates::Helpers::Markup::RDocMarkup.new(text).to_html
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# @param text [String]
|
|
37
|
+
# @return [String]
|
|
38
|
+
def escape text
|
|
39
|
+
CGI.escapeHTML(text)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# @param code [String]
|
|
43
|
+
# @return [String]
|
|
44
|
+
def ruby_to_html code
|
|
45
|
+
code
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
private_constant :Binder
|
|
49
|
+
|
|
50
|
+
# @param directory [String]
|
|
51
|
+
def initialize directory = VIEWS_PATH
|
|
52
|
+
directory = VIEWS_PATH if directory.nil? or !File.directory?(directory)
|
|
53
|
+
directories = [directory]
|
|
54
|
+
directories.push VIEWS_PATH if directory != VIEWS_PATH
|
|
55
|
+
# @type [Proc]
|
|
56
|
+
# @param template [String]
|
|
57
|
+
# @param layout [Boolean]
|
|
58
|
+
# @param locals [Hash]
|
|
59
|
+
@render_method = proc { |template, layout: false, locals: {}|
|
|
60
|
+
binder = Binder.new(locals, @render_method)
|
|
61
|
+
if layout
|
|
62
|
+
Tilt::ERBTemplate.new(Page.select_template(directories, 'layout')).render(binder) do
|
|
63
|
+
Tilt::ERBTemplate.new(Page.select_template(directories, template)).render(binder)
|
|
64
|
+
end
|
|
65
|
+
else
|
|
66
|
+
Tilt::ERBTemplate.new(Page.select_template(directories, template)).render(binder)
|
|
67
|
+
end
|
|
68
|
+
}
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# @param template [String]
|
|
72
|
+
# @param layout [Boolean]
|
|
73
|
+
# @param locals [Hash]
|
|
74
|
+
# @sg-ignore
|
|
75
|
+
# @return [String]
|
|
76
|
+
def render template, layout: true, locals: {}
|
|
77
|
+
# @type [String]
|
|
78
|
+
@render_method.call(template, layout: layout, locals: locals)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# @param directories [Array<String>]
|
|
82
|
+
# @param name [String]
|
|
83
|
+
# @return [String]
|
|
84
|
+
def self.select_template directories, name
|
|
85
|
+
directories.each do |dir|
|
|
86
|
+
path = File.join(dir, "#{name}.erb")
|
|
87
|
+
return path if File.file?(path)
|
|
88
|
+
end
|
|
89
|
+
raise FileNotFoundError, "Template not found: #{name}"
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module Parser
|
|
5
|
-
module ParserGem
|
|
6
|
-
# A custom builder for source parsers that ignores character encoding
|
|
7
|
-
# issues in literal strings.
|
|
8
|
-
#
|
|
9
|
-
class FlawedBuilder < ::Parser::Builders::Default
|
|
10
|
-
# @param token [::Parser::AST::Node]
|
|
11
|
-
# @return [String]
|
|
12
|
-
# @sg-ignore
|
|
13
|
-
def string_value(token)
|
|
14
|
-
value(token)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Parser
|
|
5
|
+
module ParserGem
|
|
6
|
+
# A custom builder for source parsers that ignores character encoding
|
|
7
|
+
# issues in literal strings.
|
|
8
|
+
#
|
|
9
|
+
class FlawedBuilder < ::Parser::Builders::Default
|
|
10
|
+
# @param token [::Parser::AST::Node]
|
|
11
|
+
# @return [String]
|
|
12
|
+
# @sg-ignore
|
|
13
|
+
def string_value(token)
|
|
14
|
+
value(token)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module Parser
|
|
5
|
-
module ParserGem
|
|
6
|
-
module NodeProcessors
|
|
7
|
-
class DefsNode < DefNode
|
|
8
|
-
include ParserGem::NodeMethods
|
|
9
|
-
|
|
10
|
-
def process
|
|
11
|
-
s_visi = region.visibility
|
|
12
|
-
s_visi = :public if s_visi == :module_function || region.scope != :class
|
|
13
|
-
loc = get_node_location(node)
|
|
14
|
-
if node.children[0].is_a?(AST::Node) && node.children[0].type == :self
|
|
15
|
-
closure = region.closure
|
|
16
|
-
else
|
|
17
|
-
closure = Solargraph::Pin::Namespace.new(
|
|
18
|
-
name: unpack_name(node.children[0])
|
|
19
|
-
)
|
|
20
|
-
end
|
|
21
|
-
pins.push Solargraph::Pin::Method.new(
|
|
22
|
-
location: loc,
|
|
23
|
-
closure: closure,
|
|
24
|
-
name: node.children[1].to_s,
|
|
25
|
-
comments: comments_for(node),
|
|
26
|
-
scope: :class,
|
|
27
|
-
visibility: s_visi,
|
|
28
|
-
node: node,
|
|
29
|
-
source: :parser,
|
|
30
|
-
)
|
|
31
|
-
process_children region.update(closure: pins.last, scope: :class)
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Parser
|
|
5
|
+
module ParserGem
|
|
6
|
+
module NodeProcessors
|
|
7
|
+
class DefsNode < DefNode
|
|
8
|
+
include ParserGem::NodeMethods
|
|
9
|
+
|
|
10
|
+
def process
|
|
11
|
+
s_visi = region.visibility
|
|
12
|
+
s_visi = :public if s_visi == :module_function || region.scope != :class
|
|
13
|
+
loc = get_node_location(node)
|
|
14
|
+
if node.children[0].is_a?(AST::Node) && node.children[0].type == :self
|
|
15
|
+
closure = region.closure
|
|
16
|
+
else
|
|
17
|
+
closure = Solargraph::Pin::Namespace.new(
|
|
18
|
+
name: unpack_name(node.children[0])
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
pins.push Solargraph::Pin::Method.new(
|
|
22
|
+
location: loc,
|
|
23
|
+
closure: closure,
|
|
24
|
+
name: node.children[1].to_s,
|
|
25
|
+
comments: comments_for(node),
|
|
26
|
+
scope: :class,
|
|
27
|
+
visibility: s_visi,
|
|
28
|
+
node: node,
|
|
29
|
+
source: :parser,
|
|
30
|
+
)
|
|
31
|
+
process_children region.update(closure: pins.last, scope: :class)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module Parser
|
|
5
|
-
module ParserGem
|
|
6
|
-
module NodeProcessors
|
|
7
|
-
class UntilNode < Parser::NodeProcessor::Base
|
|
8
|
-
include ParserGem::NodeMethods
|
|
9
|
-
|
|
10
|
-
def process
|
|
11
|
-
location = get_node_location(node)
|
|
12
|
-
# Note - this should not be considered a block, as the
|
|
13
|
-
# until statement doesn't create a closure - e.g.,
|
|
14
|
-
# variables created inside can be seen from outside as
|
|
15
|
-
# well
|
|
16
|
-
pins.push Solargraph::Pin::Until.new(
|
|
17
|
-
location: location,
|
|
18
|
-
closure: region.closure,
|
|
19
|
-
node: node,
|
|
20
|
-
comments: comments_for(node),
|
|
21
|
-
source: :parser,
|
|
22
|
-
)
|
|
23
|
-
process_children region
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Parser
|
|
5
|
+
module ParserGem
|
|
6
|
+
module NodeProcessors
|
|
7
|
+
class UntilNode < Parser::NodeProcessor::Base
|
|
8
|
+
include ParserGem::NodeMethods
|
|
9
|
+
|
|
10
|
+
def process
|
|
11
|
+
location = get_node_location(node)
|
|
12
|
+
# Note - this should not be considered a block, as the
|
|
13
|
+
# until statement doesn't create a closure - e.g.,
|
|
14
|
+
# variables created inside can be seen from outside as
|
|
15
|
+
# well
|
|
16
|
+
pins.push Solargraph::Pin::Until.new(
|
|
17
|
+
location: location,
|
|
18
|
+
closure: region.closure,
|
|
19
|
+
node: node,
|
|
20
|
+
comments: comments_for(node),
|
|
21
|
+
source: :parser,
|
|
22
|
+
)
|
|
23
|
+
process_children region
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
module Solargraph
|
|
2
|
-
module Parser
|
|
3
|
-
module ParserGem
|
|
4
|
-
autoload :FlawedBuilder, 'solargraph/parser/parser_gem/flawed_builder'
|
|
5
|
-
autoload :ClassMethods, 'solargraph/parser/parser_gem/class_methods'
|
|
6
|
-
autoload :NodeMethods, 'solargraph/parser/parser_gem/node_methods'
|
|
7
|
-
autoload :NodeChainer, 'solargraph/parser/parser_gem/node_chainer'
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
require 'solargraph/parser/parser_gem/node_processors'
|
|
1
|
+
module Solargraph
|
|
2
|
+
module Parser
|
|
3
|
+
module ParserGem
|
|
4
|
+
autoload :FlawedBuilder, 'solargraph/parser/parser_gem/flawed_builder'
|
|
5
|
+
autoload :ClassMethods, 'solargraph/parser/parser_gem/class_methods'
|
|
6
|
+
autoload :NodeMethods, 'solargraph/parser/parser_gem/node_methods'
|
|
7
|
+
autoload :NodeChainer, 'solargraph/parser/parser_gem/node_chainer'
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
require 'solargraph/parser/parser_gem/node_processors'
|
data/lib/solargraph/parser.rb
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
module Solargraph
|
|
2
|
-
module Parser
|
|
3
|
-
autoload :CommentRipper, 'solargraph/parser/comment_ripper'
|
|
4
|
-
autoload :ParserGem, 'solargraph/parser/parser_gem'
|
|
5
|
-
autoload :Region, 'solargraph/parser/region'
|
|
6
|
-
autoload :NodeProcessor, 'solargraph/parser/node_processor'
|
|
7
|
-
autoload :FlowSensitiveTyping, 'solargraph/parser/flow_sensitive_typing'
|
|
8
|
-
autoload :Snippet, 'solargraph/parser/snippet'
|
|
9
|
-
|
|
10
|
-
class SyntaxError < StandardError
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
# @deprecated
|
|
14
|
-
Legacy = ParserGem
|
|
15
|
-
|
|
16
|
-
ClassMethods = ParserGem::ClassMethods
|
|
17
|
-
# @todo should be able to just 'extend ClassMethods' here and
|
|
18
|
-
# typecheck things off it in strict mode
|
|
19
|
-
extend ParserGem::ClassMethods
|
|
20
|
-
|
|
21
|
-
NodeMethods = ParserGem::NodeMethods
|
|
22
|
-
end
|
|
23
|
-
end
|
|
1
|
+
module Solargraph
|
|
2
|
+
module Parser
|
|
3
|
+
autoload :CommentRipper, 'solargraph/parser/comment_ripper'
|
|
4
|
+
autoload :ParserGem, 'solargraph/parser/parser_gem'
|
|
5
|
+
autoload :Region, 'solargraph/parser/region'
|
|
6
|
+
autoload :NodeProcessor, 'solargraph/parser/node_processor'
|
|
7
|
+
autoload :FlowSensitiveTyping, 'solargraph/parser/flow_sensitive_typing'
|
|
8
|
+
autoload :Snippet, 'solargraph/parser/snippet'
|
|
9
|
+
|
|
10
|
+
class SyntaxError < StandardError
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# @deprecated
|
|
14
|
+
Legacy = ParserGem
|
|
15
|
+
|
|
16
|
+
ClassMethods = ParserGem::ClassMethods
|
|
17
|
+
# @todo should be able to just 'extend ClassMethods' here and
|
|
18
|
+
# typecheck things off it in strict mode
|
|
19
|
+
extend ParserGem::ClassMethods
|
|
20
|
+
|
|
21
|
+
NodeMethods = ParserGem::NodeMethods
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module Pin
|
|
5
|
-
class Constant < BaseVariable
|
|
6
|
-
attr_reader :visibility
|
|
7
|
-
|
|
8
|
-
# @param visibility [::Symbol] The visibility of the constant (:public, :protected, or :private)
|
|
9
|
-
# @param splat [Hash] Additional options supported by superclasses
|
|
10
|
-
def initialize visibility: :public, **splat
|
|
11
|
-
super(**splat)
|
|
12
|
-
@visibility = visibility
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def return_type
|
|
16
|
-
@return_type ||= generate_complex_type
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def completion_item_kind
|
|
20
|
-
Solargraph::LanguageServer::CompletionItemKinds::CONSTANT
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# @return [Integer]
|
|
24
|
-
def symbol_kind
|
|
25
|
-
LanguageServer::SymbolKinds::CONSTANT
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def path
|
|
29
|
-
@path ||= context.namespace.to_s.empty? ? name : "#{context.namespace}::#{name}"
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
private
|
|
33
|
-
|
|
34
|
-
# @return [ComplexType]
|
|
35
|
-
def generate_complex_type
|
|
36
|
-
tags = docstring.tags(:return).map(&:types).flatten.reject(&:nil?)
|
|
37
|
-
if tags.empty?
|
|
38
|
-
tags = docstring.tags(:type).map(&:types).flatten.reject(&:nil?)
|
|
39
|
-
end
|
|
40
|
-
return ComplexType::UNDEFINED if tags.empty?
|
|
41
|
-
ComplexType.try_parse *tags
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Pin
|
|
5
|
+
class Constant < BaseVariable
|
|
6
|
+
attr_reader :visibility
|
|
7
|
+
|
|
8
|
+
# @param visibility [::Symbol] The visibility of the constant (:public, :protected, or :private)
|
|
9
|
+
# @param splat [Hash] Additional options supported by superclasses
|
|
10
|
+
def initialize visibility: :public, **splat
|
|
11
|
+
super(**splat)
|
|
12
|
+
@visibility = visibility
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def return_type
|
|
16
|
+
@return_type ||= generate_complex_type
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def completion_item_kind
|
|
20
|
+
Solargraph::LanguageServer::CompletionItemKinds::CONSTANT
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# @return [Integer]
|
|
24
|
+
def symbol_kind
|
|
25
|
+
LanguageServer::SymbolKinds::CONSTANT
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def path
|
|
29
|
+
@path ||= context.namespace.to_s.empty? ? name : "#{context.namespace}::#{name}"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
# @return [ComplexType]
|
|
35
|
+
def generate_complex_type
|
|
36
|
+
tags = docstring.tags(:return).map(&:types).flatten.reject(&:nil?)
|
|
37
|
+
if tags.empty?
|
|
38
|
+
tags = docstring.tags(:type).map(&:types).flatten.reject(&:nil?)
|
|
39
|
+
end
|
|
40
|
+
return ComplexType::UNDEFINED if tags.empty?
|
|
41
|
+
ComplexType.try_parse *tags
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|