summaryrefslogtreecommitdiff
path: root/src/plugins/qmljseditor/qmltaskmanager.cpp
diff options
context:
space:
mode:
authordt <qtc-committer@nokia.com>2010-07-13 17:16:43 +0200
committerdt <qtc-committer@nokia.com>2010-07-14 13:01:43 +0200
commit3ef43f56c72694b7586d16246903e2a036c8edcb (patch)
tree14289e3899b988ce7a04fe9b9c84851f1306de3c /src/plugins/qmljseditor/qmltaskmanager.cpp
parent185bc0ee26b7d6f5f9d15d1e69bd538170ce7aa9 (diff)
downloadqt-creator-3ef43f56c72694b7586d16246903e2a036c8edcb.tar.gz
Move qmltaskmanager from qmlproject plugin to qmljseditor
Diffstat (limited to 'src/plugins/qmljseditor/qmltaskmanager.cpp')
-rw-r--r--src/plugins/qmljseditor/qmltaskmanager.cpp90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/plugins/qmljseditor/qmltaskmanager.cpp b/src/plugins/qmljseditor/qmltaskmanager.cpp
new file mode 100644
index 0000000000..30cd0a9dbe
--- /dev/null
+++ b/src/plugins/qmljseditor/qmltaskmanager.cpp
@@ -0,0 +1,90 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+#include "qmltaskmanager.h"
+#include "qmljseditorconstants.h"
+
+#include <extensionsystem/pluginmanager.h>
+#include <projectexplorer/taskhub.h>
+#include <qmljs/qmljsmodelmanagerinterface.h>
+
+#include <QDebug>
+
+namespace QmlJSEditor {
+namespace Internal {
+
+QmlTaskManager::QmlTaskManager(QObject *parent) :
+ QObject(parent),
+ m_taskHub(0)
+{
+ m_taskHub = ExtensionSystem::PluginManager::instance()->getObject<ProjectExplorer::TaskHub>();
+}
+
+void QmlTaskManager::documentChangedOnDisk(QmlJS::Document::Ptr doc)
+{
+ const QString fileName = doc->fileName();
+ removeTasksForFile(fileName);
+
+ foreach (const QmlJS::DiagnosticMessage &msg, doc->diagnosticMessages()) {
+ ProjectExplorer::Task::TaskType type
+ = msg.isError() ? ProjectExplorer::Task::Error
+ : ProjectExplorer::Task::Warning;
+
+ ProjectExplorer::Task task(type, msg.message, fileName, msg.loc.startLine,
+ 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_taskHub->addTask(task);
+}
+
+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_taskHub->removeTask(task);
+ m_docsWithTasks.remove(fileName);
+ }
+}
+
+} // Internal
+} // QmlProjectManager