MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / Run

Method Run

CodeFormatServer/src/Session/StandardIOSession.cpp:83–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81
82
83int StandardIOSession::Run(LanguageServer &server) {
84 auto &ioc = server.GetIOContext();
85 IOSession::Run(server);
86 while (true) {
87 do {
88 char *writableCursor = _protocolBuffer.GetWritableCursor();
89 std::size_t capacity = _protocolBuffer.GetRestCapacity();
90
91 std::size_t readSize = StandardIO::GetInstance().ReadSome(writableCursor, capacity);
92
93 if (StandardIO::GetInstance().HasError()) {
94 goto endLoop;
95 }
96
97 _protocolBuffer.SetWriteSize(readSize);
98
99 if (_protocolBuffer.CanReadOneProtocol()) {
100 break;
101 }
102
103 _protocolBuffer.FitCapacity();
104 } while (true);
105
106 do {
107 auto content = _protocolBuffer.ReadOneProtocol();
108 auto parser = std::make_shared<ProtocolParser>();
109 parser->Parse(content);
110 _protocolBuffer.Reset();
111 asio::post(ioc, [this, parser, &server]() {
112 std::string result = Handle(server, parser);
113
114 if (!result.empty()) {
115 Send(result);
116 }
117 });
118 } while (_protocolBuffer.CanReadOneProtocol());
119 }
120endLoop:
121 return 0;
122}
123
124void StandardIOSession::Send(std::string_view content) {
125 StandardIO::GetInstance().Write(content);

Callers

nothing calls this directly

Calls 13

postFunction · 0.85
GetWritableCursorMethod · 0.80
GetRestCapacityMethod · 0.80
ReadSomeMethod · 0.80
SetWriteSizeMethod · 0.80
CanReadOneProtocolMethod · 0.80
FitCapacityMethod · 0.80
ReadOneProtocolMethod · 0.80
RunFunction · 0.50
HasErrorMethod · 0.45
ParseMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected