Skip to content

Commit

Permalink
Merge branch 'lsp-over-websocket' into refactors-0.20.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gdotdesign committed Oct 10, 2024
2 parents 4a800c1 + 6bbfa23 commit 266fdd4
Show file tree
Hide file tree
Showing 213 changed files with 4,434 additions and 2,732 deletions.
2 changes: 1 addition & 1 deletion spec/compilers_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Dir
test: nil)

json =
Mint::MintJson.new
Mint::MintJson.parse("{}", "mint.json")

files =
Mint::Bundler.new(
Expand Down
14 changes: 10 additions & 4 deletions spec/installer/repository_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,23 @@ describe "Repository" do
repository = Mint::Installer::Repository.new("name", "success")

message = <<-MESSAGE
░ ERROR (REPOSITORY_INVALID_MINT_JSON) ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░ ERROR (INVALID_JSON) ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
I could not parse the mint.json for the package: name (success) for the version
or tag: master
I could not parse the following mint.json file:
┌ /tmp/mint-packages/success/mint.json:1:1
├─────────────────────────────────────────
1│ hello
MESSAGE

begin
repository.json("master")
fail "Should have raised!"
rescue error : Mint::Error
error.to_terminal.to_s.uncolorize.should eq(message)
result =
error.to_terminal.to_s.uncolorize

fail diff(message, result) unless result == message.strip
end
end

Expand Down
55 changes: 55 additions & 0 deletions spec/language_server/code_actions/module
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
module Test {
fun test : String {
""
}
}
------------------------------------------------------------------file test.mint
{
"id": 0,
"method": "textDocument/codeAction",
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"range": {
"start": { "line": 1, "character": 8 },
"end": { "line": 1, "character": 8 }
},
"context": {
"diagnostics": []
}
}
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": [
{
"title": "Order Entities",
"kind": "source",
"diagnostics": [],
"isPreferred": false,
"edit": {
"changes": {
"file://#{root_path}/test.mint": [
{
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 9999,
"character": 999
}
},
"newText": "module Test {\n fun test : String {\n \"\"\n }\n}"
}
]
}
}
}
],
"id": 0
}
------------------------------------------------------------------------response
59 changes: 59 additions & 0 deletions spec/language_server/code_actions/provider
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
type Test {
name : String
}

provider Test : Test {
fun test : String {
""
}
}
------------------------------------------------------------------file test.mint
{
"id": 0,
"method": "textDocument/codeAction",
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"range": {
"start": { "line": 5, "character": 11 },
"end": { "line": 5, "character": 11 }
},
"context": {
"diagnostics": []
}
}
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": [
{
"title": "Order Entities",
"kind": "source",
"diagnostics": [],
"isPreferred": false,
"edit": {
"changes": {
"file://#{root_path}/test.mint": [
{
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 9999,
"character": 999
}
},
"newText": "type Test {\n name : String\n}\n\nprovider Test : Test {\n fun test : String {\n \"\"\n }\n}"
}
]
}
}
}
],
"id": 0
}
------------------------------------------------------------------------response
37 changes: 37 additions & 0 deletions spec/language_server/completion/function
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
component Test {
fun otherFunction (name : String) : String {
name
}

fun render : String {
"Hello"
}
}
------------------------------------------------------------------file test.mint
{
"id": 0,
"method": "textDocument/completion",
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"position": {
"line": 3,
"character": 4
}
}
}
-------------------------------------------------------------------------request
{
"label": "otherFunction",
"kind": 3,
"detail": "Function",
"documentation": "",
"deprecated": false,
"preselect": false,
"sortText": "otherFunction",
"filterText": "otherFunction",
"insertText": "otherFunction()",
"insertTextFormat": 2
}
--------------------------------------------------------------response 0 contain
33 changes: 33 additions & 0 deletions spec/language_server/completion/html_component
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
component Test {
fun render : Html {
<></>
}
}
------------------------------------------------------------------file test.mint
{
"id": 0,
"method": "textDocument/completion",
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"position": {
"line": 3,
"character": 4
}
}
}
-------------------------------------------------------------------------request
{
"label": "Test",
"kind": 15,
"detail": "Component",
"documentation": "",
"deprecated": false,
"preselect": false,
"sortText": "Test",
"filterText": "Test",
"insertText": "<Test>\n \n</Test>",
"insertTextFormat": 2
}
--------------------------------------------------------------response 0 contain
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
component Test {
fun render : Html {
<></>
}
}
------------------------------------------------------------------file test.mint
{
"id": 0,
"method": "initialize",
"params": {
"capabilities": {
"textDocument": {
"completion": {
"completionItem": {
"snippetSupport": true
}
}
}
}
}
}
-------------------------------------------------------------------------request
{
"id": 1,
"method": "textDocument/completion",
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"position": {
"line": 3,
"character": 4
}
}
}
-------------------------------------------------------------------------request
{
"label": "Test",
"kind": 15,
"detail": "Component",
"documentation": "",
"deprecated": false,
"preselect": false,
"sortText": "Test",
"filterText": "Test",
"insertText": "<Test>\n $0\n</Test>",
"insertTextFormat": 2
}
--------------------------------------------------------------response 1 contain
92 changes: 0 additions & 92 deletions spec/language_server/completion_spec.cr

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ enum Status {
Error
Ok
}
------------------------------------------------------------------file status.mint
----------------------------------------------------------------file status.mint
module Test {
fun toString (status : Status) : String {
case status {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ store Theme {
"range": {
"start": {
"line": 1,
"character": 27
"character": 8
},
"end": {
"line": 1,
"character": 34
"character": 15
}
},
"uri": "file://#{root_path}/test.mint"
"uri": "file://#{root_path}/store.mint"
},
"id": 1
}
Expand Down
Loading

0 comments on commit 266fdd4

Please sign in to comment.