mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-26 09:31:59 +00:00
Index file language and send it on hover
This commit is contained in:
parent
eac644d81a
commit
28ad5b1ed1
@ -2328,7 +2328,9 @@ bool QueryDbMainLoop(Config* config,
|
||||
if (!ls_range)
|
||||
continue;
|
||||
|
||||
response.result.contents = GetHoverForSymbol(db, ref.idx);
|
||||
response.result.contents.value = GetHoverForSymbol(db, ref.idx);
|
||||
response.result.contents.language = file->def->language;
|
||||
|
||||
response.result.range = *ls_range;
|
||||
break;
|
||||
}
|
||||
|
@ -995,6 +995,24 @@ void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
|
||||
if (!db)
|
||||
return;
|
||||
|
||||
|
||||
// update the file language
|
||||
// TODO: only do this when |is_first_ownership| in ConsumeFile is true
|
||||
switch (clang_getCursorLanguage(decl->cursor)) {
|
||||
case CXLanguage_C:
|
||||
db->language = "c";
|
||||
break;
|
||||
case CXLanguage_CPlusPlus:
|
||||
db->language = "c++";
|
||||
break;
|
||||
case CXLanguage_ObjC:
|
||||
db->language = "objc";
|
||||
break;
|
||||
case CXLanguage_Invalid:
|
||||
db->language = "invalid";
|
||||
break;
|
||||
}
|
||||
|
||||
NamespaceHelper* ns = ¶m->ns;
|
||||
|
||||
// std::cerr << "DECL kind=" << decl->entityInfo->kind << " at " <<
|
||||
|
@ -473,6 +473,8 @@ struct IndexFile {
|
||||
std::string path;
|
||||
std::vector<std::string> args;
|
||||
int64_t last_modification_time = 0;
|
||||
// "c++", "c", "obj-c", "invalid" or "unknown"
|
||||
std::string language;
|
||||
|
||||
// The path to the translation unit cc file which caused the creation of this
|
||||
// IndexFile. When parsing a translation unit we generate many IndexFile
|
||||
|
@ -1179,6 +1179,24 @@ MAKE_REFLECT_STRUCT(lsSignatureHelp,
|
||||
signatures,
|
||||
activeSignature,
|
||||
activeParameter);
|
||||
|
||||
// MarkedString can be used to render human readable text. It is either a markdown string
|
||||
// or a code-block that provides a language and a code snippet. The language identifier
|
||||
// is sematically equal to the optional language identifier in fenced code blocks in GitHub
|
||||
// issues. See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting
|
||||
//
|
||||
// The pair of a language and a value is an equivalent to markdown:
|
||||
// ```${language}
|
||||
// ${value}
|
||||
// ```
|
||||
//
|
||||
// Note that markdown strings will be sanitized - that means html will be escaped.
|
||||
struct lsMarkedString {
|
||||
std::string language;
|
||||
std::string value;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(lsMarkedString, language, value);
|
||||
|
||||
struct Out_TextDocumentSignatureHelp
|
||||
: public lsOutMessage<Out_TextDocumentSignatureHelp> {
|
||||
lsRequestId id;
|
||||
@ -1228,7 +1246,7 @@ struct Ipc_TextDocumentHover : public IpcMessage<Ipc_TextDocumentHover> {
|
||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentHover, id, params);
|
||||
struct Out_TextDocumentHover : public lsOutMessage<Out_TextDocumentHover> {
|
||||
struct Result {
|
||||
std::string contents;
|
||||
lsMarkedString contents;
|
||||
optional<lsRange> range;
|
||||
};
|
||||
|
||||
|
@ -171,6 +171,7 @@ void CompareGroups(std::vector<T>& previous_data,
|
||||
QueryFile::Def BuildFileDef(const IdMap& id_map, const IndexFile& indexed) {
|
||||
QueryFile::Def def;
|
||||
def.path = indexed.path;
|
||||
def.language = indexed.language;
|
||||
def.includes = indexed.includes;
|
||||
def.inactive_regions = indexed.skipped_by_preprocessor;
|
||||
|
||||
|
@ -169,6 +169,8 @@ void Reflect(TVisitor& visitor, MergeableUpdate<TId, TValue>& value) {
|
||||
struct QueryFile {
|
||||
struct Def {
|
||||
std::string path;
|
||||
// Language identifier
|
||||
std::string language;
|
||||
// Includes in the file.
|
||||
std::vector<IndexInclude> includes;
|
||||
// Outline of the file (ie, for code lens).
|
||||
@ -191,6 +193,7 @@ struct QueryFile {
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(QueryFile::Def,
|
||||
path,
|
||||
language,
|
||||
outline,
|
||||
all_symbols,
|
||||
inactive_regions);
|
||||
|
@ -169,6 +169,7 @@ void Reflect(TVisitor& visitor, IndexFile& value) {
|
||||
if (!gTestOutputMode) {
|
||||
REFLECT_MEMBER(version);
|
||||
REFLECT_MEMBER(last_modification_time);
|
||||
REFLECT_MEMBER(language);
|
||||
REFLECT_MEMBER(import_file);
|
||||
REFLECT_MEMBER(args);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user