| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| //===- CodeComplete.h - PDLL Frontend CodeComplete Context ------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef MLIR_TOOLS_PDLL_PARSER_CODECOMPLETE_H_ | ||
| #define MLIR_TOOLS_PDLL_PARSER_CODECOMPLETE_H_ | ||
|
|
||
| #include "mlir/Support/LLVM.h" | ||
| #include "llvm/Support/SourceMgr.h" | ||
|
|
||
| namespace mlir { | ||
| namespace pdll { | ||
| namespace ast { | ||
| class CallableDecl; | ||
| class DeclScope; | ||
| class Expr; | ||
| class OperationType; | ||
| class TupleType; | ||
| class Type; | ||
| class VariableDecl; | ||
| } // namespace ast | ||
|
|
||
| /// This class provides an abstract interface into the parser for hooking in | ||
| /// code completion events. | ||
| class CodeCompleteContext { | ||
| public: | ||
| virtual ~CodeCompleteContext(); | ||
|
|
||
| /// Return the location used to provide code completion. | ||
| SMLoc getCodeCompleteLoc() const { return codeCompleteLoc; } | ||
|
|
||
| //===--------------------------------------------------------------------===// | ||
| // Completion Hooks | ||
| //===--------------------------------------------------------------------===// | ||
|
|
||
| /// Signal code completion for a member access into the given tuple type. | ||
| virtual void codeCompleteTupleMemberAccess(ast::TupleType tupleType); | ||
|
|
||
| /// Signal code completion for a member access into the given operation type. | ||
| virtual void codeCompleteOperationMemberAccess(ast::OperationType opType); | ||
|
|
||
| /// Signal code completion for a member access into the given operation type. | ||
| virtual void codeCompleteOperationAttributeName(StringRef opName) {} | ||
|
|
||
| /// Signal code completion for a constraint name with an optional decl scope. | ||
| /// `currentType` is the current type of the variable that will use the | ||
| /// constraint, or nullptr if a type is unknown. `allowNonCoreConstraints` | ||
| /// indicates if user defined constraints are allowed in the completion | ||
| /// results. `allowInlineTypeConstraints` enables inline type constraints for | ||
| /// Attr/Value/ValueRange. | ||
| virtual void codeCompleteConstraintName(ast::Type currentType, | ||
| bool allowNonCoreConstraints, | ||
| bool allowInlineTypeConstraints, | ||
| const ast::DeclScope *scope); | ||
|
|
||
| /// Signal code completion for a dialect name. | ||
| virtual void codeCompleteDialectName() {} | ||
|
|
||
| /// Signal code completion for an operation name in the given dialect. | ||
| virtual void codeCompleteOperationName(StringRef dialectName) {} | ||
|
|
||
| /// Signal code completion for Pattern metadata. | ||
| virtual void codeCompletePatternMetadata() {} | ||
|
|
||
| //===--------------------------------------------------------------------===// | ||
| // Signature Hooks | ||
| //===--------------------------------------------------------------------===// | ||
|
|
||
| /// Signal code completion for the signature of a callable. | ||
| virtual void codeCompleteCallSignature(const ast::CallableDecl *callable, | ||
| unsigned currentNumArgs) {} | ||
|
|
||
| /// Signal code completion for the signature of an operation's operands. | ||
| virtual void | ||
| codeCompleteOperationOperandsSignature(Optional<StringRef> opName, | ||
| unsigned currentNumOperands) {} | ||
|
|
||
| /// Signal code completion for the signature of an operation's results. | ||
| virtual void | ||
| codeCompleteOperationResultsSignature(Optional<StringRef> opName, | ||
| unsigned currentNumResults) {} | ||
|
|
||
| protected: | ||
| /// Create a new code completion context with the given code complete | ||
| /// location. | ||
| explicit CodeCompleteContext(SMLoc codeCompleteLoc) | ||
| : codeCompleteLoc(codeCompleteLoc) {} | ||
|
|
||
| private: | ||
| /// The location used to code complete. | ||
| SMLoc codeCompleteLoc; | ||
| }; | ||
| } // namespace pdll | ||
| } // namespace mlir | ||
|
|
||
| #endif // MLIR_TOOLS_PDLL_PARSER_CODECOMPLETE_H_ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| //===- MlirPdllLspServerMain.h - MLIR PDLL Language Server main -*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Main entry function for mlir-pdll-lsp-server for when built as standalone | ||
| // binary. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef MLIR_TOOLS_MLIR_PDLL_LSP_SERVER_MLIRPDLLLSPSERVERMAIN_H | ||
| #define MLIR_TOOLS_MLIR_PDLL_LSP_SERVER_MLIRPDLLLSPSERVERMAIN_H | ||
|
|
||
| namespace mlir { | ||
| struct LogicalResult; | ||
|
|
||
| /// Implementation for tools like `mlir-pdll-lsp-server`. | ||
| LogicalResult MlirPdllLspServerMain(int argc, char **argv); | ||
|
|
||
| } // namespace mlir | ||
|
|
||
| #endif // MLIR_TOOLS_MLIR_PDLL_LSP_SERVER_MLIRPDLLLSPSERVERMAIN_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| add_subdirectory(lsp-server-support) | ||
| add_subdirectory(mlir-lsp-server) | ||
| add_subdirectory(mlir-opt) | ||
| add_subdirectory(mlir-pdll-lsp-server) | ||
| add_subdirectory(mlir-reduce) | ||
| add_subdirectory(mlir-translate) | ||
| add_subdirectory(PDLL) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
|
|
||
| llvm_add_library(MLIRPDLLParser STATIC | ||
| CodeComplete.cpp | ||
| Lexer.cpp | ||
| Parser.cpp | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| //===- CodeComplete.cpp ---------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "mlir/Tools/PDLL/Parser/CodeComplete.h" | ||
| #include "mlir/Tools/PDLL/AST/Types.h" | ||
|
|
||
| using namespace mlir; | ||
| using namespace mlir::pdll; | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // CodeCompleteContext | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| CodeCompleteContext::~CodeCompleteContext() = default; | ||
|
|
||
| void CodeCompleteContext::codeCompleteTupleMemberAccess( | ||
| ast::TupleType tupleType) {} | ||
| void CodeCompleteContext::codeCompleteOperationMemberAccess( | ||
| ast::OperationType opType) {} | ||
|
|
||
| void CodeCompleteContext::codeCompleteConstraintName( | ||
| ast::Type currentType, bool allowNonCoreConstraints, | ||
| bool allowInlineTypeConstraints, const ast::DeclScope *scope) {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| llvm_add_library(MLIRPdllLspServerLib | ||
| LSPServer.cpp | ||
| PDLLServer.cpp | ||
| MlirPdllLspServerMain.cpp | ||
|
|
||
| ADDITIONAL_HEADER_DIRS | ||
| ${MLIR_MAIN_INCLUDE_DIR}/mlir/Tools/mlir-pdll-lsp-server | ||
|
|
||
| LINK_LIBS PUBLIC | ||
| MLIRPDLLParser | ||
| MLIRLspServerSupportLib | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,286 @@ | ||
| //===- LSPServer.cpp - PDLL Language Server -------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "LSPServer.h" | ||
|
|
||
| #include "../lsp-server-support/Logging.h" | ||
| #include "../lsp-server-support/Protocol.h" | ||
| #include "../lsp-server-support/Transport.h" | ||
| #include "PDLLServer.h" | ||
| #include "llvm/ADT/FunctionExtras.h" | ||
| #include "llvm/ADT/StringMap.h" | ||
|
|
||
| #define DEBUG_TYPE "pdll-lsp-server" | ||
|
|
||
| using namespace mlir; | ||
| using namespace mlir::lsp; | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // LSPServer | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| namespace { | ||
| struct LSPServer { | ||
| LSPServer(PDLLServer &server, JSONTransport &transport) | ||
| : server(server), transport(transport) {} | ||
|
|
||
| //===--------------------------------------------------------------------===// | ||
| // Initialization | ||
|
|
||
| void onInitialize(const InitializeParams ¶ms, | ||
| Callback<llvm::json::Value> reply); | ||
| void onInitialized(const InitializedParams ¶ms); | ||
| void onShutdown(const NoParams ¶ms, Callback<std::nullptr_t> reply); | ||
|
|
||
| //===--------------------------------------------------------------------===// | ||
| // Document Change | ||
|
|
||
| void onDocumentDidOpen(const DidOpenTextDocumentParams ¶ms); | ||
| void onDocumentDidClose(const DidCloseTextDocumentParams ¶ms); | ||
| void onDocumentDidChange(const DidChangeTextDocumentParams ¶ms); | ||
|
|
||
| //===--------------------------------------------------------------------===// | ||
| // Definitions and References | ||
|
|
||
| void onGoToDefinition(const TextDocumentPositionParams ¶ms, | ||
| Callback<std::vector<Location>> reply); | ||
| void onReference(const ReferenceParams ¶ms, | ||
| Callback<std::vector<Location>> reply); | ||
|
|
||
| //===--------------------------------------------------------------------===// | ||
| // Hover | ||
|
|
||
| void onHover(const TextDocumentPositionParams ¶ms, | ||
| Callback<Optional<Hover>> reply); | ||
|
|
||
| //===--------------------------------------------------------------------===// | ||
| // Document Symbols | ||
|
|
||
| void onDocumentSymbol(const DocumentSymbolParams ¶ms, | ||
| Callback<std::vector<DocumentSymbol>> reply); | ||
|
|
||
| //===--------------------------------------------------------------------===// | ||
| // Code Completion | ||
|
|
||
| void onCompletion(const CompletionParams ¶ms, | ||
| Callback<CompletionList> reply); | ||
|
|
||
| //===--------------------------------------------------------------------===// | ||
| // Signature Help | ||
|
|
||
| void onSignatureHelp(const TextDocumentPositionParams ¶ms, | ||
| Callback<SignatureHelp> reply); | ||
|
|
||
| //===--------------------------------------------------------------------===// | ||
| // Fields | ||
| //===--------------------------------------------------------------------===// | ||
|
|
||
| PDLLServer &server; | ||
| JSONTransport &transport; | ||
|
|
||
| /// An outgoing notification used to send diagnostics to the client when they | ||
| /// are ready to be processed. | ||
| OutgoingNotification<PublishDiagnosticsParams> publishDiagnostics; | ||
|
|
||
| /// Used to indicate that the 'shutdown' request was received from the | ||
| /// Language Server client. | ||
| bool shutdownRequestReceived = false; | ||
| }; | ||
| } // namespace | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Initialization | ||
|
|
||
| void LSPServer::onInitialize(const InitializeParams ¶ms, | ||
| Callback<llvm::json::Value> reply) { | ||
| // Send a response with the capabilities of this server. | ||
| llvm::json::Object serverCaps{ | ||
| {"textDocumentSync", | ||
| llvm::json::Object{ | ||
| {"openClose", true}, | ||
| {"change", (int)TextDocumentSyncKind::Full}, | ||
| {"save", true}, | ||
| }}, | ||
| {"completionProvider", | ||
| llvm::json::Object{ | ||
| {"allCommitCharacters", | ||
| {" ", "\t", "(", ")", "[", "]", "{", "}", "<", | ||
| ">", ":", ";", ",", "+", "-", "/", "*", "%", | ||
| "^", "&", "#", "?", ".", "=", "\"", "'", "|"}}, | ||
| {"resolveProvider", false}, | ||
| {"triggerCharacters", {".", ">", "(", "{", ",", "<", ":", "[", " "}}, | ||
| }}, | ||
| {"signatureHelpProvider", | ||
| llvm::json::Object{ | ||
| {"triggerCharacters", {"(", ","}}, | ||
| }}, | ||
| {"definitionProvider", true}, | ||
| {"referencesProvider", true}, | ||
| {"hoverProvider", true}, | ||
| {"documentSymbolProvider", true}, | ||
| }; | ||
|
|
||
| llvm::json::Object result{ | ||
| {{"serverInfo", llvm::json::Object{{"name", "mlir-pdll-lsp-server"}, | ||
| {"version", "0.0.1"}}}, | ||
| {"capabilities", std::move(serverCaps)}}}; | ||
| reply(std::move(result)); | ||
| } | ||
| void LSPServer::onInitialized(const InitializedParams &) {} | ||
| void LSPServer::onShutdown(const NoParams &, Callback<std::nullptr_t> reply) { | ||
| shutdownRequestReceived = true; | ||
| reply(nullptr); | ||
| } | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Document Change | ||
|
|
||
| void LSPServer::onDocumentDidOpen(const DidOpenTextDocumentParams ¶ms) { | ||
| PublishDiagnosticsParams diagParams(params.textDocument.uri, | ||
| params.textDocument.version); | ||
| server.addOrUpdateDocument(params.textDocument.uri, params.textDocument.text, | ||
| params.textDocument.version, | ||
| diagParams.diagnostics); | ||
|
|
||
| // Publish any recorded diagnostics. | ||
| publishDiagnostics(diagParams); | ||
| } | ||
| void LSPServer::onDocumentDidClose(const DidCloseTextDocumentParams ¶ms) { | ||
| Optional<int64_t> version = server.removeDocument(params.textDocument.uri); | ||
| if (!version) | ||
| return; | ||
|
|
||
| // Empty out the diagnostics shown for this document. This will clear out | ||
| // anything currently displayed by the client for this document (e.g. in the | ||
| // "Problems" pane of VSCode). | ||
| publishDiagnostics( | ||
| PublishDiagnosticsParams(params.textDocument.uri, *version)); | ||
| } | ||
| void LSPServer::onDocumentDidChange(const DidChangeTextDocumentParams ¶ms) { | ||
| // TODO: We currently only support full document updates, we should refactor | ||
| // to avoid this. | ||
| if (params.contentChanges.size() != 1) | ||
| return; | ||
| PublishDiagnosticsParams diagParams(params.textDocument.uri, | ||
| params.textDocument.version); | ||
| server.addOrUpdateDocument( | ||
| params.textDocument.uri, params.contentChanges.front().text, | ||
| params.textDocument.version, diagParams.diagnostics); | ||
|
|
||
| // Publish any recorded diagnostics. | ||
| publishDiagnostics(diagParams); | ||
| } | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Definitions and References | ||
|
|
||
| void LSPServer::onGoToDefinition(const TextDocumentPositionParams ¶ms, | ||
| Callback<std::vector<Location>> reply) { | ||
| std::vector<Location> locations; | ||
| server.getLocationsOf(params.textDocument.uri, params.position, locations); | ||
| reply(std::move(locations)); | ||
| } | ||
|
|
||
| void LSPServer::onReference(const ReferenceParams ¶ms, | ||
| Callback<std::vector<Location>> reply) { | ||
| std::vector<Location> locations; | ||
| server.findReferencesOf(params.textDocument.uri, params.position, locations); | ||
| reply(std::move(locations)); | ||
| } | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Hover | ||
|
|
||
| void LSPServer::onHover(const TextDocumentPositionParams ¶ms, | ||
| Callback<Optional<Hover>> reply) { | ||
| reply(server.findHover(params.textDocument.uri, params.position)); | ||
| } | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Document Symbols | ||
|
|
||
| void LSPServer::onDocumentSymbol(const DocumentSymbolParams ¶ms, | ||
| Callback<std::vector<DocumentSymbol>> reply) { | ||
| std::vector<DocumentSymbol> symbols; | ||
| server.findDocumentSymbols(params.textDocument.uri, symbols); | ||
| reply(std::move(symbols)); | ||
| } | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Code Completion | ||
|
|
||
| void LSPServer::onCompletion(const CompletionParams ¶ms, | ||
| Callback<CompletionList> reply) { | ||
| reply(server.getCodeCompletion(params.textDocument.uri, params.position)); | ||
| } | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Signature Help | ||
|
|
||
| void LSPServer::onSignatureHelp(const TextDocumentPositionParams ¶ms, | ||
| Callback<SignatureHelp> reply) { | ||
| reply(server.getSignatureHelp(params.textDocument.uri, params.position)); | ||
| } | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Entry Point | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| LogicalResult mlir::lsp::runPdllLSPServer(PDLLServer &server, | ||
| JSONTransport &transport) { | ||
| LSPServer lspServer(server, transport); | ||
| MessageHandler messageHandler(transport); | ||
|
|
||
| // Initialization | ||
| messageHandler.method("initialize", &lspServer, &LSPServer::onInitialize); | ||
| messageHandler.notification("initialized", &lspServer, | ||
| &LSPServer::onInitialized); | ||
| messageHandler.method("shutdown", &lspServer, &LSPServer::onShutdown); | ||
|
|
||
| // Document Changes | ||
| messageHandler.notification("textDocument/didOpen", &lspServer, | ||
| &LSPServer::onDocumentDidOpen); | ||
| messageHandler.notification("textDocument/didClose", &lspServer, | ||
| &LSPServer::onDocumentDidClose); | ||
| messageHandler.notification("textDocument/didChange", &lspServer, | ||
| &LSPServer::onDocumentDidChange); | ||
|
|
||
| // Definitions and References | ||
| messageHandler.method("textDocument/definition", &lspServer, | ||
| &LSPServer::onGoToDefinition); | ||
| messageHandler.method("textDocument/references", &lspServer, | ||
| &LSPServer::onReference); | ||
|
|
||
| // Hover | ||
| messageHandler.method("textDocument/hover", &lspServer, &LSPServer::onHover); | ||
|
|
||
| // Document Symbols | ||
| messageHandler.method("textDocument/documentSymbol", &lspServer, | ||
| &LSPServer::onDocumentSymbol); | ||
|
|
||
| // Code Completion | ||
| messageHandler.method("textDocument/completion", &lspServer, | ||
| &LSPServer::onCompletion); | ||
|
|
||
| // Signature Help | ||
| messageHandler.method("textDocument/signatureHelp", &lspServer, | ||
| &LSPServer::onSignatureHelp); | ||
|
|
||
| // Diagnostics | ||
| lspServer.publishDiagnostics = | ||
| messageHandler.outgoingNotification<PublishDiagnosticsParams>( | ||
| "textDocument/publishDiagnostics"); | ||
|
|
||
| // Run the main loop of the transport. | ||
| if (llvm::Error error = transport.run(messageHandler)) { | ||
| Logger::error("Transport error: {0}", error); | ||
| llvm::consumeError(std::move(error)); | ||
| return failure(); | ||
| } | ||
| return success(lspServer.shutdownRequestReceived); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| //===- LSPServer.h - PDLL LSP Server ----------------------------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LIB_MLIR_TOOLS_MLIRPDLLLSPSERVER_LSPSERVER_H | ||
| #define LIB_MLIR_TOOLS_MLIRPDLLLSPSERVER_LSPSERVER_H | ||
|
|
||
| #include <memory> | ||
|
|
||
| namespace mlir { | ||
| struct LogicalResult; | ||
|
|
||
| namespace lsp { | ||
| class JSONTransport; | ||
| class PDLLServer; | ||
|
|
||
| /// Run the main loop of the LSP server using the given PDLL server and | ||
| /// transport. | ||
| LogicalResult runPdllLSPServer(PDLLServer &server, JSONTransport &transport); | ||
|
|
||
| } // namespace lsp | ||
| } // namespace mlir | ||
|
|
||
| #endif // LIB_MLIR_TOOLS_MLIRPDLLLSPSERVER_LSPSERVER_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| //===- MlirPdllLspServerMain.cpp - MLIR PDLL Language Server main ---------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "mlir/Tools/mlir-pdll-lsp-server/MlirPdllLspServerMain.h" | ||
| #include "../lsp-server-support/Logging.h" | ||
| #include "../lsp-server-support/Transport.h" | ||
| #include "LSPServer.h" | ||
| #include "PDLLServer.h" | ||
| #include "llvm/Support/CommandLine.h" | ||
| #include "llvm/Support/Program.h" | ||
|
|
||
| using namespace mlir; | ||
| using namespace mlir::lsp; | ||
|
|
||
| LogicalResult mlir::MlirPdllLspServerMain(int argc, char **argv) { | ||
| llvm::cl::opt<JSONStreamStyle> inputStyle{ | ||
| "input-style", | ||
| llvm::cl::desc("Input JSON stream encoding"), | ||
| llvm::cl::values(clEnumValN(JSONStreamStyle::Standard, "standard", | ||
| "usual LSP protocol"), | ||
| clEnumValN(JSONStreamStyle::Delimited, "delimited", | ||
| "messages delimited by `// -----` lines, " | ||
| "with // comment support")), | ||
| llvm::cl::init(JSONStreamStyle::Standard), | ||
| llvm::cl::Hidden, | ||
| }; | ||
| llvm::cl::opt<bool> litTest{ | ||
| "lit-test", | ||
| llvm::cl::desc( | ||
| "Abbreviation for -input-style=delimited -pretty -log=verbose. " | ||
| "Intended to simplify lit tests"), | ||
| llvm::cl::init(false), | ||
| }; | ||
| llvm::cl::opt<Logger::Level> logLevel{ | ||
| "log", | ||
| llvm::cl::desc("Verbosity of log messages written to stderr"), | ||
| llvm::cl::values( | ||
| clEnumValN(Logger::Level::Error, "error", "Error messages only"), | ||
| clEnumValN(Logger::Level::Info, "info", | ||
| "High level execution tracing"), | ||
| clEnumValN(Logger::Level::Debug, "verbose", "Low level details")), | ||
| llvm::cl::init(Logger::Level::Info), | ||
| }; | ||
| llvm::cl::opt<bool> prettyPrint{ | ||
| "pretty", | ||
| llvm::cl::desc("Pretty-print JSON output"), | ||
| llvm::cl::init(false), | ||
| }; | ||
| llvm::cl::ParseCommandLineOptions(argc, argv, "MLIR LSP Language Server"); | ||
|
|
||
| if (litTest) { | ||
| inputStyle = JSONStreamStyle::Delimited; | ||
| logLevel = Logger::Level::Debug; | ||
| prettyPrint = true; | ||
| } | ||
|
|
||
| // Configure the logger. | ||
| Logger::setLogLevel(logLevel); | ||
|
|
||
| // Configure the transport used for communication. | ||
| llvm::sys::ChangeStdinToBinary(); | ||
| JSONTransport transport(stdin, llvm::outs(), inputStyle, prettyPrint); | ||
|
|
||
| // Configure the servers and start the main language server. | ||
| PDLLServer server; | ||
| return runPdllLSPServer(server, transport); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| //===- PDLLServer.h - PDL General Language Server ---------------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LIB_MLIR_TOOLS_MLIRPDLLSPSERVER_SERVER_H_ | ||
| #define LIB_MLIR_TOOLS_MLIRPDLLSPSERVER_SERVER_H_ | ||
|
|
||
| #include "mlir/Support/LLVM.h" | ||
| #include <memory> | ||
|
|
||
| namespace mlir { | ||
| namespace lsp { | ||
| struct Diagnostic; | ||
| struct CompletionList; | ||
| struct DocumentSymbol; | ||
| struct Hover; | ||
| struct Location; | ||
| struct Position; | ||
| struct SignatureHelp; | ||
| class URIForFile; | ||
|
|
||
| /// This class implements all of the PDLL related functionality necessary for a | ||
| /// language server. This class allows for keeping the PDLL specific logic | ||
| /// separate from the logic that involves LSP server/client communication. | ||
| class PDLLServer { | ||
| public: | ||
| PDLLServer(); | ||
| ~PDLLServer(); | ||
|
|
||
| /// Add or update the document, with the provided `version`, at the given URI. | ||
| /// Any diagnostics emitted for this document should be added to | ||
| /// `diagnostics`. | ||
| void addOrUpdateDocument(const URIForFile &uri, StringRef contents, | ||
| int64_t version, | ||
| std::vector<Diagnostic> &diagnostics); | ||
|
|
||
| /// Remove the document with the given uri. Returns the version of the removed | ||
| /// document, or None if the uri did not have a corresponding document within | ||
| /// the server. | ||
| Optional<int64_t> removeDocument(const URIForFile &uri); | ||
|
|
||
| /// Return the locations of the object pointed at by the given position. | ||
| void getLocationsOf(const URIForFile &uri, const Position &defPos, | ||
| std::vector<Location> &locations); | ||
|
|
||
| /// Find all references of the object pointed at by the given position. | ||
| void findReferencesOf(const URIForFile &uri, const Position &pos, | ||
| std::vector<Location> &references); | ||
|
|
||
| /// Find a hover description for the given hover position, or None if one | ||
| /// couldn't be found. | ||
| Optional<Hover> findHover(const URIForFile &uri, const Position &hoverPos); | ||
|
|
||
| /// Find all of the document symbols within the given file. | ||
| void findDocumentSymbols(const URIForFile &uri, | ||
| std::vector<DocumentSymbol> &symbols); | ||
|
|
||
| /// Get the code completion list for the position within the given file. | ||
| CompletionList getCodeCompletion(const URIForFile &uri, | ||
| const Position &completePos); | ||
|
|
||
| /// Get the signature help for the position within the given file. | ||
| SignatureHelp getSignatureHelp(const URIForFile &uri, | ||
| const Position &helpPos); | ||
|
|
||
| private: | ||
| struct Impl; | ||
|
|
||
| std::unique_ptr<Impl> impl; | ||
| }; | ||
|
|
||
| } // namespace lsp | ||
| } // namespace mlir | ||
|
|
||
| #endif // LIB_MLIR_TOOLS_MLIRPDLLSPSERVER_SERVER_H_ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,205 @@ | ||
| // RUN: mlir-pdll-lsp-server -lit-test < %s | FileCheck -strict-whitespace %s | ||
| {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"pdll","capabilities":{},"trace":"off"}} | ||
| // ----- | ||
| {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{ | ||
| "uri":"test:///foo.pdll", | ||
| "languageId":"pdll", | ||
| "version":1, | ||
| "text":"Constraint ValueCst(value: Value);\nConstraint Cst();\nPattern FooPattern with benefit(1) {\nlet tuple = (value1 = _: Op, _: Op<test.op>);\nerase tuple.value1;\n}" | ||
| }}} | ||
| // ----- | ||
| {"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{ | ||
| "textDocument":{"uri":"test:///foo.pdll"}, | ||
| "position":{"line":4,"character":12} | ||
| }} | ||
| // CHECK: "id": 1 | ||
| // CHECK-NEXT: "jsonrpc": "2.0", | ||
| // CHECK-NEXT: "result": { | ||
| // CHECK-NEXT: "isIncomplete": false, | ||
| // CHECK-NEXT: "items": [ | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "detail": "0: Op", | ||
| // CHECK-NEXT: "filterText": "0", | ||
| // CHECK-NEXT: "insertText": "0", | ||
| // CHECK-NEXT: "insertTextFormat": 1, | ||
| // CHECK-NEXT: "kind": 5, | ||
| // CHECK-NEXT: "label": "0 (field #0)", | ||
| // CHECK-NEXT: "sortText": "0" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "detail": "0: Op", | ||
| // CHECK-NEXT: "filterText": "value1 (field #0)", | ||
| // CHECK-NEXT: "insertText": "value1", | ||
| // CHECK-NEXT: "insertTextFormat": 1, | ||
| // CHECK-NEXT: "kind": 5, | ||
| // CHECK-NEXT: "label": "value1 (field #0)", | ||
| // CHECK-NEXT: "sortText": "0" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "detail": "1: Op<test.op>", | ||
| // CHECK-NEXT: "filterText": "1", | ||
| // CHECK-NEXT: "insertText": "1", | ||
| // CHECK-NEXT: "insertTextFormat": 1, | ||
| // CHECK-NEXT: "kind": 5, | ||
| // CHECK-NEXT: "label": "1 (field #1)", | ||
| // CHECK-NEXT: "sortText": "1" | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: ] | ||
| // CHECK-NEXT: } | ||
| // ----- | ||
| {"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{ | ||
| "textDocument":{"uri":"test:///foo.pdll"}, | ||
| "position":{"line":2,"character":23} | ||
| }} | ||
| // CHECK: "id": 1 | ||
| // CHECK-NEXT: "jsonrpc": "2.0", | ||
| // CHECK-NEXT: "result": { | ||
| // CHECK-NEXT: "isIncomplete": false, | ||
| // CHECK-NEXT: "items": [ | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "detail": "pattern metadata", | ||
| // CHECK-NEXT: "documentation": { | ||
| // CHECK-NEXT: "kind": "markdown", | ||
| // CHECK-NEXT: "value": "The `benefit` of matching the pattern." | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "insertText": "benefit($1)", | ||
| // CHECK-NEXT: "insertTextFormat": 2, | ||
| // CHECK-NEXT: "kind": 7, | ||
| // CHECK-NEXT: "label": "benefit" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "detail": "pattern metadata", | ||
| // CHECK-NEXT: "documentation": { | ||
| // CHECK-NEXT: "kind": "markdown", | ||
| // CHECK-NEXT: "value": "The pattern properly handles recursive application." | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "insertTextFormat": 1, | ||
| // CHECK-NEXT: "kind": 7, | ||
| // CHECK-NEXT: "label": "recursion" | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: ] | ||
| // CHECK-NEXT: } | ||
| // ----- | ||
| {"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{ | ||
| "textDocument":{"uri":"test:///foo.pdll"}, | ||
| "position":{"line":3,"character":24} | ||
| }} | ||
| // CHECK: "id": 1 | ||
| // CHECK-NEXT: "jsonrpc": "2.0", | ||
| // CHECK-NEXT: "result": { | ||
| // CHECK-NEXT: "isIncomplete": false, | ||
| // CHECK-NEXT: "items": [ | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "detail": "Attr constraint", | ||
| // CHECK-NEXT: "documentation": { | ||
| // CHECK-NEXT: "kind": "markdown", | ||
| // CHECK-NEXT: "value": "A single entity core constraint of type `mlir::Attribute`" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "insertTextFormat": 1, | ||
| // CHECK-NEXT: "kind": 7, | ||
| // CHECK-NEXT: "label": "Attr", | ||
| // CHECK-NEXT: "sortText": "0" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "detail": "Op constraint", | ||
| // CHECK-NEXT: "documentation": { | ||
| // CHECK-NEXT: "kind": "markdown", | ||
| // CHECK-NEXT: "value": "A single entity core constraint of type `mlir::Operation *`" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "insertTextFormat": 1, | ||
| // CHECK-NEXT: "kind": 7, | ||
| // CHECK-NEXT: "label": "Op", | ||
| // CHECK-NEXT: "sortText": "0" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "detail": "Value constraint", | ||
| // CHECK-NEXT: "documentation": { | ||
| // CHECK-NEXT: "kind": "markdown", | ||
| // CHECK-NEXT: "value": "A single entity core constraint of type `mlir::Value`" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "insertTextFormat": 1, | ||
| // CHECK-NEXT: "kind": 7, | ||
| // CHECK-NEXT: "label": "Value", | ||
| // CHECK-NEXT: "sortText": "0" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "detail": "ValueRange constraint", | ||
| // CHECK-NEXT: "documentation": { | ||
| // CHECK-NEXT: "kind": "markdown", | ||
| // CHECK-NEXT: "value": "A single entity core constraint of type `mlir::ValueRange`" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "insertTextFormat": 1, | ||
| // CHECK-NEXT: "kind": 7, | ||
| // CHECK-NEXT: "label": "ValueRange", | ||
| // CHECK-NEXT: "sortText": "0" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "detail": "Type constraint", | ||
| // CHECK-NEXT: "documentation": { | ||
| // CHECK-NEXT: "kind": "markdown", | ||
| // CHECK-NEXT: "value": "A single entity core constraint of type `mlir::Type`" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "insertTextFormat": 1, | ||
| // CHECK-NEXT: "kind": 7, | ||
| // CHECK-NEXT: "label": "Type", | ||
| // CHECK-NEXT: "sortText": "0" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "detail": "TypeRange constraint", | ||
| // CHECK-NEXT: "documentation": { | ||
| // CHECK-NEXT: "kind": "markdown", | ||
| // CHECK-NEXT: "value": "A single entity core constraint of type `mlir::TypeRange`" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "insertTextFormat": 1, | ||
| // CHECK-NEXT: "kind": 7, | ||
| // CHECK-NEXT: "label": "TypeRange", | ||
| // CHECK-NEXT: "sortText": "0" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "detail": "Attr<type> constraint", | ||
| // CHECK-NEXT: "documentation": { | ||
| // CHECK-NEXT: "kind": "markdown", | ||
| // CHECK-NEXT: "value": "A single entity core constraint of type `mlir::Attribute`" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "insertText": "Attr<$1>", | ||
| // CHECK-NEXT: "insertTextFormat": 2, | ||
| // CHECK-NEXT: "kind": 7, | ||
| // CHECK-NEXT: "label": "Attr<type>", | ||
| // CHECK-NEXT: "sortText": "0" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "detail": "Value<type> constraint", | ||
| // CHECK-NEXT: "documentation": { | ||
| // CHECK-NEXT: "kind": "markdown", | ||
| // CHECK-NEXT: "value": "A single entity core constraint of type `mlir::Value`" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "insertText": "Value<$1>", | ||
| // CHECK-NEXT: "insertTextFormat": 2, | ||
| // CHECK-NEXT: "kind": 7, | ||
| // CHECK-NEXT: "label": "Value<type>", | ||
| // CHECK-NEXT: "sortText": "0" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "detail": "ValueRange<type> constraint", | ||
| // CHECK-NEXT: "documentation": { | ||
| // CHECK-NEXT: "kind": "markdown", | ||
| // CHECK-NEXT: "value": "A single entity core constraint of type `mlir::ValueRange`" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "insertText": "ValueRange<$1>", | ||
| // CHECK-NEXT: "insertTextFormat": 2, | ||
| // CHECK-NEXT: "kind": 7, | ||
| // CHECK-NEXT: "label": "ValueRange<type>", | ||
| // CHECK-NEXT: "sortText": "0" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "detail": "(value: Value) -> Tuple<>", | ||
| // CHECK-NEXT: "kind": 8, | ||
| // CHECK-NEXT: "label": "ValueCst", | ||
| // CHECK-NEXT: "sortText": "2_ValueCst" | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: ] | ||
| // CHECK-NEXT: } | ||
| // ----- | ||
| {"jsonrpc":"2.0","id":3,"method":"shutdown"} | ||
| // ----- | ||
| {"jsonrpc":"2.0","method":"exit"} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // RUN: mlir-pdll-lsp-server -lit-test < %s | FileCheck %s | ||
| // This test checks support for split files by attempting to find the definition | ||
| // of a symbol in a split file. The interesting part of this test is that the | ||
| // file chunk before the one we are looking for the definition in has an error. | ||
| {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"pdll","capabilities":{},"trace":"off"}} | ||
| // ----- | ||
| {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{ | ||
| "uri":"test:///foo.pdll", | ||
| "languageId":"pdll", | ||
| "version":1, | ||
| "text":"Pattern Foo {\n// -----\nPattern {\n erase root: Op<toy.test>;\n }" | ||
| }}} | ||
| // ----- | ||
| {"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{ | ||
| "textDocument":{"uri":"test:///foo.pdll"}, | ||
| "position":{"line":3,"character":12} | ||
| }} | ||
| // CHECK: "id": 1 | ||
| // CHECK-NEXT: "jsonrpc": "2.0", | ||
| // CHECK-NEXT: "result": [ | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "range": { | ||
| // CHECK-NEXT: "end": { | ||
| // CHECK-NEXT: "character": 12, | ||
| // CHECK-NEXT: "line": 3 | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "start": { | ||
| // CHECK-NEXT: "character": 8, | ||
| // CHECK-NEXT: "line": 3 | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "uri": "{{.*}}/foo.pdll" | ||
| // CHECK-NEXT: } | ||
| // ----- | ||
| {"jsonrpc":"2.0","id":3,"method":"shutdown"} | ||
| // ----- | ||
| {"jsonrpc":"2.0","method":"exit"} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // RUN: mlir-pdll-lsp-server -lit-test < %s | FileCheck %s | ||
| {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"pdll","capabilities":{},"trace":"off"}} | ||
| // ----- | ||
| {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{ | ||
| "uri":"test:///foo.pdll", | ||
| "languageId":"pdll", | ||
| "version":1, | ||
| "text":"Pattern FooPattern {\nlet root: Op<toy.test>;\nerase root;\n}" | ||
| }}} | ||
| // ----- | ||
| {"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{ | ||
| "textDocument":{"uri":"test:///foo.pdll"}, | ||
| "position":{"line":0,"character":12} | ||
| }} | ||
| // CHECK: "id": 1 | ||
| // CHECK-NEXT: "jsonrpc": "2.0", | ||
| // CHECK-NEXT: "result": [ | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "range": { | ||
| // CHECK-NEXT: "end": { | ||
| // CHECK-NEXT: "character": 18, | ||
| // CHECK-NEXT: "line": 0 | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "start": { | ||
| // CHECK-NEXT: "character": 8, | ||
| // CHECK-NEXT: "line": 0 | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "uri": "{{.*}}/foo.pdll" | ||
| // CHECK-NEXT: } | ||
| // ----- | ||
| {"jsonrpc":"2.0","id":2,"method":"textDocument/definition","params":{ | ||
| "textDocument":{"uri":"test:///foo.pdll"}, | ||
| "position":{"line":2,"character":8} | ||
| }} | ||
| // CHECK: "id": 2 | ||
| // CHECK-NEXT: "jsonrpc": "2.0", | ||
| // CHECK-NEXT: "result": [ | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "range": { | ||
| // CHECK-NEXT: "end": { | ||
| // CHECK-NEXT: "character": 8, | ||
| // CHECK-NEXT: "line": 1 | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "start": { | ||
| // CHECK-NEXT: "character": 4, | ||
| // CHECK-NEXT: "line": 1 | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "uri": "{{.*}}/foo.pdll" | ||
| // CHECK-NEXT: } | ||
| // ----- | ||
| {"jsonrpc":"2.0","id":3,"method":"shutdown"} | ||
| // ----- | ||
| {"jsonrpc":"2.0","method":"exit"} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| // RUN: mlir-pdll-lsp-server -lit-test < %s | FileCheck -strict-whitespace %s | ||
| {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootUri":"test:///workspace","capabilities":{"textDocument":{"documentSymbol":{"hierarchicalDocumentSymbolSupport":true}}},"trace":"off"}} | ||
| // ----- | ||
| {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{ | ||
| "uri":"test:///foo.pdll", | ||
| "languageId":"pdll", | ||
| "version":1, | ||
| "text":"Pattern Foo {\nerase op<foo.op>;\n}\nConstraint Cst() -> Op{\nreturn op<toy.test>;\n}\n\nRewrite SomeRewrite() -> Op {\nreturn op: Op;\n}" | ||
| }}} | ||
| // ----- | ||
| {"jsonrpc":"2.0","id":1,"method":"textDocument/documentSymbol","params":{ | ||
| "textDocument":{"uri":"test:///foo.pdll"} | ||
| }} | ||
| // CHECK: "id": 1 | ||
| // CHECK-NEXT: "jsonrpc": "2.0", | ||
| // CHECK-NEXT: "result": [ | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "kind": 5, | ||
| // CHECK-NEXT: "name": "Foo", | ||
| // CHECK-NEXT: "range": { | ||
| // CHECK-NEXT: "end": { | ||
| // CHECK-NEXT: "character": 1, | ||
| // CHECK-NEXT: "line": 2 | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "start": { | ||
| // CHECK-NEXT: "character": 8, | ||
| // CHECK-NEXT: "line": 0 | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "selectionRange": { | ||
| // CHECK-NEXT: "end": { | ||
| // CHECK-NEXT: "character": 11, | ||
| // CHECK-NEXT: "line": 0 | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "start": { | ||
| // CHECK-NEXT: "character": 8, | ||
| // CHECK-NEXT: "line": 0 | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "kind": 12, | ||
| // CHECK-NEXT: "name": "Cst", | ||
| // CHECK-NEXT: "range": { | ||
| // CHECK-NEXT: "end": { | ||
| // CHECK-NEXT: "character": 14, | ||
| // CHECK-NEXT: "line": 3 | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "start": { | ||
| // CHECK-NEXT: "character": 11, | ||
| // CHECK-NEXT: "line": 3 | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "selectionRange": { | ||
| // CHECK-NEXT: "end": { | ||
| // CHECK-NEXT: "character": 14, | ||
| // CHECK-NEXT: "line": 3 | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "start": { | ||
| // CHECK-NEXT: "character": 11, | ||
| // CHECK-NEXT: "line": 3 | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "kind": 12, | ||
| // CHECK-NEXT: "name": "SomeRewrite", | ||
| // CHECK-NEXT: "range": { | ||
| // CHECK-NEXT: "end": { | ||
| // CHECK-NEXT: "character": 19, | ||
| // CHECK-NEXT: "line": 7 | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "start": { | ||
| // CHECK-NEXT: "character": 8, | ||
| // CHECK-NEXT: "line": 7 | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "selectionRange": { | ||
| // CHECK-NEXT: "end": { | ||
| // CHECK-NEXT: "character": 19, | ||
| // CHECK-NEXT: "line": 7 | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "start": { | ||
| // CHECK-NEXT: "character": 8, | ||
| // CHECK-NEXT: "line": 7 | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: ] | ||
| // ----- | ||
| {"jsonrpc":"2.0","id":3,"method":"shutdown"} | ||
| // ----- | ||
| {"jsonrpc":"2.0","method":"exit"} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // RUN: not mlir-pdll-lsp-server < %s 2> %t.err | ||
| // RUN: FileCheck %s < %t.err | ||
| // | ||
| // No LSP messages here, just let mlir-pdll-lsp-server see the end-of-file | ||
| // CHECK: Transport error: | ||
| // (Typically "Transport error: Input/output error" but platform-dependent). | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| // RUN: mlir-pdll-lsp-server -lit-test < %s | ||
| {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"pdll","capabilities":{},"trace":"off"}} | ||
| // ----- | ||
| {"jsonrpc":"2.0","id":3,"method":"shutdown"} | ||
| // ----- | ||
| {"jsonrpc":"2.0","method":"exit"} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| // RUN: not mlir-pdll-lsp-server -lit-test < %s | ||
| {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"pdll","capabilities":{},"trace":"off"}} | ||
| // ----- | ||
| {"jsonrpc":"2.0","method":"exit"} |