solargraph 0.20.0 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/lib/solargraph.rb +2 -3
  3. data/lib/solargraph/api_map.rb +6 -6
  4. data/lib/solargraph/api_map/source_to_yard.rb +1 -1
  5. data/lib/solargraph/language_server/host.rb +69 -10
  6. data/lib/solargraph/language_server/message.rb +1 -2
  7. data/lib/solargraph/language_server/message/initialize.rb +83 -15
  8. data/lib/solargraph/language_server/message/initialized.rb +7 -0
  9. data/lib/solargraph/language_server/message/text_document/formatting.rb +4 -1
  10. data/lib/solargraph/language_server/message/text_document/on_type_formatting.rb +20 -19
  11. data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +19 -1
  12. data/lib/solargraph/language_server/request.rb +1 -1
  13. data/lib/solargraph/language_server/transport.rb +1 -0
  14. data/lib/solargraph/language_server/transport/data_reader.rb +66 -0
  15. data/lib/solargraph/language_server/transport/socket.rb +8 -32
  16. data/lib/solargraph/library.rb +11 -6
  17. data/lib/solargraph/page.rb +1 -1
  18. data/lib/solargraph/pin/base.rb +8 -7
  19. data/lib/solargraph/pin/method_parameter.rb +2 -15
  20. data/lib/solargraph/pin/yard_object.rb +1 -1
  21. data/lib/solargraph/plugin/runtime.rb +0 -2
  22. data/lib/solargraph/shell.rb +0 -24
  23. data/lib/solargraph/source.rb +5 -169
  24. data/lib/solargraph/source/mapper.rb +8 -3
  25. data/lib/solargraph/version.rb +1 -1
  26. data/lib/solargraph/workspace.rb +3 -3
  27. data/lib/solargraph/workspace/config.rb +7 -9
  28. data/lib/solargraph/yard_map.rb +9 -48
  29. metadata +17 -74
  30. data/lib/solargraph/server.rb +0 -212
  31. data/lib/solargraph/suggestion.rb +0 -178
@@ -1,178 +0,0 @@
1
- require 'json'
2
-
3
- module Solargraph
4
- # Information about a class, module, method, or variable.
5
- #
6
- class Suggestion
7
- CLASS = 'Class'
8
- CONSTANT = 'Constant'
9
- FIELD = 'Field'
10
- KEYWORD = 'Keyword'
11
- METHOD = 'Method'
12
- MODULE = 'Module'
13
- PROPERTY = 'Property'
14
- VARIABLE = 'Variable'
15
-
16
- # @return [String]
17
- attr_reader :label
18
-
19
- # @return [String]
20
- def kind
21
- case @kind
22
- when Solargraph::LanguageServer::CompletionItemKinds::CLASS
23
- 'Class'
24
- when Solargraph::LanguageServer::CompletionItemKinds::CONSTANT
25
- 'Constant'
26
- when Solargraph::LanguageServer::CompletionItemKinds::FIELD
27
- 'Field'
28
- when Solargraph::LanguageServer::CompletionItemKinds::KEYWORD
29
- 'Keyword'
30
- when Solargraph::LanguageServer::CompletionItemKinds::METHOD
31
- 'Method'
32
- when Solargraph::LanguageServer::CompletionItemKinds::MODULE
33
- 'Module'
34
- when Solargraph::LanguageServer::CompletionItemKinds::PROPERTY
35
- 'Property'
36
- when Solargraph::LanguageServer::CompletionItemKinds::VARIABLE
37
- 'Variable'
38
- else
39
- nil
40
- end
41
- end
42
-
43
- # @return [String]
44
- attr_reader :insert
45
-
46
- # @return [String]
47
- attr_reader :detail
48
-
49
- # @return [YARD::CodeObjects::Base]
50
- #attr_reader :code_object
51
-
52
- # @return [String]
53
- attr_reader :location
54
-
55
- # @return [Array<String>]
56
- attr_reader :arguments
57
-
58
- # @return [YARD::CodeObjects::Base]
59
- attr_reader :code_object
60
-
61
- # @return [Solargraph::Pin::Base]
62
- attr_reader :pin
63
-
64
- def initialize label, kind: KEYWORD, insert: nil, detail: nil, docstring: nil, code_object: nil, location: nil, arguments: [], return_type: nil, path: nil, pin: nil
65
- @helper = Server::Helpers.new
66
- @label = label.to_s
67
- @kind = kind
68
- @insert = insert || @label
69
- @detail = detail
70
- @code_object = code_object
71
- @docstring = docstring
72
- @location = location
73
- @arguments = arguments
74
- @return_type = return_type
75
- @path = path
76
- @pin = pin
77
- end
78
-
79
- # The full path of the suggestion.
80
- #
81
- # Examples:
82
- # - MyClass
83
- # - MyModule::MyClass
84
- # - MyClass#instance_method
85
- # - MyModule.singleton_method
86
- #
87
- # @return [String]
88
- def path
89
- @path ||= (code_object.nil? ? label : code_object.path)
90
- end
91
-
92
- def namespace
93
- @namespace ||= path.split(/[#\.]/)[0]
94
- end
95
-
96
- # @return [String]
97
- def to_s
98
- label
99
- end
100
-
101
- # @return [String]
102
- def return_type
103
- if @return_type.nil? and !docstring.nil?
104
- ol = docstring.tag(:overload)
105
- t = ol.nil? ? docstring.tag(:return) : ol.tag(:return)
106
- @return_type = t.types[0] unless t.nil? or t.types.nil?
107
- end
108
- @return_type
109
- end
110
-
111
- # @return [YARD::Docstring]
112
- def docstring
113
- @docstring ||= @code_object.nil? ? nil : @code_object.docstring
114
- end
115
-
116
- # @return [String]
117
- def documentation
118
- @documentation ||= (docstring.nil? ? '' : @helper.html_markup_rdoc(docstring))
119
- end
120
-
121
- # @return [Array<String>]
122
- def params
123
- if @params.nil?
124
- @params = []
125
- return @params if docstring.nil?
126
- param_tags = docstring.tags(:param)
127
- unless param_tags.empty?
128
- param_tags.each do |t|
129
- txt = t.name.to_s
130
- txt += " [#{t.types.join(',')}]" unless t.types.nil? or t.types.empty?
131
- txt += " #{t.text}" unless t.text.nil? or t.text.empty?
132
- @params.push txt
133
- end
134
- end
135
- end
136
- @params
137
- end
138
-
139
- # True if the suggestion has documentation.
140
- # Useful for determining whether a client should resolve a suggestion's
141
- # path to retrieve more information about it.
142
- #
143
- # @return [Boolean]
144
- def has_doc?
145
- #!documentation.empty?
146
- !docstring.nil? and !docstring.all.empty?
147
- end
148
-
149
- def as_json args = {}
150
- result = {
151
- label: @label,
152
- kind: kind,
153
- insert: @insert,
154
- detail: @detail,
155
- path: path,
156
- location: (@location.nil? ? nil : @location.to_s),
157
- arguments: @arguments,
158
- params: params,
159
- return_type: return_type,
160
- has_doc: has_doc?
161
- }
162
- result[:documentation] = documentation if args[:all]
163
- result
164
- end
165
-
166
- def to_json args = {}
167
- as_json.to_json(args)
168
- end
169
-
170
- # Generate a suggestion from a pin.
171
- #
172
- # @param pin [Solargraph::Pin::Base]
173
- def self.pull pin, return_type = nil
174
- return pin if pin.kind_of?(Suggestion)
175
- Suggestion.new(pin.name, insert: pin.name.gsub(/=$/, ' = '), kind: pin.kind, docstring: pin.docstring, detail: pin.namespace, arguments: pin.parameters, path: pin.path, return_type: return_type || pin.return_type, location: pin.location, pin: pin)
176
- end
177
- end
178
- end