forked from qt-creator/qt-creator
CppTools: Add sourceFilePath to AbstractEditorSupport
Provide the source path to track a generated file source. You can for example get the modified time stamp for the source file and use it for the generated file content. Task-number: QTCREATORBUG-21876 Change-Id: Ia422e128c5cb7a3dce88960f126152c2f65afb41 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -293,6 +293,7 @@ void ClangModelManagerSupport::onCppDocumentContentsChangedOnUnsavedFile()
|
||||
}
|
||||
|
||||
void ClangModelManagerSupport::onAbstractEditorSupportContentsUpdated(const QString &filePath,
|
||||
const QString &,
|
||||
const QByteArray &content)
|
||||
{
|
||||
QTC_ASSERT(!filePath.isEmpty(), return);
|
||||
|
@@ -94,7 +94,9 @@ private:
|
||||
void onCppDocumentReloadFinishedOnUnsavedFile(bool success);
|
||||
void onCppDocumentContentsChangedOnUnsavedFile();
|
||||
|
||||
void onAbstractEditorSupportContentsUpdated(const QString &filePath, const QByteArray &content);
|
||||
void onAbstractEditorSupportContentsUpdated(const QString &filePath,
|
||||
const QString &sourceFilePath,
|
||||
const QByteArray &content);
|
||||
void onAbstractEditorSupportRemoved(const QString &filePath);
|
||||
|
||||
void onTextMarkContextMenuRequested(TextEditor::TextEditorWidget *widget,
|
||||
|
@@ -103,7 +103,9 @@ private:
|
||||
[&] (const QStringList &projectPartIds) { projectPartsRemoved(projectPartIds); });
|
||||
QObject::connect(Internal::cppModelManager(),
|
||||
&CppTools::CppModelManager::abstractEditorSupportContentsUpdated,
|
||||
[&] (const QString &filePath, const QByteArray &contents) {
|
||||
[&](const QString &filePath,
|
||||
const QString &,
|
||||
const QByteArray &contents) {
|
||||
abstractEditorUpdated(filePath, contents);
|
||||
});
|
||||
QObject::connect(Internal::cppModelManager(),
|
||||
|
@@ -84,7 +84,7 @@ void QtCreatorRefactoringProjectUpdater::connectToCppModelManager()
|
||||
|
||||
QObject::connect(cppModelManager(),
|
||||
&CppTools::CppModelManager::abstractEditorSupportContentsUpdated,
|
||||
[&] (const QString &filePath, const QByteArray &contents) {
|
||||
[&] (const QString &filePath, const QString &, const QByteArray &contents) {
|
||||
abstractEditorUpdated(filePath, contents);
|
||||
});
|
||||
|
||||
|
@@ -54,7 +54,7 @@ void AbstractEditorSupport::updateDocument()
|
||||
|
||||
void AbstractEditorSupport::notifyAboutUpdatedContents() const
|
||||
{
|
||||
m_modelmanager->emitAbstractEditorSupportContentsUpdated(fileName(), contents());
|
||||
m_modelmanager->emitAbstractEditorSupportContentsUpdated(fileName(), sourceFileName(), contents());
|
||||
}
|
||||
|
||||
QString AbstractEditorSupport::licenseTemplate(const QString &file, const QString &className)
|
||||
|
@@ -43,6 +43,7 @@ public:
|
||||
/// \returns the contents, encoded as UTF-8
|
||||
virtual QByteArray contents() const = 0;
|
||||
virtual QString fileName() const = 0;
|
||||
virtual QString sourceFileName() const = 0;
|
||||
|
||||
void updateDocument();
|
||||
void notifyAboutUpdatedContents() const;
|
||||
|
@@ -1188,9 +1188,10 @@ void CppModelManager::emitDocumentUpdated(Document::Ptr doc)
|
||||
}
|
||||
|
||||
void CppModelManager::emitAbstractEditorSupportContentsUpdated(const QString &filePath,
|
||||
const QString &sourcePath,
|
||||
const QByteArray &contents)
|
||||
{
|
||||
emit abstractEditorSupportContentsUpdated(filePath, contents);
|
||||
emit abstractEditorSupportContentsUpdated(filePath, sourcePath, contents);
|
||||
}
|
||||
|
||||
void CppModelManager::emitAbstractEditorSupportRemoved(const QString &filePath)
|
||||
|
@@ -137,6 +137,7 @@ public:
|
||||
|
||||
void emitDocumentUpdated(Document::Ptr doc);
|
||||
void emitAbstractEditorSupportContentsUpdated(const QString &filePath,
|
||||
const QString &sourcePath,
|
||||
const QByteArray &contents);
|
||||
void emitAbstractEditorSupportRemoved(const QString &filePath);
|
||||
|
||||
@@ -243,7 +244,9 @@ signals:
|
||||
|
||||
void gcFinished(); // Needed for tests.
|
||||
|
||||
void abstractEditorSupportContentsUpdated(const QString &filePath, const QByteArray &contents);
|
||||
void abstractEditorSupportContentsUpdated(const QString &filePath,
|
||||
const QString &sourcePath,
|
||||
const QByteArray &contents);
|
||||
void abstractEditorSupportRemoved(const QString &filePath);
|
||||
|
||||
public slots:
|
||||
|
@@ -108,6 +108,11 @@ QString GeneratedCodeModelSupport::fileName() const
|
||||
return m_generatedFileName.toString();
|
||||
}
|
||||
|
||||
QString GeneratedCodeModelSupport::sourceFileName() const
|
||||
{
|
||||
return m_generator->source().toString();
|
||||
}
|
||||
|
||||
void GeneratedCodeModelSupport::update(const QList<ProjectExplorer::ExtraCompiler *> &generators)
|
||||
{
|
||||
static QObjectCache extraCompilerCache;
|
||||
|
@@ -54,6 +54,7 @@ public:
|
||||
/// \returns the contents encoded in UTF-8.
|
||||
QByteArray contents() const override;
|
||||
QString fileName() const override; // The generated file
|
||||
QString sourceFileName() const override;
|
||||
|
||||
static void update(const QList<ProjectExplorer::ExtraCompiler *> &generators);
|
||||
|
||||
|
Reference in New Issue
Block a user