mirror of
https://github.com/MaskRay/ccls.git
synced 2025-02-16 13:48:04 +00:00
outline fixes
This commit is contained in:
parent
f3c8500fa9
commit
cc4d49794d
@ -436,6 +436,7 @@ void QueryDbMainLoop(IpcServer* ipc, QueryableDatabase* db) {
|
||||
info.kind = lsSymbolKind::Class;
|
||||
|
||||
if (def.def.definition.has_value()) {
|
||||
info.location.uri.SetPath(def.def.definition->path);
|
||||
info.location.range.start.line = def.def.definition->line - 1;
|
||||
info.location.range.start.character = def.def.definition->column - 1;
|
||||
}
|
||||
@ -455,6 +456,7 @@ void QueryDbMainLoop(IpcServer* ipc, QueryableDatabase* db) {
|
||||
}
|
||||
|
||||
if (def.def.definition.has_value()) {
|
||||
info.location.uri.SetPath(def.def.definition->path);
|
||||
info.location.range.start.line = def.def.definition->line - 1;
|
||||
info.location.range.start.character = def.def.definition->column - 1;
|
||||
}
|
||||
@ -467,6 +469,7 @@ void QueryDbMainLoop(IpcServer* ipc, QueryableDatabase* db) {
|
||||
info.kind = lsSymbolKind::Variable;
|
||||
|
||||
if (def.def.definition.has_value()) {
|
||||
info.location.uri.SetPath(def.def.definition->path);
|
||||
info.location.range.start.line = def.def.definition->line - 1;
|
||||
info.location.range.start.character = def.def.definition->column - 1;
|
||||
}
|
||||
|
19
indexer.cpp
19
indexer.cpp
@ -237,12 +237,7 @@ int abortQuery(CXClientData client_data, void *reserved) {
|
||||
void diagnostic(CXClientData client_data, CXDiagnosticSet diagnostics, void *reserved) {
|
||||
IndexParam* param = static_cast<IndexParam*>(client_data);
|
||||
|
||||
std::cerr << "!! Got diagnostic" << std::endl;
|
||||
/**
|
||||
* \brief Determine the number of diagnostics in a CXDiagnosticSet.
|
||||
*/
|
||||
//CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags);
|
||||
|
||||
// Print any diagnostics to std::cerr
|
||||
for (unsigned i = 0; i < clang_getNumDiagnosticsInSet(diagnostics); ++i) {
|
||||
CXDiagnostic diagnostic = clang_getDiagnosticInSet(diagnostics, i);
|
||||
|
||||
@ -253,18 +248,6 @@ void diagnostic(CXClientData client_data, CXDiagnosticSet diagnostics, void *res
|
||||
|
||||
clang_disposeDiagnostic(diagnostic);
|
||||
}
|
||||
/**
|
||||
* \brief Retrieve a diagnostic associated with the given CXDiagnosticSet.
|
||||
*
|
||||
* \param Diags the CXDiagnosticSet to query.
|
||||
* \param Index the zero-based diagnostic number to retrieve.
|
||||
*
|
||||
* \returns the requested diagnostic. This diagnostic must be freed
|
||||
* via a call to \c clang_disposeDiagnostic().
|
||||
*/
|
||||
// CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
|
||||
// unsigned Index);
|
||||
|
||||
}
|
||||
|
||||
CXIdxClientFile enteredMainFile(CXClientData client_data, CXFile mainFile, void *reserved) {
|
||||
|
30
ipc.cc
30
ipc.cc
@ -1,6 +1,26 @@
|
||||
#include "ipc.h"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace {
|
||||
struct JsonMessage {
|
||||
int message_id;
|
||||
size_t payload_size;
|
||||
|
||||
const char* payload();
|
||||
void SetPayload(size_t payload_size, const char* payload);
|
||||
};
|
||||
|
||||
JsonMessage* get_free_message(IpcDirectionalChannel* channel) {
|
||||
return reinterpret_cast<JsonMessage*>(channel->shared->shared_start + *channel->shared->shared_bytes_used);
|
||||
}
|
||||
// Messages are funky objects. They contain potentially variable amounts of
|
||||
// data and are passed between processes. This means that they need to be
|
||||
// fully relocatable, ie, it is possible to memmove them in memory to a
|
||||
// completely different address.
|
||||
|
||||
|
||||
JsonMessage* as_message(char* ptr) {
|
||||
return reinterpret_cast<JsonMessage*>(ptr);
|
||||
}
|
||||
@ -75,12 +95,12 @@ void IpcDirectionalChannel::PushMessage(BaseIpcMessageElided* message) {
|
||||
if ((*shared->shared_bytes_used + sizeof(JsonMessage) + payload_size) >= shmem_size)
|
||||
continue;
|
||||
|
||||
get_free_message()->message_id = message->hashed_runtime_id();
|
||||
get_free_message()->SetPayload(payload_size, output.GetString());
|
||||
get_free_message(this)->message_id = message->hashed_runtime_id();
|
||||
get_free_message(this)->SetPayload(payload_size, output.GetString());
|
||||
|
||||
*shared->shared_bytes_used += sizeof(JsonMessage) + get_free_message()->payload_size;
|
||||
*shared->shared_bytes_used += sizeof(JsonMessage) + get_free_message(this)->payload_size;
|
||||
assert(*shared->shared_bytes_used < shmem_size);
|
||||
get_free_message()->message_id = -1;
|
||||
get_free_message(this)->message_id = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -97,7 +117,7 @@ std::vector<std::unique_ptr<BaseIpcMessageElided>> IpcDirectionalChannel::TakeMe
|
||||
|
||||
memcpy(local_block, shared->shared_start, *shared->shared_bytes_used);
|
||||
*shared->shared_bytes_used = 0;
|
||||
get_free_message()->message_id = -1;
|
||||
get_free_message(this)->message_id = -1;
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<BaseIpcMessageElided>> result;
|
||||
|
17
ipc.h
17
ipc.h
@ -14,18 +14,6 @@
|
||||
|
||||
// TODO: We need to add support for payloads larger than the maximum shared memory buffer size.
|
||||
|
||||
// Messages are funky objects. They contain potentially variable amounts of
|
||||
// data and are passed between processes. This means that they need to be
|
||||
// fully relocatable, ie, it is possible to memmove them in memory to a
|
||||
// completely different address.
|
||||
|
||||
struct JsonMessage {
|
||||
int message_id;
|
||||
size_t payload_size;
|
||||
|
||||
const char* payload();
|
||||
void SetPayload(size_t payload_size, const char* payload);
|
||||
};
|
||||
|
||||
using IpcMessageId = std::string;
|
||||
|
||||
@ -130,11 +118,6 @@ struct IpcDirectionalChannel {
|
||||
void PushMessage(BaseIpcMessageElided* message);
|
||||
std::vector<std::unique_ptr<BaseIpcMessageElided>> TakeMessages();
|
||||
|
||||
private:
|
||||
JsonMessage* get_free_message() {
|
||||
return reinterpret_cast<JsonMessage*>(shared->shared_start + *shared->shared_bytes_used);
|
||||
}
|
||||
|
||||
// Pointer to process shared memory and process shared mutex.
|
||||
std::unique_ptr<PlatformSharedMemory> shared;
|
||||
std::unique_ptr<PlatformMutex> mutex;
|
||||
|
@ -384,6 +384,19 @@ struct In_CancelRequest : public InNotificationMessage {
|
||||
struct lsDocumentUri {
|
||||
std::string raw_uri;
|
||||
|
||||
void SetPath(const std::string& path) {
|
||||
// file:///c%3A/Users/jacob/Desktop/superindex/indexer/full_tests
|
||||
raw_uri = path;
|
||||
|
||||
size_t index = raw_uri.find(":");
|
||||
if (index != -1) {
|
||||
raw_uri.replace(raw_uri.begin() + index, raw_uri.begin() + index + 1, "%3A");
|
||||
}
|
||||
|
||||
raw_uri = "file:///" + raw_uri;
|
||||
//std::cerr << "Set uri to " << raw_uri << " from " << path;
|
||||
}
|
||||
|
||||
std::string GetPath() {
|
||||
// TODO: make this not a hack.
|
||||
std::string result = raw_uri;
|
||||
|
2
test.cc
2
test.cc
@ -97,7 +97,7 @@ void RunTests() {
|
||||
|
||||
for (std::string path : GetFilesInFolder("tests", true /*recursive*/, true /*add_folder_to_path*/)) {
|
||||
//if (path != "tests/templates/specialized_func_definition.cc") continue;
|
||||
if (path != "tests/outline/outline2.h") continue;
|
||||
//if (path != "tests/outline/outline2.cc") continue;
|
||||
//if (path == "tests/inheritance/class_inherit_templated_parent.cc") continue;
|
||||
//if (path != "tests/namespaces/namespace_reference.cc") continue;
|
||||
//if (path != "tests/stl.cc") continue;
|
||||
|
48
tests/outline/outline.cc
Normal file
48
tests/outline/outline.cc
Normal file
@ -0,0 +1,48 @@
|
||||
#include <vector>
|
||||
|
||||
struct MergeableUpdate {
|
||||
int a;
|
||||
int b;
|
||||
std::vector<int> to_add;
|
||||
};
|
||||
|
||||
/*
|
||||
OUTPUT:
|
||||
{
|
||||
"types": [{
|
||||
"id": 0,
|
||||
"usr": "c:@S@MergeableUpdate",
|
||||
"short_name": "MergeableUpdate",
|
||||
"qualified_name": "MergeableUpdate",
|
||||
"definition": "1:3:8",
|
||||
"vars": [0, 1, 2],
|
||||
"uses": ["*1:3:8"]
|
||||
}],
|
||||
"vars": [{
|
||||
"id": 0,
|
||||
"usr": "c:@S@MergeableUpdate@FI@a",
|
||||
"short_name": "a",
|
||||
"qualified_name": "MergeableUpdate::a",
|
||||
"definition": "1:4:7",
|
||||
"declaring_type": 0,
|
||||
"uses": ["1:4:7"]
|
||||
}, {
|
||||
"id": 1,
|
||||
"usr": "c:@S@MergeableUpdate@FI@b",
|
||||
"short_name": "b",
|
||||
"qualified_name": "MergeableUpdate::b",
|
||||
"definition": "1:5:7",
|
||||
"declaring_type": 0,
|
||||
"uses": ["1:5:7"]
|
||||
}, {
|
||||
"id": 2,
|
||||
"usr": "c:@S@MergeableUpdate@FI@to_add",
|
||||
"short_name": "to_add",
|
||||
"qualified_name": "MergeableUpdate::to_add",
|
||||
"definition": "1:6:20",
|
||||
"variable_type": 1,
|
||||
"declaring_type": 0,
|
||||
"uses": ["1:6:20"]
|
||||
}]
|
||||
}
|
||||
*/
|
@ -1,21 +0,0 @@
|
||||
#include <vector>
|
||||
|
||||
struct MergeableUpdate {
|
||||
int a;
|
||||
int b;
|
||||
std::vector<int> to_add;
|
||||
};
|
||||
|
||||
/*
|
||||
OUTPUT:
|
||||
{
|
||||
"types": [{
|
||||
"id": 0,
|
||||
"usr": "c:@S@MergeableUpdate",
|
||||
"short_name": "MergeableUpdate",
|
||||
"qualified_name": "MergeableUpdate",
|
||||
"definition": "1:1:8",
|
||||
"uses": ["*1:1:8"]
|
||||
}]
|
||||
}
|
||||
*/
|
Loading…
Reference in New Issue
Block a user