ide: Fixed Assist/T++ problem with function pointers

This commit is contained in:
Mirek Fidler 2025-05-07 11:03:53 +02:00
parent 8ff4d3d9d4
commit 1553ad42e6
2 changed files with 16 additions and 1 deletions

View file

@ -160,6 +160,17 @@ String CleanupId(const char *s)
was_param_type = false;
operator_def = false;
}
if(s[1] == '*') { // function pointer, e.g. int(*)(int)
was_param_type = false; // prevent skipping ^^^
while(*s && *s != ')') {
if(*s == '*') // exclude any names
mm.Cat(*s);
s++;
}
mm.Cat(')');
if(*s) s++;
continue;
}
inparams = true;
}
if(*s == ',')

View file

@ -108,6 +108,7 @@ String ClangCursorInfo::Id()
{
if(!hasid) {
String m, s;
const char *p;
int q = 0;
switch(cursorKind) {
case CXCursor_StructDecl:
@ -125,7 +126,10 @@ String ClangCursorInfo::Id()
case CXCursor_CXXMethod:
#ifdef UBUNTU2204_WORKAROUND
s = RawId();
m = CleanupId(s);
p = s;
while(*p == '&' || *p == '*') // fix CleanupId("&Accel(int (*filter)(int))") -> Accel(int(*filter)())
p++;
m = CleanupId(p);
if(s.StartsWith("template ")) { // template class method already seems to contain some scope, sometimes
int p = m.Find('(');
for(;;) { // remove any scope