fix: click a non-existing header name will get an error
This commit is contained in:
parent
29da40bb14
commit
eed7fdcf56
2
NEWS.md
2
NEWS.md
|
@ -27,7 +27,7 @@ Red Panda C++ Version 1.5
|
||||||
- enhancement: When open a project, let user choose weither open it in new window or replace the already openned project
|
- enhancement: When open a project, let user choose weither open it in new window or replace the already openned project
|
||||||
- fix: editor tooltip for #include_next is not correctly calculated
|
- fix: editor tooltip for #include_next is not correctly calculated
|
||||||
- fix: ctrl+click on #include_next header name doesn't open the right file
|
- fix: ctrl+click on #include_next header name doesn't open the right file
|
||||||
- enhancement: parser used for non-project C files won't find header files in C++ include folders.
|
- enhancement: parser used for non-project C files won't search header files in C++ include folders.
|
||||||
- fix: toggle block comment/delete to word begin/delete to word end are not correctly disabled when editor not open
|
- fix: toggle block comment/delete to word begin/delete to word end are not correctly disabled when editor not open
|
||||||
|
|
||||||
Red Panda C++ Version 1.4
|
Red Panda C++ Version 1.4
|
||||||
|
|
|
@ -1210,9 +1210,11 @@ void Editor::mouseReleaseEvent(QMouseEvent *event)
|
||||||
if (mParser->isIncludeNextLine(s)) {
|
if (mParser->isIncludeNextLine(s)) {
|
||||||
QString filename = mParser->getHeaderFileName(mFilename,s, true);
|
QString filename = mParser->getHeaderFileName(mFilename,s, true);
|
||||||
pMainWindow->openFile(filename);
|
pMainWindow->openFile(filename);
|
||||||
|
return;
|
||||||
} if (mParser->isIncludeLine(s)) {
|
} if (mParser->isIncludeLine(s)) {
|
||||||
QString filename = mParser->getHeaderFileName(mFilename,s);
|
QString filename = mParser->getHeaderFileName(mFilename,s);
|
||||||
pMainWindow->openFile(filename);
|
pMainWindow->openFile(filename);
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
gotoDefinition(p);
|
gotoDefinition(p);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1243,6 +1243,8 @@ void MainWindow::openFiles(const QStringList &files)
|
||||||
|
|
||||||
Editor* MainWindow::openFile(const QString &filename, bool activate, QTabWidget* page)
|
Editor* MainWindow::openFile(const QString &filename, bool activate, QTabWidget* page)
|
||||||
{
|
{
|
||||||
|
if (filename.isEmpty())
|
||||||
|
return nullptr;
|
||||||
Editor* editor = mEditorList->getOpenedEditorByFilename(filename);
|
Editor* editor = mEditorList->getOpenedEditorByFilename(filename);
|
||||||
if (editor!=nullptr) {
|
if (editor!=nullptr) {
|
||||||
if (activate) {
|
if (activate) {
|
||||||
|
|
|
@ -709,7 +709,7 @@ QString CppParser::getHeaderFileName(const QString &relativeTo, const QString &h
|
||||||
QString currentDir = includeTrailingPathDelimiter(extractFileDir(relativeTo));
|
QString currentDir = includeTrailingPathDelimiter(extractFileDir(relativeTo));
|
||||||
QStringList includes;
|
QStringList includes;
|
||||||
QStringList projectIncludes;
|
QStringList projectIncludes;
|
||||||
bool found;
|
bool found=false;
|
||||||
if (fromNext && mPreprocessor->includePaths().contains(currentDir)) {
|
if (fromNext && mPreprocessor->includePaths().contains(currentDir)) {
|
||||||
foreach(const QString& s, mPreprocessor->includePathList()) {
|
foreach(const QString& s, mPreprocessor->includePathList()) {
|
||||||
if (found) {
|
if (found) {
|
||||||
|
|
|
@ -460,7 +460,7 @@ void CppPreprocessor::handleInclude(const QString &line, bool fromNext)
|
||||||
QString currentDir = includeTrailingPathDelimiter(extractFileDir(file->fileName));
|
QString currentDir = includeTrailingPathDelimiter(extractFileDir(file->fileName));
|
||||||
QStringList includes;
|
QStringList includes;
|
||||||
QStringList projectIncludes;
|
QStringList projectIncludes;
|
||||||
bool found;
|
bool found=false;
|
||||||
if (fromNext && mIncludePaths.contains(currentDir)) {
|
if (fromNext && mIncludePaths.contains(currentDir)) {
|
||||||
foreach(const QString& s, mIncludePathList) {
|
foreach(const QString& s, mIncludePathList) {
|
||||||
if (found) {
|
if (found) {
|
||||||
|
@ -499,18 +499,28 @@ void CppPreprocessor::handleInclude(const QString &line, bool fromNext)
|
||||||
|
|
||||||
void CppPreprocessor::handlePreprocessor(const QString &value)
|
void CppPreprocessor::handlePreprocessor(const QString &value)
|
||||||
{
|
{
|
||||||
|
switch(value[0].unicode()) {
|
||||||
|
case 'd':
|
||||||
if (value.startsWith("define"))
|
if (value.startsWith("define"))
|
||||||
handleDefine(value);
|
handleDefine(value);
|
||||||
else if (value.startsWith("undef"))
|
break;
|
||||||
handleUndefine(value);
|
case 'e':
|
||||||
else if (value.startsWith("if")
|
if (value.startsWith("else") || value.startsWith("elif")
|
||||||
|| value.startsWith("else") || value.startsWith("elif")
|
|
||||||
|| value.startsWith("endif"))
|
|| value.startsWith("endif"))
|
||||||
handleBranch(value);
|
handleBranch(value);
|
||||||
else if (value.startsWith("include_next"))
|
break;
|
||||||
handleInclude(value,true);
|
case 'i':
|
||||||
|
if (value.startsWith("if"))
|
||||||
|
handleBranch(value);
|
||||||
else if (value.startsWith("include"))
|
else if (value.startsWith("include"))
|
||||||
handleInclude(value);
|
handleInclude(value, value.startsWith("include_next"));
|
||||||
|
break;
|
||||||
|
case 'u':
|
||||||
|
if (value.startsWith("undef"))
|
||||||
|
handleUndefine(value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppPreprocessor::handleUndefine(const QString &line)
|
void CppPreprocessor::handleUndefine(const QString &line)
|
||||||
|
|
Loading…
Reference in New Issue