Bug 295707 - Rename local variable doesn't work if use it in the same line
Summary: Rename local variable doesn't work if use it in the same line
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (old) (show other bugs)
Version: git master
Platform: Mandriva RPMs Linux
: NOR normal
Target Milestone: 4.2.3
Assignee: kdevelop-bugs-null
URL:
Keywords: reproducible, usability
Depends on:
Blocks:
 
Reported: 2012-03-10 19:05 UTC by Piotr Mierzwinski
Modified: 2013-05-24 11:19 UTC (History)
3 users (show)

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 2012-03-10 19:05:10 UTC
Example code:
void NewClass::someFuction()
{
        int var = 0; var++;
}
When I modifies declaration of a variable then shows me additional menu: "1 - Rename "var" to "var1"  0 - Hide". When I use 1 (Alt+1) then next occurrence of variable (var++) doesn't renamed.
Comment 1 Piotr Mierzwinski 2013-03-06 20:18:12 UTC
Below a practical example.

We have code like below:
QStringList infoList;
infoList << "aa" << "bb" << "cc";
for (int row = 0; row < infoList.count(); ++row) {
    // do something
    QString str = infoList.at(row);
}

Try rename "row" in "for" expression using "renamer assistant".
Unfortunately, we can't do it. Below result after rename operation:

for (int id = 0; row < infoList.count(); ++row) {
    // do something
     QString str = infoList.at(id);
}
Comment 2 Aleix Pol 2013-03-11 23:41:04 UTC
I can confirm.
Comment 3 Milian Wolff 2013-05-24 11:19:27 UTC
Git commit e434ac2f621bf918c45e7df15888ef85aa246936 by Milian Wolff.
Committed on 24/05/2013 at 13:07.
Pushed by mwolff into branch 'master'.

Transform ranges properly using the revision they actually belong to.

This is imo basically a hack to circumvent the bad RangeInRevision API
without rewriting everything...

The RangeInRevision is actually just blindly assuming that it belongs
to the revision the file was parsed in the last time. But if the file
is reparsed in between (due to changes) the ranges might be wrong. Due
to that we must store the ranges and their actual revision... Stupid!

Imo an API called RangeInRevision should _know_ which revision it
belongs to... Meh!

M  +32   -15   languages/cpp/codegen/renameaction.cpp
M  +25   -5    languages/cpp/codegen/renameaction.h
M  +13   -12   languages/cpp/codegen/renameassistant.cpp
M  +2    -1    languages/cpp/codegen/renameassistant.h
M  +8    -3    languages/cpp/codegen/signatureassistant.cpp

http://commits.kde.org/kdevelop/e434ac2f621bf918c45e7df15888ef85aa246936