forked from qt-creator/qt-creator
CppEditor: Proliferate use of FilePath a bit
Change-Id: I7e314d73a427bf40c10f3ca6c4c5804e31482f88 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -3,29 +3,32 @@
|
||||
|
||||
#include "cppmodelmanagerbase.h"
|
||||
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace CPlusPlus::CppModelManagerBase {
|
||||
|
||||
static bool (*setExtraDiagnosticsCallback)
|
||||
(const QString &, const QString &, const QList<Document::DiagnosticMessage> &) = nullptr;
|
||||
(const FilePath &, const QString &, const QList<Document::DiagnosticMessage> &) = nullptr;
|
||||
|
||||
static CPlusPlus::Snapshot (*snapshotCallback)() = nullptr;
|
||||
|
||||
|
||||
bool trySetExtraDiagnostics(const QString &fileName, const QString &kind,
|
||||
bool trySetExtraDiagnostics(const FilePath &filePath, const QString &kind,
|
||||
const QList<Document::DiagnosticMessage> &diagnostics)
|
||||
{
|
||||
if (!setExtraDiagnosticsCallback)
|
||||
return false;
|
||||
return setExtraDiagnosticsCallback(fileName, kind, diagnostics);
|
||||
return setExtraDiagnosticsCallback(filePath, kind, diagnostics);
|
||||
}
|
||||
|
||||
bool setExtraDiagnostics(const QString &fileName, const QString &kind,
|
||||
bool setExtraDiagnostics(const FilePath &filePath, const QString &kind,
|
||||
const QList<Document::DiagnosticMessage> &diagnostics)
|
||||
{
|
||||
QTC_ASSERT(setExtraDiagnosticsCallback, return false);
|
||||
return setExtraDiagnosticsCallback(fileName, kind, diagnostics);
|
||||
return setExtraDiagnosticsCallback(filePath, kind, diagnostics);
|
||||
}
|
||||
|
||||
Snapshot snapshot()
|
||||
@@ -42,7 +45,7 @@ bool hasSnapshots()
|
||||
// Installation
|
||||
|
||||
void registerSetExtraDiagnosticsCallback(
|
||||
bool (*callback)(const QString &, const QString &, const QList<Document::DiagnosticMessage> &))
|
||||
bool (*callback)(const FilePath &, const QString &, const QList<Document::DiagnosticMessage> &))
|
||||
{
|
||||
QTC_ASSERT(callback, return);
|
||||
QTC_CHECK(!setExtraDiagnosticsCallback); // bark when used twice
|
||||
|
@@ -5,13 +5,15 @@
|
||||
|
||||
#include <cplusplus/CppDocument.h>
|
||||
|
||||
namespace Utils { class FilePath; }
|
||||
|
||||
namespace CPlusPlus::CppModelManagerBase {
|
||||
|
||||
CPLUSPLUS_EXPORT bool trySetExtraDiagnostics
|
||||
(const QString &, const QString &, const QList<Document::DiagnosticMessage> &);
|
||||
(const Utils::FilePath &filePath, const QString &, const QList<Document::DiagnosticMessage> &);
|
||||
|
||||
CPLUSPLUS_EXPORT bool setSetExtraDiagnostics
|
||||
(const QString &, const QString &, const QList<Document::DiagnosticMessage> &);
|
||||
(const Utils::FilePath &, const QString &, const QList<Document::DiagnosticMessage> &);
|
||||
|
||||
CPLUSPLUS_EXPORT bool hasSnapshots();
|
||||
|
||||
@@ -23,6 +25,6 @@ CPLUSPLUS_EXPORT CPlusPlus::Snapshot snapshot();
|
||||
CPLUSPLUS_EXPORT void registerSnapshotCallback(CPlusPlus::Snapshot (*)(void));
|
||||
|
||||
CPLUSPLUS_EXPORT void registerSetExtraDiagnosticsCallback(
|
||||
bool(*)(const QString &, const QString &, const QList<Document::DiagnosticMessage> &));
|
||||
bool(*)(const Utils::FilePath &, const QString &, const QList<Document::DiagnosticMessage> &));
|
||||
|
||||
} // CPlusPlus::CppModelManagerBase
|
||||
|
@@ -842,8 +842,7 @@ QStringList FindExportedCppTypes::operator()(const CPlusPlus::Document::Ptr &doc
|
||||
FindExportsVisitor finder(document);
|
||||
finder();
|
||||
static const QString kindKey = QLatin1String("QmlJSTools.ExportedQmlTypesDiagnostic");
|
||||
CppModelManagerBase::trySetExtraDiagnostics(document->filePath().toString(), kindKey,
|
||||
finder.messages());
|
||||
CppModelManagerBase::trySetExtraDiagnostics(document->filePath(), kindKey, finder.messages());
|
||||
|
||||
// if nothing was found, done
|
||||
const QList<ContextProperty> contextPropertyDescriptions = finder.contextProperties();
|
||||
|
@@ -479,9 +479,9 @@ bool CppEditorDocument::usesClangd() const
|
||||
return CppModelManager::usesClangd(this);
|
||||
}
|
||||
|
||||
void CppEditorDocument::onDiagnosticsChanged(const QString &fileName, const QString &kind)
|
||||
void CppEditorDocument::onDiagnosticsChanged(const FilePath &fileName, const QString &kind)
|
||||
{
|
||||
if (FilePath::fromString(fileName) != filePath())
|
||||
if (fileName != filePath())
|
||||
return;
|
||||
|
||||
TextMarks removedMarks = marks();
|
||||
|
@@ -76,7 +76,7 @@ private:
|
||||
|
||||
void onAboutToReload();
|
||||
void onReloadFinished();
|
||||
void onDiagnosticsChanged(const QString &fileName, const QString &kind);
|
||||
void onDiagnosticsChanged(const Utils::FilePath &fileName, const QString &kind);
|
||||
|
||||
|
||||
void reparseWithPreferredParseContext(const QString &id);
|
||||
|
@@ -2079,12 +2079,12 @@ QThreadPool *CppModelManager::sharedThreadPool()
|
||||
return &d->m_threadPool;
|
||||
}
|
||||
|
||||
bool CppModelManager::setExtraDiagnostics(const QString &fileName,
|
||||
bool CppModelManager::setExtraDiagnostics(const FilePath &filePath,
|
||||
const QString &kind,
|
||||
const QList<Document::DiagnosticMessage> &diagnostics)
|
||||
{
|
||||
d->m_diagnosticMessages = diagnostics;
|
||||
emit m_instance->diagnosticsChanged(fileName, kind);
|
||||
emit m_instance->diagnosticsChanged(filePath, kind);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -95,7 +95,7 @@ public:
|
||||
static QByteArray codeModelConfiguration();
|
||||
static CppLocatorData *locatorData();
|
||||
|
||||
static bool setExtraDiagnostics(const QString &fileName,
|
||||
static bool setExtraDiagnostics(const Utils::FilePath &filePath,
|
||||
const QString &kind,
|
||||
const QList<Document::DiagnosticMessage> &diagnostics);
|
||||
|
||||
@@ -268,7 +268,7 @@ signals:
|
||||
void abstractEditorSupportRemoved(const QString &filePath);
|
||||
void fallbackProjectPartUpdated();
|
||||
|
||||
void diagnosticsChanged(const QString &fileName, const QString &kind);
|
||||
void diagnosticsChanged(const Utils::FilePath &filePath, const QString &kind);
|
||||
|
||||
public slots:
|
||||
static void updateModifiedSourceFiles();
|
||||
|
Reference in New Issue
Block a user