ccls/src/query_utils.h

86 lines
3.6 KiB
C
Raw Normal View History

2017-06-15 05:32:23 +00:00
#pragma once
#include "query_utils.h"
#include "query.h"
#include "working_files.h"
#include <optional.h>
2018-02-11 04:30:27 +00:00
Maybe<Use> GetDefinitionSpellingOfSymbol(QueryDatabase* db,
QueryFuncId id);
Maybe<Use> GetDefinitionSpellingOfSymbol(QueryDatabase* db,
SymbolIdx sym);
Maybe<Use> GetDefinitionExtentOfSymbol(QueryDatabase* db, SymbolIdx sym);
Maybe<QueryFileId> GetDeclarationFileForSymbol(QueryDatabase* db,
SymbolIdx sym);
2018-02-09 05:11:35 +00:00
std::vector<Use> ToUses(QueryDatabase* db,
const std::vector<QueryFuncId>& ids);
std::vector<Use> ToUses(QueryDatabase* db,
const std::vector<QueryTypeId>& ids);
std::vector<Use> ToUses(QueryDatabase* db,
const std::vector<QueryVarId>& ids);
std::vector<Use> GetUsesOfSymbol(QueryDatabase* db,
SymbolIdx sym,
bool include_decl);
std::vector<Use> GetDeclarationsOfSymbolForGotoDefinition(
2017-09-22 01:14:57 +00:00
QueryDatabase* db,
SymbolIdx sym);
bool HasCallersOnSelfOrBaseOrDerived(QueryDatabase* db, QueryFunc& root);
std::vector<Use> GetCallersForAllBaseFunctions(QueryDatabase* db,
QueryFunc& root);
std::vector<Use> GetCallersForAllDerivedFunctions(QueryDatabase* db,
QueryFunc& root);
2017-09-22 01:14:57 +00:00
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);
2018-02-09 05:11:35 +00:00
2017-09-22 01:14:57 +00:00
optional<lsLocation> GetLsLocation(QueryDatabase* db,
WorkingFiles* working_files,
2018-02-09 05:11:35 +00:00
Reference location);
optional<lsLocationEx> GetLsLocationEx(QueryDatabase* db,
WorkingFiles* working_files,
Use use,
bool extension);
std::vector<lsLocation> GetLsLocations(QueryDatabase* db,
WorkingFiles* working_files,
const std::vector<Use>& refs);
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,
SymbolIdx sym,
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,
lsPosition position);
void EmitDiagnostics(WorkingFiles* working_files,
std::string path,
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, Id<Q> x, Fn fn) {
Q& obj = collection[x.id];
2018-02-04 00:20:14 +00:00
// 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<Id<Q>>& ids, Fn fn) {
for (Id<Q> x : ids) {
Q& obj = collection[x.id];
if (obj.def) // FIXME Deprecate optional<Def> def
fn(obj);
2018-02-04 00:20:14 +00:00
}
}