mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-31 01:42:33 +00:00
Remove ToQueryLocation
This commit is contained in:
parent
67e8132dbe
commit
a131ccdcb4
@ -81,7 +81,7 @@ void AddCodeLens(const char* singular,
|
||||
const char* plural,
|
||||
CommonCodeLensParams* common,
|
||||
QueryLocation loc,
|
||||
const std::vector<QueryLocation>& uses,
|
||||
const std::vector<Reference>& uses,
|
||||
optional<QueryLocation> excluded,
|
||||
bool force_display) {
|
||||
TCodeLens code_lens;
|
||||
@ -96,8 +96,8 @@ void AddCodeLens(const char* singular,
|
||||
|
||||
// Add unique uses.
|
||||
std::unordered_set<lsLocation> unique_uses;
|
||||
for (const QueryLocation& use : uses) {
|
||||
if (excluded == use)
|
||||
for (const Reference& use : uses) {
|
||||
if (excluded && Reference(*excluded) == use)
|
||||
continue;
|
||||
optional<lsLocation> location =
|
||||
GetLsLocation(common->db, common->working_files, use);
|
||||
@ -155,20 +155,15 @@ struct TextDocumentCodeLensHandler
|
||||
continue;
|
||||
if (type.def->kind == ClangSymbolKind::Namespace)
|
||||
continue;
|
||||
// FIXME QueryRef
|
||||
std::vector<QueryLocation> uses;
|
||||
uses.reserve(type.uses.size());
|
||||
for (auto& x : type.uses)
|
||||
uses.push_back(ToQueryLocation(db, x));
|
||||
AddCodeLens("ref", "refs", &common, ref.loc.OffsetStartColumn(0),
|
||||
uses, type.def->definition_spelling,
|
||||
type.uses, type.def->definition_spelling,
|
||||
true /*force_display*/);
|
||||
AddCodeLens("derived", "derived", &common,
|
||||
ref.loc.OffsetStartColumn(1),
|
||||
ToQueryLocation(db, type.derived), nullopt,
|
||||
ToReference(db, type.derived), nullopt,
|
||||
false /*force_display*/);
|
||||
AddCodeLens("var", "vars", &common, ref.loc.OffsetStartColumn(2),
|
||||
ToQueryLocation(db, type.instances), nullopt,
|
||||
ToReference(db, type.instances), nullopt,
|
||||
false /*force_display*/);
|
||||
break;
|
||||
}
|
||||
@ -200,29 +195,29 @@ struct TextDocumentCodeLensHandler
|
||||
QueryLocation loc = try_ensure_spelling(ref);
|
||||
AddCodeLens("call", "calls", &common,
|
||||
loc.OffsetStartColumn(offset++),
|
||||
ToQueryLocation(db, func.callers), nullopt,
|
||||
ToReference(db, func.callers), nullopt,
|
||||
true /*force_display*/);
|
||||
} else {
|
||||
QueryLocation loc = try_ensure_spelling(ref);
|
||||
AddCodeLens("direct call", "direct calls", &common,
|
||||
loc.OffsetStartColumn(offset++),
|
||||
ToQueryLocation(db, func.callers), nullopt,
|
||||
ToReference(db, func.callers), nullopt,
|
||||
false /*force_display*/);
|
||||
if (!base_callers.empty())
|
||||
AddCodeLens("base call", "base calls", &common,
|
||||
loc.OffsetStartColumn(offset++),
|
||||
ToQueryLocation(db, base_callers), nullopt,
|
||||
ToReference(db, base_callers), nullopt,
|
||||
false /*force_display*/);
|
||||
if (!derived_callers.empty())
|
||||
AddCodeLens("derived call", "derived calls", &common,
|
||||
loc.OffsetStartColumn(offset++),
|
||||
ToQueryLocation(db, derived_callers), nullopt,
|
||||
ToReference(db, derived_callers), nullopt,
|
||||
false /*force_display*/);
|
||||
}
|
||||
|
||||
AddCodeLens("derived", "derived", &common,
|
||||
ref.loc.OffsetStartColumn(offset++),
|
||||
ToQueryLocation(db, func.derived), nullopt,
|
||||
ToReference(db, func.derived), nullopt,
|
||||
false /*force_display*/);
|
||||
|
||||
// "Base"
|
||||
@ -251,7 +246,7 @@ struct TextDocumentCodeLensHandler
|
||||
}
|
||||
} else {
|
||||
AddCodeLens("base", "base", &common, ref.loc.OffsetStartColumn(1),
|
||||
ToQueryLocation(db, func.def->base), nullopt,
|
||||
ToReference(db, func.def->base), nullopt,
|
||||
false /*force_display*/);
|
||||
}
|
||||
|
||||
@ -271,13 +266,8 @@ struct TextDocumentCodeLensHandler
|
||||
if (var.def->is_macro())
|
||||
force_display = false;
|
||||
|
||||
// FIXME Reference
|
||||
std::vector<QueryLocation> uses;
|
||||
for (auto x: var.uses)
|
||||
uses.push_back(QueryLocation{x.range, GetFileId(db, x), x.role});
|
||||
|
||||
AddCodeLens("ref", "refs", &common, ref.loc.OffsetStartColumn(0),
|
||||
uses, var.def->definition_spelling, force_display);
|
||||
var.uses, var.def->definition_spelling, force_display);
|
||||
break;
|
||||
}
|
||||
case SymbolKind::File:
|
||||
|
@ -14,20 +14,6 @@ int ComputeRangeSize(const Range& range) {
|
||||
return range.end.column - range.start.column;
|
||||
}
|
||||
|
||||
template <typename Q>
|
||||
std::vector<QueryLocation> ToQueryLocationHelper(
|
||||
QueryDatabase* db,
|
||||
const std::vector<Id<Q>>& ids) {
|
||||
std::vector<QueryLocation> locs;
|
||||
locs.reserve(ids.size());
|
||||
for (auto id : ids) {
|
||||
optional<QueryLocation> loc = GetDefinitionSpellingOfSymbol(db, id);
|
||||
if (loc)
|
||||
locs.push_back(*loc);
|
||||
}
|
||||
return locs;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
QueryFileId GetFileId(QueryDatabase* db, Reference ref) {
|
||||
@ -179,10 +165,6 @@ optional<QueryFileId> GetDeclarationFileForSymbol(QueryDatabase* db,
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
QueryLocation ToQueryLocation(QueryDatabase* db, Reference ref) {
|
||||
return QueryLocation{ref.range, GetFileId(db, ref), ref.role};
|
||||
}
|
||||
|
||||
std::vector<Reference> ToReference(QueryDatabase* db,
|
||||
const std::vector<QueryFuncRef>& refs) {
|
||||
std::vector<Reference> ret;
|
||||
@ -192,31 +174,6 @@ std::vector<Reference> ToReference(QueryDatabase* db,
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<QueryLocation> ToQueryLocation(
|
||||
QueryDatabase* db,
|
||||
const std::vector<QueryFuncRef>& refs) {
|
||||
std::vector<QueryLocation> locs;
|
||||
locs.reserve(refs.size());
|
||||
for (const QueryFuncRef& ref : refs)
|
||||
locs.push_back(QueryLocation{ref.range, GetFileId(db, ref), ref.role});
|
||||
return locs;
|
||||
}
|
||||
std::vector<QueryLocation> ToQueryLocation(
|
||||
QueryDatabase* db,
|
||||
const std::vector<QueryTypeId>& ids) {
|
||||
return ToQueryLocationHelper(db, ids);
|
||||
}
|
||||
std::vector<QueryLocation> ToQueryLocation(
|
||||
QueryDatabase* db,
|
||||
const std::vector<QueryFuncId>& ids) {
|
||||
return ToQueryLocationHelper(db, ids);
|
||||
}
|
||||
std::vector<QueryLocation> ToQueryLocation(
|
||||
QueryDatabase* db,
|
||||
const std::vector<QueryVarId>& ids) {
|
||||
return ToQueryLocationHelper(db, ids);
|
||||
}
|
||||
|
||||
std::vector<Reference> GetUsesOfSymbol(QueryDatabase* db,
|
||||
const SymbolIdx& symbol,
|
||||
bool include_decl) {
|
||||
|
@ -20,7 +20,6 @@ optional<QueryLocation> GetDefinitionExtentOfSymbol(QueryDatabase* db,
|
||||
optional<QueryFileId> GetDeclarationFileForSymbol(QueryDatabase* db,
|
||||
const SymbolIdx& symbol);
|
||||
|
||||
QueryLocation ToQueryLocation(QueryDatabase* db, Reference ref);
|
||||
QueryFileId GetFileId(QueryDatabase* db, Reference ref);
|
||||
|
||||
std::vector<Reference> ToReference(QueryDatabase* db,
|
||||
@ -39,17 +38,6 @@ std::vector<Reference> ToReference(QueryDatabase* db,
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<QueryLocation> ToQueryLocation(
|
||||
QueryDatabase* db,
|
||||
const std::vector<QueryFuncRef>& refs);
|
||||
std::vector<QueryLocation> ToQueryLocation(
|
||||
QueryDatabase* db,
|
||||
const std::vector<QueryTypeId>& refs);
|
||||
std::vector<QueryLocation> ToQueryLocation(
|
||||
QueryDatabase* db,
|
||||
const std::vector<QueryVarId>& refs);
|
||||
std::vector<QueryLocation> ToQueryLocation(QueryDatabase* db,
|
||||
const std::vector<QueryFuncId>& ids);
|
||||
std::vector<Reference> GetUsesOfSymbol(QueryDatabase* db,
|
||||
const SymbolIdx& symbol,
|
||||
bool include_decl);
|
||||
|
2
wscript
2
wscript
@ -166,7 +166,7 @@ def configure(ctx):
|
||||
cxxflags = ctx.env.CXXFLAGS
|
||||
else:
|
||||
cxxflags = ['-g', '-Wall', '-Wno-sign-compare', '-Werror']
|
||||
if 'g++' in ctx.env.CXX_NAME:
|
||||
if ctx.env.CXX_NAME == 'gcc':
|
||||
cxxflags.append('-Wno-return-type')
|
||||
|
||||
if all(not x.startswith('-std=') for x in ctx.env.CXXFLAGS):
|
||||
|
Loading…
Reference in New Issue
Block a user