forked from qt-creator/qt-creator
Hooked up the QML task manager again.
The QML task manager behaviour is to show warnings/errors for _saved_ files only.
This commit is contained in:
@@ -651,6 +651,7 @@ QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) :
|
|||||||
m_semanticHighlighter->setModelManager(m_modelManager);
|
m_semanticHighlighter->setModelManager(m_modelManager);
|
||||||
connect(m_modelManager, SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
|
connect(m_modelManager, SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
|
||||||
this, SLOT(onDocumentUpdated(QmlJS::Document::Ptr)));
|
this, SLOT(onDocumentUpdated(QmlJS::Document::Ptr)));
|
||||||
|
connect(this->document(), SIGNAL(modificationChanged(bool)), this, SLOT(modificationChanged(bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(m_semanticHighlighter, SIGNAL(changed(QmlJSEditor::Internal::SemanticInfo)),
|
connect(m_semanticHighlighter, SIGNAL(changed(QmlJSEditor::Internal::SemanticInfo)),
|
||||||
@@ -775,6 +776,12 @@ void QmlJSTextEditor::onDocumentUpdated(QmlJS::Document::Ptr doc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QmlJSTextEditor::modificationChanged(bool changed)
|
||||||
|
{
|
||||||
|
if (!changed && m_modelManager)
|
||||||
|
m_modelManager->fileChangedOnDisk(file()->fileName());
|
||||||
|
}
|
||||||
|
|
||||||
void QmlJSTextEditor::jumpToMethod(int index)
|
void QmlJSTextEditor::jumpToMethod(int index)
|
||||||
{
|
{
|
||||||
if (index > 0 && index <= m_semanticInfo.declarations.size()) { // indexes are 1-based
|
if (index > 0 && index <= m_semanticInfo.declarations.size()) { // indexes are 1-based
|
||||||
|
@@ -218,6 +218,7 @@ public slots:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onDocumentUpdated(QmlJS::Document::Ptr doc);
|
void onDocumentUpdated(QmlJS::Document::Ptr doc);
|
||||||
|
void modificationChanged(bool);
|
||||||
|
|
||||||
void updateDocument();
|
void updateDocument();
|
||||||
void updateDocumentNow();
|
void updateDocumentNow();
|
||||||
|
@@ -112,7 +112,7 @@ QFuture<void> ModelManager::refreshSourceFiles(const QStringList &sourceFiles)
|
|||||||
|
|
||||||
QFuture<void> result = QtConcurrent::run(&ModelManager::parse,
|
QFuture<void> result = QtConcurrent::run(&ModelManager::parse,
|
||||||
workingCopy, sourceFiles,
|
workingCopy, sourceFiles,
|
||||||
this);
|
this, false);
|
||||||
|
|
||||||
if (m_synchronizer.futures().size() > 10) {
|
if (m_synchronizer.futures().size() > 10) {
|
||||||
QList<QFuture<void> > futures = m_synchronizer.futures();
|
QList<QFuture<void> > futures = m_synchronizer.futures();
|
||||||
@@ -154,6 +154,16 @@ QMap<QString, ModelManager::WorkingCopy> ModelManager::buildWorkingCopyList()
|
|||||||
return workingCopy;
|
return workingCopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModelManager::fileChangedOnDisk(const QString &path)
|
||||||
|
{
|
||||||
|
QtConcurrent::run(&ModelManager::parse,
|
||||||
|
buildWorkingCopyList(), QStringList() << path,
|
||||||
|
this, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModelManager::emitDocumentChangedOnDisk(Document::Ptr doc)
|
||||||
|
{ emit documentChangedOnDisk(doc); }
|
||||||
|
|
||||||
void ModelManager::emitDocumentUpdated(Document::Ptr doc)
|
void ModelManager::emitDocumentUpdated(Document::Ptr doc)
|
||||||
{ emit documentUpdated(doc); }
|
{ emit documentUpdated(doc); }
|
||||||
|
|
||||||
@@ -279,7 +289,8 @@ static void findNewLibraryImports(const Document::Ptr &doc, const Snapshot &snap
|
|||||||
void ModelManager::parse(QFutureInterface<void> &future,
|
void ModelManager::parse(QFutureInterface<void> &future,
|
||||||
QMap<QString, WorkingCopy> workingCopy,
|
QMap<QString, WorkingCopy> workingCopy,
|
||||||
QStringList files,
|
QStringList files,
|
||||||
ModelManager *modelManager)
|
ModelManager *modelManager,
|
||||||
|
bool emitDocChangedOnDisk)
|
||||||
{
|
{
|
||||||
Core::MimeDatabase *db = Core::ICore::instance()->mimeDatabase();
|
Core::MimeDatabase *db = Core::ICore::instance()->mimeDatabase();
|
||||||
Core::MimeType jsSourceTy = db->findByType(QLatin1String("application/javascript"));
|
Core::MimeType jsSourceTy = db->findByType(QLatin1String("application/javascript"));
|
||||||
@@ -344,6 +355,8 @@ void ModelManager::parse(QFutureInterface<void> &future,
|
|||||||
}
|
}
|
||||||
|
|
||||||
modelManager->emitDocumentUpdated(doc);
|
modelManager->emitDocumentUpdated(doc);
|
||||||
|
if (emitDocChangedOnDisk)
|
||||||
|
modelManager->emitDocumentChangedOnDisk(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
future.setProgressValue(progressRange);
|
future.setProgressValue(progressRange);
|
||||||
|
@@ -55,18 +55,20 @@ public:
|
|||||||
|
|
||||||
virtual QmlJS::Snapshot snapshot() const;
|
virtual QmlJS::Snapshot snapshot() const;
|
||||||
virtual void updateSourceFiles(const QStringList &files);
|
virtual void updateSourceFiles(const QStringList &files);
|
||||||
|
virtual void fileChangedOnDisk(const QString &path);
|
||||||
|
|
||||||
void emitDocumentUpdated(QmlJS::Document::Ptr doc);
|
void emitDocumentUpdated(QmlJS::Document::Ptr doc);
|
||||||
void emitLibraryInfoUpdated(const QString &path, const QmlJS::LibraryInfo &info);
|
void emitLibraryInfoUpdated(const QString &path, const QmlJS::LibraryInfo &info);
|
||||||
|
void emitDocumentChangedOnDisk(QmlJS::Document::Ptr doc);
|
||||||
|
|
||||||
virtual void setProjectImportPaths(const QStringList &importPaths);
|
virtual void setProjectImportPaths(const QStringList &importPaths);
|
||||||
virtual QStringList importPaths() const;
|
virtual QStringList importPaths() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void projectPathChanged(const QString &projectPath);
|
void projectPathChanged(const QString &projectPath);
|
||||||
void aboutToRemoveFiles(const QStringList &files);
|
|
||||||
void libraryInfoUpdated(const QString &path, const QmlJS::LibraryInfo &info);
|
void libraryInfoUpdated(const QString &path, const QmlJS::LibraryInfo &info);
|
||||||
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
// this should be executed in the GUI thread.
|
// this should be executed in the GUI thread.
|
||||||
void onDocumentUpdated(QmlJS::Document::Ptr doc);
|
void onDocumentUpdated(QmlJS::Document::Ptr doc);
|
||||||
@@ -86,7 +88,8 @@ protected:
|
|||||||
static void parse(QFutureInterface<void> &future,
|
static void parse(QFutureInterface<void> &future,
|
||||||
QMap<QString, WorkingCopy> workingCopy,
|
QMap<QString, WorkingCopy> workingCopy,
|
||||||
QStringList files,
|
QStringList files,
|
||||||
ModelManager *modelManager);
|
ModelManager *modelManager,
|
||||||
|
bool emitDocChangedOnDisk);
|
||||||
|
|
||||||
void loadQmlTypeDescriptions();
|
void loadQmlTypeDescriptions();
|
||||||
|
|
||||||
|
@@ -54,12 +54,15 @@ public:
|
|||||||
|
|
||||||
virtual QmlJS::Snapshot snapshot() const = 0;
|
virtual QmlJS::Snapshot snapshot() const = 0;
|
||||||
virtual void updateSourceFiles(const QStringList &files) = 0;
|
virtual void updateSourceFiles(const QStringList &files) = 0;
|
||||||
|
virtual void fileChangedOnDisk(const QString &path) = 0;
|
||||||
|
|
||||||
virtual void setProjectImportPaths(const QStringList &importPaths) = 0;
|
virtual void setProjectImportPaths(const QStringList &importPaths) = 0;
|
||||||
virtual QStringList importPaths() const = 0;
|
virtual QStringList importPaths() const = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void documentUpdated(QmlJS::Document::Ptr doc);
|
void documentUpdated(QmlJS::Document::Ptr doc);
|
||||||
|
void documentChangedOnDisk(QmlJS::Document::Ptr doc);
|
||||||
|
void aboutToRemoveFiles(const QStringList &files);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmlJSEditor
|
} // namespace QmlJSEditor
|
||||||
|
@@ -121,14 +121,20 @@ void QmlProject::parseProject(RefreshOptions options)
|
|||||||
|
|
||||||
void QmlProject::refresh(RefreshOptions options)
|
void QmlProject::refresh(RefreshOptions options)
|
||||||
{
|
{
|
||||||
QSet<QString> oldFileList;
|
const QSet<QString> oldFiles = m_files.toSet();
|
||||||
if (!(options & Configuration))
|
|
||||||
oldFileList = m_files.toSet();
|
|
||||||
|
|
||||||
parseProject(options);
|
parseProject(options);
|
||||||
|
|
||||||
if (options & Files)
|
if (options & Files)
|
||||||
m_rootNode->refresh();
|
m_rootNode->refresh();
|
||||||
|
|
||||||
|
const QSet<QString> newFiles = m_files.toSet();
|
||||||
|
QStringList removedPaths;
|
||||||
|
foreach (const QString &oldFile, oldFiles)
|
||||||
|
if (!newFiles.contains(oldFile))
|
||||||
|
removedPaths.append(oldFile);
|
||||||
|
if (!removedPaths.isEmpty())
|
||||||
|
emit filesRemovedFromProject(removedPaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList QmlProject::convertToAbsoluteFiles(const QStringList &paths) const
|
QStringList QmlProject::convertToAbsoluteFiles(const QStringList &paths) const
|
||||||
|
@@ -101,6 +101,9 @@ public:
|
|||||||
|
|
||||||
bool addFiles(const QStringList &filePaths);
|
bool addFiles(const QStringList &filePaths);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void filesRemovedFromProject(const QStringList removedPaths);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void refreshProjectFile();
|
void refreshProjectFile();
|
||||||
void refreshFiles();
|
void refreshFiles();
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#include "qmlprojectmanager.h"
|
#include "qmlprojectmanager.h"
|
||||||
#include "qmlprojectconstants.h"
|
#include "qmlprojectconstants.h"
|
||||||
#include "qmlproject.h"
|
#include "qmlproject.h"
|
||||||
|
#include "qmltaskmanager.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/ifile.h>
|
#include <coreplugin/ifile.h>
|
||||||
@@ -79,7 +80,12 @@ ProjectExplorer::Project *Manager::openProject(const QString &fileName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fileInfo.isFile()) {
|
if (fileInfo.isFile()) {
|
||||||
return new QmlProject(this, fileName);
|
QmlProject *project = new QmlProject(this, fileName);
|
||||||
|
QmlTaskManager *taskManager = QmlTaskManager::instance();
|
||||||
|
if (taskManager)
|
||||||
|
connect(project, SIGNAL(filesRemovedFromProject(QStringList)),
|
||||||
|
taskManager, SLOT(documentsRemoved(const QStringList)));
|
||||||
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -77,6 +77,7 @@ bool QmlProjectPlugin::initialize(const QStringList &, QString *errorMessage)
|
|||||||
Manager *manager = new Manager;
|
Manager *manager = new Manager;
|
||||||
|
|
||||||
m_qmlTaskManager = new QmlTaskManager(this);
|
m_qmlTaskManager = new QmlTaskManager(this);
|
||||||
|
addAutoReleasedObject(m_qmlTaskManager);
|
||||||
|
|
||||||
addAutoReleasedObject(manager);
|
addAutoReleasedObject(manager);
|
||||||
addAutoReleasedObject(new Internal::QmlProjectRunConfigurationFactory);
|
addAutoReleasedObject(new Internal::QmlProjectRunConfigurationFactory);
|
||||||
@@ -100,8 +101,8 @@ void QmlProjectPlugin::extensionsInitialized()
|
|||||||
|
|
||||||
QmlJSEditor::ModelManagerInterface *modelManager = pluginManager->getObject<QmlJSEditor::ModelManagerInterface>();
|
QmlJSEditor::ModelManagerInterface *modelManager = pluginManager->getObject<QmlJSEditor::ModelManagerInterface>();
|
||||||
Q_ASSERT(modelManager);
|
Q_ASSERT(modelManager);
|
||||||
connect(modelManager, SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
|
connect(modelManager, SIGNAL(documentChangedOnDisk(QmlJS::Document::Ptr)),
|
||||||
m_qmlTaskManager, SLOT(documentUpdated(QmlJS::Document::Ptr)));
|
m_qmlTaskManager, SLOT(documentChangedOnDisk(QmlJS::Document::Ptr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -29,6 +29,9 @@
|
|||||||
|
|
||||||
#include "qmltaskmanager.h"
|
#include "qmltaskmanager.h"
|
||||||
#include "qmlprojectconstants.h"
|
#include "qmlprojectconstants.h"
|
||||||
|
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
namespace QmlProjectManager {
|
namespace QmlProjectManager {
|
||||||
@@ -40,29 +43,58 @@ QmlTaskManager::QmlTaskManager(QObject *parent) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QmlTaskManager *QmlTaskManager::instance()
|
||||||
|
{
|
||||||
|
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
|
||||||
|
return pluginManager->getObject<QmlTaskManager>();
|
||||||
|
}
|
||||||
|
|
||||||
void QmlTaskManager::setTaskWindow(ProjectExplorer::TaskWindow *taskWindow)
|
void QmlTaskManager::setTaskWindow(ProjectExplorer::TaskWindow *taskWindow)
|
||||||
{
|
{
|
||||||
Q_ASSERT(taskWindow);
|
Q_ASSERT(taskWindow);
|
||||||
m_taskWindow = taskWindow;
|
m_taskWindow = taskWindow;
|
||||||
|
|
||||||
m_taskWindow->addCategory(Constants::TASK_CATEGORY_QML, "QML");
|
m_taskWindow->addCategory(Constants::TASK_CATEGORY_QML, tr("QML"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlTaskManager::documentUpdated(QmlJS::Document::Ptr /*doc*/)
|
void QmlTaskManager::documentChangedOnDisk(QmlJS::Document::Ptr doc)
|
||||||
{
|
{
|
||||||
#if 0 // This will give way too many flickering errors in the build-results pane *when you're typing*
|
const QString fileName = doc->fileName();
|
||||||
m_taskWindow->clearTasks(Constants::TASK_CATEGORY_QML);
|
removeTasksForFile(fileName);
|
||||||
|
|
||||||
foreach (const QmlJS::DiagnosticMessage &msg, doc->diagnosticMessages()) {
|
foreach (const QmlJS::DiagnosticMessage &msg, doc->diagnosticMessages()) {
|
||||||
ProjectExplorer::Task::TaskType type
|
ProjectExplorer::Task::TaskType type
|
||||||
= msg.isError() ? ProjectExplorer::Task::Error
|
= msg.isError() ? ProjectExplorer::Task::Error
|
||||||
: ProjectExplorer::Task::Warning;
|
: ProjectExplorer::Task::Warning;
|
||||||
|
|
||||||
ProjectExplorer::Task task(type, msg.message, doc->fileName(), msg.loc.startLine,
|
ProjectExplorer::Task task(type, msg.message, fileName, msg.loc.startLine,
|
||||||
Constants::TASK_CATEGORY_QML);
|
Constants::TASK_CATEGORY_QML);
|
||||||
|
insertTask(fileName, task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QmlTaskManager::documentsRemoved(const QStringList path)
|
||||||
|
{
|
||||||
|
foreach (const QString &item, path)
|
||||||
|
removeTasksForFile(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QmlTaskManager::insertTask(const QString &fileName, const ProjectExplorer::Task &task)
|
||||||
|
{
|
||||||
|
QList<ProjectExplorer::Task> tasks = m_docsWithTasks.value(fileName);
|
||||||
|
tasks.append(task);
|
||||||
|
m_docsWithTasks.insert(fileName, tasks);
|
||||||
m_taskWindow->addTask(task);
|
m_taskWindow->addTask(task);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
void QmlTaskManager::removeTasksForFile(const QString &fileName)
|
||||||
|
{
|
||||||
|
if (m_docsWithTasks.contains(fileName)) {
|
||||||
|
const QList<ProjectExplorer::Task> tasks = m_docsWithTasks.value(fileName);
|
||||||
|
foreach (const ProjectExplorer::Task &task, tasks)
|
||||||
|
m_taskWindow->removeTask(task);
|
||||||
|
m_docsWithTasks.remove(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
|
@@ -34,6 +34,8 @@
|
|||||||
#include <qmljs/qmljsdocument.h>
|
#include <qmljs/qmljsdocument.h>
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QList>
|
||||||
|
#include <QtCore/QSet>
|
||||||
|
|
||||||
namespace QmlProjectManager {
|
namespace QmlProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -43,13 +45,22 @@ class QmlTaskManager : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
QmlTaskManager(QObject *parent = 0);
|
QmlTaskManager(QObject *parent = 0);
|
||||||
|
|
||||||
void setTaskWindow(ProjectExplorer::TaskWindow *taskWindow);
|
void setTaskWindow(ProjectExplorer::TaskWindow *taskWindow);
|
||||||
|
|
||||||
|
static QmlTaskManager *instance();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void documentUpdated(QmlJS::Document::Ptr doc);
|
void documentChangedOnDisk(QmlJS::Document::Ptr doc);
|
||||||
|
void documentsRemoved(const QStringList path);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void insertTask(const QString &fileName, const ProjectExplorer::Task &task);
|
||||||
|
void removeTasksForFile(const QString &fileName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ProjectExplorer::TaskWindow *m_taskWindow;
|
ProjectExplorer::TaskWindow *m_taskWindow;
|
||||||
|
QMap<QString, QList<ProjectExplorer::Task> > m_docsWithTasks;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
|
Reference in New Issue
Block a user