Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
cppit
jucipp
Commits
25ce06b7
Commit
25ce06b7
authored
Sep 15, 2020
by
Ole Christian Eidheim
Browse files
Added missing try around boost::property_tree::read_json call
parent
06d9854e
Pipeline
#190097197
passed with stages
in 17 minutes and 6 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
40 deletions
+45
-40
src/source_language_protocol.cpp
src/source_language_protocol.cpp
+45
-40
No files found.
src/source_language_protocol.cpp
View file @
25ce06b7
...
...
@@ -269,54 +269,59 @@ void LanguageProtocol::Client::parse_server_message() {
}
}
server_message_stream
.
seekg
(
server_message_content_pos
,
std
::
ios
::
beg
);
boost
::
property_tree
::
ptree
pt
;
boost
::
property_tree
::
read_json
(
server_message_stream
,
pt
);
if
(
Config
::
get
().
log
.
language_server
)
{
std
::
cout
<<
"language server: "
;
boost
::
property_tree
::
write_json
(
std
::
cout
,
pt
);
}
try
{
server_message_stream
.
seekg
(
server_message_content_pos
,
std
::
ios
::
beg
);
boost
::
property_tree
::
ptree
pt
;
boost
::
property_tree
::
read_json
(
server_message_stream
,
pt
);
if
(
Config
::
get
().
log
.
language_server
)
{
std
::
cout
<<
"language server: "
;
boost
::
property_tree
::
write_json
(
std
::
cout
,
pt
);
}
auto
message_id
=
pt
.
get_optional
<
size_t
>
(
"id"
);
{
LockGuard
lock
(
read_write_mutex
);
if
(
auto
result
=
pt
.
get_child_optional
(
"result"
))
{
if
(
message_id
)
{
auto
id_it
=
handlers
.
find
(
*
message_id
);
if
(
id_it
!=
handlers
.
end
())
{
auto
function
=
std
::
move
(
id_it
->
second
.
second
);
handlers
.
erase
(
id_it
);
lock
.
unlock
();
function
(
*
result
,
false
);
lock
.
lock
();
auto
message_id
=
pt
.
get_optional
<
size_t
>
(
"id"
);
{
LockGuard
lock
(
read_write_mutex
);
if
(
auto
result
=
pt
.
get_child_optional
(
"result"
))
{
if
(
message_id
)
{
auto
id_it
=
handlers
.
find
(
*
message_id
);
if
(
id_it
!=
handlers
.
end
())
{
auto
function
=
std
::
move
(
id_it
->
second
.
second
);
handlers
.
erase
(
id_it
);
lock
.
unlock
();
function
(
*
result
,
false
);
lock
.
lock
();
}
}
}
}
else
if
(
auto
error
=
pt
.
get_child_optional
(
"error"
))
{
if
(
!
Config
::
get
().
log
.
language_server
)
boost
::
property_tree
::
write_json
(
std
::
cerr
,
pt
);
if
(
message_id
)
{
auto
id_it
=
handlers
.
find
(
*
message_id
);
if
(
id_it
!=
handlers
.
end
())
{
auto
function
=
std
::
move
(
id_it
->
second
.
second
);
handlers
.
erase
(
id_it
);
else
if
(
auto
error
=
pt
.
get_child_optional
(
"error"
))
{
if
(
!
Config
::
get
().
log
.
language_server
)
boost
::
property_tree
::
write_json
(
std
::
cerr
,
pt
);
if
(
message_id
)
{
auto
id_it
=
handlers
.
find
(
*
message_id
);
if
(
id_it
!=
handlers
.
end
())
{
auto
function
=
std
::
move
(
id_it
->
second
.
second
);
handlers
.
erase
(
id_it
);
lock
.
unlock
();
function
(
*
error
,
true
);
lock
.
lock
();
}
}
}
else
if
(
auto
method
=
pt
.
get_optional
<
std
::
string
>
(
"method"
))
{
if
(
auto
params
=
pt
.
get_child_optional
(
"params"
))
{
lock
.
unlock
();
function
(
*
error
,
true
);
if
(
message_id
)
handle_server_request
(
*
message_id
,
*
method
,
*
params
);
else
handle_server_notification
(
*
method
,
*
params
);
lock
.
lock
();
}
}
}
else
if
(
auto
method
=
pt
.
get_optional
<
std
::
string
>
(
"method"
))
{
if
(
auto
params
=
pt
.
get_child_optional
(
"params"
))
{
lock
.
unlock
();
if
(
message_id
)
handle_server_request
(
*
message_id
,
*
method
,
*
params
);
else
handle_server_notification
(
*
method
,
*
params
);
lock
.
lock
();
}
}
}
catch
(...)
{
Terminal
::
get
().
async_print
(
"\e[31mError\e[m: failed to parse message from language server
\n
"
,
true
);
}
server_message_stream
=
std
::
stringstream
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment