forked from qt-creator/qt-creator
Listening Qml syntax errors in Tasks window
This commit is contained in:
@@ -32,8 +32,8 @@
|
||||
#include "qmljsast_p.h"
|
||||
#include "qmljslexer_p.h"
|
||||
#include "qmljsparser_p.h"
|
||||
#include "qmljsengine_p.h"
|
||||
#include "qmljsnodepool_p.h"
|
||||
#include "qmljsastfwd_p.h"
|
||||
|
||||
using namespace QmlEditor;
|
||||
using namespace QmlJS;
|
||||
|
@@ -35,10 +35,9 @@
|
||||
#include <QtCore/QSharedPointer>
|
||||
#include <QtCore/QString>
|
||||
|
||||
#include "qmleditor_global.h"
|
||||
#include "qmljsengine_p.h"
|
||||
#include "qmljsastfwd_p.h"
|
||||
#include "qmlsymbol.h"
|
||||
#include <qmleditor/qmleditor_global.h>
|
||||
#include <qmleditor/parser/qmljsengine_p.h>
|
||||
#include <qmleditor/qmlsymbol.h>
|
||||
|
||||
namespace QmlEditor {
|
||||
|
||||
|
@@ -398,8 +398,8 @@ ScriptEditor::ScriptEditor(QWidget *parent) :
|
||||
m_modelManager = ExtensionSystem::PluginManager::instance()->getObject<QmlModelManagerInterface>();
|
||||
|
||||
if (m_modelManager) {
|
||||
connect(m_modelManager, SIGNAL(documentUpdated(QmlDocument::Ptr)),
|
||||
this, SLOT(onDocumentUpdated(QmlDocument::Ptr)));
|
||||
connect(m_modelManager, SIGNAL(documentUpdated(QmlEditor::QmlDocument::Ptr)),
|
||||
this, SLOT(onDocumentUpdated(QmlEditor::QmlDocument::Ptr)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -447,7 +447,7 @@ void ScriptEditor::updateDocumentNow()
|
||||
m_modelManager->updateSourceFiles(QStringList() << fileName);
|
||||
}
|
||||
|
||||
void ScriptEditor::onDocumentUpdated(QmlDocument::Ptr doc)
|
||||
void ScriptEditor::onDocumentUpdated(QmlEditor::QmlDocument::Ptr doc)
|
||||
{
|
||||
if (file()->fileName() != doc->fileName())
|
||||
return;
|
||||
|
@@ -113,7 +113,7 @@ public slots:
|
||||
virtual void setFontSettings(const TextEditor::FontSettings &);
|
||||
|
||||
private slots:
|
||||
void onDocumentUpdated(QmlDocument::Ptr doc);
|
||||
void onDocumentUpdated(QmlEditor::QmlDocument::Ptr doc);
|
||||
|
||||
void updateDocument();
|
||||
void updateDocumentNow();
|
||||
|
@@ -52,9 +52,10 @@ QmlModelManager::QmlModelManager(QObject *parent):
|
||||
{
|
||||
m_synchronizer.setCancelOnWait(true);
|
||||
|
||||
qRegisterMetaType<QmlDocument::Ptr>("QmlDocument::Ptr");
|
||||
qRegisterMetaType<QmlEditor::QmlDocument::Ptr>("QmlEditor::QmlDocument::Ptr");
|
||||
|
||||
connect(this, SIGNAL(documentUpdated(QmlDocument::Ptr)), this, SLOT(onDocumentUpdated(QmlDocument::Ptr)));
|
||||
connect(this, SIGNAL(documentUpdated(QmlEditor::QmlDocument::Ptr)),
|
||||
this, SLOT(onDocumentUpdated(QmlEditor::QmlDocument::Ptr)));
|
||||
}
|
||||
|
||||
Snapshot QmlModelManager::snapshot() const
|
||||
@@ -122,7 +123,7 @@ QMap<QString, QString> QmlModelManager::buildWorkingCopyList()
|
||||
void QmlModelManager::emitDocumentUpdated(QmlDocument::Ptr doc)
|
||||
{ emit documentUpdated(doc); }
|
||||
|
||||
void QmlModelManager::onDocumentUpdated(QmlDocument::Ptr doc)
|
||||
void QmlModelManager::onDocumentUpdated(QmlEditor::QmlDocument::Ptr doc)
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
|
||||
|
@@ -58,13 +58,11 @@ public:
|
||||
|
||||
Q_SIGNALS:
|
||||
void projectPathChanged(const QString &projectPath);
|
||||
|
||||
void documentUpdated(QmlDocument::Ptr doc);
|
||||
void aboutToRemoveFiles(const QStringList &files);
|
||||
|
||||
private Q_SLOTS:
|
||||
// this should be executed in the GUI thread.
|
||||
void onDocumentUpdated(QmlDocument::Ptr doc);
|
||||
void onDocumentUpdated(QmlEditor::QmlDocument::Ptr doc);
|
||||
|
||||
protected:
|
||||
QFuture<void> refreshSourceFiles(const QStringList &sourceFiles);
|
||||
|
@@ -32,8 +32,10 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include <qmleditor/qmleditor_global.h>
|
||||
#include <qmleditor/qmldocument.h>
|
||||
|
||||
namespace QmlEditor {
|
||||
|
||||
@@ -49,6 +51,9 @@ public:
|
||||
|
||||
virtual Snapshot snapshot() const = 0;
|
||||
virtual void updateSourceFiles(const QStringList &files) = 0;
|
||||
|
||||
signals:
|
||||
void documentUpdated(QmlEditor::QmlDocument::Ptr doc);
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
#include "qmljsastfwd_p.h"
|
||||
#include <qmleditor/parser/qmljsastfwd_p.h>
|
||||
|
||||
namespace QmlEditor {
|
||||
|
||||
|
@@ -49,6 +49,8 @@ const char *const PROJECT_KIND = "QML";
|
||||
const char *const FILES_EDITOR = ".qmlproject Editor";
|
||||
const char *const FILES_MIMETYPE = QMLMIMETYPE;
|
||||
|
||||
const char *const TASK_CATEGORY_QML = "Task.Category.Qml";
|
||||
|
||||
} // namespace Constants
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
|
@@ -10,6 +10,7 @@ HEADERS = qmlproject.h \
|
||||
qmlprojectwizard.h \
|
||||
qmlnewprojectwizard.h \
|
||||
qmlprojectfileseditor.h \
|
||||
qmltaskmanager.h \
|
||||
qmlmakestep.h
|
||||
SOURCES = qmlproject.cpp \
|
||||
qmlprojectplugin.cpp \
|
||||
@@ -18,6 +19,7 @@ SOURCES = qmlproject.cpp \
|
||||
qmlprojectwizard.cpp \
|
||||
qmlnewprojectwizard.cpp \
|
||||
qmlprojectfileseditor.cpp \
|
||||
qmltaskmanager.cpp \
|
||||
qmlmakestep.cpp
|
||||
RESOURCES += qmlproject.qrc
|
||||
|
||||
|
@@ -35,19 +35,26 @@
|
||||
#include "qmlprojectfileseditor.h"
|
||||
#include "qmlproject.h"
|
||||
#include "qmlmakestep.h"
|
||||
#include "qmltaskmanager.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
|
||||
#include <texteditor/texteditoractionhandler.h>
|
||||
|
||||
#include <projectexplorer/taskwindow.h>
|
||||
#include <qmleditor/qmlmodelmanagerinterface.h>
|
||||
|
||||
#include <QtCore/QtPlugin>
|
||||
|
||||
using namespace QmlProjectManager;
|
||||
using namespace QmlProjectManager::Internal;
|
||||
|
||||
QmlProjectPlugin::QmlProjectPlugin()
|
||||
: m_projectFilesEditorFactory(0)
|
||||
QmlProjectPlugin::QmlProjectPlugin() :
|
||||
m_projectFilesEditorFactory(0),
|
||||
m_qmlTaskManager(0)
|
||||
{ }
|
||||
|
||||
QmlProjectPlugin::~QmlProjectPlugin()
|
||||
@@ -76,6 +83,8 @@ bool QmlProjectPlugin::initialize(const QStringList &, QString *errorMessage)
|
||||
m_projectFilesEditorFactory = new ProjectFilesFactory(manager, actionHandler);
|
||||
addObject(m_projectFilesEditorFactory);
|
||||
|
||||
m_qmlTaskManager = new QmlTaskManager(this);
|
||||
|
||||
addAutoReleasedObject(manager);
|
||||
addAutoReleasedObject(new QmlRunConfigurationFactory);
|
||||
addAutoReleasedObject(new QmlNewProjectWizard);
|
||||
@@ -86,6 +95,15 @@ bool QmlProjectPlugin::initialize(const QStringList &, QString *errorMessage)
|
||||
}
|
||||
|
||||
void QmlProjectPlugin::extensionsInitialized()
|
||||
{ }
|
||||
{
|
||||
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
|
||||
ProjectExplorer::TaskWindow *taskWindow = pluginManager->getObject<ProjectExplorer::TaskWindow>();
|
||||
m_qmlTaskManager->setTaskWindow(taskWindow);
|
||||
|
||||
QmlEditor::QmlModelManagerInterface *modelManager = pluginManager->getObject<QmlEditor::QmlModelManagerInterface>();
|
||||
Q_ASSERT(modelManager);
|
||||
connect(modelManager, SIGNAL(documentUpdated(QmlEditor::QmlDocument::Ptr)),
|
||||
m_qmlTaskManager, SLOT(documentUpdated(QmlEditor::QmlDocument::Ptr)));
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN(QmlProjectPlugin)
|
||||
|
@@ -38,6 +38,7 @@ namespace QmlProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class ProjectFilesFactory;
|
||||
class QmlTaskManager;
|
||||
|
||||
class QmlProjectPlugin: public ExtensionSystem::IPlugin
|
||||
{
|
||||
@@ -52,6 +53,7 @@ public:
|
||||
|
||||
private:
|
||||
ProjectFilesFactory *m_projectFilesEditorFactory;
|
||||
QmlTaskManager *m_qmlTaskManager;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
38
src/plugins/qmlprojectmanager/qmltaskmanager.cpp
Normal file
38
src/plugins/qmlprojectmanager/qmltaskmanager.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "qmltaskmanager.h"
|
||||
#include "qmlprojectconstants.h"
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
QmlTaskManager::QmlTaskManager(QObject *parent) :
|
||||
QObject(parent),
|
||||
m_taskWindow(0)
|
||||
{
|
||||
}
|
||||
|
||||
void QmlTaskManager::setTaskWindow(ProjectExplorer::TaskWindow *taskWindow)
|
||||
{
|
||||
Q_ASSERT(taskWindow);
|
||||
m_taskWindow = taskWindow;
|
||||
|
||||
m_taskWindow->addCategory(Constants::TASK_CATEGORY_QML, "Qml");
|
||||
}
|
||||
|
||||
void QmlTaskManager::documentUpdated(QmlEditor::QmlDocument::Ptr doc)
|
||||
{
|
||||
m_taskWindow->clearTasks(Constants::TASK_CATEGORY_QML);
|
||||
|
||||
foreach (const QmlJS::DiagnosticMessage &msg, doc->diagnosticMessages()) {
|
||||
ProjectExplorer::TaskWindow::TaskType type
|
||||
= msg.isError() ? ProjectExplorer::TaskWindow::Error
|
||||
: ProjectExplorer::TaskWindow::Warning;
|
||||
|
||||
ProjectExplorer::TaskWindow::Task task(type, msg.message, doc->fileName(), msg.loc.startLine,
|
||||
Constants::TASK_CATEGORY_QML);
|
||||
m_taskWindow->addTask(task);
|
||||
}
|
||||
}
|
||||
|
||||
} // Internal
|
||||
} // QmlEditor
|
29
src/plugins/qmlprojectmanager/qmltaskmanager.h
Normal file
29
src/plugins/qmlprojectmanager/qmltaskmanager.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef QMLTASKMANAGER_H
|
||||
#define QMLTASKMANAGER_H
|
||||
|
||||
#include <projectexplorer/taskwindow.h>
|
||||
#include <qmleditor/qmldocument.h>
|
||||
#include <QtCore/QObject>
|
||||
|
||||
|
||||
namespace QmlProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class QmlTaskManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QmlTaskManager(QObject *parent = 0);
|
||||
void setTaskWindow(ProjectExplorer::TaskWindow *taskWindow);
|
||||
|
||||
public slots:
|
||||
void documentUpdated(QmlEditor::QmlDocument::Ptr doc);
|
||||
|
||||
private:
|
||||
ProjectExplorer::TaskWindow *m_taskWindow;
|
||||
};
|
||||
|
||||
} // Internal
|
||||
} // QmlProjectManager
|
||||
|
||||
#endif // QMLTASKMANAGER_H
|
Reference in New Issue
Block a user