diff --git a/clang-tools-extra/clangd/Protocol.h b/clang-tools-extra/clangd/Protocol.h --- a/clang-tools-extra/clangd/Protocol.h +++ b/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. diff --git a/clang-tools-extra/clangd/Protocol.cpp b/clang-tools-extra/clangd/Protocol.cpp --- a/clang-tools-extra/clangd/Protocol.cpp +++ b/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: diff --git a/clang-tools-extra/clangd/tool/Check.cpp b/clang-tools-extra/clangd/tool/Check.cpp --- a/clang-tools-extra/clangd/tool/Check.cpp +++ b/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 LineRange) { + void buildInlayHints(llvm::Optional 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);