diff --git a/src/messages/text_document_code_action.cc b/src/messages/text_document_code_action.cc index 09fc97b2..214b3576 100644 --- a/src/messages/text_document_code_action.cc +++ b/src/messages/text_document_code_action.cc @@ -457,7 +457,7 @@ struct TextDocumentCodeActionHandler std::string::npos) continue; - optional decl_file_id = + Maybe decl_file_id = GetDeclarationFileForSymbol(db, db->symbols[i]); if (!decl_file_id) continue; diff --git a/src/messages/text_document_code_lens.cc b/src/messages/text_document_code_lens.cc index 8c5fc8f2..4bb13570 100644 --- a/src/messages/text_document_code_lens.cc +++ b/src/messages/text_document_code_lens.cc @@ -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 def = - GetDefinitionSpellingOfSymbol(db, sym); + Maybe 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 base_loc = + Maybe base_loc = GetDefinitionSpellingOfSymbol(db, func.def->base[0]); if (base_loc) { optional ls_base = diff --git a/src/messages/text_document_definition.cc b/src/messages/text_document_definition.cc index eff44ed0..677c6012 100644 --- a/src/messages/text_document_definition.cc +++ b/src/messages/text_document_definition.cc @@ -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 def_loc = GetDefinitionSpellingOfSymbol(db, sym); + Maybe 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 def_extent = GetDefinitionExtentOfSymbol(db, sym); + Maybe def_extent = GetDefinitionExtentOfSymbol(db, sym); if (def_loc && def_extent) def_loc->range.end = def_extent->range.end; diff --git a/src/messages/workspace_symbol.cc b/src/messages/workspace_symbol.cc index a814de8b..48c25168 100644 --- a/src/messages/workspace_symbol.cc +++ b/src/messages/workspace_symbol.cc @@ -22,7 +22,7 @@ bool InsertSymbolIntoResult(QueryDatabase* db, if (!info) return false; - optional location = GetDefinitionExtentOfSymbol(db, symbol); + Maybe location = GetDefinitionExtentOfSymbol(db, symbol); Reference loc; if (location) loc = *location; diff --git a/src/query_utils.cc b/src/query_utils.cc index 779123b1..f919e706 100644 --- a/src/query_utils.cc +++ b/src/query_utils.cc @@ -18,16 +18,16 @@ int ComputeRangeSize(const Range& range) { } // namespace -optional GetDefinitionSpellingOfSymbol(QueryDatabase* db, - const QueryFuncId& id) { +Maybe GetDefinitionSpellingOfSymbol(QueryDatabase* db, + QueryFuncId id) { QueryFunc& func = db->funcs[id.id]; if (func.def) return func.def->definition_spelling; return nullopt; } -optional GetDefinitionSpellingOfSymbol(QueryDatabase* db, - SymbolRef sym) { +Maybe GetDefinitionSpellingOfSymbol(QueryDatabase* db, + SymbolRef sym) { switch (sym.kind) { case SymbolKind::Type: { QueryType& type = db->GetType(sym); @@ -56,8 +56,7 @@ optional GetDefinitionSpellingOfSymbol(QueryDatabase* db, return nullopt; } -optional GetDefinitionExtentOfSymbol(QueryDatabase* db, - SymbolRef sym) { +Maybe GetDefinitionExtentOfSymbol(QueryDatabase* db, SymbolRef sym) { switch (sym.kind) { case SymbolKind::Type: { QueryType& type = db->GetType(sym); @@ -87,8 +86,8 @@ optional GetDefinitionExtentOfSymbol(QueryDatabase* db, return nullopt; } -optional GetDeclarationFileForSymbol(QueryDatabase* db, - SymbolRef sym) { +Maybe GetDeclarationFileForSymbol(QueryDatabase* db, + SymbolRef sym) { switch (sym.kind) { case SymbolKind::Type: { QueryType& type = db->GetType(sym); diff --git a/src/query_utils.h b/src/query_utils.h index 783a1515..f73ba439 100644 --- a/src/query_utils.h +++ b/src/query_utils.h @@ -7,14 +7,13 @@ #include -optional GetDefinitionSpellingOfSymbol(QueryDatabase* db, - const QueryFuncId& id); -optional GetDefinitionSpellingOfSymbol(QueryDatabase* db, - SymbolRef sym); -optional GetDefinitionExtentOfSymbol(QueryDatabase* db, - SymbolRef sym); -optional GetDeclarationFileForSymbol(QueryDatabase* db, - SymbolRef sym); +Maybe GetDefinitionSpellingOfSymbol(QueryDatabase* db, + QueryFuncId id); +Maybe GetDefinitionSpellingOfSymbol(QueryDatabase* db, + SymbolRef sym); +Maybe GetDefinitionExtentOfSymbol(QueryDatabase* db, SymbolRef sym); +Maybe GetDeclarationFileForSymbol(QueryDatabase* db, + SymbolRef sym); std::vector ToReference(QueryDatabase* db, const std::vector& refs);