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