mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-25 09:05:10 +00:00
good enough to index c++ headers!
This commit is contained in:
parent
b33bd54922
commit
bebb230603
22
main.cpp
22
main.cpp
@ -758,7 +758,12 @@ void VisitDeclForTypeUsageVisitorHandler(clang::Cursor cursor, VisitDeclForTypeU
|
|||||||
param->has_processed_any = true;
|
param->has_processed_any = true;
|
||||||
ParsingDatabase* db = param->db;
|
ParsingDatabase* db = param->db;
|
||||||
|
|
||||||
TypeId ref_type_id = db->ToTypeId(cursor.get_referenced().get_usr());
|
// TODO: Something in STL (type_traits)? reports an empty USR.
|
||||||
|
std::string referenced_usr = cursor.get_referenced().get_usr();
|
||||||
|
if (referenced_usr == "")
|
||||||
|
return;
|
||||||
|
|
||||||
|
TypeId ref_type_id = db->ToTypeId(referenced_usr);
|
||||||
if (!param->initial_type)
|
if (!param->initial_type)
|
||||||
param->initial_type = ref_type_id;
|
param->initial_type = ref_type_id;
|
||||||
|
|
||||||
@ -1370,6 +1375,11 @@ void DiffDocuments(rapidjson::Document& expected, rapidjson::Document& actual) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WriteToFile(const std::string& filename, const std::string& content) {
|
||||||
|
std::ofstream file(filename);
|
||||||
|
file << content;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
/*
|
/*
|
||||||
ParsingDatabase db = Parse("tests/vars/function_local.cc");
|
ParsingDatabase db = Parse("tests/vars/function_local.cc");
|
||||||
@ -1379,7 +1389,7 @@ int main(int argc, char** argv) {
|
|||||||
return 0;
|
return 0;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DUMP_AST = true;
|
DUMP_AST = false;
|
||||||
|
|
||||||
for (std::string path : GetFilesInFolder("tests")) {
|
for (std::string path : GetFilesInFolder("tests")) {
|
||||||
//if (path != "tests/declaration_vs_definition/class_member_static.cc") continue;
|
//if (path != "tests/declaration_vs_definition/class_member_static.cc") continue;
|
||||||
@ -1396,7 +1406,7 @@ int main(int argc, char** argv) {
|
|||||||
//if (path != "tests/usage/func_usage_addr_method.cc") continue;
|
//if (path != "tests/usage/func_usage_addr_method.cc") continue;
|
||||||
//if (path != "tests/usage/type_usage_typedef_and_using.cc") continue;
|
//if (path != "tests/usage/type_usage_typedef_and_using.cc") continue;
|
||||||
//if (path != "tests/usage/usage_inside_of_call.cc") continue;
|
//if (path != "tests/usage/usage_inside_of_call.cc") continue;
|
||||||
//if (path != "tests/foobar.cc") continue;
|
if (path != "tests/foobar.cc") continue;
|
||||||
//if (path != "tests/types/anonymous_struct.cc") continue;
|
//if (path != "tests/types/anonymous_struct.cc") continue;
|
||||||
|
|
||||||
// Parse expected output from the test, parse it into JSON document.
|
// Parse expected output from the test, parse it into JSON document.
|
||||||
@ -1409,6 +1419,10 @@ int main(int argc, char** argv) {
|
|||||||
std::cout << "[START] " << path << std::endl;
|
std::cout << "[START] " << path << std::endl;
|
||||||
ParsingDatabase db = Parse(path);
|
ParsingDatabase db = Parse(path);
|
||||||
std::string actual_output = db.ToString();
|
std::string actual_output = db.ToString();
|
||||||
|
|
||||||
|
WriteToFile("output.json", actual_output);
|
||||||
|
break;
|
||||||
|
|
||||||
rapidjson::Document actual;
|
rapidjson::Document actual;
|
||||||
actual.Parse(actual_output.c_str());
|
actual.Parse(actual_output.c_str());
|
||||||
|
|
||||||
@ -1428,7 +1442,7 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cin.get();
|
//std::cin.get();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user