- fix: correctly reparse modified project files when rename symbol

This commit is contained in:
Roy Qu 2022-03-17 20:28:03 +08:00
parent da05088f40
commit 12edcb22a5
2 changed files with 19 additions and 6 deletions

View File

@ -36,6 +36,7 @@ Red Panda C++ Version 1.0.0
- enhancement: create file in files view
- fix: hits in the search view not correctly displayed (overlapped with others)
- enhancement: auto convert project icon to ico format
- fix: correctly reparse modified project files when rename symbol
Red Panda C++ Version 0.14.5
- fix: the "gnu c++ 20" option in compiler set options is wrong

View File

@ -5914,7 +5914,8 @@ void MainWindow::on_actionRename_Symbol_triggered()
if (!editor)
return;
editor->beginUpdate();
// mClassBrowserModel.beginUpdate();
BufferCoord oldCaretXY = editor->caretXY();
// mClassBrowserModel.beginUpdate();
QCursor oldCursor = editor->cursor();
editor->setCursor(Qt::CursorShape::WaitCursor);
auto action = finally([oldCursor,editor]{
@ -5934,10 +5935,19 @@ void MainWindow::on_actionRename_Symbol_triggered()
return;
}
BufferCoord oldCaretXY = editor->caretXY();
if (editor->inProject() && mProject) {
mProject->cppParser()->parseFileList();
for (int i=0;i<mEditorList->pageCount();i++) {
Editor * e=(*mEditorList)[i];
if (e->modified()) {
mProject->cppParser()->parseFile(editor->filename(), editor->inProject(), false, false);
}
}
QStringList expression = editor->getExpressionAtPosition(oldCaretXY);
if (expression.isEmpty() && oldCaretXY.Char>1) {
BufferCoord coord=oldCaretXY;
coord.Char--;
expression = editor->getExpressionAtPosition(coord);
}
// Find it's definition
PStatement oldStatement = editor->parser()->findStatementOf(
editor->filename(),
@ -5975,9 +5985,11 @@ void MainWindow::on_actionRename_Symbol_triggered()
if (word == newWord)
return;
PCppParser parser = editor->parser();
//here we must reparse the file in sync, or rename may fail
parser->parseFile(editor->filename(), editor->inProject(), false, false);
if (!editor->inProject() && editor->modified() ) {
PCppParser parser = editor->parser();
//here we must reparse the file in sync, or rename may fail
parser->parseFile(editor->filename(), editor->inProject(), false, false);
}
CppRefacter refactor;
BufferCoord oldXY=editor->caretXY();
int topLine = editor->topLine();