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 .
|
$ 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.
|
||||||
|
@ -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));
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
src/query.cc
13
src/query.cc
@ -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,7 +299,8 @@ 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?
|
||||||
|
if (it->second.kind == SymbolKind::File)
|
||||||
return QueryFileId(it->second.idx);
|
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) {
|
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?
|
||||||
|
if (it->second.kind == SymbolKind::Type)
|
||||||
return QueryTypeId(it->second.idx);
|
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) {
|
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?
|
||||||
|
if (it->second.kind == SymbolKind::Func)
|
||||||
return QueryFuncId(it->second.idx);
|
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) {
|
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?
|
||||||
|
if (it->second.kind == SymbolKind::Var)
|
||||||
return QueryVarId(it->second.idx);
|
return QueryVarId(it->second.idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user