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 tests for hover feature #591

Merged
merged 1 commit into from
May 1, 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
36 changes: 36 additions & 0 deletions spec/language_server/hover/argument
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
component Test {
state comment : String = ""

fun setComment (value : String) : Promise(Void) {
next { comment: value }
}

fun render {
<div/>
}
}
------------------------------------------------------------------file test.mint
{
"id": 0,
"method": "textDocument/hover",
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"position": {
"line": 3,
"character": 20
}
}
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": {
"contents": [
"**value : String**"
]
},
"id": 0
}
------------------------------------------------------------------------response
60 changes: 60 additions & 0 deletions spec/language_server/hover/css_definition
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
component Test {
style test {
background: mintcream;
}

fun render {
<div::test />
}
}
------------------------------------------------------------------file test.mint
{
"id": 0,
"method": "textDocument/hover",
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"position": {
"line": 2,
"character": 10
}
}
}
-------------------------------------------------------------------------request
{
"id": 1,
"method": "textDocument/hover",
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"position": {
"line": 2,
"character": 21
}
}
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": {
"contents": [
"CSS Property - **background**",
"[MDN Docs](https://developer.mozilla.org/en-US/docs/Web/CSS/background)"
]
},
"id": 0
}
------------------------------------------------------------------------response
{
"jsonrpc": "2.0",
"result": {
"contents": [
"CSS Property - **background**",
"[MDN Docs](https://developer.mozilla.org/en-US/docs/Web/CSS/background)"
]
},
"id": 1
}
------------------------------------------------------------------------response
33 changes: 33 additions & 0 deletions spec/language_server/hover/enum
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* Comment for Status enum. */
enum Status {
Error
Ok
}
------------------------------------------------------------------file test.mint
{
"id": 0,
"method": "textDocument/hover",
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"position": {
"line": 1,
"character": 0
}
}
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": {
"contents": [
"**Status**\n",
"Comment for Status enum.\n",
"**Error**",
"**Ok**"
]
},
"id": 0
}
------------------------------------------------------------------------response
42 changes: 42 additions & 0 deletions spec/language_server/hover/enum_destructuring
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* Comment for Status enum. */
enum Status {
Error
Ok
}

module Test {
fun toString (status : Status) : String {
case (status) {
Status::Error => "Error"
Status::Ok => "Ok"
}
}
}
------------------------------------------------------------------file test.mint
{
"id": 0,
"method": "textDocument/hover",
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"position": {
"line": 9,
"character": 10
}
}
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": {
"contents": [
"**Status**\n",
"Comment for Status enum.\n",
"**Error**",
"**Ok**"
]
},
"id": 0
}
------------------------------------------------------------------------response
39 changes: 39 additions & 0 deletions spec/language_server/hover/enum_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* Comment for Status enum. */
enum Status {
Error
Ok
}

module Test {
fun success : Status {
Status::Ok
}
}
------------------------------------------------------------------file test.mint
{
"id": 0,
"method": "textDocument/hover",
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"position": {
"line": 8,
"character": 13
}
}
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": {
"contents": [
"**Status**\n",
"Comment for Status enum.\n",
"**Error**",
"**Ok**"
]
},
"id": 0
}
------------------------------------------------------------------------response
33 changes: 33 additions & 0 deletions spec/language_server/hover/enum_option
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* Comment for Status enum. */
enum Status {
Error
Ok
}
------------------------------------------------------------------file test.mint
{
"id": 0,
"method": "textDocument/hover",
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"position": {
"line": 2,
"character": 6
}
}
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": {
"contents": [
"**Status**\n",
"Comment for Status enum.\n",
"**Error**",
"**Ok**"
]
},
"id": 0
}
------------------------------------------------------------------------response
32 changes: 32 additions & 0 deletions spec/language_server/hover/function_component
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
component Test {
/* Comment for the function render. */
fun render : Html {
<div/>
}
}
------------------------------------------------------------------file test.mint
{
"id": 0,
"method": "textDocument/hover",
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"position": {
"line": 2,
"character": 4
}
}
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": {
"contents": [
"**Test.render: Html**\n",
"Comment for the function render."
]
},
"id": 0
}
------------------------------------------------------------------------response
32 changes: 32 additions & 0 deletions spec/language_server/hover/function_module
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module Test {
/* Comment for the function test. */
fun test : String {
"Test"
}
}
------------------------------------------------------------------file test.mint
{
"id": 0,
"method": "textDocument/hover",
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"position": {
"line": 2,
"character": 4
}
}
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": {
"contents": [
"**Test.test: String**\n",
"Comment for the function test."
]
},
"id": 0
}
------------------------------------------------------------------------response
36 changes: 36 additions & 0 deletions spec/language_server/hover/function_provider
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
record Test.Subscription {

}

provider Test : Test.Subscription {
/* Comment for the function test. */
fun test : String {
"Test"
}
}
------------------------------------------------------------------file test.mint
{
"id": 0,
"method": "textDocument/hover",
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"position": {
"line": 6,
"character": 4
}
}
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": {
"contents": [
"**Test.test: String**\n",
"Comment for the function test."
]
},
"id": 0
}
------------------------------------------------------------------------response
32 changes: 32 additions & 0 deletions spec/language_server/hover/function_store
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
store Test {
/* Comment for the function test. */
fun test : String {
"Test"
}
}
------------------------------------------------------------------file test.mint
{
"id": 0,
"method": "textDocument/hover",
"params": {
"textDocument": {
"uri": "file://#{root_path}/test.mint"
},
"position": {
"line": 2,
"character": 4
}
}
}
-------------------------------------------------------------------------request
{
"jsonrpc": "2.0",
"result": {
"contents": [
"**Test.test: String**\n",
"Comment for the function test."
]
},
"id": 0
}
------------------------------------------------------------------------response
Loading