Misc fixes

This commit is contained in:
Jacob Dufault 2017-04-18 17:05:14 -07:00
parent 2e8e3d29c5
commit 85734278d8
6 changed files with 76 additions and 35 deletions

View File

@ -46,10 +46,13 @@ $ npm install
$ code . $ code .
``` ```
After VSCode is running, you can hit `F5` to launch the extension locally. Make After VSCode is running, update the `ServerOptions` `cwd` parameter to point to
sure to open up settings and look over the configuration options. You will the absolute path of your build directory.
probably want to increase the number of indexers that run from 7 to 40 or 50,
depending on how many cores are on your CPUs. You can hit then `F5` to launch the extension locally. Make sure to open up
settings and look over the configuration options. You will probably want to
increase the number of indexers that run from 7 to 40 or 50, depending on how
many CPU cores you have.
If you run into issues, you can view debug output by running the If you run into issues, you can view debug output by running the
(`F1`) `View: Toggle Output` command and opening the `cquery` output section. (`F1`) `View: Toggle Output` command and opening the `cquery` output section.

View File

@ -82,7 +82,7 @@ struct IpcManager {
// TODO: Rename TypedBidiMessageQueue to IpcTransport? // TODO: Rename TypedBidiMessageQueue to IpcTransport?
using IpcMessageQueue = TypedBidiMessageQueue<IpcId, BaseIpcMessage>; using IpcMessageQueue = TypedBidiMessageQueue<IpcId, BaseIpcMessage>;
static constexpr const char* kIpcLanguageClientName = "language_client"; static constexpr const char* kIpcLanguageClientName = "lanclient";
static constexpr const int kQueueSizeBytes = 1024 * 8; static constexpr const int kQueueSizeBytes = 1024 * 8;
static IpcManager* instance_; static IpcManager* instance_;
@ -970,8 +970,8 @@ void IndexMain(
Index_DoIdMapQueue* queue_do_id_map, Index_DoIdMapQueue* queue_do_id_map,
Index_OnIdMappedQueue* queue_on_id_mapped, Index_OnIdMappedQueue* queue_on_id_mapped,
Index_OnIndexedQueue* queue_on_indexed) { Index_OnIndexedQueue* queue_on_indexed) {
SetCurrentThreadName("indexer");
SetCurrentThreadName("indexer");
while (true) { while (true) {
// TODO: process all off IndexMain_DoIndex before calling IndexMain_DoCreateIndexUpdate for // TODO: process all off IndexMain_DoIndex before calling IndexMain_DoCreateIndexUpdate for
// better icache behavior. We need to have some threads spinning on both though // better icache behavior. We need to have some threads spinning on both though
@ -1590,7 +1590,6 @@ void QueryDbMainLoop(
} }
void QueryDbMain(IndexerConfig* config) { void QueryDbMain(IndexerConfig* config) {
SetCurrentThreadName("querydb");
//std::cerr << "Running QueryDb" << std::endl; //std::cerr << "Running QueryDb" << std::endl;
// Create queues. // Create queues.
@ -1613,6 +1612,7 @@ void QueryDbMain(IndexerConfig* config) {
} }
// Run query db main loop. // Run query db main loop.
SetCurrentThreadName("querydb");
QueryDatabase db; QueryDatabase db;
while (true) { while (true) {
QueryDbMainLoop(config, &db, &queue_do_index, &queue_do_id_map, &queue_on_id_mapped, &queue_on_indexed, &project, &working_files, &completion_manager); QueryDbMainLoop(config, &db, &queue_do_index, &queue_do_id_map, &queue_on_id_mapped, &queue_on_indexed, &project, &working_files, &completion_manager);
@ -1691,9 +1691,9 @@ void QueryDbMain(IndexerConfig* config) {
// //
// |ipc| is connected to a server. // |ipc| is connected to a server.
void LanguageServerStdinLoop(IndexerConfig* config) { void LanguageServerStdinLoop(IndexerConfig* config) {
SetCurrentThreadName("stdin");
IpcManager* ipc = IpcManager::instance(); IpcManager* ipc = IpcManager::instance();
SetCurrentThreadName("stdin");
while (true) { while (true) {
std::unique_ptr<BaseIpcMessage> message = MessageRegistry::instance()->ReadMessageFromStdin(); std::unique_ptr<BaseIpcMessage> message = MessageRegistry::instance()->ReadMessageFromStdin();
@ -1890,12 +1890,12 @@ void LanguageServerMainLoop() {
} }
void LanguageServerMain(IndexerConfig* config) { void LanguageServerMain(IndexerConfig* config) {
SetCurrentThreadName("server");
// Run language client. // Run language client.
new std::thread([&config]() { new std::thread([&config]() {
LanguageServerStdinLoop(config); LanguageServerStdinLoop(config);
}); });
SetCurrentThreadName("server");
while (true) { while (true) {
LanguageServerMainLoop(); LanguageServerMainLoop();
std::this_thread::sleep_for(std::chrono::milliseconds(2)); std::this_thread::sleep_for(std::chrono::milliseconds(2));

View File

@ -1406,6 +1406,9 @@ void indexEntityReference(CXClientData client_data,
std::vector<std::unique_ptr<IndexedFile>> Parse(IndexerConfig* config, FileConsumer::SharedState* file_consumer_shared, std::string filename, std::vector<std::string> args, bool dump_ast) { std::vector<std::unique_ptr<IndexedFile>> Parse(IndexerConfig* config, FileConsumer::SharedState* file_consumer_shared, std::string filename, std::vector<std::string> args, bool dump_ast) {
// NOTE: uncomment to disable indexer
//return {};
filename = NormalizePath(filename); filename = NormalizePath(filename);
clang::Index index(0 /*excludeDeclarationsFromPCH*/, clang::Index index(0 /*excludeDeclarationsFromPCH*/,
@ -1446,6 +1449,33 @@ std::vector<std::unique_ptr<IndexedFile>> Parse(IndexerConfig* config, FileConsu
entry->path = NormalizePath(entry->path); entry->path = NormalizePath(entry->path);
entry->id_cache.primary_file = entry->path; entry->id_cache.primary_file = entry->path;
} }
/*
TODO: Fix interesting checks.
for (auto& entry : result) {
for (auto& type : entry->types) {
if (!type.HasInterestingState()) {
std::cerr << "!!!! NO INTERSETING STATE FOR " << entry->path << " of !!! " << filename << std::endl;
std::cerr << "!!!! USR " << type.def.usr << std::endl;
assert(false);
}
}
for (auto& func : entry->funcs) {
if (!func.HasInterestingState()) {
std::cerr << "!!!! NO INTERSETING STATE FOR " << entry->path << " of !!! " << filename << std::endl;
std::cerr << "!!!! USR " << func.def.usr << std::endl;
assert(false);
}
}
for (auto& var : entry->vars) {
if (!var.HasInterestingState()) {
std::cerr << "!!!! NO INTERSETING STATE FOR " << entry->path << " of !!! " << filename << std::endl;
std::cerr << "!!!! USR " << var.def.usr << std::endl;
assert(false);
}
}
}
*/
return result; return result;
} }

View File

@ -4,6 +4,7 @@
#include <optional.h> #include <optional.h>
#include <cassert>
#include <cstdint> #include <cstdint>
#include <functional> #include <functional>
#include <unordered_set> #include <unordered_set>
@ -298,8 +299,9 @@ void CompareGroups(
QueryFileId GetQueryFileIdFromPath(QueryDatabase* query_db, const std::string& path) { QueryFileId GetQueryFileIdFromPath(QueryDatabase* query_db, const std::string& path) {
auto it = query_db->usr_to_symbol.find(path); auto it = query_db->usr_to_symbol.find(path);
if (it != query_db->usr_to_symbol.end() && it->second.kind != SymbolKind::Invalid) { if (it != query_db->usr_to_symbol.end() && it->second.kind != SymbolKind::Invalid) {
assert(it->second.kind == SymbolKind::File); // TODO: should this be an assert?
return QueryFileId(it->second.idx); if (it->second.kind == SymbolKind::File)
return QueryFileId(it->second.idx);
} }
size_t idx = query_db->files.size(); size_t idx = query_db->files.size();
@ -311,8 +313,9 @@ QueryFileId GetQueryFileIdFromPath(QueryDatabase* query_db, const std::string& p
QueryTypeId GetQueryTypeIdFromUsr(QueryDatabase* query_db, const Usr& usr) { QueryTypeId GetQueryTypeIdFromUsr(QueryDatabase* query_db, const Usr& usr) {
auto it = query_db->usr_to_symbol.find(usr); auto it = query_db->usr_to_symbol.find(usr);
if (it != query_db->usr_to_symbol.end() && it->second.kind != SymbolKind::Invalid) { if (it != query_db->usr_to_symbol.end() && it->second.kind != SymbolKind::Invalid) {
assert(it->second.kind == SymbolKind::Type); // TODO: should this be an assert?
return QueryTypeId(it->second.idx); if (it->second.kind == SymbolKind::Type)
return QueryTypeId(it->second.idx);
} }
size_t idx = query_db->types.size(); size_t idx = query_db->types.size();
@ -324,8 +327,9 @@ QueryTypeId GetQueryTypeIdFromUsr(QueryDatabase* query_db, const Usr& usr) {
QueryFuncId GetQueryFuncIdFromUsr(QueryDatabase* query_db, const Usr& usr) { QueryFuncId GetQueryFuncIdFromUsr(QueryDatabase* query_db, const Usr& usr) {
auto it = query_db->usr_to_symbol.find(usr); auto it = query_db->usr_to_symbol.find(usr);
if (it != query_db->usr_to_symbol.end() && it->second.kind != SymbolKind::Invalid) { if (it != query_db->usr_to_symbol.end() && it->second.kind != SymbolKind::Invalid) {
assert(it->second.kind == SymbolKind::Func); // TODO: should this be an assert?
return QueryFuncId(it->second.idx); if (it->second.kind == SymbolKind::Func)
return QueryFuncId(it->second.idx);
} }
size_t idx = query_db->funcs.size(); size_t idx = query_db->funcs.size();
@ -337,8 +341,9 @@ QueryFuncId GetQueryFuncIdFromUsr(QueryDatabase* query_db, const Usr& usr) {
QueryVarId GetQueryVarIdFromUsr(QueryDatabase* query_db, const Usr& usr) { QueryVarId GetQueryVarIdFromUsr(QueryDatabase* query_db, const Usr& usr) {
auto it = query_db->usr_to_symbol.find(usr); auto it = query_db->usr_to_symbol.find(usr);
if (it != query_db->usr_to_symbol.end() && it->second.kind != SymbolKind::Invalid) { if (it != query_db->usr_to_symbol.end() && it->second.kind != SymbolKind::Invalid) {
assert(it->second.kind == SymbolKind::Var); // TODO: should this be an assert?
return QueryVarId(it->second.idx); if (it->second.kind == SymbolKind::Var)
return QueryVarId(it->second.idx);
} }
size_t idx = query_db->vars.size(); size_t idx = query_db->vars.size();

View File

@ -101,12 +101,13 @@ bool ReflectMemberStart(Reader& reader, IndexedTypeDef& value) {
return true; return true;
} }
bool ReflectMemberStart(Writer& writer, IndexedTypeDef& value) { bool ReflectMemberStart(Writer& writer, IndexedTypeDef& value) {
if (!value.HasInterestingState()) // TODO: this is crashing
std::cerr << "bad"; // if (!value.HasInterestingState())
assert(value.HasInterestingState()); // std::cerr << "bad";
// assert(value.HasInterestingState());
//if (value.is_bad_def) if (!value.HasInterestingState())
// return false; return false;
DefaultReflectMemberStart(writer); DefaultReflectMemberStart(writer);
return true; return true;
} }
@ -137,12 +138,13 @@ bool ReflectMemberStart(Reader& reader, IndexedFuncDef& value) {
return true; return true;
} }
bool ReflectMemberStart(Writer& writer, IndexedFuncDef& value) { bool ReflectMemberStart(Writer& writer, IndexedFuncDef& value) {
if (!value.HasInterestingState()) // TODO: this is crashing
std::cerr << "bad"; // if (!value.HasInterestingState())
assert(value.HasInterestingState()); // std::cerr << "bad";
// assert(value.HasInterestingState());
//if (value.is_bad_def) if (!value.HasInterestingState())
// return false; return false;
DefaultReflectMemberStart(writer); DefaultReflectMemberStart(writer);
return true; return true;
} }
@ -172,12 +174,13 @@ bool ReflectMemberStart(Reader& reader, IndexedVarDef& value) {
return true; return true;
} }
bool ReflectMemberStart(Writer& writer, IndexedVarDef& value) { bool ReflectMemberStart(Writer& writer, IndexedVarDef& value) {
if (!value.HasInterestingState()) // TODO: this is crashing
std::cerr << "bad"; // if (!value.HasInterestingState())
assert(value.HasInterestingState()); // std::cerr << "bad";
// assert(value.HasInterestingState());
//if (value.is_bad_def) if (!value.HasInterestingState())
// return false; return false;
DefaultReflectMemberStart(writer); DefaultReflectMemberStart(writer);
return true; return true;
} }