This commit is contained in:
Jacob Dufault 2017-03-25 13:40:04 -07:00
parent 38acb8c1a1
commit c4a9590398
3 changed files with 26 additions and 62 deletions

View File

@ -165,7 +165,7 @@ struct IpcMessage_Cout : public BaseIpcMessage<IpcMessage_Cout> {
std::string content; std::string content;
IpcMessage_Cout() {} IpcMessage_Cout() {}
IpcMessage_Cout(OutMessage& message) { IpcMessage_Cout(lsOutMessage& message) {
std::ostringstream out; std::ostringstream out;
message.Send(out); message.Send(out);
content = out.str(); content = out.str();
@ -176,7 +176,7 @@ void Reflect(TVisitor& visitor, IpcMessage_Cout& value) {
Reflect(visitor, value.content); Reflect(visitor, value.content);
} }
void SendOutMessageToClient(IpcMessageQueue* queue, OutMessage& response) { void SendOutMessageToClient(IpcMessageQueue* queue, lsOutMessage& response) {
IpcMessage_Cout out(response); IpcMessage_Cout out(response);
queue->SendMessage(&queue->for_client, IpcMessage_Cout::kMethod, out); queue->SendMessage(&queue->for_client, IpcMessage_Cout::kMethod, out);
} }
@ -186,7 +186,7 @@ void SendOutMessageToClient(IpcMessageQueue* queue, OutMessage& response) {
template<typename T> template<typename T>
void RegisterId(IpcMessageQueue* t) { void RegisterId(IpcMessageQueue* t) {
t->RegisterId(T::kMethod, t->RegisterId(T::kMethod,
[](Writer& visitor, lsBaseMessage& message) { [](Writer& visitor, InMessage& message) {
T& m = static_cast<T&>(message); T& m = static_cast<T&>(message);
Reflect(visitor, m); Reflect(visitor, m);
}, [](Reader& visitor) { }, [](Reader& visitor) {

View File

@ -338,14 +338,7 @@ struct IndexedTypeDef {
} }
}; };
namespace std { MAKE_HASHABLE(IndexedTypeDef, t.def.usr);
template <>
struct hash<IndexedTypeDef> {
size_t operator()(const IndexedTypeDef& k) const {
return hash<string>()(k.def.usr);
}
};
}
template <typename TypeId = TypeId, template <typename TypeId = TypeId,
typename FuncId = FuncId, typename FuncId = FuncId,
@ -446,15 +439,7 @@ struct IndexedFuncDef {
return def.usr < other.def.usr; return def.usr < other.def.usr;
} }
}; };
MAKE_HASHABLE(IndexedFuncDef, t.def.usr);
namespace std {
template <>
struct hash<IndexedFuncDef> {
size_t operator()(const IndexedFuncDef& k) const {
return hash<string>()(k.def.usr);
}
};
}
template <typename TypeId = TypeId, template <typename TypeId = TypeId,
typename FuncId = FuncId, typename FuncId = FuncId,
@ -530,15 +515,7 @@ struct IndexedVarDef {
return def.usr < other.def.usr; return def.usr < other.def.usr;
} }
}; };
MAKE_HASHABLE(IndexedVarDef, t.def.usr);
namespace std {
template <>
struct hash<IndexedVarDef> {
size_t operator()(const IndexedVarDef& k) const {
return hash<string>()(k.def.usr);
}
};
}
struct IdCache { struct IdCache {
std::unordered_map<std::string, FileId> file_path_to_file_id; std::unordered_map<std::string, FileId> file_path_to_file_id;

View File

@ -187,9 +187,7 @@ MessageRegistry* MessageRegistry::instance() {
return instance_; return instance_;
} }
struct lsBaseMessage {}; struct InMessage {
struct InMessage : public lsBaseMessage {
const lsMethodId method_id; const lsMethodId method_id;
InMessage(lsMethodId method_id) : method_id(method_id) {} InMessage(lsMethodId method_id) : method_id(method_id) {}
}; };
@ -202,7 +200,7 @@ struct InNotificationMessage : public InMessage {
InNotificationMessage(lsMethodId method) : InMessage(method) {} InNotificationMessage(lsMethodId method) : InMessage(method) {}
}; };
struct OutMessage : public lsBaseMessage { struct lsOutMessage {
// Write out the body of the message. The writer expects object key/value // Write out the body of the message. The writer expects object key/value
// pairs. // pairs.
virtual void WriteMessageBody(Writer& writer) = 0; virtual void WriteMessageBody(Writer& writer) = 0;
@ -224,7 +222,7 @@ struct OutMessage : public lsBaseMessage {
} }
}; };
struct OutRequestMessage : public OutMessage { struct OutRequestMessage : public lsOutMessage {
RequestId id; RequestId id;
virtual std::string Method() = 0; virtual std::string Method() = 0;
@ -281,7 +279,7 @@ struct lsResponseError {
} }
}; };
struct OutResponseMessage : public OutMessage { struct OutResponseMessage : public lsOutMessage {
RequestId id; RequestId id;
virtual optional<lsResponseError> Error() { virtual optional<lsResponseError> Error() {
@ -307,7 +305,7 @@ struct OutResponseMessage : public OutMessage {
} }
}; };
struct OutNotificationMessage : public OutMessage { struct OutNotificationMessage : public lsOutMessage {
virtual std::string Method() = 0; virtual std::string Method() = 0;
virtual void SerializeParams(Writer& writer) = 0; virtual void SerializeParams(Writer& writer) = 0;
@ -1004,15 +1002,15 @@ void Reflect(Reader& reader, lsInitializeParams::lsTrace& value) {
void Reflect(Writer& writer, lsInitializeParams::lsTrace& value) { void Reflect(Writer& writer, lsInitializeParams::lsTrace& value) {
switch (value) { switch (value) {
case lsInitializeParams::lsTrace::Off: case lsInitializeParams::lsTrace::Off:
writer.String("off"); writer.String("off");
break; break;
case lsInitializeParams::lsTrace::Messages: case lsInitializeParams::lsTrace::Messages:
writer.String("messages"); writer.String("messages");
break; break;
case lsInitializeParams::lsTrace::Verbose: case lsInitializeParams::lsTrace::Verbose:
writer.String("verbose"); writer.String("verbose");
break; break;
} }
} }
@ -1028,20 +1026,6 @@ void Reflect(TVisitor& visitor, lsInitializeParams& value) {
} }
#if false
/**
* Known error codes for an `InitializeError`;
*/
export namespace lsInitializeError {
/**
* If the protocol version provided by the client can't be handled by the server.
* @deprecated This initialize error got replaced by client capabilities. There is
* no version handshake in version 3.0x
*/
export const unknownProtocolVersion : number = 1;
}
#endif
struct lsInitializeError { struct lsInitializeError {
// Indicates whether the client should retry to send the // Indicates whether the client should retry to send the
// initilize request after showing the message provided // initilize request after showing the message provided
@ -1071,8 +1055,11 @@ enum class lsTextDocumentSyncKind {
Incremental = 2 Incremental = 2
}; };
void Reflect(Writer& writer, lsTextDocumentSyncKind& value) { template<typename TVisitor>
writer.Int(static_cast<int>(value)); void Reflect(TVisitor& visitor, lsTextDocumentSyncKind& value) {
int value0 = static_cast<int>(value);
Reflect(visitor, value0);
value = static_cast<lsTextDocumentSyncKind>(value0);
} }
// Completion options. // Completion options.
@ -1302,7 +1289,7 @@ struct Out_InitializeResponse : public OutResponseMessage {
struct In_InitializedNotification : public InNotificationMessage { struct In_InitializedNotification : public InNotificationMessage {
const static lsMethodId kMethod = lsMethodId::Initialized; const static lsMethodId kMethod = lsMethodId::Initialized;
RequestId id; RequestId id;
In_InitializedNotification() : InNotificationMessage(kMethod) {} In_InitializedNotification() : InNotificationMessage(kMethod) {}