#include "TableGenServer.h"
#include "mlir/Support/IndentedOstream.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"
#include "llvm/Support/Path.h"
#include "llvm/TableGen/Parser.h"
#include "llvm/TableGen/Record.h"
#include <optional>
usingnamespacemlir;
static SMRange convertTokenLocToRange(SMLoc loc) { … }
static lsp::URIForFile getURIFromLoc(const llvm::SourceMgr &mgr, SMLoc loc,
const lsp::URIForFile &mainFileURI) { … }
static lsp::Location getLocationFromLoc(llvm::SourceMgr &mgr, SMRange loc,
const lsp::URIForFile &uri) { … }
static lsp::Location getLocationFromLoc(llvm::SourceMgr &mgr, SMLoc loc,
const lsp::URIForFile &uri) { … }
static std::optional<lsp::Diagnostic>
getLspDiagnoticFromDiag(const llvm::SMDiagnostic &diag,
const lsp::URIForFile &uri) { … }
static std::pair<const llvm::Record *, const llvm::RecordVal *>
getBaseValue(const llvm::Record *record, const llvm::RecordVal *value) { … }
namespace {
struct TableGenIndexSymbol { … };
struct TableGenRecordSymbol : public TableGenIndexSymbol { … };
struct TableGenRecordValSymbol : public TableGenIndexSymbol { … };
class TableGenIndex { … };
}
void TableGenIndex::initialize(const llvm::RecordKeeper &records) { … }
const TableGenIndexSymbol *
TableGenIndex::lookup(SMLoc loc, SMRange *overlappedRange) const { … }
namespace {
class TableGenTextFile { … };
}
TableGenTextFile::TableGenTextFile(
const lsp::URIForFile &uri, StringRef fileContents, int64_t version,
const std::vector<std::string> &extraIncludeDirs,
std::vector<lsp::Diagnostic> &diagnostics)
: … { … }
LogicalResult
TableGenTextFile::update(const lsp::URIForFile &uri, int64_t newVersion,
ArrayRef<lsp::TextDocumentContentChangeEvent> changes,
std::vector<lsp::Diagnostic> &diagnostics) { … }
void TableGenTextFile::initialize(const lsp::URIForFile &uri,
int64_t newVersion,
std::vector<lsp::Diagnostic> &diagnostics) { … }
void TableGenTextFile::getLocationsOf(const lsp::URIForFile &uri,
const lsp::Position &defPos,
std::vector<lsp::Location> &locations) { … }
void TableGenTextFile::findReferencesOf(
const lsp::URIForFile &uri, const lsp::Position &pos,
std::vector<lsp::Location> &references) { … }
void TableGenTextFile::getDocumentLinks(const lsp::URIForFile &uri,
std::vector<lsp::DocumentLink> &links) { … }
std::optional<lsp::Hover>
TableGenTextFile::findHover(const lsp::URIForFile &uri,
const lsp::Position &hoverPos) { … }
lsp::Hover TableGenTextFile::buildHoverForRecord(const llvm::Record *record,
const SMRange &hoverRange) { … }
lsp::Hover
TableGenTextFile::buildHoverForTemplateArg(const llvm::Record *record,
const llvm::RecordVal *value,
const SMRange &hoverRange) { … }
lsp::Hover TableGenTextFile::buildHoverForField(const llvm::Record *record,
const llvm::RecordVal *value,
const SMRange &hoverRange) { … }
struct lsp::TableGenServer::Impl { … };
lsp::TableGenServer::TableGenServer(const Options &options)
: … { … }
lsp::TableGenServer::~TableGenServer() = default;
void lsp::TableGenServer::addDocument(const URIForFile &uri, StringRef contents,
int64_t version,
std::vector<Diagnostic> &diagnostics) { … }
void lsp::TableGenServer::updateDocument(
const URIForFile &uri, ArrayRef<TextDocumentContentChangeEvent> changes,
int64_t version, std::vector<Diagnostic> &diagnostics) { … }
std::optional<int64_t>
lsp::TableGenServer::removeDocument(const URIForFile &uri) { … }
void lsp::TableGenServer::getLocationsOf(const URIForFile &uri,
const Position &defPos,
std::vector<Location> &locations) { … }
void lsp::TableGenServer::findReferencesOf(const URIForFile &uri,
const Position &pos,
std::vector<Location> &references) { … }
void lsp::TableGenServer::getDocumentLinks(
const URIForFile &uri, std::vector<DocumentLink> &documentLinks) { … }
std::optional<lsp::Hover>
lsp::TableGenServer::findHover(const URIForFile &uri,
const Position &hoverPos) { … }