Bug 299393

Summary: 'Update declaration signature' doesn't update declaration of function after change function from const to non const in definition
Product: [Applications] kdevelop Reporter: Piotr Mierzwinski <piotr.mierzwinski>
Component: Language Support: CPP (old)Assignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: normal CC: olivier.jg, piotr.mierzwinski
Priority: NOR Keywords: usability
Version: git master   
Target Milestone: 4.3.0   
Platform: Mandriva RPMs   
OS: Linux   
Latest Commit: Version Fixed In:

Description Piotr Mierzwinski 2012-05-04 18:08:10 UTC
I have const function (declaration in header's file and declaration in cpp file). I want non const function. Thats why I remove key word 'const' (that causes the function is constatnt) from definition of function. I press 'Update declaration signature' button (toolTip shows correct transformation). In declaration (header file) key word 'const' didn't removed.

Reproducible: Always

Steps to Reproduce:
1. Declare const function in header's file
2. Create definition of const function in cpp file
3. Save all files
4. Remove key word: const (that causes the function is constant) from definition of function
5, Choose ''Update declaration signature' from popuping menu
6. Check header file
Actual Results:  
void foo( const QString& param) const;

Expected Results:  
void foo( const QString& param);
Comment 1 Olivier.jg 2012-10-26 22:19:01 UTC
Seems to work fine now.
Comment 2 Piotr Mierzwinski 2012-11-09 18:42:00 UTC
Sorry, but doesn't. Works partially. Only if function has not parameters. Let's try with:
header file:
void foo2( const QString & str ) const;

cpp file:
void foo2( const QString & str ) const
{
     qDebug() << "aa";
}

1. Remove const in cpp file (i.e.: press Ctrl+Backspace when cursor is at end of method signature)
2, Choose ''Update declaration signature' in popuping menu
3. Check header file

Actual Results:  
void foo( const QString& str) const;

Expected Results:  
void foo( const QString& str);


I tested on Mandriva 2011.0 (KDE-4.6.5), qt-4.7.4) and KDevelop 4.4.1. System newly installed (and updated) on VirtualBox 4.2.0. KDevelop builded from official sources.
Comment 3 Milian Wolff 2012-11-09 19:58:25 UTC
indeed, this is broken
Comment 4 Piotr Mierzwinski 2013-01-15 19:43:30 UTC
In branch: master is still broken.
Comment 5 Milian Wolff 2013-01-17 21:42:53 UTC
Git commit 15ef959f791389c1cf3b4a8e31751191890098e4 by Milian Wolff.
Committed on 17/01/2013 at 22:40.
Pushed by mwolff into branch '4.5'.

Properly cope with function signatures containing whitespace.

The main issue is that our function contexts don't go from the
opening paren to the closing paren, but from the first to the last
token inside the closing parens. Thus if you put whitespace padding
in there the old code broke down...

M  +23   -15   languages/cpp/codegen/adaptsignatureaction.cpp
M  +9    -0    languages/cpp/tests/test_cppassistants.cpp

http://commits.kde.org/kdevelop/15ef959f791389c1cf3b4a8e31751191890098e4