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
|
||||
- fix: editor tooltip for #include_next is not correctly calculated
|
||||
- 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
|
||||
|
||||
Red Panda C++ Version 1.4
|
||||
|
|
|
@ -1210,9 +1210,11 @@ void Editor::mouseReleaseEvent(QMouseEvent *event)
|
|||
if (mParser->isIncludeNextLine(s)) {
|
||||
QString filename = mParser->getHeaderFileName(mFilename,s, true);
|
||||
pMainWindow->openFile(filename);
|
||||
return;
|
||||
} if (mParser->isIncludeLine(s)) {
|
||||
QString filename = mParser->getHeaderFileName(mFilename,s);
|
||||
pMainWindow->openFile(filename);
|
||||
return;
|
||||
} else {
|
||||
gotoDefinition(p);
|
||||
return;
|
||||
|
|
|
@ -1243,6 +1243,8 @@ void MainWindow::openFiles(const QStringList &files)
|
|||
|
||||
Editor* MainWindow::openFile(const QString &filename, bool activate, QTabWidget* page)
|
||||
{
|
||||
if (filename.isEmpty())
|
||||
return nullptr;
|
||||
Editor* editor = mEditorList->getOpenedEditorByFilename(filename);
|
||||
if (editor!=nullptr) {
|
||||
if (activate) {
|
||||
|
|
|
@ -709,7 +709,7 @@ QString CppParser::getHeaderFileName(const QString &relativeTo, const QString &h
|
|||
QString currentDir = includeTrailingPathDelimiter(extractFileDir(relativeTo));
|
||||
QStringList includes;
|
||||
QStringList projectIncludes;
|
||||
bool found;
|
||||
bool found=false;
|
||||
if (fromNext && mPreprocessor->includePaths().contains(currentDir)) {
|
||||
foreach(const QString& s, mPreprocessor->includePathList()) {
|
||||
if (found) {
|
||||
|
|
|
@ -460,7 +460,7 @@ void CppPreprocessor::handleInclude(const QString &line, bool fromNext)
|
|||
QString currentDir = includeTrailingPathDelimiter(extractFileDir(file->fileName));
|
||||
QStringList includes;
|
||||
QStringList projectIncludes;
|
||||
bool found;
|
||||
bool found=false;
|
||||
if (fromNext && mIncludePaths.contains(currentDir)) {
|
||||
foreach(const QString& s, mIncludePathList) {
|
||||
if (found) {
|
||||
|
@ -499,18 +499,28 @@ void CppPreprocessor::handleInclude(const QString &line, bool fromNext)
|
|||
|
||||
void CppPreprocessor::handlePreprocessor(const QString &value)
|
||||
{
|
||||
switch(value[0].unicode()) {
|
||||
case 'd':
|
||||
if (value.startsWith("define"))
|
||||
handleDefine(value);
|
||||
else if (value.startsWith("undef"))
|
||||
handleUndefine(value);
|
||||
else if (value.startsWith("if")
|
||||
|| value.startsWith("else") || value.startsWith("elif")
|
||||
break;
|
||||
case 'e':
|
||||
if (value.startsWith("else") || value.startsWith("elif")
|
||||
|| value.startsWith("endif"))
|
||||
handleBranch(value);
|
||||
else if (value.startsWith("include_next"))
|
||||
handleInclude(value,true);
|
||||
break;
|
||||
case 'i':
|
||||
if (value.startsWith("if"))
|
||||
handleBranch(value);
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue