MLIR 22.0.0git
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 "llvm/Support/VirtualFileSystem.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.
static bool isMainFileLoc (llvm::SourceMgr &mgr, SMRange loc)
 Returns true if the given location is in the main file of the source manager.
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.
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.
static std::optional< std::string > getDocumentationFor (llvm::SourceMgr &sourceMgr, const ast::Decl *decl)
 Get or extract the documentation for the given decl.
static bool shouldAddHintFor (const ast::Expr *expr, StringRef name)
 Returns true if the given name should be added as a hint for expr.

Function Documentation

◆ getDocumentationFor()

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 123 of file PDLLServer.cpp.

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

◆ getLocationFromLoc()

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 66 of file PDLLServer.cpp.

References getURIFromLoc().

Referenced by getLspDiagnoticFromDiag().

◆ getLspDiagnoticFromDiag()

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 74 of file PDLLServer.cpp.

References diag(), and getLocationFromLoc().

◆ getURIFromLoc()

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 43 of file PDLLServer.cpp.

Referenced by getLocationFromLoc().

◆ isMainFileLoc()

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 60 of file PDLLServer.cpp.

◆ shouldAddHintFor()

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 1183 of file PDLLServer.cpp.

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