Bug 396876

Summary: Generated function definitions should exactly match declarations in headers
Product: [Applications] kdevelop Reporter: Cyp <cyp561>
Component: Code completionAssignee: kdevelop-bugs-null
Status: REPORTED ---    
Severity: wishlist CC: igorkuo, null
Priority: NOR    
Version First Reported In: 5.2.1   
Target Milestone: ---   
Platform: Other   
OS: All   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Cyp 2018-07-26 13:00:40 UTC
If a header contains a declaration

myFunc(char const *str);

then autogenerating the definition in the source file creates

myFunc(const char *str)
{
}

. I think it would be better if the generated signature exactly matched the header, even if "char const" and "const char" are equivalent.

Also, it would be nice if it were possible to set the { to appear on the same line as the ).
Comment 1 Unknown 2023-01-04 20:21:23 UTC
This would also be useful for trailing return types. For example 'auto max(int a, int b) -> int' auto completes to 'int max(int a, int b)'.
Comment 2 Igor Kushnir 2023-01-05 06:48:07 UTC
Generated code is not derived from the textual representation of declarations or typed-in code, but from libclang's code model. That is, matching the declaration or the typed-in code in specific ways (`const char` vs `char const` or keeping the trailing return type) requires separate specific implementations. Generated code is then formatted with currently configured source formatter style. Most formatters/styles don't reorder `const` or affect the trailing return type. Feel free to implement the features you need and create merge requests at https://invent.kde.org/kdevelop/kdevelop/-/merge_requests