llvm-project/mlir/test/mlir-lsp-server/hover.test

158 lines
5.3 KiB
Plaintext

// RUN: mlir-lsp-server -lit-test < %s | FileCheck -strict-whitespace %s
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"mlir","capabilities":{},"trace":"off"}}
// -----
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{
"uri":"test:///foo.mlir",
"languageId":"mlir",
"version":1,
"text":"func @foo(%arg: i1) {\n%value = arith.constant true\ncf.br ^bb2\n^bb2:\nreturn\n}"
}}}
// -----
// Hover on an operation.
{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{
"textDocument":{"uri":"test:///foo.mlir"},
"position":{"line":1,"character":12}
}}
// CHECK: "id": 1,
// CHECK-NEXT: "jsonrpc": "2.0",
// CHECK-NEXT: "result": {
// CHECK-NEXT: "contents": {
// CHECK-NEXT: "kind": "markdown",
// CHECK-NEXT: "value": "\"arith.constant\"\n\nGeneric Form:\n\n```mlir\n%0 = \"arith.constant\"() {value = true} : () -> i1\n```\n"
// CHECK-NEXT: },
// CHECK-NEXT: "range": {
// CHECK-NEXT: "end": {
// CHECK-NEXT: "character": 23,
// CHECK-NEXT: "line": 1
// CHECK-NEXT: },
// CHECK-NEXT: "start": {
// CHECK-NEXT: "character": 9,
// CHECK-NEXT: "line": 1
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: }
// -----
// Hover on an operation result.
{"jsonrpc":"2.0","id":2,"method":"textDocument/hover","params":{
"textDocument":{"uri":"test:///foo.mlir"},
"position":{"line":1,"character":2}
}}
// CHECK: "id": 2,
// CHECK-NEXT: "jsonrpc": "2.0",
// CHECK-NEXT: "result": {
// CHECK-NEXT: "contents": {
// CHECK-NEXT: "kind": "markdown",
// CHECK-NEXT: "value": "Operation: \"arith.constant\"\n\nResult #0\n\nType: `i1`\n\n"
// CHECK-NEXT: },
// CHECK-NEXT: "range": {
// CHECK-NEXT: "end": {
// CHECK-NEXT: "character": 6,
// CHECK-NEXT: "line": 1
// CHECK-NEXT: },
// CHECK-NEXT: "start": {
// CHECK-NEXT: "character": 0,
// CHECK-NEXT: "line": 1
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: }
// -----
// Hover on a Block.
{"jsonrpc":"2.0","id":3,"method":"textDocument/hover","params":{
"textDocument":{"uri":"test:///foo.mlir"},
"position":{"line":3,"character":2}
}}
// CHECK: "id": 3,
// CHECK-NEXT: "jsonrpc": "2.0",
// CHECK-NEXT: "result": {
// CHECK-NEXT: "contents": {
// CHECK-NEXT: "kind": "markdown",
// CHECK-NEXT: "value": "Operation: \"func.func\"\n\nBlock #1\n\nPredecessors: <Block #0>\n\n"
// CHECK-NEXT: },
// CHECK-NEXT: "range": {
// CHECK-NEXT: "end": {
// CHECK-NEXT: "character": 4,
// CHECK-NEXT: "line": 3
// CHECK-NEXT: },
// CHECK-NEXT: "start": {
// CHECK-NEXT: "character": 0,
// CHECK-NEXT: "line": 3
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: }
// -----
// Hover on a Block argument.
{"jsonrpc":"2.0","id":4,"method":"textDocument/hover","params":{
"textDocument":{"uri":"test:///foo.mlir"},
"position":{"line":0,"character":12}
}}
// CHECK: "id": 4,
// CHECK-NEXT: "jsonrpc": "2.0",
// CHECK-NEXT: "result": {
// CHECK-NEXT: "contents": {
// CHECK-NEXT: "kind": "markdown",
// CHECK-NEXT: "value": "Operation: \"func.func\"\n\nBlock: <Block #0>\n\nArgument #0\n\nType: `i1`\n\n"
// CHECK-NEXT: },
// CHECK-NEXT: "range": {
// CHECK-NEXT: "end": {
// CHECK-NEXT: "character": 14,
// CHECK-NEXT: "line": 0
// CHECK-NEXT: },
// CHECK-NEXT: "start": {
// CHECK-NEXT: "character": 10,
// CHECK-NEXT: "line": 0
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: }
// -----
// Hover on a region operation.
{"jsonrpc":"2.0","id":5,"method":"textDocument/hover","params":{
"textDocument":{"uri":"test:///foo.mlir"},
"position":{"line":0,"character":1}
}}
// CHECK: "id": 5,
// CHECK-NEXT: "jsonrpc": "2.0",
// CHECK-NEXT: "result": {
// CHECK-NEXT: "contents": {
// CHECK-NEXT: "kind": "markdown",
// CHECK-NEXT: "value": "\"func.func\" : public @foo\n\nGeneric Form:\n\n```mlir\n\"func.func\"() ({\n}) {function_type = (i1) -> (), sym_name = \"foo\"} : () -> ()\n```\n"
// CHECK-NEXT: },
// CHECK-NEXT: "range": {
// CHECK-NEXT: "end": {
// CHECK-NEXT: "character": 4,
// CHECK-NEXT: "line": 0
// CHECK-NEXT: },
// CHECK-NEXT: "start": {
// CHECK-NEXT: "character": 0,
// CHECK-NEXT: "line": 0
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: }
// -----
// Hover on a symbol reference.
{"jsonrpc":"2.0","id":6,"method":"textDocument/hover","params":{
"textDocument":{"uri":"test:///foo.mlir"},
"position":{"line":0,"character":8}
}}
// CHECK: "id": 6,
// CHECK-NEXT: "jsonrpc": "2.0",
// CHECK-NEXT: "result": {
// CHECK-NEXT: "contents": {
// CHECK-NEXT: "kind": "markdown",
// CHECK-NEXT: "value": "\"func.func\" : public @foo\n\nGeneric Form:\n\n```mlir\n\"func.func\"() ({\n}) {function_type = (i1) -> (), sym_name = \"foo\"} : () -> ()\n```\n"
// CHECK-NEXT: },
// CHECK-NEXT: "range": {
// CHECK-NEXT: "end": {
// CHECK-NEXT: "character": 9,
// CHECK-NEXT: "line": 0
// CHECK-NEXT: },
// CHECK-NEXT: "start": {
// CHECK-NEXT: "character": 5,
// CHECK-NEXT: "line": 0
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: }
// -----
{"jsonrpc":"2.0","id":7,"method":"shutdown"}
// -----
{"jsonrpc":"2.0","method":"exit"}