Move InsertSymbolIntoResult into query_utils.cc

This commit is contained in:
Jacob Dufault 2017-09-21 18:18:24 -07:00
parent f5314b62b1
commit 772df3e92a
3 changed files with 31 additions and 24 deletions

View File

@ -655,29 +655,6 @@ void RegisterMessageTypes() {
MessageRegistry::instance()->Register<Ipc_CqueryExitWhenIdle>();
}
void InsertSymbolIntoResult(QueryDatabase* db,
WorkingFiles* working_files,
SymbolIdx symbol,
std::vector<lsSymbolInformation>* result) {
optional<lsSymbolInformation> info = GetSymbolInfo(db, working_files, symbol);
if (!info)
return;
optional<QueryLocation> location = GetDefinitionExtentOfSymbol(db, symbol);
if (!location) {
auto decls = GetDeclarationsOfSymbolForGotoDefinition(db, symbol);
if (decls.empty())
return;
location = decls[0];
}
optional<lsLocation> 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.

View File

@ -916,3 +916,27 @@ NonElidedVector<Out_CqueryCallTree::CallEntry> BuildExpandCallTree(
return result;
}
void InsertSymbolIntoResult(QueryDatabase* db,
WorkingFiles* working_files,
SymbolIdx symbol,
std::vector<lsSymbolInformation>* result) {
optional<lsSymbolInformation> info = GetSymbolInfo(db, working_files, symbol);
if (!info)
return;
optional<QueryLocation> location = GetDefinitionExtentOfSymbol(db, symbol);
if (!location) {
auto decls = GetDeclarationsOfSymbolForGotoDefinition(db, symbol);
if (decls.empty())
return;
location = decls[0];
}
optional<lsLocation> ls_location =
GetLsLocation(db, working_files, *location);
if (!ls_location)
return;
info->location = *ls_location;
result->push_back(*info);
}

View File

@ -107,4 +107,10 @@ NonElidedVector<Out_CqueryCallTree::CallEntry> BuildInitialCallTree(
NonElidedVector<Out_CqueryCallTree::CallEntry> BuildExpandCallTree(
QueryDatabase* db,
WorkingFiles* working_files,
QueryFuncId root);
QueryFuncId root);
// Lookup |symbol| in |db| and insert the value into |result|.
void InsertSymbolIntoResult(QueryDatabase* db,
WorkingFiles* working_files,
SymbolIdx symbol,
std::vector<lsSymbolInformation>* result);