Commit 29b91a6
authored
Experimental project structure (#773)
* Experimental project structure
This commit represents a new structure for the experimental project, and
a path forward. With these changes the project now has:
* A build option enabling the experimental server
* Per-message routing for the experimental server. If enabled, it can
either share messages with the existing server or take them over.
Presently, the find references and formatting providers are
implemented and "exclusive", meaning that they're handled solely by
the experimental server
* A consistent interface for building providers.
* A consistent way to convert lsp messages into data structures and
back again. This conversion is handled automatically for providers.
* A genserver-like interface for providers to implement
* Data structures representing LSP messages that are simple to define
and build.
* Fast and efficient conversion between utf8 and utf16.
* A separation between what a provider does and how it responds to
messages. This allows the work that underpins providers to be tested
independently from the language server.
* Add underscore code action
Created a code action that prepends an underscore to unused variable
names.
* Notifications can be sent from the server
* Properly handled spacing
* Enforced required keys for jsonrpc messages
* removed unused variable
* Committed to pipeline
* Added tests that check to ensure comments are preserved
* Code modification framework
First attempt at a standard interface for code modification. Code mod
modules take the original text, the ast of the original text and
arguments that they specify. They return a list of code edits or an
error.
* Simplified diff, change name of code action functions from appy to text_edits
* Fixed off-by-one error that was vexing code unit conversions.
The problem was that the character positions are _before_ the reported
unit, so the 0th code unit is before the start of the line and the 1st
code unit is the first character. The prior code added one to
character counts to smooth this out, but you can't do that, because
you could end up indexing into the middle of a multibyte character.
* The code action needs to fix up the line numbers
Code mods deal with snippets of code that need to have their line
numbers fixed up by the code actions.
* Fixed type spec
The AST type is very complicated, and dialyzer was telling us I got it wrong.
* Made type aliases a thing
While working on the automatic protocol generators, it became clear
that type aliases needed to be their own thing, as they operate quite
differently from the other defined things in the jsonrpc
protocol. Since they're just aliases, it makes sense to keep their
definitions on hand and then spit them out when other things make use
of them during encode and decode.
This did require going back to encoding and ensuring all the encode
functions return OK tuples.
* Fixed unit tests
When patches are unapplied, getting the beam file returned an empty
path charlist, which dialyzer assumed was a real file name due to a
weak assumption, which caused unit tests to fail. This was remedied by
checking for a non-empty charlist, which allows tests to succeed.
Also made patch a test only dependency for .formatter.exs, as this was
causing formatters to fail.
* removed unused module attribute
* Added sourceror to ease ast to string conversion
Under 1.12, Macro.to_string proudces wonky output, making `def` calls
look like function calls by adding needless parenthesis. These
parenthesis throw off the diff algorithm, and caused an off-by-one
error in the code mod.
Sourceror has backported the newer code generation so that it's
compatible all the way back to 1.10, and produces the correct output.
* Added patch as a dev dependency
Patch's assertions will fail in CI due to `mix format
--check-formatted` running in dev. Importing patch's deps in test will
fix this.
* Run check formatted in test so patch assertions work
* Fixed dialyzer errors
* Encapsulated sourceror1 parent d9dc1b1 commit 29b91a6
File tree
77 files changed
+4910
-218
lines changed- .github/workflows
- apps/language_server
- lib
- language_server
- dialyzer
- experimental
- code_mod
- protocol
- proto
- macros
- provider
- code_action
- handlers
- server
- configuration
- source_file
- server
- test
- experimental
- code_mod
- protocol
- provider
- code_action
- handlers
- server
- source_file
- support
- experimental/code_mod
- fixtures
- config
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
77 files changed
+4910
-218
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
127 | | - | |
| 126 | + | |
| 127 | + | |
128 | 128 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
6 | 13 | | |
| 14 | + | |
7 | 15 | | |
8 | 16 | | |
9 | | - | |
| 17 | + | |
| 18 | + | |
10 | 19 | | |
11 | 20 | | |
12 | 21 | | |
13 | 22 | | |
14 | 23 | | |
| 24 | + | |
15 | 25 | | |
16 | 26 | | |
17 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | 10 | | |
14 | 11 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
27 | 25 | | |
28 | 26 | | |
29 | 27 | | |
| |||
42 | 40 | | |
43 | 41 | | |
44 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
45 | 64 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | | - | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
Lines changed: 106 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
0 commit comments