From 873e6d0411503d9b5e25160dac092db8187309a9 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 16 Jul 2018 23:22:34 -0700 Subject: [PATCH 1/2] Better bases/derived --- src/indexer.cc | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/indexer.cc b/src/indexer.cc index 7f8300f0..fe740018 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -729,14 +729,23 @@ public: switch (D->getKind()) { case Decl::Namespace: type->def.kind = lsSymbolKind::Namespace; + if (OrigD->isFirstDecl()) { + auto *ND = cast(OrigD); + auto *ND1 = cast(ND->getParent()); + if (isa(ND1)) { + Usr usr1 = GetUsr(ND1); + type->def.bases.push_back(usr1); + db->ToType(usr1).derived.push_back(usr); + } + } break; case Decl::NamespaceAlias: { type->def.kind = lsSymbolKind::TypeAlias; - auto* NAD = cast(D); - if (const NamespaceDecl* ND = NAD->getNamespace()) { + auto *NAD = cast(D); + if (const NamespaceDecl *ND = NAD->getNamespace()) { Usr usr1 = GetUsr(ND); - if (db->usr2type.count(usr1)) - type->def.alias_of = usr1; + type->def.alias_of = usr1; + (void)db->ToType(usr1); } break; } @@ -786,11 +795,8 @@ public: } if (BaseD) { Usr usr1 = GetUsr(BaseD); - auto it = db->usr2type.find(usr1); - if (it != db->usr2type.end()) { - type->def.bases.push_back(usr1); - it->second.derived.push_back(usr); - } + type->def.bases.push_back(usr1); + db->ToType(usr1).derived.push_back(usr); } } } @@ -831,11 +837,8 @@ public: D1 = RD->getInstantiatedFromMemberClass(); if (D1) { Usr usr1 = GetUsr(D1); - auto it = db->usr2type.find(usr1); - if (it != db->usr2type.end()) { - type->def.bases.push_back(usr1); - it->second.derived.push_back(usr); - } + type->def.bases.push_back(usr1); + db->ToType(usr1).derived.push_back(usr); } } } @@ -871,11 +874,8 @@ public: Ctx->getOverriddenMethods(ND, OverDecls); for (const auto* ND1 : OverDecls) { Usr usr1 = GetUsr(ND1); - auto it = db->usr2func.find(usr1); - if (it != db->usr2func.end()) { - func->def.bases.push_back(usr1); - it->second.derived.push_back(usr); - } + func->def.bases.push_back(usr1); + db->ToFunc(usr1).derived.push_back(usr); } } } From 7923ce5ee9c7f0e65045d11cf5fa18cdda4ee3db Mon Sep 17 00:00:00 2001 From: y2kbcm1 <40973495+y2kbcm1@users.noreply.github.com> Date: Tue, 17 Jul 2018 00:52:52 -0700 Subject: [PATCH 2/2] update README.md - fixed run-on sentences - add the reference of Cquery --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 289e80ff..1578ddad 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ccls -ccls is a rewrite of cquery (originally written by Jacob Dufault), +ccls is a rewrite of [cquery](https://github.com/cquery-project/cquery) (originally written by Jacob Dufault), a C/C++/Objective-C language server. * code completion (with both signature help and snippets) @@ -14,7 +14,7 @@ a C/C++/Objective-C language server. * preprocessor skipped regions * semantic highlighting, including support for [rainbow semantic highlighting](https://medium.com/@evnbr/coding-in-color-3a6db2743a1e) -It makes use of C++17 features, has less third-party dependencies and slimmed-down code base. Cross reference features are strenghened, (see [wiki/FAQ](../../wiki/FAQ). It currently uses libclang to index C++ code but will switch to Clang C++ API. Refactoring and formatting are non-goals as they can be provided by clang-format, clang-include-fixer and other Clang based tools. +Ccls uses C++17 features, has less third-party dependencies, and slims down code base. Cross reference features are strenghened, (see [wiki/FAQ](../../wiki/FAQ). It currently uses libclang to index C++ code, but will switch to Clang C++ API. Refactoring and formatting are non-goals as they can be provided by clang-format, clang-include-fixer, and other Clang based tools. The comparison with cquery as noted on 2018-07-15: