2017-06-15 05:32:23 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "query_utils.h"
|
|
|
|
|
|
|
|
#include "query.h"
|
|
|
|
#include "working_files.h"
|
|
|
|
|
|
|
|
#include <optional.h>
|
|
|
|
|
2017-09-22 01:14:57 +00:00
|
|
|
optional<QueryLocation> GetDefinitionSpellingOfSymbol(QueryDatabase* db,
|
|
|
|
const QueryTypeId& id);
|
|
|
|
optional<QueryLocation> GetDefinitionSpellingOfSymbol(QueryDatabase* db,
|
|
|
|
const QueryFuncId& id);
|
|
|
|
optional<QueryLocation> GetDefinitionSpellingOfSymbol(QueryDatabase* db,
|
|
|
|
const QueryVarId& id);
|
|
|
|
optional<QueryLocation> GetDefinitionSpellingOfSymbol(QueryDatabase* db,
|
|
|
|
const SymbolIdx& symbol);
|
|
|
|
optional<QueryLocation> GetDefinitionExtentOfSymbol(QueryDatabase* db,
|
|
|
|
const SymbolIdx& symbol);
|
|
|
|
optional<QueryFileId> GetDeclarationFileForSymbol(QueryDatabase* db,
|
|
|
|
const SymbolIdx& symbol);
|
|
|
|
std::vector<QueryLocation> ToQueryLocation(
|
|
|
|
QueryDatabase* db,
|
|
|
|
const std::vector<QueryFuncRef>& refs);
|
2018-02-03 21:12:03 +00:00
|
|
|
std::vector<QueryLocation> ToQueryLocation(
|
|
|
|
QueryDatabase* db,
|
|
|
|
const std::vector<QueryTypeId>& refs);
|
2018-02-04 00:20:14 +00:00
|
|
|
std::vector<QueryLocation> ToQueryLocation(QueryDatabase* db,
|
|
|
|
std::vector<WithGen<QueryFuncId>>*);
|
2017-09-22 01:14:57 +00:00
|
|
|
std::vector<QueryLocation> ToQueryLocation(QueryDatabase* db,
|
2018-02-03 21:12:03 +00:00
|
|
|
std::vector<WithGen<QueryTypeId>>*);
|
2018-02-04 00:20:14 +00:00
|
|
|
std::vector<QueryLocation> ToQueryLocation(QueryDatabase* db,
|
|
|
|
std::vector<WithGen<QueryVarId>>*);
|
2017-09-22 01:14:57 +00:00
|
|
|
std::vector<QueryLocation> ToQueryLocation(QueryDatabase* db,
|
|
|
|
const std::vector<QueryFuncId>& ids);
|
|
|
|
std::vector<QueryLocation> GetUsesOfSymbol(QueryDatabase* db,
|
2018-01-27 01:31:50 +00:00
|
|
|
const SymbolIdx& symbol,
|
|
|
|
bool include_decl);
|
2017-09-22 01:14:57 +00:00
|
|
|
std::vector<QueryLocation> GetDeclarationsOfSymbolForGotoDefinition(
|
|
|
|
QueryDatabase* db,
|
|
|
|
const SymbolIdx& symbol);
|
2017-12-20 06:20:44 +00:00
|
|
|
|
2017-07-19 07:17:38 +00:00
|
|
|
bool HasCallersOnSelfOrBaseOrDerived(QueryDatabase* db, QueryFunc& root);
|
2017-09-22 01:14:57 +00:00
|
|
|
std::vector<QueryFuncRef> GetCallersForAllBaseFunctions(QueryDatabase* db,
|
|
|
|
QueryFunc& root);
|
|
|
|
std::vector<QueryFuncRef> GetCallersForAllDerivedFunctions(QueryDatabase* db,
|
|
|
|
QueryFunc& root);
|
|
|
|
optional<lsPosition> GetLsPosition(WorkingFile* working_file,
|
|
|
|
const Position& position);
|
2017-06-15 05:32:23 +00:00
|
|
|
optional<lsRange> GetLsRange(WorkingFile* working_file, const Range& location);
|
2017-09-22 01:14:57 +00:00
|
|
|
lsDocumentUri GetLsDocumentUri(QueryDatabase* db,
|
|
|
|
QueryFileId file_id,
|
|
|
|
std::string* path);
|
2017-06-15 05:32:23 +00:00
|
|
|
lsDocumentUri GetLsDocumentUri(QueryDatabase* db, QueryFileId file_id);
|
2017-09-22 01:14:57 +00:00
|
|
|
optional<lsLocation> GetLsLocation(QueryDatabase* db,
|
|
|
|
WorkingFiles* working_files,
|
|
|
|
const QueryLocation& location);
|
2017-12-12 05:20:29 +00:00
|
|
|
std::vector<lsLocation> GetLsLocations(
|
2017-09-22 01:14:57 +00:00
|
|
|
QueryDatabase* db,
|
|
|
|
WorkingFiles* working_files,
|
|
|
|
const std::vector<QueryLocation>& locations);
|
2017-06-15 05:32:23 +00:00
|
|
|
// Returns a symbol. The symbol will have *NOT* have a location assigned.
|
2017-09-22 01:14:57 +00:00
|
|
|
optional<lsSymbolInformation> GetSymbolInfo(QueryDatabase* db,
|
|
|
|
WorkingFiles* working_files,
|
2017-12-19 05:31:19 +00:00
|
|
|
SymbolIdx symbol,
|
|
|
|
bool use_short_name);
|
2017-06-15 05:32:23 +00:00
|
|
|
|
2017-09-22 01:14:57 +00:00
|
|
|
std::vector<SymbolRef> FindSymbolsAtLocation(WorkingFile* working_file,
|
|
|
|
QueryFile* file,
|
2017-12-20 06:20:44 +00:00
|
|
|
lsPosition position);
|
2017-12-24 01:30:52 +00:00
|
|
|
|
|
|
|
void EmitDiagnostics(WorkingFiles* working_files,
|
|
|
|
std::string path,
|
2018-01-27 01:31:50 +00:00
|
|
|
std::vector<lsDiagnostic> diagnostics);
|
2018-02-04 00:20:14 +00:00
|
|
|
|
2018-02-04 21:43:29 +00:00
|
|
|
template <typename Q, typename Fn>
|
|
|
|
void EachWithGen(std::vector<Q>& collection, WithGen<Id<Q>> x, Fn fn) {
|
2018-02-04 00:20:14 +00:00
|
|
|
Q& obj = collection[x.value.id];
|
|
|
|
// FIXME Deprecate optional<Def> def
|
2018-02-04 02:34:07 +00:00
|
|
|
// if (obj.gen == x.gen && obj.def)
|
|
|
|
if (obj.def)
|
2018-02-04 00:20:14 +00:00
|
|
|
fn(obj);
|
|
|
|
}
|
|
|
|
|
2018-02-04 21:43:29 +00:00
|
|
|
template <typename Q, typename Fn>
|
|
|
|
void EachWithGen(std::vector<Q>& collection, std::vector<WithGen<Id<Q>>>& ids, Fn fn) {
|
2018-02-04 00:20:14 +00:00
|
|
|
size_t j = 0;
|
|
|
|
for (WithGen<Id<Q>> x : ids) {
|
|
|
|
Q& obj = collection[x.value.id];
|
2018-02-04 02:34:07 +00:00
|
|
|
if (1 /*obj.gen == x.gen*/) {
|
2018-02-04 00:20:14 +00:00
|
|
|
if (obj.def) // FIXME Deprecate optional<Def> def
|
|
|
|
fn(obj);
|
|
|
|
ids[j++] = x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ids.resize(j);
|
|
|
|
}
|