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/session.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/taskhub.h>
|
||||
|
||||
#include <texteditor/textdocument.h>
|
||||
|
||||
@@ -650,6 +651,8 @@ void ClangTool::startTool(ClangTool::FileSelection fileSelection,
|
||||
return;
|
||||
}
|
||||
|
||||
TaskHub::clearTasks(taskCategory());
|
||||
|
||||
// Collect files to analyze
|
||||
const FileInfos fileInfos = collectFileInfos(project, fileSelection);
|
||||
if (fileInfos.empty())
|
||||
@@ -726,8 +729,12 @@ FileInfos ClangTool::collectFileInfos(Project *project, FileSelection fileSelect
|
||||
FileSelectionType *selectionType = get_if<FileSelectionType>(&fileSelection);
|
||||
// early bailout
|
||||
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 {};
|
||||
}
|
||||
|
||||
auto projectInfo = CppTools::CppModelManager::instance()->projectInfo(project);
|
||||
QTC_ASSERT(projectInfo.isValid(), return FileInfos());
|
||||
@@ -757,6 +764,11 @@ FileInfos ClangTool::collectFileInfos(Project *project, FileSelection fileSelect
|
||||
});
|
||||
if (!fileInfo.file.isEmpty())
|
||||
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 {};
|
||||
|
@@ -60,6 +60,7 @@
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/projectpanelfactory.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/taskhub.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QDebug>
|
||||
@@ -114,6 +115,8 @@ bool ClangToolsPlugin::initialize(const QStringList &arguments, QString *errorSt
|
||||
Q_UNUSED(arguments)
|
||||
Q_UNUSED(errorString)
|
||||
|
||||
TaskHub::addCategory(taskCategory(), tr("Clang Tools"));
|
||||
|
||||
// Import tidy/clazy diagnostic configs from CppTools now
|
||||
// instead of at opening time of the settings page
|
||||
ClangToolsSettings::instance();
|
||||
|
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <cpptools/clangdiagnosticconfig.h>
|
||||
|
||||
#include <utils/id.h>
|
||||
#include <utils/optional.h>
|
||||
|
||||
#include <QtGlobal>
|
||||
@@ -87,5 +88,7 @@ CppTools::ClangDiagnosticConfig diagnosticConfig(const Utils::Id &diagConfigId);
|
||||
QStringList extraClangToolsPrependOptions();
|
||||
QStringList extraClangToolsAppendOptions();
|
||||
|
||||
inline Utils::Id taskCategory() { return "ClangTools"; }
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangTools
|
||||
|
Reference in New Issue
Block a user