mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-29 11:01:57 +00:00
GetDefinitionSpellingOfSymbol: optional -> Maybe
This commit is contained in:
parent
749ecf0faa
commit
bd4482df5e
@ -457,7 +457,7 @@ struct TextDocumentCodeActionHandler
|
||||
std::string::npos)
|
||||
continue;
|
||||
|
||||
optional<QueryFileId> decl_file_id =
|
||||
Maybe<QueryFileId> decl_file_id =
|
||||
GetDeclarationFileForSymbol(db, db->symbols[i]);
|
||||
if (!decl_file_id)
|
||||
continue;
|
||||
|
@ -175,8 +175,7 @@ struct TextDocumentCodeLensHandler
|
||||
// extent since that is better for outline. This tries to convert the
|
||||
// extent location to the spelling location.
|
||||
auto try_ensure_spelling = [&](SymbolRef sym) {
|
||||
optional<Reference> def =
|
||||
GetDefinitionSpellingOfSymbol(db, sym);
|
||||
Maybe<Reference> def = GetDefinitionSpellingOfSymbol(db, sym);
|
||||
if (!def || db->GetFileId(*def) != db->GetFileId(sym) ||
|
||||
def->range.start.line != sym.range.start.line) {
|
||||
return sym;
|
||||
@ -216,7 +215,7 @@ struct TextDocumentCodeLensHandler
|
||||
|
||||
// "Base"
|
||||
if (func.def->base.size() == 1) {
|
||||
optional<Reference> base_loc =
|
||||
Maybe<Reference> base_loc =
|
||||
GetDefinitionSpellingOfSymbol(db, func.def->base[0]);
|
||||
if (base_loc) {
|
||||
optional<lsLocation> ls_base =
|
||||
|
@ -74,12 +74,12 @@ struct TextDocumentDefinitionHandler
|
||||
// - start at spelling but end at extent for better mouse tooltip
|
||||
// - goto declaration while in definition of recursive type
|
||||
|
||||
optional<Reference> def_loc = GetDefinitionSpellingOfSymbol(db, sym);
|
||||
Maybe<Reference> def_loc = GetDefinitionSpellingOfSymbol(db, sym);
|
||||
|
||||
// We use spelling start and extent end because this causes vscode to
|
||||
// highlight the entire definition when previewing / hoving with the
|
||||
// mouse.
|
||||
optional<Reference> def_extent = GetDefinitionExtentOfSymbol(db, sym);
|
||||
Maybe<Reference> def_extent = GetDefinitionExtentOfSymbol(db, sym);
|
||||
if (def_loc && def_extent)
|
||||
def_loc->range.end = def_extent->range.end;
|
||||
|
||||
|
@ -22,7 +22,7 @@ bool InsertSymbolIntoResult(QueryDatabase* db,
|
||||
if (!info)
|
||||
return false;
|
||||
|
||||
optional<Reference> location = GetDefinitionExtentOfSymbol(db, symbol);
|
||||
Maybe<Reference> location = GetDefinitionExtentOfSymbol(db, symbol);
|
||||
Reference loc;
|
||||
if (location)
|
||||
loc = *location;
|
||||
|
@ -18,16 +18,16 @@ int ComputeRangeSize(const Range& range) {
|
||||
|
||||
} // namespace
|
||||
|
||||
optional<Reference> GetDefinitionSpellingOfSymbol(QueryDatabase* db,
|
||||
const QueryFuncId& id) {
|
||||
Maybe<Reference> GetDefinitionSpellingOfSymbol(QueryDatabase* db,
|
||||
QueryFuncId id) {
|
||||
QueryFunc& func = db->funcs[id.id];
|
||||
if (func.def)
|
||||
return func.def->definition_spelling;
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
optional<Reference> GetDefinitionSpellingOfSymbol(QueryDatabase* db,
|
||||
SymbolRef sym) {
|
||||
Maybe<Reference> GetDefinitionSpellingOfSymbol(QueryDatabase* db,
|
||||
SymbolRef sym) {
|
||||
switch (sym.kind) {
|
||||
case SymbolKind::Type: {
|
||||
QueryType& type = db->GetType(sym);
|
||||
@ -56,8 +56,7 @@ optional<Reference> GetDefinitionSpellingOfSymbol(QueryDatabase* db,
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
optional<Reference> GetDefinitionExtentOfSymbol(QueryDatabase* db,
|
||||
SymbolRef sym) {
|
||||
Maybe<Reference> GetDefinitionExtentOfSymbol(QueryDatabase* db, SymbolRef sym) {
|
||||
switch (sym.kind) {
|
||||
case SymbolKind::Type: {
|
||||
QueryType& type = db->GetType(sym);
|
||||
@ -87,8 +86,8 @@ optional<Reference> GetDefinitionExtentOfSymbol(QueryDatabase* db,
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
optional<QueryFileId> GetDeclarationFileForSymbol(QueryDatabase* db,
|
||||
SymbolRef sym) {
|
||||
Maybe<QueryFileId> GetDeclarationFileForSymbol(QueryDatabase* db,
|
||||
SymbolRef sym) {
|
||||
switch (sym.kind) {
|
||||
case SymbolKind::Type: {
|
||||
QueryType& type = db->GetType(sym);
|
||||
|
@ -7,14 +7,13 @@
|
||||
|
||||
#include <optional.h>
|
||||
|
||||
optional<Reference> GetDefinitionSpellingOfSymbol(QueryDatabase* db,
|
||||
const QueryFuncId& id);
|
||||
optional<Reference> GetDefinitionSpellingOfSymbol(QueryDatabase* db,
|
||||
SymbolRef sym);
|
||||
optional<Reference> GetDefinitionExtentOfSymbol(QueryDatabase* db,
|
||||
SymbolRef sym);
|
||||
optional<QueryFileId> GetDeclarationFileForSymbol(QueryDatabase* db,
|
||||
SymbolRef sym);
|
||||
Maybe<Reference> GetDefinitionSpellingOfSymbol(QueryDatabase* db,
|
||||
QueryFuncId id);
|
||||
Maybe<Reference> GetDefinitionSpellingOfSymbol(QueryDatabase* db,
|
||||
SymbolRef sym);
|
||||
Maybe<Reference> GetDefinitionExtentOfSymbol(QueryDatabase* db, SymbolRef sym);
|
||||
Maybe<QueryFileId> GetDeclarationFileForSymbol(QueryDatabase* db,
|
||||
SymbolRef sym);
|
||||
|
||||
std::vector<Reference> ToReference(QueryDatabase* db,
|
||||
const std::vector<QueryFuncRef>& refs);
|
||||
|
Loading…
Reference in New Issue
Block a user