Files
clice/tests/unit/feature/hover_tests.cpp
ykiko 418e190fa0 chore(deps): migrate from eventide to kotatsu (#428)
## Summary

- The `eventide` dep was renamed to
[kotatsu](https://github.com/clice-io/kotatsu) with a broad rename of
CMake identifiers, namespaces, header paths, and a few module reorgs
(`serde` → `codec`, `reflection` → `meta`, `common` → `support`). Align
clice to the new names.
- CMake: FetchContent target, option prefix (`ETD_*` → `KOTA_*`,
`ETD_SERDE_*` → `KOTA_CODEC_*`), target names
(`eventide::{ipc::lsp,serde::toml,deco,zest}` →
`kota::{ipc::lsp,codec::toml,deco,zest}`).
- Namespaces: `eventide::` → `kota::`, `eventide::serde::` →
`kota::codec::`, `eventide::refl::` → `kota::meta::`. The short `et`
alias is dropped — all usages now spell `kota::` directly.
- Headers: `eventide/*` → `kota/*`, including special cases
`serde/serde/raw_value.h` → `codec/raw_value.h`, `ipc/json_codec.h` →
`ipc/codec/json.h`, `common/meta.h` → `support/type_traits.h`,
`common/ranges.h` → `support/ranges.h`.
- Kotatsu split `JsonPeer` / `BincodePeer` out of `ipc/peer.h` into the
codec-specific headers; added `kota/ipc/codec/{json,bincode}.h` includes
where those types are used.
- Depends on clice-io/kotatsu#110 (already merged) to prevent `-Wall
-Wextra -Werror` from transitively propagating out of
`kota::project_options`.

## Test plan

- [x] `pixi run unit-test RelWithDebInfo` — 518/518 pass (9 skipped,
unchanged from main)
- [x] `pixi run integration-test RelWithDebInfo` — 119/119 pass
- [x] `pixi run smoke-test RelWithDebInfo` — 2/2 pass
- [x] `pixi run format` clean

## Notes

- `tests/smoke/rapid_edit.jsonl` was intentionally left untouched: the
embedded `#include "eventide/..."` strings are frozen snapshots of file
contents the client sent at record time, not clice source.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Chores**
* Updated internal dependencies from `eventide` to `kota`, including
async runtime, IPC transport, serialization codec, and metadata
libraries.
* Updated build configuration and CMake variables to align with the new
dependency.

* **Refactor**
* Migrated internal implementation to use `kota` namespace and APIs
throughout the codebase.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 13:49:07 +08:00

194 lines
3.2 KiB
C++

#include <optional>
#include "test/test.h"
#include "test/tester.h"
#include "feature/feature.h"
namespace clice::testing {
namespace {
namespace protocol = kota::ipc::protocol;
TEST_SUITE(Hover, Tester) {
std::optional<protocol::Hover> result;
void run(llvm::StringRef code) {
add_main("main.cpp", code);
ASSERT_TRUE(compile());
auto points = nameless_points();
ASSERT_EQ(points.size(), 1U);
auto offset = points[0];
result = feature::hover(*unit, offset, {}, feature::PositionEncoding::UTF8);
}
void compile_only(llvm::StringRef code) {
add_main("main.cpp", code);
ASSERT_TRUE(compile());
}
TEST_CASE(Namespace) {
run(R"cpp(
namespace $A {
}
)cpp");
ASSERT_TRUE(result.has_value());
auto* content = std::get_if<protocol::MarkupContent>(&result->contents);
ASSERT_TRUE(content != nullptr);
ASSERT_TRUE(content->value.find("namespace") != std::string::npos);
}
TEST_CASE(FunctionReference) {
run(R"cpp(
int foo() { return 0; }
int x = $foo();
)cpp");
ASSERT_TRUE(result.has_value());
auto* content = std::get_if<protocol::MarkupContent>(&result->contents);
ASSERT_TRUE(content != nullptr);
ASSERT_TRUE(content->value.find("foo") != std::string::npos);
}
TEST_CASE(RecordScope) {
compile_only(R"cpp(
typedef struct A {
struct B {
struct C {};
};
struct {
struct D {};
} _;
} T;
struct FORWARD_STRUCT;
struct FORWARD_CLASS;
void f() {
struct X {};
class Y {};
struct {
struct Z {};
} _;
}
namespace n1 {
namespace n2 {
struct NA {
struct NB {};
};
}
namespace {
struct NC {};
}
}
namespace out {
namespace in {
struct M {
int x;
double y;
char z;
T a, b;
};
}
}
)cpp");
}
TEST_CASE(EnumStyle) {
compile_only(R"cpp(
enum Free {
A = 1,
B = 2,
C = 999,
};
enum class Scope: long {
A = -8,
B = 2,
C = 100,
};
)cpp");
}
TEST_CASE(FunctionStyle) {
compile_only(R"cpp(
typedef long long ll;
ll f(int x, int y, ll z = 1) { return 0; }
template<typename T, typename S>
T t(T a, T b, int c, ll d, S s) { return a; }
namespace {
constexpr static const char* g() { return "hello"; }
}
namespace test {
namespace {
[[deprecated("test deprecate message")]] consteval int h() { return 1; }
}
}
struct A {
constexpr static A m(int left, double right) { return A(); }
};
)cpp");
}
TEST_CASE(VariableStyle) {
compile_only(R"cpp(
void f() {
constexpr static auto x1 = 1;
}
)cpp");
}
TEST_CASE(AutoAndDecltype) {
compile_only(R"cpp(
$(a1)aut$(a2)o$(a3) i = -1;
$(d1)dec$(d2)ltype$(d3)(i) j = 2;
struct A { int x; };
aut$(a4)o va$(a5)r = A{};
a$(fa)uto f1() { return 1; }
de$(fn_decltype)cltype(au$(fn_decltype_auto)to) f2() {}
int f3(au$(fn_para_auto)to x) {}
)cpp");
}
TEST_CASE(Expr) {
compile_only(R"cpp(
int xxxx = 1;
int yyyy = xx$(e1)xx;
struct A {
int function(int param) {
return thi$(e2)s$(e3)->$(e4)funct$(e5)ion(para$(e6)m);
}
int fn(int param) {
return static$(e7)_cast<A*>(nul$(e8)lptr)->function(par$(e9)am);
}
};
)cpp");
}
}; // TEST_SUITE(Hover)
} // namespace
} // namespace clice::testing