mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-29 11:01:57 +00:00
[hover] Better heuristics to insert function name right before the paren pair enclosing parameters (#178)
This commit is contained in:
parent
fb491e6c6d
commit
156d4891c3
@ -1203,16 +1203,23 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
|
|||||||
ns->QualifiedName(decl->semanticContainer, func->def.short_name);
|
ns->QualifiedName(decl->semanticContainer, func->def.short_name);
|
||||||
std::string type_desc = decl_cursor.get_type_description();
|
std::string type_desc = decl_cursor.get_type_description();
|
||||||
{
|
{
|
||||||
size_t offset = 0;
|
size_t balance = 0, offset;
|
||||||
if (type_desc.back() == ')') {
|
for (offset = type_desc.size(); offset;) {
|
||||||
size_t balance = 0;
|
offset--;
|
||||||
for (offset = type_desc.size(); offset;) {
|
if (type_desc[offset] == ')')
|
||||||
offset--;
|
balance++;
|
||||||
if (type_desc[offset] == ')')
|
// Balanced paren pair that may appear before the paren enclosing
|
||||||
balance++;
|
// function parameters, see clang/lib/AST/TypePrinter.cpp
|
||||||
else if (type_desc[offset] == '(' && --balance == 0)
|
else if (type_desc[offset] == '(' && --balance == 0 &&
|
||||||
break;
|
!((offset >= 5 &&
|
||||||
}
|
!type_desc.compare(offset - 5, 5, "throw")) ||
|
||||||
|
(offset >= 6 &&
|
||||||
|
!type_desc.compare(offset - 6, 6, "typeof")) ||
|
||||||
|
(offset >= 8 &&
|
||||||
|
!type_desc.compare(offset - 8, 8, "decltype")) ||
|
||||||
|
(offset >= 13 &&
|
||||||
|
!type_desc.compare(offset - 13, 13, "__attribute__"))))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (offset > 0) {
|
if (offset > 0) {
|
||||||
type_desc.insert(offset, qualified_name);
|
type_desc.insert(offset, qualified_name);
|
||||||
@ -1869,4 +1876,4 @@ void ClangSanityCheck() {
|
|||||||
|
|
||||||
std::string GetClangVersion() {
|
std::string GetClangVersion() {
|
||||||
return ToString(clang_getClangVersion());
|
return ToString(clang_getClangVersion());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user