mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-25 17:11:59 +00:00
Add $cquery/textDocumentDidView.
This allows for more stable semantic highlighting, among other potential features. Requires custom support from the client, though.
This commit is contained in:
parent
697968b15f
commit
ab7ffa302a
@ -645,6 +645,7 @@ void RegisterMessageTypes() {
|
|||||||
MessageRegistry::instance()->Register<Ipc_InitializedNotification>();
|
MessageRegistry::instance()->Register<Ipc_InitializedNotification>();
|
||||||
MessageRegistry::instance()->Register<Ipc_Exit>();
|
MessageRegistry::instance()->Register<Ipc_Exit>();
|
||||||
MessageRegistry::instance()->Register<Ipc_TextDocumentDidOpen>();
|
MessageRegistry::instance()->Register<Ipc_TextDocumentDidOpen>();
|
||||||
|
MessageRegistry::instance()->Register<Ipc_CqueryTextDocumentDidView>();
|
||||||
MessageRegistry::instance()->Register<Ipc_TextDocumentDidChange>();
|
MessageRegistry::instance()->Register<Ipc_TextDocumentDidChange>();
|
||||||
MessageRegistry::instance()->Register<Ipc_TextDocumentDidClose>();
|
MessageRegistry::instance()->Register<Ipc_TextDocumentDidClose>();
|
||||||
MessageRegistry::instance()->Register<Ipc_TextDocumentDidSave>();
|
MessageRegistry::instance()->Register<Ipc_TextDocumentDidSave>();
|
||||||
@ -1888,6 +1889,25 @@ bool QueryDbMainLoop(Config* config,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case IpcId::CqueryTextDocumentDidView: {
|
||||||
|
auto msg = message->As<Ipc_CqueryTextDocumentDidView>();
|
||||||
|
std::string path = msg->params.textDocumentUri.GetPath();
|
||||||
|
|
||||||
|
WorkingFile* working_file = working_files->GetFileByFilename(path);
|
||||||
|
if (!working_file)
|
||||||
|
break;
|
||||||
|
QueryFile* file = nullptr;
|
||||||
|
if (!FindFileOrFail(db, nullopt, path, &file))
|
||||||
|
break;
|
||||||
|
|
||||||
|
clang_complete->NotifyView(path);
|
||||||
|
if (file->def) {
|
||||||
|
EmitInactiveLines(working_file, file->def->inactive_regions);
|
||||||
|
EmitSemanticHighlighting(db, semantic_cache, working_file, file);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case IpcId::TextDocumentDidChange: {
|
case IpcId::TextDocumentDidChange: {
|
||||||
auto msg = message->As<Ipc_TextDocumentDidChange>();
|
auto msg = message->As<Ipc_TextDocumentDidChange>();
|
||||||
std::string path = msg->params.textDocument.uri.GetPath();
|
std::string path = msg->params.textDocument.uri.GetPath();
|
||||||
@ -2834,16 +2854,6 @@ bool QueryDbMainLoop(Config* config,
|
|||||||
|
|
||||||
ipc->SendOutMessageToClient(IpcId::TextDocumentCodeLens, response);
|
ipc->SendOutMessageToClient(IpcId::TextDocumentCodeLens, response);
|
||||||
|
|
||||||
// TODO: We need to move this to a separate request, as the user may
|
|
||||||
// have turned code lens off (ie, a custom DidView notification).
|
|
||||||
if (file && file->def) {
|
|
||||||
WorkingFile* working_file =
|
|
||||||
working_files->GetFileByFilename(file->def->path);
|
|
||||||
EmitInactiveLines(working_file, file->def->inactive_regions);
|
|
||||||
// Do not emit semantic highlighting information here, as it has not
|
|
||||||
// been updated.
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3069,6 +3079,7 @@ void LaunchStdinLoop(Config* config,
|
|||||||
|
|
||||||
case IpcId::Initialize:
|
case IpcId::Initialize:
|
||||||
case IpcId::TextDocumentDidOpen:
|
case IpcId::TextDocumentDidOpen:
|
||||||
|
case IpcId::CqueryTextDocumentDidView:
|
||||||
case IpcId::TextDocumentDidChange:
|
case IpcId::TextDocumentDidChange:
|
||||||
case IpcId::TextDocumentDidClose:
|
case IpcId::TextDocumentDidClose:
|
||||||
case IpcId::TextDocumentDidSave:
|
case IpcId::TextDocumentDidSave:
|
||||||
|
@ -49,6 +49,8 @@ const char* IpcIdToString(IpcId id) {
|
|||||||
case IpcId::WorkspaceSymbol:
|
case IpcId::WorkspaceSymbol:
|
||||||
return "workspace/symbol";
|
return "workspace/symbol";
|
||||||
|
|
||||||
|
case IpcId::CqueryTextDocumentDidView:
|
||||||
|
return "$cquery/textDocumentDidView";
|
||||||
case IpcId::CqueryPublishInactiveRegions:
|
case IpcId::CqueryPublishInactiveRegions:
|
||||||
return "$cquery/publishInactiveRegions";
|
return "$cquery/publishInactiveRegions";
|
||||||
case IpcId::CqueryPublishSemanticHighlighting:
|
case IpcId::CqueryPublishSemanticHighlighting:
|
||||||
|
@ -31,6 +31,9 @@ enum class IpcId : int {
|
|||||||
WorkspaceSymbol,
|
WorkspaceSymbol,
|
||||||
|
|
||||||
// Custom notifications
|
// Custom notifications
|
||||||
|
// Comes from the client. Does various things, like update semantic
|
||||||
|
// highlighting.
|
||||||
|
CqueryTextDocumentDidView,
|
||||||
CqueryPublishInactiveRegions,
|
CqueryPublishInactiveRegions,
|
||||||
CqueryPublishSemanticHighlighting,
|
CqueryPublishSemanticHighlighting,
|
||||||
|
|
||||||
|
@ -969,7 +969,7 @@ struct Ipc_CancelRequest : public IpcMessage<Ipc_CancelRequest> {
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CancelRequest, id);
|
MAKE_REFLECT_STRUCT(Ipc_CancelRequest, id);
|
||||||
|
|
||||||
// Open, update, close file
|
// Open, view, change, close file
|
||||||
struct Ipc_TextDocumentDidOpen : public IpcMessage<Ipc_TextDocumentDidOpen> {
|
struct Ipc_TextDocumentDidOpen : public IpcMessage<Ipc_TextDocumentDidOpen> {
|
||||||
struct Params {
|
struct Params {
|
||||||
lsTextDocumentItem textDocument;
|
lsTextDocumentItem textDocument;
|
||||||
@ -980,6 +980,17 @@ struct Ipc_TextDocumentDidOpen : public IpcMessage<Ipc_TextDocumentDidOpen> {
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidOpen::Params, textDocument);
|
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidOpen::Params, textDocument);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidOpen, params);
|
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidOpen, params);
|
||||||
|
struct Ipc_CqueryTextDocumentDidView
|
||||||
|
: public IpcMessage<Ipc_CqueryTextDocumentDidView> {
|
||||||
|
struct Params {
|
||||||
|
lsDocumentUri textDocumentUri;
|
||||||
|
};
|
||||||
|
|
||||||
|
const static IpcId kIpcId = IpcId::CqueryTextDocumentDidView;
|
||||||
|
Params params;
|
||||||
|
};
|
||||||
|
MAKE_REFLECT_STRUCT(Ipc_CqueryTextDocumentDidView::Params, textDocumentUri);
|
||||||
|
MAKE_REFLECT_STRUCT(Ipc_CqueryTextDocumentDidView, params);
|
||||||
struct Ipc_TextDocumentDidChange
|
struct Ipc_TextDocumentDidChange
|
||||||
: public IpcMessage<Ipc_TextDocumentDidChange> {
|
: public IpcMessage<Ipc_TextDocumentDidChange> {
|
||||||
struct lsTextDocumentContentChangeEvent {
|
struct lsTextDocumentContentChangeEvent {
|
||||||
|
Loading…
Reference in New Issue
Block a user