Improve AST handling (#165)

This commit is contained in:
ykiko
2025-08-03 17:43:42 +08:00
committed by GitHub
parent 893edc7634
commit 139eaa44f7
47 changed files with 1205 additions and 1094 deletions

View File

@@ -1,76 +1,75 @@
#include "Test/IndexTester.h"
namespace clice::testing {
namespace {
TEST(Index, FunctionParams) {
const char* code = R"cpp(
void foo(int);
void bar(int, int y = 2);
)cpp";
IndexTester tester("main.cpp", code);
tester.run();
/// auto data = tester.indices.find(tester.info->interested_file())->second.toJSON();
/// TODO: add more tests, FunctionTemplate, VarTemplate, ..., Dependent Name, ..., etc.
/// add tests for find references ..., !test symbol count.
}
TEST(Index, FunctionType) {
const char* code = R"cpp(
template <typename T>
struct function;
void bar(function<void(int)>& f);
void bar2(function<void(int x)>& f);
)cpp";
IndexTester tester("main.cpp", code);
tester.run();
/// auto data = tester.indices.find(tester.info->interested_file())->second.toJSON();
/// println("{}", data);
/// tester.info->tu()->dump();
/// TODO: add more tests, FunctionTemplate, VarTemplate, ..., Dependent Name, ..., etc.
/// add tests for find references ..., !test symbol count.
}
TEST(Index, Method) {
const char* code = R"cpp(
template <typename T, typename U>
struct function;
template <typename T, typename U>
requires (__is_same(U, int))
struct function<T, U> {
void foo();
};
template <typename T, typename U>
requires (__is_same(U, float))
struct function<T, U> {
void foo();
};
)cpp";
IndexTester tester("main.cpp", code);
tester.run();
/// auto data = tester.indices.find(tester.info->interested_file())->second.toJSON();
/// println("{}", data);
/// tester.info->tu()->dump();
/// TODO: add more tests, FunctionTemplate, VarTemplate, ..., Dependent Name, ..., etc.
/// add tests for find references ..., !test symbol count.
}
} // namespace
} // namespace clice::testing
/// #include "Test/IndexTester.h"
///
/// namespace clice::testing {
///
/// namespace {
///
/// TEST(Index, FunctionParams) {
/// const char* code = R"cpp(
/// void foo(int);
///
/// void bar(int, int y = 2);
/// )cpp";
///
/// IndexTester tester("main.cpp", code);
/// tester.run();
///
/// /// auto data = tester.indices.find(tester.info->interested_file())->second.toJSON();
///
/// /// TODO: add more tests, FunctionTemplate, VarTemplate, ..., Dependent Name, ..., etc.
/// /// add tests for find references ..., !test symbol count.
/// }
///
/// TEST(Index, FunctionType) {
/// const char* code = R"cpp(
/// template <typename T>
/// struct function;
///
/// void bar(function<void(int)>& f);
///
/// void bar2(function<void(int x)>& f);
/// )cpp";
///
/// IndexTester tester("main.cpp", code);
/// tester.run();
///
/// /// auto data = tester.indices.find(tester.info->interested_file())->second.toJSON();
/// /// println("{}", data);
/// /// tester.info->tu()->dump();
///
/// /// TODO: add more tests, FunctionTemplate, VarTemplate, ..., Dependent Name, ..., etc.
/// /// add tests for find references ..., !test symbol count.
/// }
///
/// TEST(Index, Method) {
/// const char* code = R"cpp(
/// template <typename T, typename U>
/// struct function;
///
/// template <typename T, typename U>
/// requires (__is_same(U, int))
/// struct function<T, U> {
/// void foo();
/// };
///
/// template <typename T, typename U>
/// requires (__is_same(U, float))
/// struct function<T, U> {
/// void foo();
/// };
/// )cpp";
///
/// IndexTester tester("main.cpp", code);
/// tester.run();
///
/// /// auto data = tester.indices.find(tester.info->interested_file())->second.toJSON();
/// /// println("{}", data);
/// /// tester.info->tu()->dump();
///
/// /// TODO: add more tests, FunctionTemplate, VarTemplate, ..., Dependent Name, ..., etc.
/// /// add tests for find references ..., !test symbol count.
/// }
///
/// } // namespace
///
/// } // namespace clice::testing