From 772df3e92a01a16ab99bc66d063d1ad5385cec3d Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Thu, 21 Sep 2017 18:18:24 -0700 Subject: [PATCH] Move InsertSymbolIntoResult into query_utils.cc --- src/command_line.cc | 23 ----------------------- src/query_utils.cc | 24 ++++++++++++++++++++++++ src/query_utils.h | 8 +++++++- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/command_line.cc b/src/command_line.cc index a6655c45..1e3dfbf8 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -655,29 +655,6 @@ void RegisterMessageTypes() { MessageRegistry::instance()->Register(); } -void InsertSymbolIntoResult(QueryDatabase* db, - WorkingFiles* working_files, - SymbolIdx symbol, - std::vector* result) { - optional info = GetSymbolInfo(db, working_files, symbol); - if (!info) - return; - - optional location = GetDefinitionExtentOfSymbol(db, symbol); - if (!location) { - auto decls = GetDeclarationsOfSymbolForGotoDefinition(db, symbol); - if (decls.empty()) - return; - location = decls[0]; - } - - optional ls_location = - GetLsLocation(db, working_files, *location); - if (!ls_location) - return; - info->location = *ls_location; - result->push_back(*info); -} // Manages files inside of the indexing pipeline so we don't have the same file // being imported multiple times. diff --git a/src/query_utils.cc b/src/query_utils.cc index 11db68d6..14150cde 100644 --- a/src/query_utils.cc +++ b/src/query_utils.cc @@ -916,3 +916,27 @@ NonElidedVector BuildExpandCallTree( return result; } + +void InsertSymbolIntoResult(QueryDatabase* db, + WorkingFiles* working_files, + SymbolIdx symbol, + std::vector* result) { + optional info = GetSymbolInfo(db, working_files, symbol); + if (!info) + return; + + optional location = GetDefinitionExtentOfSymbol(db, symbol); + if (!location) { + auto decls = GetDeclarationsOfSymbolForGotoDefinition(db, symbol); + if (decls.empty()) + return; + location = decls[0]; + } + + optional ls_location = + GetLsLocation(db, working_files, *location); + if (!ls_location) + return; + info->location = *ls_location; + result->push_back(*info); +} \ No newline at end of file diff --git a/src/query_utils.h b/src/query_utils.h index c5f84596..e99d2ad0 100644 --- a/src/query_utils.h +++ b/src/query_utils.h @@ -107,4 +107,10 @@ NonElidedVector BuildInitialCallTree( NonElidedVector BuildExpandCallTree( QueryDatabase* db, WorkingFiles* working_files, - QueryFuncId root); \ No newline at end of file + QueryFuncId root); + +// Lookup |symbol| in |db| and insert the value into |result|. +void InsertSymbolIntoResult(QueryDatabase* db, + WorkingFiles* working_files, + SymbolIdx symbol, + std::vector* result); \ No newline at end of file