Skip to content

Commit 7bc5273

Browse files
committed
[mlir][NFC] Move the LSP agnostic files to a new lsp-server directory
This allows for sharing the implementation of key components across multiple MLIR language servers. These will be used in a followup to help implement a PDLL language server. Differential Revision: https://reviews.llvm.org/D121540
1 parent 943ad66 commit 7bc5273

File tree

12 files changed

+43
-34
lines changed

12 files changed

+43
-34
lines changed

mlir/lib/Tools/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
add_subdirectory(lsp-server-support)
12
add_subdirectory(mlir-lsp-server)
23
add_subdirectory(mlir-opt)
34
add_subdirectory(mlir-reduce)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
add_mlir_library(MLIRLspServerSupportLib
2+
Logging.cpp
3+
Protocol.cpp
4+
Transport.cpp
5+
6+
ADDITIONAL_HEADER_DIRS
7+
${MLIR_MAIN_INCLUDE_DIR}/mlir/Tools/lsp-server
8+
9+
LINK_LIBS PUBLIC
10+
MLIRSupport
11+
)

mlir/lib/Tools/mlir-lsp-server/lsp/Logging.h renamed to mlir/lib/Tools/lsp-server-support/Logging.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LIB_MLIR_TOOLS_MLIRLSPSERVER_LSP_LOGGING_H
10-
#define LIB_MLIR_TOOLS_MLIRLSPSERVER_LSP_LOGGING_H
9+
#ifndef LIB_MLIR_TOOLS_LSPSERVERSUPPORT_LOGGING_H
10+
#define LIB_MLIR_TOOLS_LSPSERVERSUPPORT_LOGGING_H
1111

1212
#include "mlir/Support/LLVM.h"
1313
#include "llvm/Support/Debug.h"
@@ -30,13 +30,16 @@ class Logger {
3030

3131
/// Initiate a log message at various severity levels. These should be called
3232
/// after a call to `initialize`.
33-
template <typename... Ts> static void debug(const char *fmt, Ts &&... vals) {
33+
template <typename... Ts>
34+
static void debug(const char *fmt, Ts &&...vals) {
3435
log(Level::Debug, fmt, llvm::formatv(fmt, std::forward<Ts>(vals)...));
3536
}
36-
template <typename... Ts> static void info(const char *fmt, Ts &&... vals) {
37+
template <typename... Ts>
38+
static void info(const char *fmt, Ts &&...vals) {
3739
log(Level::Info, fmt, llvm::formatv(fmt, std::forward<Ts>(vals)...));
3840
}
39-
template <typename... Ts> static void error(const char *fmt, Ts &&... vals) {
41+
template <typename... Ts>
42+
static void error(const char *fmt, Ts &&...vals) {
4043
log(Level::Error, fmt, llvm::formatv(fmt, std::forward<Ts>(vals)...));
4144
}
4245

@@ -59,4 +62,4 @@ class Logger {
5962
} // namespace lsp
6063
} // namespace mlir
6164

62-
#endif // LIB_MLIR_TOOLS_MLIRLSPSERVER_LSP_LOGGING_H
65+
#endif // LIB_MLIR_TOOLS_LSPSERVERSUPPORT_LOGGING_H

mlir/lib/Tools/mlir-lsp-server/lsp/Protocol.h renamed to mlir/lib/Tools/lsp-server-support/Protocol.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
//
2121
//===----------------------------------------------------------------------===//
2222

23-
#ifndef LIB_MLIR_TOOLS_MLIRLSPSERVER_LSP_PROTOCOL_H_
24-
#define LIB_MLIR_TOOLS_MLIRLSPSERVER_LSP_PROTOCOL_H_
23+
#ifndef LIB_MLIR_TOOLS_LSPSERVERSUPPORT_PROTOCOL_H_
24+
#define LIB_MLIR_TOOLS_LSPSERVERSUPPORT_PROTOCOL_H_
2525

2626
#include "mlir/Support/LLVM.h"
2727
#include "llvm/ADT/Optional.h"
@@ -644,7 +644,8 @@ llvm::json::Value toJSON(const PublishDiagnosticsParams &params);
644644
} // namespace mlir
645645

646646
namespace llvm {
647-
template <> struct format_provider<mlir::lsp::Position> {
647+
template <>
648+
struct format_provider<mlir::lsp::Position> {
648649
static void format(const mlir::lsp::Position &pos, raw_ostream &os,
649650
StringRef style) {
650651
assert(style.empty() && "style modifiers for this type are not supported");

mlir/lib/Tools/mlir-lsp-server/lsp/Transport.h renamed to mlir/lib/Tools/lsp-server-support/Transport.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
#ifndef LIB_MLIR_TOOLS_MLIRLSPSERVER_LSP_TRANSPORT_H_
16-
#define LIB_MLIR_TOOLS_MLIRLSPSERVER_LSP_TRANSPORT_H_
15+
#ifndef LIB_MLIR_TOOLS_LSPSERVERSUPPORT_TRANSPORT_H_
16+
#define LIB_MLIR_TOOLS_LSPSERVERSUPPORT_TRANSPORT_H_
1717

1818
#include "Logging.h"
1919
#include "Protocol.h"
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
add_mlir_library(MLIRLspServerLib
2-
lsp/Logging.cpp
3-
lsp/Protocol.cpp
4-
lsp/Transport.cpp
52
LSPServer.cpp
63
MLIRServer.cpp
74
MlirLspServerMain.cpp
@@ -11,5 +8,6 @@ add_mlir_library(MLIRLspServerLib
118

129
LINK_LIBS PUBLIC
1310
MLIRIR
11+
MLIRLspServerSupportLib
1412
MLIRParser
1513
)

mlir/lib/Tools/mlir-lsp-server/LSPServer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "LSPServer.h"
10+
#include "../lsp-server-support/Logging.h"
11+
#include "../lsp-server-support/Protocol.h"
12+
#include "../lsp-server-support/Transport.h"
1013
#include "MLIRServer.h"
11-
#include "lsp/Logging.h"
12-
#include "lsp/Protocol.h"
13-
#include "lsp/Transport.h"
1414
#include "llvm/ADT/FunctionExtras.h"
1515
#include "llvm/ADT/StringMap.h"
1616

0 commit comments

Comments
 (0)