- fix: "Goto declaration" / "Goto definition" / "Find occurences" not correctly disabled for non-c/c++ files.

This commit is contained in:
Roy Qu 2023-01-07 20:04:51 +08:00
parent 32088a18d0
commit 2ab5efc6fe
4 changed files with 14 additions and 16 deletions

View File

@ -18,6 +18,7 @@ Red Panda C++ Version 2.8
- enhancement: Print syntax colored content. - enhancement: Print syntax colored content.
- enhancement: Correctly handle tab in the exported RTF. - enhancement: Correctly handle tab in the exported RTF.
- change: Disable undo limit by default. - change: Disable undo limit by default.
- fix: "Goto declaration" / "Goto definition" / "Find occurences" not correctly disabled for non-c/c++ files.
Red Panda C++ Version 2.7 Red Panda C++ Version 2.7

View File

@ -4131,15 +4131,8 @@ void Editor::gotoDeclaration(const QSynedit::BufferCoord &pos)
filename(), filename(),
expression, expression,
pos.line); pos.line);
// QString phrase = getWordAtPosition(this,pos,pBeginPos,pEndPos, WordPurpose::wpInformation);
// if (phrase.isEmpty())
// return;
// PStatement statement = mParser->findStatementOf(
// mFilename,phrase,pos.Line);
if (!statement) { if (!statement) {
// pMainWindow->updateStatusbarMessage(tr("Symbol '%1' not found!").arg(phrase));
return; return;
} }
QString filename; QString filename;
@ -4159,6 +4152,8 @@ void Editor::gotoDeclaration(const QSynedit::BufferCoord &pos)
void Editor::gotoDefinition(const QSynedit::BufferCoord &pos) void Editor::gotoDefinition(const QSynedit::BufferCoord &pos)
{ {
if (!parser())
return;
QStringList expression = getExpressionAtPosition(pos); QStringList expression = getExpressionAtPosition(pos);
// Find it's definition // Find it's definition
@ -4587,7 +4582,7 @@ void Editor::checkSyntaxInBack()
pMainWindow->checkSyntaxInBack(this); pMainWindow->checkSyntaxInBack(this);
} }
const PCppParser &Editor::parser() const PCppParser &Editor::parser() const
{ {
return mParser; return mParser;
} }

View File

@ -229,7 +229,7 @@ public:
const QSynedit::BufferCoord& pos); const QSynedit::BufferCoord& pos);
void resetBookmarks(); void resetBookmarks();
const PCppParser &parser(); const PCppParser &parser() const;
void tab() override; void tab() override;
signals: signals:

View File

@ -576,6 +576,10 @@ void MainWindow::updateEditorActions(const Editor *e)
ui->actionGo_to_Line->setEnabled(false); ui->actionGo_to_Line->setEnabled(false);
ui->actionLocate_in_Files_View->setEnabled(false); ui->actionLocate_in_Files_View->setEnabled(false);
ui->actionToggle_Readonly->setEnabled(false); ui->actionToggle_Readonly->setEnabled(false);
ui->actionGoto_Declaration->setEnabled(false);
ui->actionGoto_Definition->setEnabled(false);
ui->actionFind_references->setEnabled(false);
} else { } else {
ui->actionAuto_Detect->setEnabled(true); ui->actionAuto_Detect->setEnabled(true);
ui->actionEncode_in_ANSI->setEnabled(true); ui->actionEncode_in_ANSI->setEnabled(true);
@ -632,6 +636,11 @@ void MainWindow::updateEditorActions(const Editor *e)
ui->actionGo_to_Line->setEnabled(true); ui->actionGo_to_Line->setEnabled(true);
ui->actionLocate_in_Files_View->setEnabled(!e->isNew()); ui->actionLocate_in_Files_View->setEnabled(!e->isNew());
ui->actionToggle_Readonly->setEnabled(!e->modified()); ui->actionToggle_Readonly->setEnabled(!e->modified());
//these actions needs parser
ui->actionGoto_Declaration->setEnabled(e->parser()!=nullptr);
ui->actionGoto_Definition->setEnabled(e->parser()!=nullptr);
ui->actionFind_references->setEnabled(e->parser()!=nullptr);
} }
updateCompileActions(e); updateCompileActions(e);
@ -4785,13 +4794,6 @@ void MainWindow::onEditorContextMenu(const QPoint& pos)
menu.addAction(ui->actionGo_to_Line); menu.addAction(ui->actionGo_to_Line);
menu.addSeparator(); menu.addSeparator();
menu.addAction(ui->actionFile_Properties); menu.addAction(ui->actionFile_Properties);
//these actions needs parser
if (editor->parser() && editor->parser()->enabled()) {
ui->actionGoto_Declaration->setEnabled(!editor->parser()->parsing());
ui->actionGoto_Definition->setEnabled(!editor->parser()->parsing());
ui->actionFind_references->setEnabled(!editor->parser()->parsing());
}
} else { } else {
//mouse on gutter //mouse on gutter