|
MLIR 23.0.0git
|
#include "MLIRServer.h"#include "Protocol.h"#include "mlir/AsmParser/AsmParser.h"#include "mlir/AsmParser/AsmParserState.h"#include "mlir/AsmParser/CodeComplete.h"#include "mlir/Bytecode/BytecodeWriter.h"#include "mlir/IR/Operation.h"#include "mlir/Interfaces/FunctionInterfaces.h"#include "mlir/Parser/Parser.h"#include "mlir/Support/ToolUtilities.h"#include "mlir/Tools/lsp-server-support/SourceMgrUtils.h"#include "llvm/ADT/StringExtras.h"#include "llvm/Support/Base64.h"#include "llvm/Support/FileSystem.h"#include "llvm/Support/LSP/Logging.h"#include "llvm/Support/Path.h"#include "llvm/Support/SourceMgr.h"#include <optional>Go to the source code of this file.
Classes | |
| struct | mlir::lsp::MLIRServer::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 std::optional< lsp::Location > | getLocationFromLoc (StringRef uriScheme, FileLineColLoc loc, StringRef workspaceRoot) |
| Returns a language server location from the given MLIR file location. | |
| static std::optional< lsp::Location > | getLocationFromLoc (llvm::SourceMgr &sourceMgr, Location loc, StringRef uriScheme, StringRef workspaceRoot, const lsp::URIForFile *uri=nullptr) |
| Returns a language server location from the given MLIR location, or std::nullopt if one couldn't be created. | |
| static void | collectLocationsFromLoc (Location loc, std::vector< lsp::Location > &locations, const lsp::URIForFile &uri, StringRef workspaceRoot) |
| Collect all of the locations from the given MLIR location that are not contained within the given URI. | |
| static bool | contains (SMRange range, SMLoc loc) |
| Returns true if the given range contains the given source location. | |
| static bool | isDefOrUse (const AsmParserState::SMDefinition &def, SMLoc loc, SMRange *overlappedRange=nullptr) |
| Returns true if the given location is contained by the definition or one of the uses of the given SMDefinition. | |
| static std::optional< unsigned > | getResultNumberFromLoc (SMLoc loc) |
| Given a location pointing to a result, return the result number it refers to or std::nullopt if it refers to all of the results. | |
| static std::optional< StringRef > | getTextFromRange (SMRange range) |
| Given a source location range, return the text covered by the given range. | |
| static void | printDefBlockName (raw_ostream &os, Block *block, SMRange loc={}) |
| Given a block and source location, print the source name of the block to the given output stream. | |
| static void | printDefBlockName (raw_ostream &os, const AsmParserState::BlockDefinition &def) |
| static lsp::Diagnostic | getLspDiagnoticFromDiag (llvm::SourceMgr &sourceMgr, Diagnostic &diag, const lsp::URIForFile &uri, StringRef workspaceRoot) |
| Convert the given MLIR diagnostic to the LSP form. | |
|
static |
Collect all of the locations from the given MLIR location that are not contained within the given URI.
Definition at line 108 of file MLIRServer.cpp.
References mlir::WalkResult::advance(), getLocationFromLoc(), and mlir::LocationAttr::walk().
|
static |
Returns true if the given range contains the given source location.
Note that this has slightly different behavior than SMRange because it is inclusive of the end location.
Definition at line 129 of file MLIRServer.cpp.
Referenced by mlir::detail::Parser::codeCompleteDialectOrElidedOpName(), isDefOrUse(), and lexLocStringTok().
|
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 MLIRServer.cpp.
References mlir::lsp::convertTokenLocToRange().
Referenced by getLocationFromLoc().
|
static |
Returns a language server location from the given MLIR location, or std::nullopt if one couldn't be created.
uriScheme is the scheme to use when building new uris. uri is an optional additional filter that, when present, is used to filter sub locations that do not share the same uri.
Definition at line 75 of file MLIRServer.cpp.
References mlir::WalkResult::advance(), convertTokenLocToRange(), getLocationFromLoc(), mlir::WalkResult::interrupt(), and mlir::LocationAttr::walk().
|
static |
Returns a language server location from the given MLIR file location.
uriScheme is the scheme to use when building new uris.
Definition at line 40 of file MLIRServer.cpp.
References mlir::FileLineColLoc::getColumn(), mlir::FileLineColLoc::getFilename(), and mlir::FileLineColLoc::getLine().
Referenced by collectLocationsFromLoc(), getLocationFromLoc(), and getLspDiagnoticFromDiag().
|
static |
Convert the given MLIR diagnostic to the LSP form.
Definition at line 212 of file MLIRServer.cpp.
References diag(), mlir::Error, getLocationFromLoc(), mlir::Note, mlir::Remark, and mlir::Warning.
|
static |
Given a location pointing to a result, return the result number it refers to or std::nullopt if it refers to all of the results.
Definition at line 159 of file MLIRServer.cpp.
|
static |
Given a source location range, return the text covered by the given range.
If the range is invalid, returns std::nullopt.
Definition at line 186 of file MLIRServer.cpp.
|
static |
Returns true if the given location is contained by the definition or one of the uses of the given SMDefinition.
If provided, overlappedRange is set to the range within def that the provided loc overlapped with.
Definition at line 137 of file MLIRServer.cpp.
References contains(), mlir::AsmParserState::SMDefinition::loc, and mlir::AsmParserState::SMDefinition::uses.
|
static |
Given a block and source location, print the source name of the block to the given output stream.
Definition at line 195 of file MLIRServer.cpp.
Referenced by printDefBlockName().
|
static |
Definition at line 206 of file MLIRServer.cpp.
References mlir::AsmParserState::BlockDefinition::block, mlir::AsmParserState::BlockDefinition::definition, mlir::AsmParserState::SMDefinition::loc, and printDefBlockName().