Workaround weird issue with broken children of function definition
This commit is contained in:
parent
2ce5ddc295
commit
099ff00908
2 changed files with 19 additions and 3 deletions
|
|
@ -333,6 +333,8 @@ namespace
|
||||||
else
|
else
|
||||||
stream.bump();
|
stream.bump();
|
||||||
}
|
}
|
||||||
|
if (stream.peek() == "{" || stream.peek() == ":" || stream.peek() == "try")
|
||||||
|
result.body_kind = cpp_function_definition;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -356,6 +358,9 @@ namespace
|
||||||
|
|
||||||
if (detail::skip_if(stream, "="))
|
if (detail::skip_if(stream, "="))
|
||||||
parse_body(stream, result, allow_virtual);
|
parse_body(stream, result, allow_virtual);
|
||||||
|
else if (detail::skip_if(stream, "{") || detail::skip_if(stream, ":")
|
||||||
|
|| detail::skip_if(stream, "try"))
|
||||||
|
result.body_kind = cpp_function_definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ namespace
|
||||||
auto kind = clang_getCursorKind(cur);
|
auto kind = clang_getCursorKind(cur);
|
||||||
if (cursor_is_function(kind) || cursor_is_function(clang_getTemplateCursorKind(cur)))
|
if (cursor_is_function(kind) || cursor_is_function(clang_getTemplateCursorKind(cur)))
|
||||||
{
|
{
|
||||||
auto range_shrunk = false;
|
auto is_definition = false;
|
||||||
|
|
||||||
// if a function we need to remove the body
|
// if a function we need to remove the body
|
||||||
// it does not need to be parsed
|
// it does not need to be parsed
|
||||||
|
|
@ -105,11 +105,22 @@ namespace
|
||||||
{
|
{
|
||||||
auto child_extent = clang_getCursorExtent(child);
|
auto child_extent = clang_getCursorExtent(child);
|
||||||
end = clang_getRangeStart(child_extent);
|
end = clang_getRangeStart(child_extent);
|
||||||
range_shrunk = true;
|
is_definition = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!range_shrunk && !token_after_is(tu, file, cur, end, ";"))
|
if (!is_definition)
|
||||||
|
{
|
||||||
|
// i have no idea why this is necessary
|
||||||
|
is_definition = token_after_is(tu, file, cur, end, "{")
|
||||||
|
|| token_after_is(tu, file, cur, end, "try")
|
||||||
|
|| token_after_is(tu, file, cur, end, ":");
|
||||||
|
if (is_definition)
|
||||||
|
// need to extend range here to include the token
|
||||||
|
end = get_next_location(tu, file, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_definition && !token_after_is(tu, file, cur, end, ";"))
|
||||||
{
|
{
|
||||||
// we do not have a body, but it is not a declaration either
|
// we do not have a body, but it is not a declaration either
|
||||||
do
|
do
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue