mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
Misc
This commit is contained in:
parent
8eeb1bb3af
commit
bfb759fd09
@ -92,7 +92,7 @@ OUTPUT:
|
|||||||
"detailed_name": "int x",
|
"detailed_name": "int x",
|
||||||
"qual_name_offset": 4,
|
"qual_name_offset": 4,
|
||||||
"short_name": "x",
|
"short_name": "x",
|
||||||
"hover": "int x = ",
|
"hover": "int x = A",
|
||||||
"declarations": [],
|
"declarations": [],
|
||||||
"spell": "8:5-8:6|0|1|2",
|
"spell": "8:5-8:6|0|1|2",
|
||||||
"extent": "8:1-1:1|0|1|0",
|
"extent": "8:1-1:1|0|1|0",
|
||||||
|
@ -87,8 +87,8 @@ OUTPUT:
|
|||||||
}],
|
}],
|
||||||
"usr2var": [{
|
"usr2var": [{
|
||||||
"usr": 3182917058194750998,
|
"usr": 3182917058194750998,
|
||||||
"detailed_name": "Foo<ns::bool> b",
|
"detailed_name": "Foo<bool> ns::b",
|
||||||
"qual_name_offset": 4,
|
"qual_name_offset": 10,
|
||||||
"short_name": "b",
|
"short_name": "b",
|
||||||
"declarations": [],
|
"declarations": [],
|
||||||
"spell": "6:13-6:14|11072669167287398027|2|1026",
|
"spell": "6:13-6:14|11072669167287398027|2|1026",
|
||||||
|
@ -367,7 +367,7 @@ OUTPUT:
|
|||||||
}, {
|
}, {
|
||||||
"usr": 2933643612409209903,
|
"usr": 2933643612409209903,
|
||||||
"detailed_name": "function<void (int)> f",
|
"detailed_name": "function<void (int)> f",
|
||||||
"qual_name_offset": 0,
|
"qual_name_offset": 21,
|
||||||
"short_name": "f",
|
"short_name": "f",
|
||||||
"declarations": [],
|
"declarations": [],
|
||||||
"spell": "7:21-7:22|0|1|2",
|
"spell": "7:21-7:22|0|1|2",
|
||||||
|
@ -65,7 +65,7 @@ OUTPUT:
|
|||||||
"usr2var": [{
|
"usr2var": [{
|
||||||
"usr": 12028309045033782423,
|
"usr": 12028309045033782423,
|
||||||
"detailed_name": "Foo<bool> b",
|
"detailed_name": "Foo<bool> b",
|
||||||
"qual_name_offset": 4,
|
"qual_name_offset": 10,
|
||||||
"short_name": "b",
|
"short_name": "b",
|
||||||
"declarations": [],
|
"declarations": [],
|
||||||
"spell": "5:11-5:12|0|1|2",
|
"spell": "5:11-5:12|0|1|2",
|
||||||
|
@ -65,8 +65,8 @@ OUTPUT:
|
|||||||
}],
|
}],
|
||||||
"usr2var": [{
|
"usr2var": [{
|
||||||
"usr": 8804696910588009104,
|
"usr": 8804696910588009104,
|
||||||
"detailed_name": "Foo::bool b",
|
"detailed_name": "bool Foo::b",
|
||||||
"qual_name_offset": 0,
|
"qual_name_offset": 5,
|
||||||
"short_name": "b",
|
"short_name": "b",
|
||||||
"declarations": [],
|
"declarations": [],
|
||||||
"spell": "3:8-3:9|8501689086387244262|2|1026",
|
"spell": "3:8-3:9|8501689086387244262|2|1026",
|
||||||
|
@ -100,8 +100,8 @@ OUTPUT:
|
|||||||
"storage": 0
|
"storage": 0
|
||||||
}, {
|
}, {
|
||||||
"usr": 8804696910588009104,
|
"usr": 8804696910588009104,
|
||||||
"detailed_name": "Foo::bool b : 3",
|
"detailed_name": "bool Foo::b : 3",
|
||||||
"qual_name_offset": 0,
|
"qual_name_offset": 5,
|
||||||
"short_name": "b",
|
"short_name": "b",
|
||||||
"declarations": [],
|
"declarations": [],
|
||||||
"spell": "3:8-3:9|8501689086387244262|2|1026",
|
"spell": "3:8-3:9|8501689086387244262|2|1026",
|
||||||
|
@ -28,7 +28,7 @@ OUTPUT:
|
|||||||
"usr2var": [{
|
"usr2var": [{
|
||||||
"usr": 1346710425945444872,
|
"usr": 1346710425945444872,
|
||||||
"detailed_name": "extern T t",
|
"detailed_name": "extern T t",
|
||||||
"qual_name_offset": 0,
|
"qual_name_offset": 9,
|
||||||
"short_name": "t",
|
"short_name": "t",
|
||||||
"declarations": ["3:10-3:11|0|1|1"],
|
"declarations": ["3:10-3:11|0|1|1"],
|
||||||
"type": 5673439900521455039,
|
"type": 5673439900521455039,
|
||||||
|
@ -70,8 +70,8 @@ OUTPUT:
|
|||||||
}],
|
}],
|
||||||
"usr2var": [{
|
"usr2var": [{
|
||||||
"usr": 14314859014962085433,
|
"usr": 14314859014962085433,
|
||||||
"detailed_name": "ForwFoo::ardType *a",
|
"detailed_name": "ForwardType *Foo::a",
|
||||||
"qual_name_offset": 0,
|
"qual_name_offset": 13,
|
||||||
"short_name": "a",
|
"short_name": "a",
|
||||||
"declarations": [],
|
"declarations": [],
|
||||||
"spell": "5:16-5:17|15041163540773201510|2|1026",
|
"spell": "5:16-5:17|15041163540773201510|2|1026",
|
||||||
|
@ -75,7 +75,7 @@ OUTPUT:
|
|||||||
}, {
|
}, {
|
||||||
"usr": 16374832544037266261,
|
"usr": 16374832544037266261,
|
||||||
"detailed_name": "ForwardType *a",
|
"detailed_name": "ForwardType *a",
|
||||||
"qual_name_offset": 0,
|
"qual_name_offset": 13,
|
||||||
"short_name": "a",
|
"short_name": "a",
|
||||||
"declarations": [],
|
"declarations": [],
|
||||||
"spell": "5:16-5:17|4654328188330986029|3|2",
|
"spell": "5:16-5:17|4654328188330986029|3|2",
|
||||||
|
@ -27,7 +27,7 @@ OUTPUT:
|
|||||||
"usr2var": [{
|
"usr2var": [{
|
||||||
"usr": 6601831367240627080,
|
"usr": 6601831367240627080,
|
||||||
"detailed_name": "static Type t",
|
"detailed_name": "static Type t",
|
||||||
"qual_name_offset": 0,
|
"qual_name_offset": 12,
|
||||||
"short_name": "t",
|
"short_name": "t",
|
||||||
"declarations": [],
|
"declarations": [],
|
||||||
"spell": "2:13-2:14|0|1|2",
|
"spell": "2:13-2:14|0|1|2",
|
||||||
|
@ -44,7 +44,7 @@ OUTPUT:
|
|||||||
"usr2var": [{
|
"usr2var": [{
|
||||||
"usr": 11823161916242867318,
|
"usr": 11823161916242867318,
|
||||||
"detailed_name": "static int a",
|
"detailed_name": "static int a",
|
||||||
"qual_name_offset": 0,
|
"qual_name_offset": 11,
|
||||||
"short_name": "a",
|
"short_name": "a",
|
||||||
"declarations": [],
|
"declarations": [],
|
||||||
"spell": "1:12-1:13|0|1|2",
|
"spell": "1:12-1:13|0|1|2",
|
||||||
|
@ -162,16 +162,16 @@ void IncludeComplete::InsertIncludesFromDirectory(std::string directory,
|
|||||||
bool use_angle_brackets) {
|
bool use_angle_brackets) {
|
||||||
directory = NormalizePath(directory);
|
directory = NormalizePath(directory);
|
||||||
EnsureEndsInSlash(directory);
|
EnsureEndsInSlash(directory);
|
||||||
if (match_ && !match_->IsMatch(directory)) {
|
if (match_ && !match_->IsMatch(directory))
|
||||||
// Don't even enter the directory if it fails the patterns.
|
|
||||||
return;
|
return;
|
||||||
}
|
bool include_cpp = directory.find("include/c++") != std::string::npos;
|
||||||
|
|
||||||
std::vector<CompletionCandidate> results;
|
std::vector<CompletionCandidate> results;
|
||||||
GetFilesInFolder(
|
GetFilesInFolder(
|
||||||
directory, true /*recursive*/, false /*add_folder_to_path*/,
|
directory, true /*recursive*/, false /*add_folder_to_path*/,
|
||||||
[&](const std::string& path) {
|
[&](const std::string &path) {
|
||||||
if (!EndsWithAny(path, g_config->completion.includeSuffixWhitelist))
|
if (!include_cpp &&
|
||||||
|
!EndsWithAny(path, g_config->completion.includeSuffixWhitelist))
|
||||||
return;
|
return;
|
||||||
if (match_ && !match_->IsMatch(directory + path))
|
if (match_ && !match_->IsMatch(directory + path))
|
||||||
return;
|
return;
|
||||||
|
@ -431,6 +431,10 @@ public:
|
|||||||
std::string name = OS.str();
|
std::string name = OS.str();
|
||||||
SimplifyAnonymous(name);
|
SimplifyAnonymous(name);
|
||||||
auto i = name.find(short_name);
|
auto i = name.find(short_name);
|
||||||
|
if (short_name.size())
|
||||||
|
while (i != std::string::npos && ((i && isalnum(name[i - 1])) ||
|
||||||
|
isalnum(name[i + short_name.size()])))
|
||||||
|
i = name.find(short_name, i + short_name.size());
|
||||||
if (i == std::string::npos) {
|
if (i == std::string::npos) {
|
||||||
// e.g. operator type-parameter-1
|
// e.g. operator type-parameter-1
|
||||||
i = 0;
|
i = 0;
|
||||||
@ -492,7 +496,11 @@ public:
|
|||||||
if (init) {
|
if (init) {
|
||||||
SourceManager &SM = Ctx->getSourceManager();
|
SourceManager &SM = Ctx->getSourceManager();
|
||||||
const LangOptions& Lang = Ctx->getLangOpts();
|
const LangOptions& Lang = Ctx->getLangOpts();
|
||||||
SourceRange R = init->getSourceRange();
|
SourceRange R = SM.getExpansionRange(init->getSourceRange())
|
||||||
|
#if LLVM_VERSION_MAJOR >= 7
|
||||||
|
.getAsRange()
|
||||||
|
#endif
|
||||||
|
;
|
||||||
SourceLocation L = D->getLocation();
|
SourceLocation L = D->getLocation();
|
||||||
if (L.isMacroID() || !SM.isBeforeInTranslationUnit(L, R.getBegin()))
|
if (L.isMacroID() || !SM.isBeforeInTranslationUnit(L, R.getBegin()))
|
||||||
return;
|
return;
|
||||||
@ -879,8 +887,10 @@ public:
|
|||||||
if (specialization) {
|
if (specialization) {
|
||||||
const TypeSourceInfo *TSI = TD->getTypeSourceInfo();
|
const TypeSourceInfo *TSI = TD->getTypeSourceInfo();
|
||||||
SourceLocation L1 = TSI->getTypeLoc().getBeginLoc();
|
SourceLocation L1 = TSI->getTypeLoc().getBeginLoc();
|
||||||
Range loc1 = FromTokenRange(SM, Lang, {L1, L1});
|
if (SM.getFileID(L1) == LocFID) {
|
||||||
type1.uses.push_back(GetUse(db, loc1, LexDC, Role::Reference));
|
Range loc1 = FromTokenRange(SM, Lang, {L1, L1});
|
||||||
|
type1.uses.push_back(GetUse(db, loc1, LexDC, Role::Reference));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ using namespace ccls;
|
|||||||
#include <clang/Frontend/CompilerInstance.h>
|
#include <clang/Frontend/CompilerInstance.h>
|
||||||
#include <clang/Tooling/CompilationDatabase.h>
|
#include <clang/Tooling/CompilationDatabase.h>
|
||||||
#include <llvm/ADT/ArrayRef.h>
|
#include <llvm/ADT/ArrayRef.h>
|
||||||
|
#include <llvm/ADT/StringSet.h>
|
||||||
#include <llvm/Support/LineIterator.h>
|
#include <llvm/Support/LineIterator.h>
|
||||||
using namespace clang;
|
using namespace clang;
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
@ -296,14 +297,16 @@ std::vector<Project::Entry> LoadCompilationEntriesFromDirectory(
|
|||||||
|
|
||||||
LOG_S(INFO) << "loaded " << Path.c_str();
|
LOG_S(INFO) << "loaded " << Path.c_str();
|
||||||
|
|
||||||
|
StringSet<> Seen;
|
||||||
std::vector<Project::Entry> result;
|
std::vector<Project::Entry> result;
|
||||||
for (tooling::CompileCommand &Cmd : CDB->getAllCompileCommands()) {
|
for (tooling::CompileCommand &Cmd : CDB->getAllCompileCommands()) {
|
||||||
CompileCommandsEntry entry;
|
CompileCommandsEntry entry;
|
||||||
entry.directory = std::move(Cmd.Directory);
|
entry.directory = std::move(Cmd.Directory);
|
||||||
entry.file = entry.ResolveIfRelative(Cmd.Filename);
|
entry.file = entry.ResolveIfRelative(Cmd.Filename);
|
||||||
entry.args = std::move(Cmd.CommandLine);
|
entry.args = std::move(Cmd.CommandLine);
|
||||||
result.push_back(
|
auto entry1 = GetCompilationEntryFromCompileCommandEntry(project, entry);
|
||||||
GetCompilationEntryFromCompileCommandEntry(project, entry));
|
if (Seen.insert(entry1.filename).second)
|
||||||
|
result.push_back(entry1);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user