Skip to content

Commit

Permalink
LSP: Add Go To Definition support for Ast::Access (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
jansul authored Sep 6, 2023
1 parent 4383b5d commit a037f8c
Show file tree
Hide file tree
Showing 10 changed files with 589 additions and 1 deletion.
57 changes: 57 additions & 0 deletions spec/language_server/definition/location/access_array
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
record Header {
titles : Array(String)
}
----------------------------------------------------------------file record.mint
module Test {
fun getFirstTitle (header : Header) : Maybe(String) {
header.titles[0]
}
}
------------------------------------------------------------------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": 11
}
},
"method": "textDocument/definition"
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": {
"range": {
"start": {
"line": 1,
"character": 2
},
"end": {
"line": 1,
"character": 8
}
},
"uri": "file://#{root_path}/record.mint"
},
"id": 1
}
------------------------------------------------------------------------response
57 changes: 57 additions & 0 deletions spec/language_server/definition/location/access_call
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
record Header {
hide : Function(Void)
}
----------------------------------------------------------------file record.mint
module Test {
fun hideHeader (header : Header) : Void {
header.hide()
}
}
------------------------------------------------------------------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": 11
}
},
"method": "textDocument/definition"
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": {
"range": {
"start": {
"line": 1,
"character": 2
},
"end": {
"line": 1,
"character": 6
}
},
"uri": "file://#{root_path}/record.mint"
},
"id": 1
}
------------------------------------------------------------------------response
65 changes: 65 additions & 0 deletions spec/language_server/definition/location/access_record_multiple
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
record Nested3 {
field3 : String
}
---------------------------------------------------------------file nested3.mint
record Nested2 {
field2 : Nested3
}
---------------------------------------------------------------file nested2.mint
record Nested {
field1 : Nested2
}
---------------------------------------------------------------file nested1.mint
module Test {
fun getNestedField (nested : Nested) : String {
nested.field1.field2.field3
}
}
------------------------------------------------------------------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": 18
}
},
"method": "textDocument/definition"
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": {
"range": {
"start": {
"line": 1,
"character": 2
},
"end": {
"line": 1,
"character": 8
}
},
"uri": "file://#{root_path}/nested2.mint"
},
"id": 1
}
------------------------------------------------------------------------response
57 changes: 57 additions & 0 deletions spec/language_server/definition/location/access_record_single
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
record Header {
title : String
}
----------------------------------------------------------------file record.mint
module Test {
fun getTitle (header : Header) : String {
header.title
}
}
------------------------------------------------------------------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": 11
}
},
"method": "textDocument/definition"
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": {
"range": {
"start": {
"line": 1,
"character": 2
},
"end": {
"line": 1,
"character": 7
}
},
"uri": "file://#{root_path}/record.mint"
},
"id": 1
}
------------------------------------------------------------------------response
79 changes: 79 additions & 0 deletions spec/language_server/definition/location_link/access_array
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
record Header {
titles : Array(String)
}
----------------------------------------------------------------file record.mint
module Test {
fun getFirstTitle (header : Header) : Maybe(String) {
header.titles[0]
}
}
------------------------------------------------------------------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": 11
}
},
"method": "textDocument/definition"
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": [
{
"originSelectionRange": {
"start": {
"line": 2,
"character": 11
},
"end": {
"line": 2,
"character": 17
}
},
"targetUri": "file://#{root_path}/record.mint",
"targetRange": {
"start": {
"line": 1,
"character": 2
},
"end": {
"line": 1,
"character": 24
}
},
"targetSelectionRange": {
"start": {
"line": 1,
"character": 2
},
"end": {
"line": 1,
"character": 8
}
}
}
],
"id": 1
}
------------------------------------------------------------------------response
79 changes: 79 additions & 0 deletions spec/language_server/definition/location_link/access_call
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
record Header {
hide : Function(Void)
}
----------------------------------------------------------------file record.mint
module Test {
fun hideHeader (header : Header) : Void {
header.hide()
}
}
------------------------------------------------------------------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": 11
}
},
"method": "textDocument/definition"
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": [
{
"originSelectionRange": {
"start": {
"line": 2,
"character": 11
},
"end": {
"line": 2,
"character": 15
}
},
"targetUri": "file://#{root_path}/record.mint",
"targetRange": {
"start": {
"line": 1,
"character": 2
},
"end": {
"line": 1,
"character": 23
}
},
"targetSelectionRange": {
"start": {
"line": 1,
"character": 2
},
"end": {
"line": 1,
"character": 6
}
}
}
],
"id": 1
}
------------------------------------------------------------------------response
Loading

0 comments on commit a037f8c

Please sign in to comment.