Bug 367735 - Problem in semantic analysis - cannot rename all variables after click in usage this variable
Summary: Problem in semantic analysis - cannot rename all variables after click in usa...
Status: CONFIRMED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (Clang-based) (show other bugs)
Version: unspecified
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-23 20:19 UTC by Piotr Mierzwinski
Modified: 2016-09-07 13:45 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Mierzwinski 2016-08-23 20:19:24 UTC
There is an example of code:

foo()
{
	QString sFileName  = QFileDialog::getSaveFileName(this, tr("Save as"), m_InitialPath);

	if (! sFileName.isEmpty()) {
		if (QFileInfo(sFileName).exists()) {
			// file already exists
		}
                else
                       saveFile(sFileName);
	}
}

I rename declaration of sFileName to sFileName2, so now first line looks like this:
	QString sFileName2  = QFileDialog::getSaveFileName(this, tr("Save as"), m_InitialPath);

All occurrences for not declared variable  are underlined. OK. I move cursor over declaration and I get: Solution (1): Rename "sFileName" to "sFileName2". But wait. In this place variable is already renamed :/. OK. Nevermind. I click "Solution (1)" and all occurrences are renamed. Great. This is what I wanted.
I undo all changes, and again rename declaration in the same way. Now I move cursor over first usage. This is mentioned line:
         if (! sFileName.isEmpty()) 
I get the same tool tip, so again I click in "Solution (1)". After that only occurrence under cursor is renamed. This is happen on every next usages of variable. Why?
I'm not sure, but I think it was working before change with tool tip: "Problem in semantic analysis". I mean all occurrences were always renamed.


Reproducible: Always

Steps to Reproduce:
1. Rename declaration of local variable
2. Try to use "Semantic analysis helper" for any usage of variable not for declaration
3. Click "Solution (1)"

Actual Results:  
Only occurrence under cursor is renamed

Expected Results:  
All occurrences for selected variable should be renamed.
Thanks that kdevelop will avoid forcing an user to go back to declaration and again back to current code.

kdevelop 5.0.0.r23419.7314e99  (built 22/08/2016, branch: 5.0)
kdevplatform 5.0.0.r13346.09a1848  (built 22/08/2016, branch: 5.0)
KFrameworks 5.25, Qt-5.7.0
Comment 1 Milian Wolff 2016-09-07 13:45:45 UTC
this should be enough to reproduce:

void foo()
{
    int bar = 0;
    bar++;
    bar++;
    bar++;
}

I agree that rename should be done everywhere.
Also, making it simpler to apply the change everywhere after doing the rename would be nice to have.