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 .
```
After VSCode is running, you can hit `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 cores are on your CPUs.
After VSCode is running, update the `ServerOptions` `cwd` parameter to point to
the absolute path of your build directory.
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
(`F1`) `View: Toggle Output` command and opening the `cquery` output section.

View File

@ -82,7 +82,7 @@ struct IpcManager {
// TODO: Rename TypedBidiMessageQueue to IpcTransport?
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 IpcManager* instance_;
@ -970,8 +970,8 @@ void IndexMain(
Index_DoIdMapQueue* queue_do_id_map,
Index_OnIdMappedQueue* queue_on_id_mapped,
Index_OnIndexedQueue* queue_on_indexed) {
SetCurrentThreadName("indexer");
SetCurrentThreadName("indexer");
while (true) {
// TODO: process all off IndexMain_DoIndex before calling IndexMain_DoCreateIndexUpdate for
// better icache behavior. We need to have some threads spinning on both though
@ -1590,7 +1590,6 @@ void QueryDbMainLoop(
}
void QueryDbMain(IndexerConfig* config) {
SetCurrentThreadName("querydb");
//std::cerr << "Running QueryDb" << std::endl;
// Create queues.
@ -1613,6 +1612,7 @@ void QueryDbMain(IndexerConfig* config) {
}
// Run query db main loop.
SetCurrentThreadName("querydb");
QueryDatabase db;
while (true) {
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.
void LanguageServerStdinLoop(IndexerConfig* config) {
SetCurrentThreadName("stdin");
IpcManager* ipc = IpcManager::instance();
SetCurrentThreadName("stdin");
while (true) {
std::unique_ptr<BaseIpcMessage> message = MessageRegistry::instance()->ReadMessageFromStdin();
@ -1890,12 +1890,12 @@ void LanguageServerMainLoop() {
}
void LanguageServerMain(IndexerConfig* config) {
SetCurrentThreadName("server");
// Run language client.
new std::thread([&config]() {
LanguageServerStdinLoop(config);
});
SetCurrentThreadName("server");
while (true) {
LanguageServerMainLoop();
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) {
// NOTE: uncomment to disable indexer
//return {};
filename = NormalizePath(filename);
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->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;
}

View File

@ -4,6 +4,7 @@
#include <optional.h>
#include <cassert>
#include <cstdint>
#include <functional>
#include <unordered_set>
@ -298,7 +299,8 @@ void CompareGroups(
QueryFileId GetQueryFileIdFromPath(QueryDatabase* query_db, const std::string& path) {
auto it = query_db->usr_to_symbol.find(path);
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?
if (it->second.kind == SymbolKind::File)
return QueryFileId(it->second.idx);
}
@ -311,7 +313,8 @@ QueryFileId GetQueryFileIdFromPath(QueryDatabase* query_db, const std::string& p
QueryTypeId GetQueryTypeIdFromUsr(QueryDatabase* query_db, const Usr& usr) {
auto it = query_db->usr_to_symbol.find(usr);
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?
if (it->second.kind == SymbolKind::Type)
return QueryTypeId(it->second.idx);
}
@ -324,7 +327,8 @@ QueryTypeId GetQueryTypeIdFromUsr(QueryDatabase* query_db, const Usr& usr) {
QueryFuncId GetQueryFuncIdFromUsr(QueryDatabase* query_db, const Usr& usr) {
auto it = query_db->usr_to_symbol.find(usr);
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?
if (it->second.kind == SymbolKind::Func)
return QueryFuncId(it->second.idx);
}
@ -337,7 +341,8 @@ QueryFuncId GetQueryFuncIdFromUsr(QueryDatabase* query_db, const Usr& usr) {
QueryVarId GetQueryVarIdFromUsr(QueryDatabase* query_db, const Usr& usr) {
auto it = query_db->usr_to_symbol.find(usr);
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?
if (it->second.kind == SymbolKind::Var)
return QueryVarId(it->second.idx);
}

View File

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