MLIR  20.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/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>

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 lsp::URIForFile getURIFromLoc (const SourceMgr &mgr, SMLoc loc, const lsp::URIForFile &mainFileURI)
 Returns a language server uri for the given source location. More...
 
static lsp::Location getLocationFromLoc (SourceMgr &mgr, SMRange loc, const lsp::URIForFile &uri)
 Returns a language server location from the given source range. More...
 
static lsp::Location getLocationFromLoc (SourceMgr &mgr, SMLoc loc, const lsp::URIForFile &uri)
 
static std::optional< lsp::DiagnosticgetLspDiagnoticFromDiag (const llvm::SMDiagnostic &diag, const 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 108 of file TableGenServer.cpp.

◆ getLocationFromLoc() [1/2]

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

Definition at line 59 of file TableGenServer.cpp.

References convertTokenLocToRange(), and getLocationFromLoc().

◆ getLocationFromLoc() [2/2]

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

Returns a language server location from the given source range.

Definition at line 54 of file TableGenServer.cpp.

References getURIFromLoc().

Referenced by getLocationFromLoc(), and getLspDiagnoticFromDiag().

◆ getLspDiagnoticFromDiag()

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

◆ getURIFromLoc()

static lsp::URIForFile getURIFromLoc ( const SourceMgr &  mgr,
SMLoc  loc,
const 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 39 of file TableGenServer.cpp.

References mlir::lsp::Logger::error(), mlir::lsp::URIForFile::fromFile(), and toString().

Referenced by getLocationFromLoc().