Fix API of InlayHint, FoldingRange. (#87)

Co-authored-by: ur4t <46435411+ur4t@users.noreply.github.com>
This commit is contained in:
Shiyu
2025-02-20 20:56:51 +08:00
committed by GitHub
parent 6b12e7f610
commit bcb4c3895a
16 changed files with 632 additions and 684 deletions

View File

@@ -14,6 +14,8 @@ struct Tester {
llvm::StringMap<proto::Position> locations;
std::vector<std::string> sources;
proto::Position eof;
public:
Tester() = default;
@@ -31,6 +33,10 @@ public:
params.remappedFiles.emplace_back(name, content);
}
proto::Position endOfFile() const {
return eof;
}
llvm::StringRef annoate(llvm::StringRef content) {
auto& source = sources.emplace_back();
source.reserve(content.size());
@@ -75,6 +81,8 @@ public:
source.push_back(c);
}
eof.line = line;
eof.character = column;
return source;
}

View File

@@ -29,21 +29,21 @@ inline void EXPECT_EQ(const LHS& lhs,
const RHS& rhs,
std::source_location current = std::source_location::current()) {
if(!refl::equal(lhs, rhs)) {
std::string expect;
std::string left;
if constexpr(requires { json::Serde<LHS>::serialize; }) {
llvm::raw_string_ostream(expect) << json::serialize(lhs);
llvm::raw_string_ostream(left) << json::serialize(lhs);
} else {
expect = "cannot dump value";
left = "cannot dump value";
}
std::string actual;
std::string right;
if constexpr(requires { json::Serde<RHS>::serialize; }) {
llvm::raw_string_ostream(actual) << json::serialize(rhs);
llvm::raw_string_ostream(right) << json::serialize(rhs);
} else {
actual = "cannot dump value";
right = "cannot dump value";
}
EXPECT_FAILURE(std::format("expect: {}, actual: {}\n", expect, actual), current);
EXPECT_FAILURE(std::format("left : {}\nright: {}\n", left, right), current);
}
}