[PATCH] D124344: [clangd] Output inlay hints with `clangd --check`
Tobias Ribizel via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 25 01:15:31 PDT 2022
upsj updated this revision to Diff 424838.
upsj added a comment.
Review updates
- Fix inverted check-lines condition
- Output InlayHintKind via ostream operators
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124344/new/
https://reviews.llvm.org/D124344
Files:
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/tool/Check.cpp
Index: clang-tools-extra/clangd/tool/Check.cpp
===================================================================
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -193,14 +193,13 @@
}
// Build Inlay Hints for the entire AST or the specified range
- bool buildInlayHints(llvm::Optional<Range> LineRange) {
+ void buildInlayHints(llvm::Optional<Range> LineRange) {
log("Building inlay hints");
auto Hints = inlayHints(*AST, LineRange);
for (const auto &Hint : Hints) {
- vlog(" {0} {1} {2}", toString(Hint.kind), Hint.position, Hint.label);
+ vlog(" {0} {1} {2}", Hint.kind, Hint.position, Hint.label);
}
- return true;
}
// Run AST-based features at each token in the file.
@@ -219,7 +218,7 @@
unsigned End = Start + Tok.length();
Position Pos = offsetToPosition(Inputs.Contents, Start);
- if (LineRange && LineRange->contains(Pos))
+ if (LineRange && !LineRange->contains(Pos))
continue;
trace::Span Trace("Token");
@@ -293,8 +292,9 @@
: /*Don't turn on local configs for an arbitrary temp path.*/ ""));
Checker C(File, Opts);
if (!C.buildCommand(TFS) || !C.buildInvocation(TFS, Contents) ||
- !C.buildAST() || !C.buildInlayHints(LineRange))
+ !C.buildAST())
return false;
+ C.buildInlayHints(LineRange);
C.testLocationFeatures(LineRange, EnableCodeCompletion);
log("All checks completed, {0} errors", C.ErrCount);
Index: clang-tools-extra/clangd/Protocol.h
===================================================================
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -1576,10 +1576,10 @@
/// naturally when placed inline with the code.
std::string label;
};
-const char *toString(InlayHintKind);
llvm::json::Value toJSON(const InlayHint &);
bool operator==(const InlayHint &, const InlayHint &);
bool operator<(const InlayHint &, const InlayHint &);
+llvm::raw_ostream &operator<<(llvm::raw_ostream &, InlayHintKind);
struct ReferenceContext {
/// Include the declaration of the current symbol.
Index: clang-tools-extra/clangd/Protocol.cpp
===================================================================
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -1345,6 +1345,10 @@
std::tie(B.position, B.range, B.kind, B.label);
}
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, InlayHintKind Kind) {
+ return OS << toString(Kind);
+}
+
static const char *toString(OffsetEncoding OE) {
switch (OE) {
case OffsetEncoding::UTF8:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124344.424838.patch
Type: text/x-patch
Size: 2629 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220425/c19f7140/attachment.bin>
More information about the cfe-commits
mailing list