- 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: rename in files view's context menu
- enhancement: delete in files view's context menu - enhancement: delete in files view's context menu
- change: drag&drop in files view default to move - change: drag&drop in files view default to move
- fix: rename macro doesn't work in project
Red Panda C++ Version 1.0.10 Red Panda C++ Version 1.0.10
- fix: modify watch doesn't work - fix: modify watch doesn't work

View File

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

View File

@ -451,32 +451,50 @@ void SynEditCppHighlighter::directiveProc()
mRun+=1; mRun+=1;
} }
if (directive == "define") { if (directive == "define") {
do { while(mLine[mRun]!=0 && isSpaceChar(mLine[mRun]))
switch(mLine[mRun].unicode()) { mRun++;
case '/': //comment? mRange.state = RangeState::rsDefineIdentifier;
switch (mLine[mRun+1].unicode()) { return;
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);
} else } else
mRange.state = RangeState::rsUnknown; 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() void SynEditCppHighlighter::directiveEndProc()
{ {
mTokenId = TokenKind::Directive; mTokenId = TokenKind::Directive;
@ -1518,6 +1536,12 @@ void SynEditCppHighlighter::next()
asciiCharProc(); asciiCharProc();
} }
break; break;
case RangeState::rsDefineIdentifier:
defineIdentProc();
break;
case RangeState::rsDefineRemaining:
defineRemainingProc();
break;
default: default:
mRange.state = RangeState::rsUnknown; mRange.state = RangeState::rsUnknown;
if (mLine[mRun] == 'R' && mLine[mRun+1] == '"') { if (mLine[mRun] == 'R' && mLine[mRun+1] == '"') {

View File

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