Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSP: Add support for Go to Definition #575

Merged
merged 17 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions spec/language_server/definition/core_component
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
component Test {
fun render : Html {
<Unless condition={true}>
<div/>
</Unless>
}
}
------------------------------------------------------------------file test.mint
{
"jsonrpc": "2.0",
"id": 0,
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"position": {
"line": 2,
"character": 7
}
},
"method": "textDocument/definition"
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"id": 1,
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"position": {
"line": 2,
"character": 13
}
},
"method": "textDocument/definition"
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": null,
"id": 0
}
------------------------------------------------------------------------response
{
"jsonrpc": "2.0",
"result": null,
"id": 1
}
------------------------------------------------------------------------response
61 changes: 61 additions & 0 deletions spec/language_server/definition/location/html_attribute
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
component Button {
property size : String = "small"

fun render : Html {
<button/>
}
}
----------------------------------------------------------------file button.mint
component Test {
fun render : Html {
<Button size="large"/>
}
}
------------------------------------------------------------------file test.mint
{
"id": 0,
"method": "initialize",
"params": {
"capabilities": {
"textDocument": {
"definition": {
"linkSupport": false
}
}
}
}
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"id": 1,
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"position": {
"line": 2,
"character": 13
}
},
"method": "textDocument/definition"
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": {
"range": {
"start": {
"line": 1,
"character": 11
},
"end": {
"line": 1,
"character": 15
}
},
"uri": "file://#{root_path}/button.mint"
},
"id": 1
}
------------------------------------------------------------------------response
60 changes: 60 additions & 0 deletions spec/language_server/definition/location/html_component
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* Comment for Button component. */
component Button {
fun render : Html {
<button />
}
}
----------------------------------------------------------------file button.mint
component Test {
fun render : Html {
<Button />
}
}
------------------------------------------------------------------file test.mint
{
"id": 0,
"method": "initialize",
"params": {
"capabilities": {
"textDocument": {
"definition": {
"linkSupport": false
}
}
}
}
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"id": 1,
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"position": {
"line": 2,
"character": 7
}
},
"method": "textDocument/definition"
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": {
"range": {
"start": {
"line": 1,
"character": 10
},
"end": {
"line": 1,
"character": 16
}
},
"uri": "file://#{root_path}/button.mint"
},
"id": 1
}
------------------------------------------------------------------------response
57 changes: 57 additions & 0 deletions spec/language_server/definition/location/html_style
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
component Test {
style test {

}

fun render : Html {
<div::test/>
}
}
------------------------------------------------------------------file test.mint
{
"id": 0,
"method": "initialize",
"params": {
"capabilities": {
"textDocument": {
"definition": {
"linkSupport": false
}
}
}
}
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"id": 1,
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"position": {
"line": 6,
"character": 12
}
},
"method": "textDocument/definition"
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": {
"range": {
"start": {
"line": 1,
"character": 8
},
"end": {
"line": 1,
"character": 12
}
},
"uri": "file://#{root_path}/test.mint"
},
"id": 1
}
------------------------------------------------------------------------response
81 changes: 81 additions & 0 deletions spec/language_server/definition/location_link/html_attribute
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
component Button {
property size : String = "small"

fun render : Html {
<button/>
}
}
----------------------------------------------------------------file button.mint
component Test {
fun render : Html {
<Button size="large"/>
}
}
------------------------------------------------------------------file test.mint
{
"id": 0,
"method": "initialize",
"params": {
"capabilities": {
"textDocument": {
"definition": {
"linkSupport": true
}
}
}
}
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"id": 1,
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"position": {
"line": 2,
"character": 13
}
},
"method": "textDocument/definition"
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": {
"originSelectionRange": {
"start": {
"line": 2,
"character": 12
},
"end": {
"line": 2,
"character": 16
}
},
"targetUri": "file://#{root_path}/button.mint",
"targetRange": {
"start": {
"line": 1,
"character": 2
},
"end": {
"line": 1,
"character": 34
}
},
"targetSelectionRange": {
"start": {
"line": 1,
"character": 11
},
"end": {
"line": 1,
"character": 15
}
}
},
"id": 1
}
------------------------------------------------------------------------response
80 changes: 80 additions & 0 deletions spec/language_server/definition/location_link/html_component
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/* Comment for Button component. */
component Button {
fun render : Html {
<button />
}
}
----------------------------------------------------------------file button.mint
component Test {
fun render : Html {
<Button />
}
}
------------------------------------------------------------------file test.mint
{
"id": 0,
"method": "initialize",
"params": {
"capabilities": {
"textDocument": {
"definition": {
"linkSupport": true
}
}
}
}
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"id": 1,
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"position": {
"line": 2,
"character": 7
}
},
"method": "textDocument/definition"
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": {
"originSelectionRange": {
"start": {
"line": 2,
"character": 5
},
"end": {
"line": 2,
"character": 11
}
},
"targetUri": "file://#{root_path}/button.mint",
"targetRange": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 5,
"character": 1
}
},
"targetSelectionRange": {
"start": {
"line": 1,
"character": 10
},
"end": {
"line": 1,
"character": 16
}
}
},
"id": 1
}
------------------------------------------------------------------------response
Loading