Skip to content

Commit a037f8c

Browse files
authored
LSP: Add Go To Definition support for Ast::Access (#636)
1 parent 4383b5d commit a037f8c

File tree

10 files changed

+589
-1
lines changed

10 files changed

+589
-1
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
record Header {
2+
titles : Array(String)
3+
}
4+
----------------------------------------------------------------file record.mint
5+
module Test {
6+
fun getFirstTitle (header : Header) : Maybe(String) {
7+
header.titles[0]
8+
}
9+
}
10+
------------------------------------------------------------------file test.mint
11+
{
12+
"id": 0,
13+
"method": "initialize",
14+
"params": {
15+
"capabilities": {
16+
"textDocument": {
17+
"definition": {
18+
"linkSupport": false
19+
}
20+
}
21+
}
22+
}
23+
}
24+
-------------------------------------------------------------------------request
25+
{
26+
"jsonrpc": "2.0",
27+
"id": 1,
28+
"params": {
29+
"textDocument": {
30+
"uri": "file://#{root_path}/test.mint"
31+
},
32+
"position": {
33+
"line": 2,
34+
"character": 11
35+
}
36+
},
37+
"method": "textDocument/definition"
38+
}
39+
-------------------------------------------------------------------------request
40+
{
41+
"jsonrpc": "2.0",
42+
"result": {
43+
"range": {
44+
"start": {
45+
"line": 1,
46+
"character": 2
47+
},
48+
"end": {
49+
"line": 1,
50+
"character": 8
51+
}
52+
},
53+
"uri": "file://#{root_path}/record.mint"
54+
},
55+
"id": 1
56+
}
57+
------------------------------------------------------------------------response
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
record Header {
2+
hide : Function(Void)
3+
}
4+
----------------------------------------------------------------file record.mint
5+
module Test {
6+
fun hideHeader (header : Header) : Void {
7+
header.hide()
8+
}
9+
}
10+
------------------------------------------------------------------file test.mint
11+
{
12+
"id": 0,
13+
"method": "initialize",
14+
"params": {
15+
"capabilities": {
16+
"textDocument": {
17+
"definition": {
18+
"linkSupport": false
19+
}
20+
}
21+
}
22+
}
23+
}
24+
-------------------------------------------------------------------------request
25+
{
26+
"jsonrpc": "2.0",
27+
"id": 1,
28+
"params": {
29+
"textDocument": {
30+
"uri": "file://#{root_path}/test.mint"
31+
},
32+
"position": {
33+
"line": 2,
34+
"character": 11
35+
}
36+
},
37+
"method": "textDocument/definition"
38+
}
39+
-------------------------------------------------------------------------request
40+
{
41+
"jsonrpc": "2.0",
42+
"result": {
43+
"range": {
44+
"start": {
45+
"line": 1,
46+
"character": 2
47+
},
48+
"end": {
49+
"line": 1,
50+
"character": 6
51+
}
52+
},
53+
"uri": "file://#{root_path}/record.mint"
54+
},
55+
"id": 1
56+
}
57+
------------------------------------------------------------------------response
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
record Nested3 {
2+
field3 : String
3+
}
4+
---------------------------------------------------------------file nested3.mint
5+
record Nested2 {
6+
field2 : Nested3
7+
}
8+
---------------------------------------------------------------file nested2.mint
9+
record Nested {
10+
field1 : Nested2
11+
}
12+
---------------------------------------------------------------file nested1.mint
13+
module Test {
14+
fun getNestedField (nested : Nested) : String {
15+
nested.field1.field2.field3
16+
}
17+
}
18+
------------------------------------------------------------------file test.mint
19+
{
20+
"id": 0,
21+
"method": "initialize",
22+
"params": {
23+
"capabilities": {
24+
"textDocument": {
25+
"definition": {
26+
"linkSupport": false
27+
}
28+
}
29+
}
30+
}
31+
}
32+
-------------------------------------------------------------------------request
33+
{
34+
"jsonrpc": "2.0",
35+
"id": 1,
36+
"params": {
37+
"textDocument": {
38+
"uri": "file://#{root_path}/test.mint"
39+
},
40+
"position": {
41+
"line": 2,
42+
"character": 18
43+
}
44+
},
45+
"method": "textDocument/definition"
46+
}
47+
-------------------------------------------------------------------------request
48+
{
49+
"jsonrpc": "2.0",
50+
"result": {
51+
"range": {
52+
"start": {
53+
"line": 1,
54+
"character": 2
55+
},
56+
"end": {
57+
"line": 1,
58+
"character": 8
59+
}
60+
},
61+
"uri": "file://#{root_path}/nested2.mint"
62+
},
63+
"id": 1
64+
}
65+
------------------------------------------------------------------------response
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
record Header {
2+
title : String
3+
}
4+
----------------------------------------------------------------file record.mint
5+
module Test {
6+
fun getTitle (header : Header) : String {
7+
header.title
8+
}
9+
}
10+
------------------------------------------------------------------file test.mint
11+
{
12+
"id": 0,
13+
"method": "initialize",
14+
"params": {
15+
"capabilities": {
16+
"textDocument": {
17+
"definition": {
18+
"linkSupport": false
19+
}
20+
}
21+
}
22+
}
23+
}
24+
-------------------------------------------------------------------------request
25+
{
26+
"jsonrpc": "2.0",
27+
"id": 1,
28+
"params": {
29+
"textDocument": {
30+
"uri": "file://#{root_path}/test.mint"
31+
},
32+
"position": {
33+
"line": 2,
34+
"character": 11
35+
}
36+
},
37+
"method": "textDocument/definition"
38+
}
39+
-------------------------------------------------------------------------request
40+
{
41+
"jsonrpc": "2.0",
42+
"result": {
43+
"range": {
44+
"start": {
45+
"line": 1,
46+
"character": 2
47+
},
48+
"end": {
49+
"line": 1,
50+
"character": 7
51+
}
52+
},
53+
"uri": "file://#{root_path}/record.mint"
54+
},
55+
"id": 1
56+
}
57+
------------------------------------------------------------------------response
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
record Header {
2+
titles : Array(String)
3+
}
4+
----------------------------------------------------------------file record.mint
5+
module Test {
6+
fun getFirstTitle (header : Header) : Maybe(String) {
7+
header.titles[0]
8+
}
9+
}
10+
------------------------------------------------------------------file test.mint
11+
{
12+
"id": 0,
13+
"method": "initialize",
14+
"params": {
15+
"capabilities": {
16+
"textDocument": {
17+
"definition": {
18+
"linkSupport": true
19+
}
20+
}
21+
}
22+
}
23+
}
24+
-------------------------------------------------------------------------request
25+
{
26+
"jsonrpc": "2.0",
27+
"id": 1,
28+
"params": {
29+
"textDocument": {
30+
"uri": "file://#{root_path}/test.mint"
31+
},
32+
"position": {
33+
"line": 2,
34+
"character": 11
35+
}
36+
},
37+
"method": "textDocument/definition"
38+
}
39+
-------------------------------------------------------------------------request
40+
{
41+
"jsonrpc": "2.0",
42+
"result": [
43+
{
44+
"originSelectionRange": {
45+
"start": {
46+
"line": 2,
47+
"character": 11
48+
},
49+
"end": {
50+
"line": 2,
51+
"character": 17
52+
}
53+
},
54+
"targetUri": "file://#{root_path}/record.mint",
55+
"targetRange": {
56+
"start": {
57+
"line": 1,
58+
"character": 2
59+
},
60+
"end": {
61+
"line": 1,
62+
"character": 24
63+
}
64+
},
65+
"targetSelectionRange": {
66+
"start": {
67+
"line": 1,
68+
"character": 2
69+
},
70+
"end": {
71+
"line": 1,
72+
"character": 8
73+
}
74+
}
75+
}
76+
],
77+
"id": 1
78+
}
79+
------------------------------------------------------------------------response
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
record Header {
2+
hide : Function(Void)
3+
}
4+
----------------------------------------------------------------file record.mint
5+
module Test {
6+
fun hideHeader (header : Header) : Void {
7+
header.hide()
8+
}
9+
}
10+
------------------------------------------------------------------file test.mint
11+
{
12+
"id": 0,
13+
"method": "initialize",
14+
"params": {
15+
"capabilities": {
16+
"textDocument": {
17+
"definition": {
18+
"linkSupport": true
19+
}
20+
}
21+
}
22+
}
23+
}
24+
-------------------------------------------------------------------------request
25+
{
26+
"jsonrpc": "2.0",
27+
"id": 1,
28+
"params": {
29+
"textDocument": {
30+
"uri": "file://#{root_path}/test.mint"
31+
},
32+
"position": {
33+
"line": 2,
34+
"character": 11
35+
}
36+
},
37+
"method": "textDocument/definition"
38+
}
39+
-------------------------------------------------------------------------request
40+
{
41+
"jsonrpc": "2.0",
42+
"result": [
43+
{
44+
"originSelectionRange": {
45+
"start": {
46+
"line": 2,
47+
"character": 11
48+
},
49+
"end": {
50+
"line": 2,
51+
"character": 15
52+
}
53+
},
54+
"targetUri": "file://#{root_path}/record.mint",
55+
"targetRange": {
56+
"start": {
57+
"line": 1,
58+
"character": 2
59+
},
60+
"end": {
61+
"line": 1,
62+
"character": 23
63+
}
64+
},
65+
"targetSelectionRange": {
66+
"start": {
67+
"line": 1,
68+
"character": 2
69+
},
70+
"end": {
71+
"line": 1,
72+
"character": 6
73+
}
74+
}
75+
}
76+
],
77+
"id": 1
78+
}
79+
------------------------------------------------------------------------response

0 commit comments

Comments
 (0)