- fix: rename macro doesn't work in project

This commit is contained in:
Roy Qu 2022-06-12 18:26:39 +08:00
parent e0442dcca4
commit 2182553fe1
4 changed files with 56 additions and 29 deletions

View File

@ -7,6 +7,7 @@ Red Panda C++ Version 1.1.0
- enhancement: rename in files view's context menu
- enhancement: delete in files view's context menu
- change: drag&drop in files view default to move
- fix: rename macro doesn't work in project
Red Panda C++ Version 1.0.10
- fix: modify watch doesn't work

View File

@ -4175,7 +4175,6 @@ void MainWindow::onFileChanged(const QString &path)
mFilesChangedNotifying.insert(path);
Editor *e = mEditorList->getOpenedEditorByFilename(path);
if (e) {
e->setModified(true);
if (fileExists(path)) {
e->activate();
if (QMessageBox::question(this,tr("File Changed"),
@ -4187,6 +4186,8 @@ void MainWindow::onFileChanged(const QString &path)
} catch(FileError e) {
QMessageBox::critical(this,tr("Error"),e.reason());
}
} else {
e->setModified(true);
}
} else {
mFileSystemWatcher.removePath(path);
@ -4197,7 +4198,6 @@ void MainWindow::onFileChanged(const QString &path)
mEditorList->closeEditor(e);
} else {
e->setModified(true);
e->updateCaption();
}
}
}
@ -6317,11 +6317,11 @@ void MainWindow::on_actionRename_Symbol_triggered()
coord.Char--;
expression = editor->getExpressionAtPosition(coord);
}
// Find it's definition
// Find it's definition
PStatement oldStatement = editor->parser()->findStatementOf(
editor->filename(),
expression,
oldCaretXY.Line);
editor->filename(),
expression,
oldCaretXY.Line);
// definition of the symbol not found
if (!oldStatement)
return;

View File

@ -451,32 +451,50 @@ void SynEditCppHighlighter::directiveProc()
mRun+=1;
}
if (directive == "define") {
do {
switch(mLine[mRun].unicode()) {
case '/': //comment?
switch (mLine[mRun+1].unicode()) {
case '/': // is end of directive as well
mRange.state = RangeState::rsUnknown;
return;
case '*': // might be embeded only
mRange.state = RangeState::rsDirectiveComment;
return;
}
break;
case '\\': // yet another line?
if (mLine[mRun+1] == 0) {
mRun+=1;
mRange.state = RangeState::rsMultiLineDirective;
return;
}
break;
}
mRun+=1;
} while (mLine[mRun]!=0);
while(mLine[mRun]!=0 && isSpaceChar(mLine[mRun]))
mRun++;
mRange.state = RangeState::rsDefineIdentifier;
return;
} else
mRange.state = RangeState::rsUnknown;
}
void SynEditCppHighlighter::defineIdentProc()
{
mTokenId = TokenKind::Identifier;
while(mLine[mRun]!=0 && isIdentChar(mLine[mRun]))
mRun++;
mRange.state = RangeState::rsDefineRemaining;
}
void SynEditCppHighlighter::defineRemainingProc()
{
mTokenId = TokenKind::Directive;
do {
switch(mLine[mRun].unicode()) {
case '/': //comment?
switch (mLine[mRun+1].unicode()) {
case '/': // is end of directive as well
mRange.state = RangeState::rsUnknown;
return;
case '*': // might be embeded only
mRange.state = RangeState::rsDirectiveComment;
return;
}
break;
case '\\': // yet another line?
if (mLine[mRun+1] == 0) {
mRun+=1;
mRange.state = RangeState::rsMultiLineDirective;
return;
}
break;
}
mRun+=1;
} while (mLine[mRun]!=0);
mRange.state=RangeState::rsUnknown;
}
void SynEditCppHighlighter::directiveEndProc()
{
mTokenId = TokenKind::Directive;
@ -1518,6 +1536,12 @@ void SynEditCppHighlighter::next()
asciiCharProc();
}
break;
case RangeState::rsDefineIdentifier:
defineIdentProc();
break;
case RangeState::rsDefineRemaining:
defineRemainingProc();
break;
default:
mRange.state = RangeState::rsUnknown;
if (mLine[mRun] == 'R' && mLine[mRun+1] == '"') {

View File

@ -62,7 +62,7 @@ class SynEditCppHighlighter: public SynHighlighter
rsMultiLineString, rsMultiLineDirective, rsCppComment,
rsStringEscapeSeq, rsMultiLineStringEscapeSeq,
rsRawString, rsSpace,rsRawStringEscaping,rsRawStringNotEscaping,rsChar,
rsCppCommentEnded
rsCppCommentEnded, rsDefineStart, rsDefineIdentifier, rsDefineRemaining
};
public:
@ -111,6 +111,8 @@ private:
void colonProc();
void commaProc();
void directiveProc();
void defineIdentProc();
void defineRemainingProc();
void directiveEndProc();
void equalProc();
void greaterProc();