MLIR  22.0.0git
Classes | Functions
PDLLServer.cpp File Reference
#include "PDLLServer.h"
#include "Protocol.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/Support/ToolUtilities.h"
#include "mlir/Tools/PDLL/AST/Context.h"
#include "mlir/Tools/PDLL/AST/Nodes.h"
#include "mlir/Tools/PDLL/AST/Types.h"
#include "mlir/Tools/PDLL/CodeGen/CPPGen.h"
#include "mlir/Tools/PDLL/CodeGen/MLIRGen.h"
#include "mlir/Tools/PDLL/ODS/Constraint.h"
#include "mlir/Tools/PDLL/ODS/Context.h"
#include "mlir/Tools/PDLL/ODS/Dialect.h"
#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/SourceMgrUtils.h"
#include "llvm/ADT/IntervalMap.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/LSP/Logging.h"
#include "llvm/Support/Path.h"
#include <optional>

Go to the source code of this file.

Classes

struct  mlir::lsp::PDLLServer::Impl
 

Functions

static llvm::lsp::URIForFile getURIFromLoc (llvm::SourceMgr &mgr, SMRange loc, const llvm::lsp::URIForFile &mainFileURI)
 Returns a language server uri for the given source location. More...
 
static bool isMainFileLoc (llvm::SourceMgr &mgr, SMRange loc)
 Returns true if the given location is in the main file of the source manager. More...
 
static llvm::lsp::Location getLocationFromLoc (llvm::SourceMgr &mgr, SMRange range, const llvm::lsp::URIForFile &uri)
 Returns a language server location from the given source range. More...
 
static std::optional< llvm::lsp::Diagnostic > getLspDiagnoticFromDiag (llvm::SourceMgr &sourceMgr, const ast::Diagnostic &diag, const llvm::lsp::URIForFile &uri)
 Convert the given MLIR diagnostic to the LSP form. More...
 
static std::optional< std::string > getDocumentationFor (llvm::SourceMgr &sourceMgr, const ast::Decl *decl)
 Get or extract the documentation for the given decl. More...
 
static bool shouldAddHintFor (const ast::Expr *expr, StringRef name)
 Returns true if the given name should be added as a hint for expr. More...
 

Function Documentation

◆ getDocumentationFor()

static std::optional<std::string> getDocumentationFor ( llvm::SourceMgr &  sourceMgr,
const ast::Decl decl 
)
static

Get or extract the documentation for the given decl.

Definition at line 122 of file PDLLServer.cpp.

References mlir::lsp::extractSourceDocComment(), mlir::pdll::ast::Decl::getDocComment(), and mlir::pdll::ast::Node::getLoc().

◆ getLocationFromLoc()

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

Returns a language server location from the given source range.

Definition at line 65 of file PDLLServer.cpp.

References getURIFromLoc().

Referenced by getLspDiagnoticFromDiag().

◆ getLspDiagnoticFromDiag()

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

Convert the given MLIR diagnostic to the LSP form.

Definition at line 73 of file PDLLServer.cpp.

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

◆ getURIFromLoc()

static llvm::lsp::URIForFile getURIFromLoc ( llvm::SourceMgr &  mgr,
SMRange  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 42 of file PDLLServer.cpp.

References toString().

Referenced by getLocationFromLoc().

◆ isMainFileLoc()

static bool isMainFileLoc ( llvm::SourceMgr &  mgr,
SMRange  loc 
)
static

Returns true if the given location is in the main file of the source manager.

Definition at line 59 of file PDLLServer.cpp.

◆ shouldAddHintFor()

static bool shouldAddHintFor ( const ast::Expr expr,
StringRef  name 
)
static

Returns true if the given name should be added as a hint for expr.

Definition at line 1181 of file PDLLServer.cpp.

References mlir::pdll::ast::Name::getName().