solargraph 0.32.1 → 0.32.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.rubocop.yml +6 -0
- data/.travis.yml +25 -0
- data/EXAMPLES.md +76 -0
- data/Gemfile +3 -0
- data/LANGUAGE_SERVER.md +51 -0
- data/LICENSE +21 -0
- data/OVERVIEW.md +37 -0
- data/README.md +106 -0
- data/Rakefile +14 -0
- data/SERVER.md +95 -0
- data/bin/solargraph +0 -0
- data/bin/solargraph-runtime +5 -5
- data/lib/solargraph.rb +54 -54
- data/lib/solargraph/api_map.rb +659 -659
- data/lib/solargraph/api_map/cache.rb +49 -49
- data/lib/solargraph/api_map/source_to_yard.rb +67 -67
- data/lib/solargraph/api_map/store.rb +201 -201
- data/lib/solargraph/bundle.rb +24 -24
- data/lib/solargraph/complex_type.rb +150 -150
- data/lib/solargraph/complex_type/type_methods.rb +124 -124
- data/lib/solargraph/complex_type/unique_type.rb +44 -44
- data/lib/solargraph/core_fills.rb +37 -37
- data/lib/solargraph/diagnostics.rb +52 -52
- data/lib/solargraph/diagnostics/base.rb +20 -20
- data/lib/solargraph/diagnostics/require_not_found.rb +28 -28
- data/lib/solargraph/diagnostics/rubocop.rb +98 -98
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +46 -46
- data/lib/solargraph/diagnostics/type_not_defined.rb +108 -108
- data/lib/solargraph/diagnostics/update_errors.rb +38 -38
- data/lib/solargraph/language_server/completion_item_kinds.rb +33 -33
- data/lib/solargraph/language_server/error_codes.rb +18 -18
- data/lib/solargraph/language_server/host.rb +684 -681
- data/lib/solargraph/language_server/host/cataloger.rb +54 -79
- data/lib/solargraph/language_server/host/diagnoser.rb +80 -80
- data/lib/solargraph/language_server/host/dispatch.rb +112 -113
- data/lib/solargraph/language_server/host/sources.rb +138 -138
- data/lib/solargraph/language_server/message.rb +90 -90
- data/lib/solargraph/language_server/message/base.rb +83 -83
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +40 -40
- data/lib/solargraph/language_server/message/exit_notification.rb +11 -11
- data/lib/solargraph/language_server/message/extended.rb +19 -19
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +86 -86
- data/lib/solargraph/language_server/message/extended/document.rb +18 -18
- data/lib/solargraph/language_server/message/extended/document_gems.rb +30 -30
- data/lib/solargraph/language_server/message/extended/environment.rb +20 -20
- data/lib/solargraph/language_server/message/extended/search.rb +18 -18
- data/lib/solargraph/language_server/message/initialize.rb +141 -141
- data/lib/solargraph/language_server/message/initialized.rb +23 -23
- data/lib/solargraph/language_server/message/shutdown.rb +11 -11
- data/lib/solargraph/language_server/message/text_document.rb +25 -25
- data/lib/solargraph/language_server/message/text_document/completion.rb +51 -51
- data/lib/solargraph/language_server/message/text_document/definition.rb +18 -18
- data/lib/solargraph/language_server/message/text_document/did_change.rb +13 -13
- data/lib/solargraph/language_server/message/text_document/document_symbol.rb +21 -21
- data/lib/solargraph/language_server/message/text_document/folding_range.rb +24 -24
- data/lib/solargraph/language_server/message/text_document/formatting.rb +50 -50
- data/lib/solargraph/language_server/message/text_document/hover.rb +31 -31
- data/lib/solargraph/language_server/message/text_document/on_type_formatting.rb +32 -32
- data/lib/solargraph/language_server/message/text_document/prepare_rename.rb +9 -9
- data/lib/solargraph/language_server/message/text_document/references.rb +14 -14
- data/lib/solargraph/language_server/message/text_document/rename.rb +17 -17
- data/lib/solargraph/language_server/message/text_document/signature_help.rb +19 -19
- data/lib/solargraph/language_server/message/workspace.rb +12 -12
- data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +29 -29
- data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +29 -27
- data/lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb +24 -24
- data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +21 -21
- data/lib/solargraph/language_server/request.rb +22 -22
- data/lib/solargraph/language_server/symbol_kinds.rb +34 -34
- data/lib/solargraph/language_server/transport.rb +11 -11
- data/lib/solargraph/language_server/transport/adapter.rb +60 -60
- data/lib/solargraph/language_server/transport/data_reader.rb +66 -66
- data/lib/solargraph/language_server/uri_helpers.rb +25 -25
- data/lib/solargraph/library.rb +421 -419
- data/lib/solargraph/live_map.rb +126 -126
- data/lib/solargraph/live_map/cache.rb +38 -38
- data/lib/solargraph/location.rb +31 -31
- data/lib/solargraph/logging.rb +25 -25
- data/lib/solargraph/page.rb +68 -68
- data/lib/solargraph/pin.rb +50 -50
- data/lib/solargraph/pin/attribute.rb +41 -41
- data/lib/solargraph/pin/base.rb +280 -280
- data/lib/solargraph/pin/base_method.rb +76 -76
- data/lib/solargraph/pin/base_variable.rb +72 -72
- data/lib/solargraph/pin/block.rb +32 -32
- data/lib/solargraph/pin/block_parameter.rb +103 -103
- data/lib/solargraph/pin/class_variable.rb +9 -9
- data/lib/solargraph/pin/constant.rb +30 -30
- data/lib/solargraph/pin/conversions.rb +79 -79
- data/lib/solargraph/pin/documenting.rb +41 -41
- data/lib/solargraph/pin/duck_method.rb +14 -14
- data/lib/solargraph/pin/global_variable.rb +9 -9
- data/lib/solargraph/pin/instance_variable.rb +9 -9
- data/lib/solargraph/pin/keyword.rb +17 -17
- data/lib/solargraph/pin/local_variable.rb +23 -23
- data/lib/solargraph/pin/localized.rb +22 -22
- data/lib/solargraph/pin/method.rb +126 -126
- data/lib/solargraph/pin/method_alias.rb +30 -30
- data/lib/solargraph/pin/method_parameter.rb +40 -40
- data/lib/solargraph/pin/namespace.rb +54 -54
- data/lib/solargraph/pin/plugin/method.rb +25 -25
- data/lib/solargraph/pin/proxy_type.rb +35 -35
- data/lib/solargraph/pin/reference.rb +22 -22
- data/lib/solargraph/pin/reference/extend.rb +11 -11
- data/lib/solargraph/pin/reference/include.rb +11 -11
- data/lib/solargraph/pin/reference/require.rb +15 -15
- data/lib/solargraph/pin/reference/superclass.rb +11 -11
- data/lib/solargraph/pin/symbol.rb +44 -44
- data/lib/solargraph/pin/yard_pin.rb +10 -10
- data/lib/solargraph/pin/yard_pin/constant.rb +14 -14
- data/lib/solargraph/pin/yard_pin/method.rb +35 -35
- data/lib/solargraph/pin/yard_pin/namespace.rb +19 -19
- data/lib/solargraph/pin/yard_pin/yard_mixin.rb +14 -14
- data/lib/solargraph/plugin.rb +8 -8
- data/lib/solargraph/plugin/base.rb +41 -41
- data/lib/solargraph/plugin/canceler.rb +11 -11
- data/lib/solargraph/plugin/process.rb +172 -172
- data/lib/solargraph/plugin/runtime.rb +134 -134
- data/lib/solargraph/position.rb +110 -110
- data/lib/solargraph/range.rb +83 -83
- data/lib/solargraph/server_methods.rb +14 -14
- data/lib/solargraph/shell.rb +102 -102
- data/lib/solargraph/source.rb +521 -521
- data/lib/solargraph/source/chain.rb +120 -120
- data/lib/solargraph/source/chain/call.rb +107 -107
- data/lib/solargraph/source/chain/class_variable.rb +11 -11
- data/lib/solargraph/source/chain/constant.rb +30 -30
- data/lib/solargraph/source/chain/global_variable.rb +11 -11
- data/lib/solargraph/source/chain/head.rb +33 -33
- data/lib/solargraph/source/chain/instance_variable.rb +11 -11
- data/lib/solargraph/source/chain/link.rb +33 -33
- data/lib/solargraph/source/chain/literal.rb +21 -21
- data/lib/solargraph/source/chain/variable.rb +11 -11
- data/lib/solargraph/source/change.rb +77 -77
- data/lib/solargraph/source/cursor.rb +157 -157
- data/lib/solargraph/source/node_chainer.rb +96 -96
- data/lib/solargraph/source/node_methods.rb +225 -225
- data/lib/solargraph/source/source_chainer.rb +183 -183
- data/lib/solargraph/source_map.rb +169 -169
- data/lib/solargraph/source_map/clip.rb +145 -145
- data/lib/solargraph/source_map/completion.rb +21 -21
- data/lib/solargraph/source_map/mapper.rb +149 -149
- data/lib/solargraph/source_map/node_processor.rb +78 -78
- data/lib/solargraph/source_map/node_processor/alias_node.rb +19 -19
- data/lib/solargraph/source_map/node_processor/args_node.rb +28 -28
- data/lib/solargraph/source_map/node_processor/base.rb +68 -68
- data/lib/solargraph/source_map/node_processor/begin_node.rb +11 -11
- data/lib/solargraph/source_map/node_processor/block_node.rb +14 -14
- data/lib/solargraph/source_map/node_processor/casgn_node.rb +14 -14
- data/lib/solargraph/source_map/node_processor/cvasgn_node.rb +14 -14
- data/lib/solargraph/source_map/node_processor/def_node.rb +54 -54
- data/lib/solargraph/source_map/node_processor/defs_node.rb +21 -21
- data/lib/solargraph/source_map/node_processor/gvasgn_node.rb +12 -12
- data/lib/solargraph/source_map/node_processor/ivasgn_node.rb +18 -18
- data/lib/solargraph/source_map/node_processor/lvasgn_node.rb +16 -16
- data/lib/solargraph/source_map/node_processor/namespace_node.rb +26 -26
- data/lib/solargraph/source_map/node_processor/orasgn_node.rb +12 -12
- data/lib/solargraph/source_map/node_processor/sclass_node.rb +11 -11
- data/lib/solargraph/source_map/node_processor/send_node.rb +162 -162
- data/lib/solargraph/source_map/node_processor/sym_node.rb +11 -11
- data/lib/solargraph/source_map/region.rb +58 -58
- data/lib/solargraph/version.rb +3 -3
- data/lib/solargraph/views/environment.erb +53 -53
- data/lib/solargraph/workspace.rb +183 -183
- data/lib/solargraph/workspace/config.rb +170 -170
- data/lib/solargraph/yard_map.rb +298 -298
- data/lib/solargraph/yard_map/cache.rb +17 -17
- data/lib/solargraph/yard_map/core_docs.rb +163 -163
- data/lib/solargraph/yard_map/core_gen.rb +76 -76
- data/lib/yard-coregen.rb +16 -16
- data/lib/yard-solargraph.rb +18 -18
- data/solargraph.gemspec +37 -0
- data/travis-bundler.rb +10 -0
- metadata +19 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80e5d1c7f259f52bafd116d70e972be0409e282539c568f19ecb4114d7b88f36
|
4
|
+
data.tar.gz: ae52fc598ab045b3cae66f84fcc5157f69d3d51cbd283f396760fab35f22ec4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1473f5115ab0b6890318053325754af90eb37b949dab4397efbd71db929d1a0272d6e4b9429a21cb127aaa6c4268ee0112837be9fc794fd4581cc9f3729face2
|
7
|
+
data.tar.gz: 23c8737bafb64c0acf80db643d0df6e990cc73f1ef3ece715507170c3dbc1449118cb923642f6ef7da73c426c448710eda58dcf3e2167ed8b0f986db04caa56e
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.1
|
4
|
+
- 2.2
|
5
|
+
- 2.3
|
6
|
+
- 2.4
|
7
|
+
- 2.5.1
|
8
|
+
- 2.5.3
|
9
|
+
- 2.6.0
|
10
|
+
- 2.6.1
|
11
|
+
- jruby-9.1.16.0
|
12
|
+
- jruby-9.2
|
13
|
+
matrix:
|
14
|
+
include:
|
15
|
+
- rvm: 2.4
|
16
|
+
os: osx
|
17
|
+
# Update RubyGems and Bundler due to error with Bundler 1.16.1 and RubyGems 2.7.3
|
18
|
+
# See https://github.com/travis-ci/travis-ci/issues/8978
|
19
|
+
before_install:
|
20
|
+
- ruby ./travis-bundler.rb
|
21
|
+
- bundle install
|
22
|
+
before_script: bundle exec yard gems
|
23
|
+
script: bundle exec rspec
|
24
|
+
# cache:
|
25
|
+
# - bundler
|
data/EXAMPLES.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# Code Examples
|
2
|
+
|
3
|
+
This document provides simple examples of how to use the Solargraph library. The examples are intended as a starting point for developers who want to modify or extend the library, or integrate its tools into other software.
|
4
|
+
|
5
|
+
Language client implementors who want to connect to Solargraph language servers should refer to [LANGUAGE_SERVER.md](LANGUAGE_SERVER.md).
|
6
|
+
|
7
|
+
## Querying Ruby Core Methods
|
8
|
+
|
9
|
+
```Ruby
|
10
|
+
api_map = Solargraph::ApiMap.new
|
11
|
+
pins = api_map.get_methods('String') # Get public instance methods of the String class
|
12
|
+
```
|
13
|
+
|
14
|
+
## Adding a File to an ApiMap
|
15
|
+
|
16
|
+
```Ruby
|
17
|
+
api_map = Solargraph::ApiMap.new
|
18
|
+
source = Solargraph::Source.load_string('class MyClass; end', 'my_class.rb')
|
19
|
+
api_map.map source # Add the source to the map
|
20
|
+
pins = api_map.get_constants('') # The constants in the global namespace will include `MyClass`
|
21
|
+
```
|
22
|
+
|
23
|
+
## Adding a Workspace to an ApiMap
|
24
|
+
|
25
|
+
```Ruby
|
26
|
+
api_map = Solargraph::ApiMap.load('/path/to/workspace')
|
27
|
+
pins = api_map.get_constants('') # Results will include constants defined in the project's code
|
28
|
+
```
|
29
|
+
|
30
|
+
## Querying Definitions from a Location in Source Code
|
31
|
+
|
32
|
+
```Ruby
|
33
|
+
api_map = Solargraph::ApiMap.new
|
34
|
+
source = Solargraph::Source.load_string("var = 'a string'; puts var", 'example.rb')
|
35
|
+
api_map.virtualize source
|
36
|
+
clip = api_map.clip_at('example.rb', Solargraph::Position.new(0, 23))
|
37
|
+
pins = clip.define # `var` is recognized as a local variable containing a String
|
38
|
+
```
|
39
|
+
|
40
|
+
## Querying Completion Suggestions
|
41
|
+
```Ruby
|
42
|
+
api_map = Solargraph::ApiMap.new
|
43
|
+
source = Solargraph::Source.load_string("String.", 'example.rb')
|
44
|
+
api_map.map source
|
45
|
+
clip = api_map.clip_at('example.rb', Solargraph::Position.new(0, 7))
|
46
|
+
completion = clip.complete # Suggestions will include String class methods
|
47
|
+
```
|
48
|
+
|
49
|
+
## Adding a Message to the Language Server Protocol
|
50
|
+
|
51
|
+
```Ruby
|
52
|
+
class MyMessage < Solargraph::LanguageServer::Message::Base
|
53
|
+
def process
|
54
|
+
STDERR.puts "Server received MyMessage with the following parameters: #{params}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
Solargraph::LanguageServer::Message.register '$/myMessage', MyMessage
|
59
|
+
```
|
60
|
+
|
61
|
+
## Adding a Diagnostics Reporter to the Language Server
|
62
|
+
|
63
|
+
```Ruby
|
64
|
+
class MyReporter < Solargraph::Diagnostics::Base
|
65
|
+
def diagnose source, api_map
|
66
|
+
# Return an array of hash objects that conform to the LSP's Diagnostic specification
|
67
|
+
[]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
Solargraph::Diagnostics.register 'my_reporter', MyReporter
|
72
|
+
```
|
73
|
+
|
74
|
+
## More Examples
|
75
|
+
|
76
|
+
Developers are encouraged to refer to the specs for more examples of how to use Solargraph.
|
data/Gemfile
ADDED
data/LANGUAGE_SERVER.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Language Server Protocol
|
2
|
+
|
3
|
+
Solargraph supports the language server protocol as of gem version 0.18.0. The VSCode extension uses LSP as of extension version 0.14.0.
|
4
|
+
|
5
|
+
## Using the Language Server
|
6
|
+
|
7
|
+
Run `solargraph stdio` to use the language server via stdio.
|
8
|
+
|
9
|
+
Run `solargraph socket` to use the language server via TCP socket. The default port is 7658.
|
10
|
+
|
11
|
+
## Supported Capabilities
|
12
|
+
|
13
|
+
* Hover
|
14
|
+
* Completion
|
15
|
+
* Signature help
|
16
|
+
* Definition
|
17
|
+
* Document symbols
|
18
|
+
* Workspace symbols
|
19
|
+
* Rename symbols
|
20
|
+
* References
|
21
|
+
* Formatting
|
22
|
+
* Diagnostics (linting)
|
23
|
+
|
24
|
+
## Work in Progress
|
25
|
+
|
26
|
+
* On type formatting
|
27
|
+
|
28
|
+
## Custom Features
|
29
|
+
|
30
|
+
Solargraph's language server extends the protocol with additional methods for inline document pages.
|
31
|
+
|
32
|
+
## Linting and Formatting
|
33
|
+
|
34
|
+
Solargraph uses RuboCop for linting and formatting.
|
35
|
+
|
36
|
+
## Diagnostics Reporters
|
37
|
+
|
38
|
+
A .solargraph.yml file can be used to select which diagnostics reporters Solargraph should use. Example:
|
39
|
+
|
40
|
+
```
|
41
|
+
reporters:
|
42
|
+
- rubocop
|
43
|
+
- require_not_found
|
44
|
+
```
|
45
|
+
|
46
|
+
`rubocop` enables RuboCop linting. Its rules can be configured in a .rubocop.yml file.
|
47
|
+
|
48
|
+
`require_not_found` highlights `require` calls where Solargraph could not resolve a required path. Note that this error does not
|
49
|
+
necessarily mean that the path is incorrect; only that Solargraph was unable to recognize it.
|
50
|
+
|
51
|
+
Run `solargraph reporters` for a list of available reporters.
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017-2019 by Fred Snyder for Castwide Technologies
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/OVERVIEW.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# An Overview of Solargraph
|
2
|
+
|
3
|
+
The Solargraph library consists of two major groups of components: the data providers and the language servers. The data providers manage the maps of information about a program. The language servers are the concrete implementations of transports and messages that enable the language server protocol.
|
4
|
+
|
5
|
+
## Data Providers
|
6
|
+
|
7
|
+
**ApiMap** (`Solargraph::ApiMap`): The component that provides information about a program based on its Workspace, external gems, and the Ruby core.
|
8
|
+
|
9
|
+
**Workspace** (`Solargraph::Workspace`): A collection of Sources that comprise a project. Workspaces have configurations that define which files to include in maps and other project-related options. Users can configure the Workspace through a .solargraph.yml file in a project's root directory.
|
10
|
+
|
11
|
+
**Source** (`Solargraph::Source`): Data about a single Ruby file. Sources parse Ruby code into an AST and handle incremental updates.
|
12
|
+
|
13
|
+
**SourceMap** (`Solargraph::SourceMap`): A Source with generated pins for use in ApiMaps.
|
14
|
+
|
15
|
+
**Pins** (`Solargraph::Pin`): Information about classes, modules, methods, variables, etc. Pins for different types of components extend `Pin::Base`. Most ApiMap queries return results as an array of Pins.
|
16
|
+
|
17
|
+
**Cursor** (`Solargraph::Source::Cursor`): Information about a specific location in a Source.
|
18
|
+
|
19
|
+
**Clip** (`Solargraph::SourceMap::Clip`): A Cursor bundled with an ApiMap to provide definitions, completions, and other information.
|
20
|
+
|
21
|
+
**YardMap** (`Solargraph::YardMap`): A collection of YARD documents. ApiMaps use YardMaps to gather data from external gems and the Ruby core.
|
22
|
+
|
23
|
+
**Library** (`Solargraph::Library`): The component that synchronizes a Workspace with an ApiMap. Libraries help ensure that the ApiMap gets updated when a file in the Workspace changes.
|
24
|
+
|
25
|
+
## Language Servers
|
26
|
+
|
27
|
+
**Host** (`Solargraph::LanguageServer::Host`): The component responsible for processing messages between the server and the client. Hosts maintain a project's Library and provide thread-safe methods for asynchronous operations.
|
28
|
+
|
29
|
+
**Messages** (`Solargraph::LanguageServer::Message`): Implementations of LSP methods and notifications. Each message implementation extends `Message::Base`.
|
30
|
+
|
31
|
+
**Transports** (`Solargraph::LanguageServer::Transport`): Server implementations for various protocols. The two transports that are currently supported are socket and stdio. The `Transport::DataReader` class provides a common interface for processing incoming JSON-RPC messages.
|
32
|
+
|
33
|
+
## More Information
|
34
|
+
|
35
|
+
The [EXAMPLES.md](EXAMPLES.md) document provides simple examples of how to use, extend, and modify the Solargraph library.
|
36
|
+
|
37
|
+
Refer to [LANGUAGE_SERVER.md](LANGUAGE_SERVER.md) for information about connecting language clients to Solargraph language servers.
|
data/README.md
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
# Solargraph
|
2
|
+
|
3
|
+
IDE tools for the Ruby language.
|
4
|
+
|
5
|
+
Solargraph is a set of tools to integrate Ruby code completion and inline documentation into IDEs.
|
6
|
+
|
7
|
+
## Online Demo
|
8
|
+
|
9
|
+
A web-based demonstration of Solargraph is available at http://solargraph.org/demo.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Solargraph is available as a Ruby gem:
|
14
|
+
|
15
|
+
gem install solargraph
|
16
|
+
|
17
|
+
## Using Solargraph
|
18
|
+
|
19
|
+
Plug-ins and extensions are available for the following editors:
|
20
|
+
|
21
|
+
* **Visual Studio Code**
|
22
|
+
* Extension: https://marketplace.visualstudio.com/items?itemName=castwide.solargraph
|
23
|
+
* GitHub: https://github.com/castwide/vscode-solargraph
|
24
|
+
|
25
|
+
* **Atom**
|
26
|
+
* Package: https://atom.io/packages/ruby-solargraph
|
27
|
+
* GitHub: https://github.com/castwide/atom-solargraph
|
28
|
+
|
29
|
+
* **Vim**
|
30
|
+
* GitHub: https://github.com/autozimu/LanguageClient-neovim
|
31
|
+
|
32
|
+
* **Emacs**
|
33
|
+
* GitHub: https://github.com/guskovd/emacs-solargraph
|
34
|
+
|
35
|
+
* **Eclipse**
|
36
|
+
* Plugin: https://marketplace.eclipse.org/content/ruby-solargraph
|
37
|
+
* GitHub: https://github.com/PyvesB/eclipse-solargraph
|
38
|
+
|
39
|
+
### Gem Support
|
40
|
+
|
41
|
+
Solargraph is capable of providing code completion and documentation for gems that have YARD documentation. You can make sure your gems are documented by running `yard gems` from the command line. (The first time you run it might take a while if you have a lot of gems installed).
|
42
|
+
|
43
|
+
When editing code, a `require` call that references a gem will pull the documentation into the code maps and include the gem's API in code completion and intellisense.
|
44
|
+
|
45
|
+
### More Information
|
46
|
+
|
47
|
+
See [http://solargraph.org/tips](http://solargraph.org/tips) for more tips on using Solargraph with an editor.
|
48
|
+
|
49
|
+
## How It Works
|
50
|
+
|
51
|
+
Solargraph uses [parser](https://github.com/whitequark/parser) for code analysis and [YARD](https://github.com/lsegal/yard) for API documentation.
|
52
|
+
|
53
|
+
## Using the `solargraph` Executable
|
54
|
+
|
55
|
+
The gem includes an executable that provides access to the library's features. For code completion, IDEs will typically integrate using `solargraph stdio` or `solargraph socket`.
|
56
|
+
|
57
|
+
### Language Server Protocol
|
58
|
+
|
59
|
+
The language server protocol is the recommended way for integrating Solargraph into editors and IDEs. Clients can connect using either stdio or TCP.
|
60
|
+
See [LANGUAGE_SERVER.md](LANGUAGE_SERVER.md) for more information.
|
61
|
+
|
62
|
+
The Solargraph gem ships with documentation for Ruby 2.2.2. As of gem version 0.15.0, there's an option to download additional documentation for other Ruby versions from the command line.
|
63
|
+
|
64
|
+
$ solargraph list-cores # List the installed documentation versions
|
65
|
+
$ solargraph available-cores # List the versions available for download
|
66
|
+
$ solargraph download-core # Install the best match for your Ruby version
|
67
|
+
$ solargraph clear-cores # Clear the documentation cache
|
68
|
+
|
69
|
+
## Solargraph and Bundler
|
70
|
+
|
71
|
+
If you're using the Solargraph language server with a project that uses Bundler, the most comprehensive way to use your bundled gems is to bundle Solargraph.
|
72
|
+
|
73
|
+
In the Gemfile:
|
74
|
+
|
75
|
+
gem 'solargraph', group: :development
|
76
|
+
|
77
|
+
Run `bundle install` and use `bundle exec yard gems` to generate the documentation. This process documents cached or vendored gems, or even gems that are installed from a local path.
|
78
|
+
|
79
|
+
In order to access the gems in your project, you'll need to start the language server with Bundler. In VS Code, there's a `solargraph.useBundler` option. Other clients will vary, but the command you probably want to run is `bundle exec solargraph socket` or `bundle exec solargraph stdio`.
|
80
|
+
|
81
|
+
## Runtime Suggestions (EXPERIMENTAL)
|
82
|
+
|
83
|
+
As of gem version 0.15.0, Solargraph includes experimental support for plugins.
|
84
|
+
|
85
|
+
The Runtime plugin enhances code completion by querying namespaces for method names in a subprocess. If it finds any undocumented or "magic" methods, they get added to the suggestions.
|
86
|
+
|
87
|
+
This feature is currently disabled by default. If you'd like to try it, you can enable it by setting the `plugins` section in your project's .solargraph.yml file:
|
88
|
+
|
89
|
+
plugins:
|
90
|
+
- runtime
|
91
|
+
|
92
|
+
## Contributing to Solargraph
|
93
|
+
|
94
|
+
### Bug Reports and Feature Requests
|
95
|
+
|
96
|
+
GitHub Issues are the best place to ask questions, report problems, and suggest improvements.
|
97
|
+
|
98
|
+
### Development
|
99
|
+
|
100
|
+
Code contributions are always appreciated. Feel free to fork the repo and submit pull requests. Check for open issues that could use help. Start new issues to discuss changes that have a major impact on the code or require large time commitments.
|
101
|
+
|
102
|
+
### Sponsorship and Donation
|
103
|
+
|
104
|
+
Use Patreon to support ongoing development of Solargraph at [https://www.patreon.com/castwide](https://www.patreon.com/castwide).
|
105
|
+
|
106
|
+
You can also make one-time donations via PayPal at [https://www.paypal.me/castwide](https://www.paypal.me/castwide).
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
RSpec::Core::RakeTask.new(:spec)
|
8
|
+
rescue LoadError
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "Open a Pry session preloaded with this library"
|
12
|
+
task :console do
|
13
|
+
sh "pry -I lib -r solargraph.rb"
|
14
|
+
end
|
data/SERVER.md
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
# Solargraph Server Documentation
|
2
|
+
|
3
|
+
**NOTE: The legacy web server is deprecated and no longer available as of gem version 0.21.0. This document is archived for the benefit of extensions and plugins that still use it. Client implementors should use the [language server protocol](LANGUAGE_SERVER.md) instead.**
|
4
|
+
|
5
|
+
## Running the Server
|
6
|
+
|
7
|
+
Use the following command to start the server:
|
8
|
+
|
9
|
+
```
|
10
|
+
solargraph server
|
11
|
+
```
|
12
|
+
|
13
|
+
The command accepts an optional `--port` setting. The default port is 7657. If you set the port to 0, the server will select the first available port.
|
14
|
+
|
15
|
+
## API Endpoints
|
16
|
+
|
17
|
+
### POST /suggest
|
18
|
+
|
19
|
+
Get an array of suggestions to complete the code at the specified line and column of a file.
|
20
|
+
|
21
|
+
**Parameters:**
|
22
|
+
- `text` - the contents of the file
|
23
|
+
- `filename` - the absolute path to the file
|
24
|
+
- `line` - the zero-based line position of the cursor
|
25
|
+
- `column` - the zero-based column position of the cursor
|
26
|
+
- `workspace` - (optional) the root directory of the project
|
27
|
+
- `with_all` - (optional) request verbose suggestions
|
28
|
+
|
29
|
+
If `with_all` is set to 1, the suggestions will include documentation. The default is 0.
|
30
|
+
|
31
|
+
### POST /define
|
32
|
+
|
33
|
+
Get an array of suggestions that point to definitions for the symbol at the
|
34
|
+
specified location in the file. This method supports classes, modules, method
|
35
|
+
definitions, and variable assignments. The suggestions have a `location`
|
36
|
+
property that identifies the definition's file, line, and column.
|
37
|
+
|
38
|
+
**Parameters:**
|
39
|
+
- `text` - the contents of the file
|
40
|
+
- `filename` - the absolute path to the file
|
41
|
+
- `line` - the zero-based line position of the cursor
|
42
|
+
- `column` - the zero-based column position of the cursor
|
43
|
+
- `workspace` - (optional) the root directory of the project
|
44
|
+
|
45
|
+
### POST /resolve
|
46
|
+
|
47
|
+
**Parameters:**
|
48
|
+
- `filename` - the absolute path to the file
|
49
|
+
- `path` - the code path to find (e.g., `String#upcase`)
|
50
|
+
- `workspace` - (optional) the root directory of the project
|
51
|
+
|
52
|
+
### POST /signify
|
53
|
+
|
54
|
+
**Parameters:**
|
55
|
+
- `text` - the contents of the file
|
56
|
+
- `filename` - the absolute path to the file
|
57
|
+
- `line` - the zero-based line position of the cursor
|
58
|
+
- `column` - the zero-based column position of the cursor
|
59
|
+
- `workspace` - (optional) the root directory of the project
|
60
|
+
|
61
|
+
### GET /search
|
62
|
+
|
63
|
+
Request an HTML page containing search results for the specified text.
|
64
|
+
A search for "str" will include the String class in the results.
|
65
|
+
|
66
|
+
**Parameters:**
|
67
|
+
- `query` - the text to find
|
68
|
+
- `workspace` - (optional) the root directory of the project
|
69
|
+
|
70
|
+
### GET /document
|
71
|
+
|
72
|
+
Request an HTML page containing documentation for the specified path. A path
|
73
|
+
can be a class or module name, a class method (e.g., `Object.superclass`), or
|
74
|
+
an instance method (e.g., `String#upcase`). Documentation will also be
|
75
|
+
generated for the current workspace.
|
76
|
+
|
77
|
+
**Parameters:**
|
78
|
+
- `path` - the code path to find
|
79
|
+
- `workspace` - (optional) the root directory of the project
|
80
|
+
|
81
|
+
### POST /prepare
|
82
|
+
|
83
|
+
Initialize an ApiMap for the specified workspace. This method can make
|
84
|
+
subsequent requests for suggestions significantly faster.
|
85
|
+
|
86
|
+
**Parameters:**
|
87
|
+
- `workspace` - the root directory of the project
|
88
|
+
|
89
|
+
### POST /update
|
90
|
+
|
91
|
+
Update a file in the ApiMap for the specified workspace.
|
92
|
+
|
93
|
+
**Parameters:**
|
94
|
+
- `filename` - the absolute path to the file
|
95
|
+
- `workspace` - the root directory of the project
|