continue migrating to new api

This commit is contained in:
Jacob Dufault 2017-03-24 18:27:41 -07:00
parent 14af7453c3
commit e86509edb0
2 changed files with 96 additions and 42 deletions

View File

@ -1039,20 +1039,33 @@ void PreMain() {
IpcMessage_WorkspaceSymbolsRequest::kIpcId);
IpcRegistry::instance()->Register<IpcMessage_WorkspaceSymbolsResponse>(
IpcMessage_WorkspaceSymbolsResponse::kIpcId);
MessageRegistry::instance()->Register<In_CancelRequest>();
MessageRegistry::instance()->Register<In_InitializeRequest>();
MessageRegistry::instance()->Register<In_InitializedNotification>();
MessageRegistry::instance()->Register<In_DocumentSymbolRequest>();
MessageRegistry::instance()->Register<In_DocumentCodeLensRequest>();
MessageRegistry::instance()->Register<In_WorkspaceSymbolRequest>();
}
int main(int argc, char** argv) {
// TODO: real impl
template<typename T>
void RegisterId(TypedBidiMessageQueue<lsMethodId, lsBaseMessage>& t) {
t.RegisterId(T::kMethod,
[](Writer& visitor, lsBaseMessage& message) {
T& m = static_cast<T&>(message);
Reflect(visitor, m);
}, [](Reader& visitor) {
auto m = MakeUnique<T>();
Reflect(visitor, *m);
return m;
});
}
int main(int argc, char** argv) {j
// TODO: real queue size
const int kQueueSize = 128;
TypedBidiMessageQueue<lsMethodId, lsBaseMessage> t("foo", kQueueSize);
RegisterId<In_CancelRequest>(t);
RegisterId<In_InitializeRequest>(t);
RegisterId<In_InitializedNotification>(t);
RegisterId<In_DocumentSymbolRequest>(t);
RegisterId<In_DocumentCodeLensRequest>(t);
RegisterId<In_WorkspaceSymbolRequest>(t);
/*
// TODO: We can make this entire function a template.
t.RegisterId(In_DocumentSymbolRequest::kMethod,
[](Writer& visitor, lsBaseMessage& message) {
@ -1063,6 +1076,7 @@ int main(int argc, char** argv) {
Reflect(visitor, *m);
return m;
});
*/
//struct In_DocumentSymbolRequest : public InRequestMessage {
// const static lsMethodId kMethod = lsMethodId::TextDocumentDocumentSymbol;

View File

@ -199,19 +199,15 @@ struct InMessage : public lsBaseMessage {
const lsMethodId method_id;
optional<RequestId> id;
InMessage(lsMethodId method_id, optional<RequestId> id, Reader& reader)
// We verify there are no duplicate hashes inside of MessageRegistry.
: method_id(method_id), id(id) {}
InMessage(lsMethodId method_id) : method_id(method_id) {}
};
struct InRequestMessage : public InMessage {
InRequestMessage(lsMethodId method, optional<RequestId> id, Reader& reader)
: InMessage(method, id, reader) {}
InRequestMessage(lsMethodId method) : InMessage(method) {}
};
struct InNotificationMessage : public InMessage {
InNotificationMessage(lsMethodId method, optional<RequestId> id, Reader& reader)
: InMessage(method, id, reader) {}
InNotificationMessage(lsMethodId method) : InMessage(method) {}
};
struct OutMessage : public lsBaseMessage {
@ -350,10 +346,16 @@ struct OutNotificationMessage : public OutMessage {
struct In_CancelRequest : public InNotificationMessage {
static const lsMethodId kMethod = lsMethodId::CancelRequest;
In_CancelRequest(optional<RequestId> id, Reader& reader)
: InNotificationMessage(kMethod, id, reader) {}
In_CancelRequest() : InNotificationMessage(kMethod) {}
};
template<typename TVisitor>
void Reflect(TVisitor& visitor, In_CancelRequest& value) {
REFLECT_MEMBER_START();
REFLECT_MEMBER(id);
REFLECT_MEMBER_END();
}
@ -1006,6 +1008,20 @@ void Reflect(Reader& reader, lsInitializeParams::lsTrace& value) {
value = lsInitializeParams::lsTrace::Verbose;
}
void Reflect(Writer& writer, lsInitializeParams::lsTrace& value) {
switch (value) {
case lsInitializeParams::lsTrace::Off:
writer.String("off");
break;
case lsInitializeParams::lsTrace::Messages:
writer.String("messages");
break;
case lsInitializeParams::lsTrace::Verbose:
writer.String("verbose");
break;
}
}
template<typename TVisitor>
void Reflect(TVisitor& visitor, lsInitializeParams& value) {
REFLECT_MEMBER_START();
@ -1268,13 +1284,17 @@ struct In_InitializeRequest : public InRequestMessage {
const static lsMethodId kMethod = lsMethodId::Initialize;
lsInitializeParams params;
In_InitializeRequest(optional<RequestId> id, Reader& reader)
: InRequestMessage(kMethod, id, reader) {
Reflect(reader, params);
std::cerr << "done" << std::endl;
}
In_InitializeRequest() : InRequestMessage(kMethod) {}
};
template<typename TVisitor>
void Reflect(TVisitor& visitor, In_InitializeRequest& value) {
REFLECT_MEMBER_START();
REFLECT_MEMBER(id);
REFLECT_MEMBER(params);
REFLECT_MEMBER_END();
}
struct Out_InitializeResponse : public OutResponseMessage {
lsInitializeResult result;
@ -1287,10 +1307,15 @@ struct Out_InitializeResponse : public OutResponseMessage {
struct In_InitializedNotification : public InNotificationMessage {
const static lsMethodId kMethod = lsMethodId::Initialized;
In_InitializedNotification(optional<RequestId> id, Reader& reader)
: InNotificationMessage(kMethod, id, reader) {}
In_InitializedNotification() : InNotificationMessage(kMethod) {}
};
template<typename TVisitor>
void Reflect(TVisitor& visitor, In_InitializedNotification& value) {
REFLECT_MEMBER_START();
REFLECT_MEMBER(id);
REFLECT_MEMBER_END();
}
@ -1352,15 +1377,15 @@ struct In_DocumentSymbolRequest : public InRequestMessage {
lsDocumentSymbolParams params;
In_DocumentSymbolRequest(optional<RequestId> id, Reader& reader)
: InRequestMessage(kMethod, id, reader) {
Reflect(reader, params);
}
In_DocumentSymbolRequest() : InRequestMessage(kMethod) {}
};
template<typename TVisitor>
void Reflect(TVisitor& visitor, In_DocumentSymbolRequest& value) {
Reflect(visitor, value.params);
REFLECT_MEMBER_START();
REFLECT_MEMBER(id);
REFLECT_MEMBER(params);
REFLECT_MEMBER_END();
}
struct Out_DocumentSymbolResponse : public OutResponseMessage {
@ -1425,12 +1450,17 @@ struct In_DocumentCodeLensRequest : public InRequestMessage {
lsDocumentCodeLensParams params;
In_DocumentCodeLensRequest(optional<RequestId> id, Reader& reader)
: InRequestMessage(kMethod, id, reader) {
Reflect(reader, params);
}
In_DocumentCodeLensRequest() : InRequestMessage(kMethod) {}
};
template<typename TVisitor>
void Reflect(TVisitor& visitor, In_DocumentCodeLensRequest& value) {
REFLECT_MEMBER_START();
REFLECT_MEMBER(id);
REFLECT_MEMBER(params);
REFLECT_MEMBER_END();
}
struct Out_DocumentCodeLensResponse : public OutResponseMessage {
std::vector<lsCodeLens<lsCodeLensUserData, lsCodeLensCommandArguments>> result;
@ -1445,12 +1475,17 @@ struct In_DocumentCodeLensResolveRequest : public InRequestMessage {
TCodeLens params;
In_DocumentCodeLensResolveRequest(optional<RequestId> id, Reader& reader)
: InRequestMessage(kMethod, id, reader) {
Reflect(reader, params);
}
In_DocumentCodeLensResolveRequest() : InRequestMessage(kMethod) {}
};
template<typename TVisitor>
void Reflect(TVisitor& visitor, In_DocumentCodeLensResolveRequest& value) {
REFLECT_MEMBER_START();
REFLECT_MEMBER(id);
REFLECT_MEMBER(params);
REFLECT_MEMBER_END();
}
struct Out_DocumentCodeLensResolveResponse : public OutResponseMessage {
TCodeLens result;
@ -1483,12 +1518,17 @@ struct In_WorkspaceSymbolRequest : public InRequestMessage {
lsWorkspaceSymbolParams params;
In_WorkspaceSymbolRequest(optional<RequestId> id, Reader& reader)
: InRequestMessage(kMethod, id, reader) {
Reflect(reader, params);
}
In_WorkspaceSymbolRequest() : InRequestMessage(kMethod) {}
};
template<typename TVisitor>
void Reflect(TVisitor& visitor, In_WorkspaceSymbolRequest& value) {
REFLECT_MEMBER_START();
REFLECT_MEMBER(id);
REFLECT_MEMBER(params);
REFLECT_MEMBER_END();
}
struct Out_WorkspaceSymbolResponse : public OutResponseMessage {
std::vector<lsSymbolInformation> result;