forked from qt-creator/qt-creator
ClangTools: Give a hint to users as to why we didn't do anything
Task-number: QTCREATORBUG-25565 Change-Id: I27cb0e5bc2a02a88ddf1d42b996e45840d6c1385 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -56,6 +56,7 @@
|
|||||||
#include <projectexplorer/projectexplorericons.h>
|
#include <projectexplorer/projectexplorericons.h>
|
||||||
#include <projectexplorer/session.h>
|
#include <projectexplorer/session.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
|
#include <projectexplorer/taskhub.h>
|
||||||
|
|
||||||
#include <texteditor/textdocument.h>
|
#include <texteditor/textdocument.h>
|
||||||
|
|
||||||
@@ -650,6 +651,8 @@ void ClangTool::startTool(ClangTool::FileSelection fileSelection,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TaskHub::clearTasks(taskCategory());
|
||||||
|
|
||||||
// Collect files to analyze
|
// Collect files to analyze
|
||||||
const FileInfos fileInfos = collectFileInfos(project, fileSelection);
|
const FileInfos fileInfos = collectFileInfos(project, fileSelection);
|
||||||
if (fileInfos.empty())
|
if (fileInfos.empty())
|
||||||
@@ -726,8 +729,12 @@ FileInfos ClangTool::collectFileInfos(Project *project, FileSelection fileSelect
|
|||||||
FileSelectionType *selectionType = get_if<FileSelectionType>(&fileSelection);
|
FileSelectionType *selectionType = get_if<FileSelectionType>(&fileSelection);
|
||||||
// early bailout
|
// early bailout
|
||||||
if (selectionType && *selectionType == FileSelectionType::CurrentFile
|
if (selectionType && *selectionType == FileSelectionType::CurrentFile
|
||||||
&& !EditorManager::currentDocument())
|
&& !EditorManager::currentDocument()) {
|
||||||
|
TaskHub::addTask(Task::Error, tr("Cannot analyze current file: No files open."),
|
||||||
|
taskCategory());
|
||||||
|
TaskHub::requestPopup();
|
||||||
return {};
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
auto projectInfo = CppTools::CppModelManager::instance()->projectInfo(project);
|
auto projectInfo = CppTools::CppModelManager::instance()->projectInfo(project);
|
||||||
QTC_ASSERT(projectInfo.isValid(), return FileInfos());
|
QTC_ASSERT(projectInfo.isValid(), return FileInfos());
|
||||||
@@ -757,6 +764,11 @@ FileInfos ClangTool::collectFileInfos(Project *project, FileSelection fileSelect
|
|||||||
});
|
});
|
||||||
if (!fileInfo.file.isEmpty())
|
if (!fileInfo.file.isEmpty())
|
||||||
return {fileInfo};
|
return {fileInfo};
|
||||||
|
TaskHub::addTask(Task::Error,
|
||||||
|
tr("Cannot analyze current file: \"%1\" is not a known source file.")
|
||||||
|
.arg(filePath.toUserOutput()),
|
||||||
|
taskCategory());
|
||||||
|
TaskHub::requestPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
@@ -60,6 +60,7 @@
|
|||||||
#include <projectexplorer/kitinformation.h>
|
#include <projectexplorer/kitinformation.h>
|
||||||
#include <projectexplorer/projectpanelfactory.h>
|
#include <projectexplorer/projectpanelfactory.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
|
#include <projectexplorer/taskhub.h>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@@ -114,6 +115,8 @@ bool ClangToolsPlugin::initialize(const QStringList &arguments, QString *errorSt
|
|||||||
Q_UNUSED(arguments)
|
Q_UNUSED(arguments)
|
||||||
Q_UNUSED(errorString)
|
Q_UNUSED(errorString)
|
||||||
|
|
||||||
|
TaskHub::addCategory(taskCategory(), tr("Clang Tools"));
|
||||||
|
|
||||||
// Import tidy/clazy diagnostic configs from CppTools now
|
// Import tidy/clazy diagnostic configs from CppTools now
|
||||||
// instead of at opening time of the settings page
|
// instead of at opening time of the settings page
|
||||||
ClangToolsSettings::instance();
|
ClangToolsSettings::instance();
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include <cpptools/clangdiagnosticconfig.h>
|
#include <cpptools/clangdiagnosticconfig.h>
|
||||||
|
|
||||||
|
#include <utils/id.h>
|
||||||
#include <utils/optional.h>
|
#include <utils/optional.h>
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
@@ -87,5 +88,7 @@ CppTools::ClangDiagnosticConfig diagnosticConfig(const Utils::Id &diagConfigId);
|
|||||||
QStringList extraClangToolsPrependOptions();
|
QStringList extraClangToolsPrependOptions();
|
||||||
QStringList extraClangToolsAppendOptions();
|
QStringList extraClangToolsAppendOptions();
|
||||||
|
|
||||||
|
inline Utils::Id taskCategory() { return "ClangTools"; }
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace ClangTools
|
} // namespace ClangTools
|
||||||
|
Reference in New Issue
Block a user