mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-25 00:55:08 +00:00
Misc fixes
This commit is contained in:
parent
2e8e3d29c5
commit
85734278d8
11
README.md
11
README.md
@ -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.
|
||||
|
@ -39,4 +39,4 @@ void WriteToCache(const std::string& cache_directory, const std::string& filenam
|
||||
assert(cache.good());
|
||||
cache << indexed_content;
|
||||
cache.close();
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
21
src/query.cc
21
src/query.cc
@ -4,6 +4,7 @@
|
||||
|
||||
#include <optional.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <unordered_set>
|
||||
@ -298,8 +299,9 @@ 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);
|
||||
return QueryFileId(it->second.idx);
|
||||
// TODO: should this be an assert?
|
||||
if (it->second.kind == SymbolKind::File)
|
||||
return QueryFileId(it->second.idx);
|
||||
}
|
||||
|
||||
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) {
|
||||
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);
|
||||
return QueryTypeId(it->second.idx);
|
||||
// TODO: should this be an assert?
|
||||
if (it->second.kind == SymbolKind::Type)
|
||||
return QueryTypeId(it->second.idx);
|
||||
}
|
||||
|
||||
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) {
|
||||
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);
|
||||
return QueryFuncId(it->second.idx);
|
||||
// TODO: should this be an assert?
|
||||
if (it->second.kind == SymbolKind::Func)
|
||||
return QueryFuncId(it->second.idx);
|
||||
}
|
||||
|
||||
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) {
|
||||
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);
|
||||
return QueryVarId(it->second.idx);
|
||||
// TODO: should this be an assert?
|
||||
if (it->second.kind == SymbolKind::Var)
|
||||
return QueryVarId(it->second.idx);
|
||||
}
|
||||
|
||||
size_t idx = query_db->vars.size();
|
||||
|
@ -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) {
|
||||
// TODO: this is crashing
|
||||
// if (!value.HasInterestingState())
|
||||
// std::cerr << "bad";
|
||||
// assert(value.HasInterestingState());
|
||||
|
||||
if (!value.HasInterestingState())
|
||||
std::cerr << "bad";
|
||||
assert(value.HasInterestingState());
|
||||
|
||||
//if (value.is_bad_def)
|
||||
// return false;
|
||||
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;
|
||||
}
|
||||
@ -246,7 +249,7 @@ optional<IndexedFile> Deserialize(std::string path, std::string serialized) {
|
||||
|
||||
IndexedFile file(path);
|
||||
Reflect(reader, file);
|
||||
|
||||
|
||||
// Restore non-serialized state.
|
||||
file.path = path;
|
||||
file.id_cache.primary_file = file.path;
|
||||
|
Loading…
Reference in New Issue
Block a user