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