MLIR 22.0.0git
TableGenServer.cpp File Reference
#include "TableGenServer.h"
#include "mlir/Support/IndentedOstream.h"
#include "mlir/Tools/lsp-server-support/CompilationDatabase.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/LSP/Logging.h"
#include "llvm/Support/LSP/Protocol.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/TableGen/Parser.h"
#include "llvm/TableGen/Record.h"
#include <optional>

Go to the source code of this file.

Classes

struct  mlir::lsp::TableGenServer::Impl

Functions

static SMRange convertTokenLocToRange (SMLoc loc)
 Returns the range of a lexical token given a SMLoc corresponding to the start of an token location.
static llvm::lsp::URIForFile getURIFromLoc (const SourceMgr &mgr, SMLoc loc, const llvm::lsp::URIForFile &mainFileURI)
 Returns a language server uri for the given source location.
static llvm::lsp::Location getLocationFromLoc (SourceMgr &mgr, SMRange loc, const llvm::lsp::URIForFile &uri)
 Returns a language server location from the given source range.
static llvm::lsp::Location getLocationFromLoc (SourceMgr &mgr, SMLoc loc, const llvm::lsp::URIForFile &uri)
static std::optional< llvm::lsp::Diagnostic > getLspDiagnoticFromDiag (const llvm::SMDiagnostic &diag, const llvm::lsp::URIForFile &uri)
 Convert the given TableGen diagnostic to the LSP form.
static std::pair< const Record *, const RecordVal * > getBaseValue (const Record *record, const RecordVal *value)
 Get the base definition of the given record value, or nullptr if one couldn't be found.

Function Documentation

◆ convertTokenLocToRange()

SMRange convertTokenLocToRange ( SMLoc loc)
static

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.

Definition at line 34 of file TableGenServer.cpp.

References mlir::lsp::convertTokenLocToRange().

Referenced by getLocationFromLoc().

◆ getBaseValue()

std::pair< const Record *, const RecordVal * > getBaseValue ( const Record * record,
const RecordVal * value )
static

Get the base definition of the given record value, or nullptr if one couldn't be found.

Definition at line 113 of file TableGenServer.cpp.

◆ getLocationFromLoc() [1/2]

llvm::lsp::Location getLocationFromLoc ( SourceMgr & mgr,
SMLoc loc,
const llvm::lsp::URIForFile & uri )
static

Definition at line 64 of file TableGenServer.cpp.

References convertTokenLocToRange(), and getLocationFromLoc().

◆ getLocationFromLoc() [2/2]

llvm::lsp::Location getLocationFromLoc ( SourceMgr & mgr,
SMRange loc,
const llvm::lsp::URIForFile & uri )
static

Returns a language server location from the given source range.

Definition at line 58 of file TableGenServer.cpp.

References getURIFromLoc().

Referenced by getLocationFromLoc(), and getLspDiagnoticFromDiag().

◆ getLspDiagnoticFromDiag()

std::optional< llvm::lsp::Diagnostic > getLspDiagnoticFromDiag ( const llvm::SMDiagnostic & diag,
const llvm::lsp::URIForFile & uri )
static

Convert the given TableGen diagnostic to the LSP form.

Definition at line 71 of file TableGenServer.cpp.

References diag(), and getLocationFromLoc().

◆ getURIFromLoc()

llvm::lsp::URIForFile getURIFromLoc ( const SourceMgr & mgr,
SMLoc loc,
const llvm::lsp::URIForFile & mainFileURI )
static

Returns a language server uri for the given source location.

mainFileURI corresponds to the uri for the main file of the source manager.

Definition at line 41 of file TableGenServer.cpp.

Referenced by getLocationFromLoc().