MLIR  22.0.0git
Classes | Functions
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/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. More...
 
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. More...
 
static llvm::lsp::Location getLocationFromLoc (SourceMgr &mgr, SMRange loc, const llvm::lsp::URIForFile &uri)
 Returns a language server location from the given source range. More...
 
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. More...
 
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. More...
 

Function Documentation

◆ convertTokenLocToRange()

static 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 33 of file TableGenServer.cpp.

References mlir::lsp::convertTokenLocToRange().

Referenced by getLocationFromLoc().

◆ getBaseValue()

static 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 112 of file TableGenServer.cpp.

◆ getLocationFromLoc() [1/2]

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

Definition at line 63 of file TableGenServer.cpp.

References convertTokenLocToRange(), and getLocationFromLoc().

◆ getLocationFromLoc() [2/2]

static 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 57 of file TableGenServer.cpp.

References getURIFromLoc().

Referenced by getLocationFromLoc(), and getLspDiagnoticFromDiag().

◆ getLspDiagnoticFromDiag()

static 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 70 of file TableGenServer.cpp.

References diag(), Error, and getLocationFromLoc().

◆ getURIFromLoc()

static 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 40 of file TableGenServer.cpp.

References toString().

Referenced by getLocationFromLoc().