[Mlir-commits] [mlir] 305d718 - [mlir][NFC] Move the headers for lsp-server-support to include/
River Riddle
llvmlistbot at llvm.org
Fri Jan 27 17:36:20 PST 2023
Author: River Riddle
Date: 2023-01-27T17:36:06-08:00
New Revision: 305d718539659fb5fccd9b6e0771bbabc6c3c821
URL: https://github.com/llvm/llvm-project/commit/305d718539659fb5fccd9b6e0771bbabc6c3c821
DIFF: https://github.com/llvm/llvm-project/commit/305d718539659fb5fccd9b6e0771bbabc6c3c821.diff
LOG: [mlir][NFC] Move the headers for lsp-server-support to include/
This makes it a bit easier to share the functionality for building
language servers, and makes the API public. No real functional
change, as the API was already intended for this anyways.
Differential Revision: https://reviews.llvm.org/D142790
Added:
mlir/include/mlir/Tools/lsp-server-support/CompilationDatabase.h
mlir/include/mlir/Tools/lsp-server-support/Logging.h
mlir/include/mlir/Tools/lsp-server-support/Protocol.h
mlir/include/mlir/Tools/lsp-server-support/SourceMgrUtils.h
mlir/include/mlir/Tools/lsp-server-support/Transport.h
Modified:
mlir/lib/Tools/lsp-server-support/CMakeLists.txt
mlir/lib/Tools/lsp-server-support/CompilationDatabase.cpp
mlir/lib/Tools/lsp-server-support/Logging.cpp
mlir/lib/Tools/lsp-server-support/Protocol.cpp
mlir/lib/Tools/lsp-server-support/SourceMgrUtils.cpp
mlir/lib/Tools/lsp-server-support/Transport.cpp
mlir/lib/Tools/mlir-lsp-server/LSPServer.cpp
mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp
mlir/lib/Tools/mlir-lsp-server/MlirLspServerMain.cpp
mlir/lib/Tools/mlir-lsp-server/Protocol.h
mlir/lib/Tools/mlir-pdll-lsp-server/LSPServer.cpp
mlir/lib/Tools/mlir-pdll-lsp-server/MlirPdllLspServerMain.cpp
mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
mlir/lib/Tools/mlir-pdll-lsp-server/Protocol.h
mlir/lib/Tools/tblgen-lsp-server/LSPServer.cpp
mlir/lib/Tools/tblgen-lsp-server/TableGenLspServerMain.cpp
mlir/lib/Tools/tblgen-lsp-server/TableGenServer.cpp
Removed:
mlir/lib/Tools/lsp-server-support/CompilationDatabase.h
mlir/lib/Tools/lsp-server-support/Logging.h
mlir/lib/Tools/lsp-server-support/Protocol.h
mlir/lib/Tools/lsp-server-support/SourceMgrUtils.h
mlir/lib/Tools/lsp-server-support/Transport.h
################################################################################
diff --git a/mlir/lib/Tools/lsp-server-support/CompilationDatabase.h b/mlir/include/mlir/Tools/lsp-server-support/CompilationDatabase.h
similarity index 92%
rename from mlir/lib/Tools/lsp-server-support/CompilationDatabase.h
rename to mlir/include/mlir/Tools/lsp-server-support/CompilationDatabase.h
index 56a3d5126739b..84807ec2002c1 100644
--- a/mlir/lib/Tools/lsp-server-support/CompilationDatabase.h
+++ b/mlir/include/mlir/Tools/lsp-server-support/CompilationDatabase.h
@@ -13,8 +13,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LIB_MLIR_TOOLS_LSPSERVERSUPPORT_COMPILATIONDATABASE_H_
-#define LIB_MLIR_TOOLS_LSPSERVERSUPPORT_COMPILATIONDATABASE_H_
+#ifndef MLIR_TOOLS_LSPSERVERSUPPORT_COMPILATIONDATABASE_H
+#define MLIR_TOOLS_LSPSERVERSUPPORT_COMPILATIONDATABASE_H
#include "mlir/Support/LLVM.h"
#include "llvm/ADT/StringMap.h"
@@ -67,4 +67,4 @@ class CompilationDatabase {
} // namespace lsp
} // namespace mlir
-#endif // LIB_MLIR_TOOLS_LSPSERVERSUPPORT_COMPILATIONDATABASE_H_
+#endif // MLIR_TOOLS_LSPSERVERSUPPORT_COMPILATIONDATABASE_H
diff --git a/mlir/lib/Tools/lsp-server-support/Logging.h b/mlir/include/mlir/Tools/lsp-server-support/Logging.h
similarity index 92%
rename from mlir/lib/Tools/lsp-server-support/Logging.h
rename to mlir/include/mlir/Tools/lsp-server-support/Logging.h
index 5e68e7eb00f09..9b090d05f7fa4 100644
--- a/mlir/lib/Tools/lsp-server-support/Logging.h
+++ b/mlir/include/mlir/Tools/lsp-server-support/Logging.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LIB_MLIR_TOOLS_LSPSERVERSUPPORT_LOGGING_H
-#define LIB_MLIR_TOOLS_LSPSERVERSUPPORT_LOGGING_H
+#ifndef MLIR_TOOLS_LSPSERVERSUPPORT_LOGGING_H
+#define MLIR_TOOLS_LSPSERVERSUPPORT_LOGGING_H
#include "mlir/Support/LLVM.h"
#include "llvm/Support/Debug.h"
@@ -62,4 +62,4 @@ class Logger {
} // namespace lsp
} // namespace mlir
-#endif // LIB_MLIR_TOOLS_LSPSERVERSUPPORT_LOGGING_H
+#endif // MLIR_TOOLS_LSPSERVERSUPPORT_LOGGING_H
diff --git a/mlir/lib/Tools/lsp-server-support/Protocol.h b/mlir/include/mlir/Tools/lsp-server-support/Protocol.h
similarity index 99%
rename from mlir/lib/Tools/lsp-server-support/Protocol.h
rename to mlir/include/mlir/Tools/lsp-server-support/Protocol.h
index 8818a370e89d9..7e8360eba9da9 100644
--- a/mlir/lib/Tools/lsp-server-support/Protocol.h
+++ b/mlir/include/mlir/Tools/lsp-server-support/Protocol.h
@@ -20,8 +20,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LIB_MLIR_TOOLS_LSPSERVERSUPPORT_PROTOCOL_H_
-#define LIB_MLIR_TOOLS_LSPSERVERSUPPORT_PROTOCOL_H_
+#ifndef MLIR_TOOLS_LSPSERVERSUPPORT_PROTOCOL_H
+#define MLIR_TOOLS_LSPSERVERSUPPORT_PROTOCOL_H
#include "mlir/Support/LLVM.h"
#include "llvm/Support/JSON.h"
@@ -29,10 +29,10 @@
#include "llvm/Support/raw_ostream.h"
#include <bitset>
#include <memory>
+#include <optional>
#include <string>
#include <utility>
#include <vector>
-#include <optional>
namespace mlir {
struct LogicalResult;
diff --git a/mlir/lib/Tools/lsp-server-support/SourceMgrUtils.h b/mlir/include/mlir/Tools/lsp-server-support/SourceMgrUtils.h
similarity index 91%
rename from mlir/lib/Tools/lsp-server-support/SourceMgrUtils.h
rename to mlir/include/mlir/Tools/lsp-server-support/SourceMgrUtils.h
index 523ef89cf0ecc..969058b022889 100644
--- a/mlir/lib/Tools/lsp-server-support/SourceMgrUtils.h
+++ b/mlir/include/mlir/Tools/lsp-server-support/SourceMgrUtils.h
@@ -11,10 +11,10 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LIB_MLIR_TOOLS_LSPSERVERSUPPORT_TRANSPORT_H_
-#define LIB_MLIR_TOOLS_LSPSERVERSUPPORT_TRANSPORT_H_
+#ifndef MLIR_TOOLS_LSPSERVERSUPPORT_TRANSPORT_H
+#define MLIR_TOOLS_LSPSERVERSUPPORT_TRANSPORT_H
-#include "Protocol.h"
+#include "mlir/Tools/lsp-server-support/Protocol.h"
#include "llvm/Support/SourceMgr.h"
#include <optional>
@@ -27,7 +27,7 @@ namespace lsp {
/// Returns the range of a lexical token given a SMLoc corresponding to the
/// start of an token location. The range is computed heuristically, and
/// supports identifier-like tokens, strings, etc.
-SMRange convertTokenLocToRange(SMLoc loc);
+SMRange convertTokenLocToRange(SMLoc loc, StringRef identifierChars = "");
/// Extract a documentation comment for the given location within the source
/// manager. Returns std::nullopt if no comment could be computed.
diff --git a/mlir/lib/Tools/lsp-server-support/Transport.h b/mlir/include/mlir/Tools/lsp-server-support/Transport.h
similarity index 97%
rename from mlir/lib/Tools/lsp-server-support/Transport.h
rename to mlir/include/mlir/Tools/lsp-server-support/Transport.h
index 1f2f7d05219e6..0deb7e35fab6c 100644
--- a/mlir/lib/Tools/lsp-server-support/Transport.h
+++ b/mlir/include/mlir/Tools/lsp-server-support/Transport.h
@@ -12,13 +12,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LIB_MLIR_TOOLS_LSPSERVERSUPPORT_TRANSPORT_H_
-#define LIB_MLIR_TOOLS_LSPSERVERSUPPORT_TRANSPORT_H_
+#ifndef MLIR_TOOLS_LSPSERVERSUPPORT_TRANSPORT_H
+#define MLIR_TOOLS_LSPSERVERSUPPORT_TRANSPORT_H
-#include "Logging.h"
-#include "Protocol.h"
#include "mlir/Support/LLVM.h"
#include "mlir/Support/LogicalResult.h"
+#include "mlir/Tools/lsp-server-support/Logging.h"
+#include "mlir/Tools/lsp-server-support/Protocol.h"
#include "llvm/ADT/FunctionExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
diff --git a/mlir/lib/Tools/lsp-server-support/CMakeLists.txt b/mlir/lib/Tools/lsp-server-support/CMakeLists.txt
index d71ecfaa6b521..48a96016b792f 100644
--- a/mlir/lib/Tools/lsp-server-support/CMakeLists.txt
+++ b/mlir/lib/Tools/lsp-server-support/CMakeLists.txt
@@ -6,7 +6,7 @@ add_mlir_library(MLIRLspServerSupportLib
Transport.cpp
ADDITIONAL_HEADER_DIRS
- ${MLIR_MAIN_INCLUDE_DIR}/mlir/Tools/lsp-server
+ ${MLIR_MAIN_INCLUDE_DIR}/mlir/Tools/lsp-server-support
LINK_LIBS PUBLIC
MLIRSupport
diff --git a/mlir/lib/Tools/lsp-server-support/CompilationDatabase.cpp b/mlir/lib/Tools/lsp-server-support/CompilationDatabase.cpp
index 229e50a5de235..3688b6975a630 100644
--- a/mlir/lib/Tools/lsp-server-support/CompilationDatabase.cpp
+++ b/mlir/lib/Tools/lsp-server-support/CompilationDatabase.cpp
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "CompilationDatabase.h"
-#include "../lsp-server-support/Logging.h"
-#include "Protocol.h"
+#include "mlir/Tools/lsp-server-support/CompilationDatabase.h"
#include "mlir/Support/FileUtilities.h"
+#include "mlir/Tools/lsp-server-support/Logging.h"
+#include "mlir/Tools/lsp-server-support/Protocol.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/YAMLTraits.h"
diff --git a/mlir/lib/Tools/lsp-server-support/Logging.cpp b/mlir/lib/Tools/lsp-server-support/Logging.cpp
index 1feead5013949..6335fbfb5dfb8 100644
--- a/mlir/lib/Tools/lsp-server-support/Logging.cpp
+++ b/mlir/lib/Tools/lsp-server-support/Logging.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "Logging.h"
+#include "mlir/Tools/lsp-server-support/Logging.h"
#include "llvm/Support/Chrono.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/raw_ostream.h"
diff --git a/mlir/lib/Tools/lsp-server-support/Protocol.cpp b/mlir/lib/Tools/lsp-server-support/Protocol.cpp
index 3fdb95a4c56d6..0eba9fa4e60b8 100644
--- a/mlir/lib/Tools/lsp-server-support/Protocol.cpp
+++ b/mlir/lib/Tools/lsp-server-support/Protocol.cpp
@@ -10,9 +10,9 @@
//
//===----------------------------------------------------------------------===//
-#include "Protocol.h"
-#include "Logging.h"
+#include "mlir/Tools/lsp-server-support/Protocol.h"
#include "mlir/Support/LogicalResult.h"
+#include "mlir/Tools/lsp-server-support/Logging.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringSet.h"
diff --git a/mlir/lib/Tools/lsp-server-support/SourceMgrUtils.cpp b/mlir/lib/Tools/lsp-server-support/SourceMgrUtils.cpp
index 122d4e02ddb51..cb36066d4bc0c 100644
--- a/mlir/lib/Tools/lsp-server-support/SourceMgrUtils.cpp
+++ b/mlir/lib/Tools/lsp-server-support/SourceMgrUtils.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "SourceMgrUtils.h"
+#include "mlir/Tools/lsp-server-support/SourceMgrUtils.h"
#include "llvm/Support/Path.h"
#include <optional>
@@ -43,7 +43,7 @@ static const char *lexLocStringTok(const char *curPtr) {
return curPtr - 1;
}
-SMRange lsp::convertTokenLocToRange(SMLoc loc) {
+SMRange lsp::convertTokenLocToRange(SMLoc loc, StringRef identifierChars) {
if (!loc.isValid())
return SMRange();
const char *curPtr = loc.getPointer();
@@ -55,8 +55,8 @@ SMRange lsp::convertTokenLocToRange(SMLoc loc) {
// Otherwise, default to handling an identifier.
} else {
// Return if the given character is a valid identifier character.
- auto isIdentifierChar = [](char c) {
- return isalnum(c) || c == '$' || c == '.' || c == '_' || c == '-';
+ auto isIdentifierChar = [=](char c) {
+ return isalnum(c) || c == '_' || identifierChars.contains(c);
};
while (*curPtr && isIdentifierChar(*(++curPtr)))
diff --git a/mlir/lib/Tools/lsp-server-support/Transport.cpp b/mlir/lib/Tools/lsp-server-support/Transport.cpp
index e5bceac1e907c..92171f1a053ae 100644
--- a/mlir/lib/Tools/lsp-server-support/Transport.cpp
+++ b/mlir/lib/Tools/lsp-server-support/Transport.cpp
@@ -6,15 +6,15 @@
//
//===----------------------------------------------------------------------===//
-#include "Transport.h"
-#include "Logging.h"
-#include "Protocol.h"
+#include "mlir/Tools/lsp-server-support/Transport.h"
+#include "mlir/Tools/lsp-server-support/Logging.h"
+#include "mlir/Tools/lsp-server-support/Protocol.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/Errno.h"
#include "llvm/Support/Error.h"
+#include <optional>
#include <system_error>
#include <utility>
-#include <optional>
using namespace mlir;
using namespace mlir::lsp;
diff --git a/mlir/lib/Tools/mlir-lsp-server/LSPServer.cpp b/mlir/lib/Tools/mlir-lsp-server/LSPServer.cpp
index ab98729e57c13..d272164b1d267 100644
--- a/mlir/lib/Tools/mlir-lsp-server/LSPServer.cpp
+++ b/mlir/lib/Tools/mlir-lsp-server/LSPServer.cpp
@@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#include "LSPServer.h"
-#include "../lsp-server-support/Logging.h"
-#include "../lsp-server-support/Transport.h"
#include "MLIRServer.h"
#include "Protocol.h"
+#include "mlir/Tools/lsp-server-support/Logging.h"
+#include "mlir/Tools/lsp-server-support/Transport.h"
#include "llvm/ADT/FunctionExtras.h"
#include "llvm/ADT/StringMap.h"
#include <optional>
diff --git a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp
index 3699b51f2de46..397f2598ef73a 100644
--- a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp
+++ b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp
@@ -7,8 +7,6 @@
//===----------------------------------------------------------------------===//
#include "MLIRServer.h"
-#include "../lsp-server-support/Logging.h"
-#include "../lsp-server-support/SourceMgrUtils.h"
#include "Protocol.h"
#include "mlir/AsmParser/AsmParser.h"
#include "mlir/AsmParser/AsmParserState.h"
@@ -17,12 +15,21 @@
#include "mlir/IR/FunctionInterfaces.h"
#include "mlir/IR/Operation.h"
#include "mlir/Parser/Parser.h"
+#include "mlir/Tools/lsp-server-support/Logging.h"
+#include "mlir/Tools/lsp-server-support/SourceMgrUtils.h"
#include "llvm/Support/Base64.h"
#include "llvm/Support/SourceMgr.h"
#include <optional>
using namespace mlir;
+/// Returns the range of a lexical token given a SMLoc corresponding to the
+/// start of an token location. The range is computed heuristically, and
+/// supports identifier-like tokens, strings, etc.
+static SMRange convertTokenLocToRange(SMLoc loc) {
+ return lsp::convertTokenLocToRange(loc, "$-.");
+}
+
/// Returns a language server location from the given MLIR file location.
/// `uriScheme` is the scheme to use when building new uris.
static std::optional<lsp::Location> getLocationFromLoc(StringRef uriScheme,
@@ -65,7 +72,7 @@ getLocationFromLoc(llvm::SourceMgr &sourceMgr, Location loc,
// Use range of potential identifier starting at location, else length 1
// range.
location->range.end.character += 1;
- if (std::optional<SMRange> range = lsp::convertTokenLocToRange(loc)) {
+ if (std::optional<SMRange> range = convertTokenLocToRange(loc)) {
auto lineCol = sourceMgr.getLineAndColumn(range->End);
location->range.end.character =
std::max(fileLoc.getColumn() + 1, lineCol.second - 1);
diff --git a/mlir/lib/Tools/mlir-lsp-server/MlirLspServerMain.cpp b/mlir/lib/Tools/mlir-lsp-server/MlirLspServerMain.cpp
index f7558ad64372d..259bd2613a6cc 100644
--- a/mlir/lib/Tools/mlir-lsp-server/MlirLspServerMain.cpp
+++ b/mlir/lib/Tools/mlir-lsp-server/MlirLspServerMain.cpp
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "mlir/Tools/mlir-lsp-server/MlirLspServerMain.h"
-#include "../lsp-server-support/Logging.h"
-#include "../lsp-server-support/Transport.h"
#include "LSPServer.h"
#include "MLIRServer.h"
#include "mlir/IR/Dialect.h"
+#include "mlir/Tools/lsp-server-support/Logging.h"
+#include "mlir/Tools/lsp-server-support/Transport.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Program.h"
diff --git a/mlir/lib/Tools/mlir-lsp-server/Protocol.h b/mlir/lib/Tools/mlir-lsp-server/Protocol.h
index 12a4dd269b537..d910780e1ee92 100644
--- a/mlir/lib/Tools/mlir-lsp-server/Protocol.h
+++ b/mlir/lib/Tools/mlir-lsp-server/Protocol.h
@@ -20,7 +20,7 @@
#ifndef LIB_MLIR_TOOLS_MLIRLSPSERVER_PROTOCOL_H_
#define LIB_MLIR_TOOLS_MLIRLSPSERVER_PROTOCOL_H_
-#include "../lsp-server-support/Protocol.h"
+#include "mlir/Tools/lsp-server-support/Protocol.h"
namespace mlir {
namespace lsp {
diff --git a/mlir/lib/Tools/mlir-pdll-lsp-server/LSPServer.cpp b/mlir/lib/Tools/mlir-pdll-lsp-server/LSPServer.cpp
index c91dc89505433..f02372367e38c 100644
--- a/mlir/lib/Tools/mlir-pdll-lsp-server/LSPServer.cpp
+++ b/mlir/lib/Tools/mlir-pdll-lsp-server/LSPServer.cpp
@@ -8,10 +8,10 @@
#include "LSPServer.h"
-#include "../lsp-server-support/Logging.h"
-#include "../lsp-server-support/Transport.h"
#include "PDLLServer.h"
#include "Protocol.h"
+#include "mlir/Tools/lsp-server-support/Logging.h"
+#include "mlir/Tools/lsp-server-support/Transport.h"
#include "llvm/ADT/FunctionExtras.h"
#include "llvm/ADT/StringMap.h"
#include <optional>
diff --git a/mlir/lib/Tools/mlir-pdll-lsp-server/MlirPdllLspServerMain.cpp b/mlir/lib/Tools/mlir-pdll-lsp-server/MlirPdllLspServerMain.cpp
index 8c483b9228aa6..287a131ecd17d 100644
--- a/mlir/lib/Tools/mlir-pdll-lsp-server/MlirPdllLspServerMain.cpp
+++ b/mlir/lib/Tools/mlir-pdll-lsp-server/MlirPdllLspServerMain.cpp
@@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#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 "mlir/Tools/lsp-server-support/Logging.h"
+#include "mlir/Tools/lsp-server-support/Transport.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Program.h"
diff --git a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
index f209f2a62c24c..4c6aaf34ba05c 100644
--- a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
+++ b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
@@ -8,9 +8,6 @@
#include "PDLLServer.h"
-#include "../lsp-server-support/CompilationDatabase.h"
-#include "../lsp-server-support/Logging.h"
-#include "../lsp-server-support/SourceMgrUtils.h"
#include "Protocol.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/Tools/PDLL/AST/Context.h"
@@ -24,6 +21,9 @@
#include "mlir/Tools/PDLL/ODS/Operation.h"
#include "mlir/Tools/PDLL/Parser/CodeComplete.h"
#include "mlir/Tools/PDLL/Parser/Parser.h"
+#include "mlir/Tools/lsp-server-support/CompilationDatabase.h"
+#include "mlir/Tools/lsp-server-support/Logging.h"
+#include "mlir/Tools/lsp-server-support/SourceMgrUtils.h"
#include "llvm/ADT/IntervalMap.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringSet.h"
diff --git a/mlir/lib/Tools/mlir-pdll-lsp-server/Protocol.h b/mlir/lib/Tools/mlir-pdll-lsp-server/Protocol.h
index 3de2ae0f56c91..0706316631851 100644
--- a/mlir/lib/Tools/mlir-pdll-lsp-server/Protocol.h
+++ b/mlir/lib/Tools/mlir-pdll-lsp-server/Protocol.h
@@ -20,7 +20,7 @@
#ifndef LIB_MLIR_TOOLS_MLIRPDLLLSPSERVER_PROTOCOL_H_
#define LIB_MLIR_TOOLS_MLIRPDLLLSPSERVER_PROTOCOL_H_
-#include "../lsp-server-support/Protocol.h"
+#include "mlir/Tools/lsp-server-support/Protocol.h"
namespace mlir {
namespace lsp {
diff --git a/mlir/lib/Tools/tblgen-lsp-server/LSPServer.cpp b/mlir/lib/Tools/tblgen-lsp-server/LSPServer.cpp
index 81fb5a015fa0a..b62f68db9d60f 100644
--- a/mlir/lib/Tools/tblgen-lsp-server/LSPServer.cpp
+++ b/mlir/lib/Tools/tblgen-lsp-server/LSPServer.cpp
@@ -8,10 +8,10 @@
#include "LSPServer.h"
-#include "../lsp-server-support/Logging.h"
-#include "../lsp-server-support/Protocol.h"
-#include "../lsp-server-support/Transport.h"
#include "TableGenServer.h"
+#include "mlir/Tools/lsp-server-support/Logging.h"
+#include "mlir/Tools/lsp-server-support/Protocol.h"
+#include "mlir/Tools/lsp-server-support/Transport.h"
#include "llvm/ADT/FunctionExtras.h"
#include "llvm/ADT/StringMap.h"
#include <optional>
diff --git a/mlir/lib/Tools/tblgen-lsp-server/TableGenLspServerMain.cpp b/mlir/lib/Tools/tblgen-lsp-server/TableGenLspServerMain.cpp
index 9f47a791f3ff4..21af78c9a506c 100644
--- a/mlir/lib/Tools/tblgen-lsp-server/TableGenLspServerMain.cpp
+++ b/mlir/lib/Tools/tblgen-lsp-server/TableGenLspServerMain.cpp
@@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#include "mlir/Tools/tblgen-lsp-server/TableGenLspServerMain.h"
-#include "../lsp-server-support/Logging.h"
-#include "../lsp-server-support/Transport.h"
#include "LSPServer.h"
#include "TableGenServer.h"
+#include "mlir/Tools/lsp-server-support/Logging.h"
+#include "mlir/Tools/lsp-server-support/Transport.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Program.h"
diff --git a/mlir/lib/Tools/tblgen-lsp-server/TableGenServer.cpp b/mlir/lib/Tools/tblgen-lsp-server/TableGenServer.cpp
index 33d20c94b820d..5ea91a226c831 100644
--- a/mlir/lib/Tools/tblgen-lsp-server/TableGenServer.cpp
+++ b/mlir/lib/Tools/tblgen-lsp-server/TableGenServer.cpp
@@ -8,12 +8,12 @@
#include "TableGenServer.h"
-#include "../lsp-server-support/CompilationDatabase.h"
-#include "../lsp-server-support/Logging.h"
-#include "../lsp-server-support/Protocol.h"
-#include "../lsp-server-support/SourceMgrUtils.h"
#include "mlir/Support/IndentedOstream.h"
#include "mlir/Support/LogicalResult.h"
+#include "mlir/Tools/lsp-server-support/CompilationDatabase.h"
+#include "mlir/Tools/lsp-server-support/Logging.h"
+#include "mlir/Tools/lsp-server-support/Protocol.h"
+#include "mlir/Tools/lsp-server-support/SourceMgrUtils.h"
#include "llvm/ADT/IntervalMap.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/StringMap.h"
@@ -27,6 +27,13 @@
using namespace mlir;
+/// Returns the range of a lexical token given a SMLoc corresponding to the
+/// start of an token location. The range is computed heuristically, and
+/// supports identifier-like tokens, strings, etc.
+static SMRange convertTokenLocToRange(SMLoc loc) {
+ return lsp::convertTokenLocToRange(loc, "$");
+}
+
/// Returns a language server uri for the given source location. `mainFileURI`
/// corresponds to the uri for the main file of the source manager.
static lsp::URIForFile getURIFromLoc(const llvm::SourceMgr &mgr, SMLoc loc,
@@ -51,7 +58,7 @@ static lsp::Location getLocationFromLoc(llvm::SourceMgr &mgr, SMRange loc,
}
static lsp::Location getLocationFromLoc(llvm::SourceMgr &mgr, SMLoc loc,
const lsp::URIForFile &uri) {
- return getLocationFromLoc(mgr, lsp::convertTokenLocToRange(loc), uri);
+ return getLocationFromLoc(mgr, convertTokenLocToRange(loc), uri);
}
/// Convert the given TableGen diagnostic to the LSP form.
@@ -139,10 +146,9 @@ namespace {
struct TableGenIndexSymbol {
TableGenIndexSymbol(const llvm::Record *record)
: definition(record),
- defLoc(lsp::convertTokenLocToRange(record->getLoc().front())) {}
+ defLoc(convertTokenLocToRange(record->getLoc().front())) {}
TableGenIndexSymbol(const llvm::RecordVal *value)
- : definition(value),
- defLoc(lsp::convertTokenLocToRange(value->getLoc())) {}
+ : definition(value), defLoc(convertTokenLocToRange(value->getLoc())) {}
virtual ~TableGenIndexSymbol() = default;
// The main definition of the symbol.
@@ -256,7 +262,7 @@ void TableGenIndex::initialize(const llvm::RecordKeeper &records) {
// If the location we got was empty, try to lex a token from the start
// location.
if (startLoc == endLoc) {
- refLoc = lsp::convertTokenLocToRange(SMLoc::getFromPointer(startLoc));
+ refLoc = convertTokenLocToRange(SMLoc::getFromPointer(startLoc));
startLoc = refLoc.Start.getPointer();
endLoc = refLoc.End.getPointer();
@@ -286,7 +292,7 @@ void TableGenIndex::initialize(const llvm::RecordKeeper &records) {
// Add references to the definition.
for (SMLoc loc : def.getLoc().drop_front())
- insertRef(sym, lsp::convertTokenLocToRange(loc));
+ insertRef(sym, convertTokenLocToRange(loc));
for (SMRange loc : def.getReferenceLocs())
insertRef(sym, loc);
More information about the Mlir-commits
mailing list