Utils: Introduce a FilePath constructor from char arrays

Similar to QT_RESTRICTED_CAST_FROM_ASCII to avoid the need for
decorations in user code.

At the same time, drop some convenience constructors and functions
in CommandLine and Icon essentially serving the same purpose.

Change-Id: Ida4e5ac19c2da0a4298a97b2a8e1511d56bbb79d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2021-08-10 16:19:02 +02:00
parent 98cba6e50c
commit 7c28c4f744
109 changed files with 452 additions and 483 deletions

View File

@@ -124,7 +124,7 @@ public:
// Add files outside of the base directory to a separate node
Tree *externalFilesNode = createDirNode(SelectableFilesDialog::tr(
"Files outside of the base directory"),
FilePath::fromString("/"));
"/");
linkDirNode(m_root, externalFilesNode);
for (const FileInfo &fileInfo : outOfBaseDirFiles)
linkFileNode(externalFilesNode, createFileNode(fileInfo, true));

View File

@@ -105,7 +105,7 @@ bool ClangToolRunner::supportsVFSOverlay() const
auto it = vfsCapabilities.find(m_executable);
if (it == vfsCapabilities.end()) {
QtcProcess p;
p.setCommand({m_executable, {"--help"}});
p.setCommand({FilePath::fromString(m_executable), {"--help"}});
p.runBlocking();
it = vfsCapabilities.insert(m_executable, p.allOutput().contains("vfsoverlay"));
}
@@ -137,7 +137,7 @@ bool ClangToolRunner::run(const QString &fileToAnalyze, const QStringList &compi
m_outputFilePath = createOutputFilePath(m_outputDirPath, fileToAnalyze);
QTC_ASSERT(!m_outputFilePath.isEmpty(), return false);
m_commandLine = {m_executable, m_argsCreator(compilerOptions)};
m_commandLine = {FilePath::fromString(m_executable), m_argsCreator(compilerOptions)};
qCDebug(LOG).noquote() << "Starting" << m_commandLine.toUserOutput();
m_process->setCommand(m_commandLine);

View File

@@ -66,7 +66,7 @@ static QString runExecutable(const Utils::CommandLine &commandLine, QueryFailMod
return cpp.stdOut();
}
static QStringList queryClangTidyChecks(const QString &executable,
static QStringList queryClangTidyChecks(const FilePath &executable,
const QString &checksArgument)
{
QStringList arguments = QStringList("-list-checks");
@@ -100,7 +100,7 @@ static QStringList queryClangTidyChecks(const QString &executable,
return checks;
}
static ClazyChecks querySupportedClazyChecks(const QString &executablePath)
static ClazyChecks querySupportedClazyChecks(const FilePath &executablePath)
{
static const QString queryFlag = "-supported-checks-json";
QString jsonOutput = runExecutable(CommandLine(executablePath, {queryFlag}),
@@ -159,15 +159,15 @@ static ClazyChecks querySupportedClazyChecks(const QString &executablePath)
}
ClangTidyInfo::ClangTidyInfo(const QString &executablePath)
: defaultChecks(queryClangTidyChecks(executablePath, {}))
, supportedChecks(queryClangTidyChecks(executablePath, "-checks=*"))
: defaultChecks(queryClangTidyChecks(FilePath::fromString(executablePath), {}))
, supportedChecks(queryClangTidyChecks(FilePath::fromString(executablePath), "-checks=*"))
{}
ClazyStandaloneInfo::ClazyStandaloneInfo(const QString &executablePath)
: defaultChecks(queryClangTidyChecks(executablePath, {})) // Yup, behaves as clang-tidy.
, supportedChecks(querySupportedClazyChecks(executablePath))
: defaultChecks(queryClangTidyChecks(FilePath::fromString(executablePath), {})) // Yup, behaves as clang-tidy.
, supportedChecks(querySupportedClazyChecks(FilePath::fromString(executablePath)))
{
QString output = runExecutable(CommandLine(executablePath, {"--version"}),
QString output = runExecutable(CommandLine(FilePath::fromString(executablePath), {"--version"}),
QueryFailMode::Silent);
QTextStream stream(&output);
while (!stream.atEnd()) {