summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@nokia.com>2012-04-13 11:57:34 +0200
committerKai Koehne <kai.koehne@nokia.com>2012-04-16 16:55:54 +0200
commitaca66125defc98581e1b6473db84e58234383d63 (patch)
tree2dbf3020ee821877aabc3048bd7b6269ebd3dec5 /src
parent04ef3766372a0b9a309c38aefdcbb8ac4e77c1fa (diff)
downloadqt-creator-aca66125defc98581e1b6473db84e58234383d63.tar.gz
QmlJSInspector: Remove dependency to QmlJSEditor
Change-Id: I6f90bff623437b25887bdd288987c013a45029be Reviewed-by: Aurindam Jana <aurindam.jana@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/plugins.pro2
-rw-r--r--src/plugins/qmljseditor/qmljseditor.cpp14
-rw-r--r--src/plugins/qmljseditor/qmljseditor.h7
-rw-r--r--src/plugins/qmljsinspector/QmlJSInspector.pluginspec.in2
-rw-r--r--src/plugins/qmljsinspector/qmljsinspector.cpp37
-rw-r--r--src/plugins/qmljsinspector/qmljsinspector.pro3
-rw-r--r--src/plugins/qmljsinspector/qmljsinspector.qbs9
-rw-r--r--src/plugins/qmljsinspector/qmljslivetextpreview.cpp62
-rw-r--r--src/plugins/qmljsinspector/qmljslivetextpreview.h7
-rw-r--r--src/plugins/qmljstools/qmljsmodelmanager.cpp2
-rw-r--r--src/plugins/qmljstools/qmljssemanticinfo.h2
11 files changed, 80 insertions, 67 deletions
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index fb8e76952b..a906d325f3 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -258,7 +258,7 @@ plugin_qmldesigner.depends += plugin_cpptools
plugin_qmljsinspector.subdir = qmljsinspector
plugin_qmljsinspector.depends += plugin_debugger
-plugin_qmljsinspector.depends += plugin_qmljseditor
+plugin_qmljsinspector.depends += plugin_qmljstools
plugin_mercurial.subdir = mercurial
plugin_mercurial.depends = plugin_vcsbase
diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp
index fbab50c126..8d7a86bef7 100644
--- a/src/plugins/qmljseditor/qmljseditor.cpp
+++ b/src/plugins/qmljseditor/qmljseditor.cpp
@@ -457,12 +457,9 @@ QmlJSTextEditorWidget::QmlJSTextEditorWidget(QWidget *parent) :
m_modelManager(0),
m_futureSemanticInfoRevision(0),
m_contextPane(0),
- m_updateSelectedElements(false),
m_findReferences(new FindReferences(this)),
m_semanticHighlighter(new SemanticHighlighter(this))
{
- qRegisterMetaType<QmlJSTools::SemanticInfo>("QmlJSTools::SemanticInfo");
-
m_semanticInfoUpdater = new SemanticInfoUpdater(this);
m_semanticInfoUpdater->start();
@@ -850,15 +847,6 @@ void QmlJSTextEditorWidget::updateUses()
m_updateUsesTimer->start();
}
-bool QmlJSTextEditorWidget::updateSelectedElements() const
-{
- return m_updateSelectedElements;
-}
-
-void QmlJSTextEditorWidget::setUpdateSelectedElements(bool value)
-{
- m_updateSelectedElements = value;
-}
void QmlJSTextEditorWidget::updateUsesNow()
{
@@ -977,7 +965,7 @@ protected:
void QmlJSTextEditorWidget::setSelectedElements()
{
- if (!m_updateSelectedElements)
+ if (!receivers(SIGNAL(selectedElementsChanged(QList<int>,QString))))
return;
QTextCursor tc = textCursor();
diff --git a/src/plugins/qmljseditor/qmljseditor.h b/src/plugins/qmljseditor/qmljseditor.h
index 058ab75919..6b8bd6b1c5 100644
--- a/src/plugins/qmljseditor/qmljseditor.h
+++ b/src/plugins/qmljseditor/qmljseditor.h
@@ -92,6 +92,9 @@ class QMLJSEDITOR_EXPORT QmlJSTextEditorWidget : public TextEditor::BaseTextEdit
{
Q_OBJECT
+ // used e.g. in qmljsprofiler
+ Q_PROPERTY(QmlJSTools::SemanticInfo semanticInfo READ semanticInfo)
+
public:
QmlJSTextEditorWidget(QWidget *parent = 0);
~QmlJSTextEditorWidget();
@@ -105,9 +108,6 @@ public:
Internal::QmlOutlineModel *outlineModel() const;
QModelIndex outlineModelIndex();
- bool updateSelectedElements() const;
- void setUpdateSelectedElements(bool value);
-
static QVector<QString> highlighterFormatCategories();
TextEditor::IAssistInterface *createAssistInterface(TextEditor::AssistKind assistKind,
@@ -193,7 +193,6 @@ private:
QmlJS::IContextPane *m_contextPane;
int m_oldCursorPosition;
- bool m_updateSelectedElements;
FindReferences *m_findReferences;
Internal::SemanticHighlighter *m_semanticHighlighter;
diff --git a/src/plugins/qmljsinspector/QmlJSInspector.pluginspec.in b/src/plugins/qmljsinspector/QmlJSInspector.pluginspec.in
index d1da435148..98d166e4ee 100644
--- a/src/plugins/qmljsinspector/QmlJSInspector.pluginspec.in
+++ b/src/plugins/qmljsinspector/QmlJSInspector.pluginspec.in
@@ -21,6 +21,6 @@ will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.</license>
<url>http://qt.nokia.com</url>
<dependencyList>
<dependency name=\"Debugger\" version=\"$$QTCREATOR_VERSION\"/>
- <dependency name=\"QmlJSEditor\" version=\"$$QTCREATOR_VERSION\"/>
+ <dependency name=\"QmlJSTools\" version=\"$$QTCREATOR_VERSION\"/>
</dependencyList>
</plugin>
diff --git a/src/plugins/qmljsinspector/qmljsinspector.cpp b/src/plugins/qmljsinspector/qmljsinspector.cpp
index 95049e71b2..dcc07ea023 100644
--- a/src/plugins/qmljsinspector/qmljsinspector.cpp
+++ b/src/plugins/qmljsinspector/qmljsinspector.cpp
@@ -193,15 +193,33 @@ void InspectorUi::onEngineStateChanged(Debugger::DebuggerState state)
m_propertyInspector->reset();
}
+// Get semantic info from QmlJSTextEditorWidget
+// (we use the meta object system here to avoid having to link
+// against qmljseditor)
+QmlJSTools::SemanticInfo getSemanticInfo(QPlainTextEdit *qmlJSTextEdit)
+{
+ QmlJSTools::SemanticInfo info;
+ QTC_ASSERT(QLatin1String(qmlJSTextEdit->metaObject()->className())
+ == QLatin1String("QmlJSEditor::QmlJSTextEditorWidget"),
+ return info);
+ QTC_ASSERT(qmlJSTextEdit->metaObject()->indexOfProperty("semanticInfo") != -1, return info);
+
+ info = qmlJSTextEdit->property("semanticInfo").value<QmlJSTools::SemanticInfo>();
+ return info;
+}
+
void InspectorUi::showDebuggerTooltip(const QPoint &mousePos, TextEditor::ITextEditor *editor,
int cursorPos)
{
Q_UNUSED(mousePos);
if (m_clientProxy && editor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
- QmlJSEditor::QmlJSTextEditorWidget *qmlEditor =
- static_cast<QmlJSEditor::QmlJSTextEditorWidget*>(editor->widget());
+ TextEditor::BaseTextEditor *baseTextEditor =
+ static_cast<TextEditor::BaseTextEditor*>(editor);
+ QPlainTextEdit *editWidget = qobject_cast<QPlainTextEdit*>(baseTextEditor->widget());
+
+ QmlJSTools::SemanticInfo semanticInfo = getSemanticInfo(editWidget);
- QTextCursor tc(qmlEditor->document());
+ QTextCursor tc(editWidget->document());
tc.setPosition(cursorPos);
tc.movePosition(QTextCursor::StartOfWord);
tc.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
@@ -210,13 +228,13 @@ void InspectorUi::showDebuggerTooltip(const QPoint &mousePos, TextEditor::ITextE
QString query;
QLatin1Char doubleQuote('"');
- QmlJS::AST::Node *qmlNode = qmlEditor->semanticInfo().astNodeAt(cursorPos);
+ QmlJS::AST::Node *qmlNode = semanticInfo.astNodeAt(cursorPos);
if (!qmlNode)
return;
QmlDebugObjectReference ref;
if (QmlJS::AST::Node *node
- = qmlEditor->semanticInfo().declaringMemberNoProperties(cursorPos)) {
+ = semanticInfo.declaringMemberNoProperties(cursorPos)) {
if (QmlJS::AST::UiObjectMember *objMember = node->uiObjectMemberCast()) {
ref = m_clientProxy->objectReferenceForLocation(
objMember->firstSourceLocation().startLine,
@@ -727,11 +745,14 @@ QmlDebugObjectReference InspectorUi::objectReferenceForLocation(const QString &f
if (textEditor && m_clientProxy && textEditor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
if (cursorPosition == -1)
cursorPosition = textEditor->position();
- QmlJSEditor::QmlJSTextEditorWidget *qmlEditor =
- static_cast<QmlJSEditor::QmlJSTextEditorWidget*>(textEditor->widget());
+ TextEditor::BaseTextEditor *baseTextEditor =
+ static_cast<TextEditor::BaseTextEditor*>(editor);
+ QPlainTextEdit *editWidget = qobject_cast<QPlainTextEdit*>(baseTextEditor->widget());
+
+ QmlJSTools::SemanticInfo semanticInfo = getSemanticInfo(editWidget);
if (QmlJS::AST::Node *node
- = qmlEditor->semanticInfo().declaringMemberNoProperties(cursorPosition)) {
+ = semanticInfo.declaringMemberNoProperties(cursorPosition)) {
if (QmlJS::AST::UiObjectMember *objMember = node->uiObjectMemberCast()) {
return m_clientProxy->objectReferenceForLocation(
objMember->firstSourceLocation().startLine,
diff --git a/src/plugins/qmljsinspector/qmljsinspector.pro b/src/plugins/qmljsinspector/qmljsinspector.pro
index c50cc52088..f82d39c810 100644
--- a/src/plugins/qmljsinspector/qmljsinspector.pro
+++ b/src/plugins/qmljsinspector/qmljsinspector.pro
@@ -42,6 +42,7 @@ RESOURCES += qmljsinspector.qrc
include(../../qtcreatorplugin.pri)
include(../../libs/qmljsdebugclient/qmljsdebugclient.pri)
+include(../../libs/qmleditorwidgets/qmleditorwidgets.pri)
include(../../plugins/debugger/debugger.pri)
-include(../../plugins/qmljseditor/qmljseditor.pri)
+include(../../plugins/qmljstools/qmljstools.pri)
diff --git a/src/plugins/qmljsinspector/qmljsinspector.qbs b/src/plugins/qmljsinspector/qmljsinspector.qbs
index 08e742744b..f5dc9516dc 100644
--- a/src/plugins/qmljsinspector/qmljsinspector.qbs
+++ b/src/plugins/qmljsinspector/qmljsinspector.qbs
@@ -7,14 +7,11 @@ QtcPlugin {
Depends { name: "qt"; submodules: ['widgets'] }
Depends { name: "Core" }
- Depends { name: "ProjectExplorer" }
- Depends { name: "QmlProjectManager" }
- Depends { name: "TextEditor" }
Depends { name: "Debugger" }
- Depends { name: "QmlJS" }
- Depends { name: "QmlJSEditor" }
- Depends { name: "symbianutils" }
Depends { name: "LanguageUtils" }
+ Depends { name: "TextEditor" }
+ Depends { name: "QmlJS" }
+ Depends { name: "QmlJSTools" }
Depends { name: "QmlEditorWidgets" }
Depends { name: "QmlJSDebugClient" }
diff --git a/src/plugins/qmljsinspector/qmljslivetextpreview.cpp b/src/plugins/qmljsinspector/qmljslivetextpreview.cpp
index 0496e30b48..657c860618 100644
--- a/src/plugins/qmljsinspector/qmljslivetextpreview.cpp
+++ b/src/plugins/qmljsinspector/qmljslivetextpreview.cpp
@@ -39,7 +39,6 @@
#include "qmljsinspectorconstants.h"
#include <qmljseditor/qmljseditorconstants.h>
-#include <qmljseditor/qmljseditor.h>
#include <qmljs/qmljsdelta.h>
#include <qmljs/parser/qmljsast_p.h>
#include <extensionsystem/pluginmanager.h>
@@ -54,6 +53,8 @@
#include <debugger/debuggerconstants.h>
+#include <utils/qtcassert.h>
+
#include <QDebug>
using namespace QmlJS;
@@ -142,29 +143,34 @@ QmlJS::ModelManagerInterface *QmlJSLiveTextPreview::modelManager()
void QmlJSLiveTextPreview::associateEditor(Core::IEditor *editor)
{
+ using namespace TextEditor;
if (editor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
- QmlJSEditor::QmlJSTextEditorWidget* qmljsEditor = qobject_cast<QmlJSEditor::QmlJSTextEditorWidget*>(editor->widget());
- if (qmljsEditor && !m_editors.contains(qmljsEditor)) {
- qmljsEditor->setUpdateSelectedElements(true);
- m_editors << qmljsEditor;
- connect(qmljsEditor,
- SIGNAL(selectedElementsChanged(QList<int>,QString)),
- SLOT(changeSelectedElements(QList<int>,QString)));
+ QTC_ASSERT(QLatin1String(editor->widget()->metaObject()->className()) ==
+ QLatin1String("QmlJSEditor::QmlJSTextEditorWidget"),
+ return);
+
+ BaseTextEditorWidget *editWidget = qobject_cast<BaseTextEditorWidget*>(editor->widget());
+ QTC_ASSERT(editWidget, return);
+
+ if (!m_editors.contains(editWidget)) {
+ m_editors << editWidget;
+ if (m_clientProxy.data())
+ connect(editWidget, SIGNAL(selectedElementsChanged(QList<int>,QString)),
+ SLOT(changeSelectedElements(QList<int>,QString)));
}
}
}
void QmlJSLiveTextPreview::unassociateEditor(Core::IEditor *oldEditor)
{
+ using namespace TextEditor;
if (oldEditor && oldEditor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
- QmlJSEditor::QmlJSTextEditorWidget* qmljsEditor = qobject_cast<QmlJSEditor::QmlJSTextEditorWidget*>(oldEditor->widget());
- if (qmljsEditor && m_editors.contains(qmljsEditor)) {
- m_editors.removeOne(qmljsEditor);
- qmljsEditor->setUpdateSelectedElements(false);
- disconnect(qmljsEditor,
- SIGNAL(selectedElementsChanged(QList<int>,QString)),
- this,
- SLOT(changeSelectedElements(QList<int>,QString)));
+ BaseTextEditorWidget *editWidget = qobject_cast<BaseTextEditorWidget*>(oldEditor->widget());
+ QTC_ASSERT(editWidget, return);
+
+ if (m_editors.contains(editWidget)) {
+ m_editors.removeOne(editWidget);
+ disconnect(editWidget, 0, this, 0);
}
}
}
@@ -593,7 +599,7 @@ void QmlJSLiveTextPreview::documentChanged(QmlJS::Document::Ptr doc)
void QmlJSLiveTextPreview::showExperimentalWarning()
{
- foreach (QWeakPointer<QmlJSEditor::QmlJSTextEditorWidget> editor, m_editors)
+ foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editor, m_editors)
if (editor) {
Core::InfoBarEntry info(
Constants::INFO_EXPERIMENTAL,
@@ -624,7 +630,7 @@ void QmlJSLiveTextPreview::showSyncWarning(UnsyncronizableChangeType unsyncroniz
errorMessage.append(tr("You can continue debugging, but behavior can be unexpected."));
- foreach (QWeakPointer<QmlJSEditor::QmlJSTextEditorWidget> editor, m_editors)
+ foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editor, m_editors)
if (editor)
editor.data()->editorDocument()->infoBar()->addInfo(Core::InfoBarEntry(
QLatin1String(Constants::INFO_OUT_OF_SYNC), errorMessage));
@@ -632,7 +638,7 @@ void QmlJSLiveTextPreview::showSyncWarning(UnsyncronizableChangeType unsyncroniz
void QmlJSLiveTextPreview::reloadQmlViewer()
{
- foreach (QWeakPointer<QmlJSEditor::QmlJSTextEditorWidget> editor, m_editors)
+ foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editor, m_editors)
if (editor)
editor.data()->editorDocument()->infoBar()->removeInfo(Constants::INFO_OUT_OF_SYNC);
emit reloadQmlViewerRequested();
@@ -640,7 +646,7 @@ void QmlJSLiveTextPreview::reloadQmlViewer()
void QmlJSLiveTextPreview::disableLivePreview()
{
- foreach (QWeakPointer<QmlJSEditor::QmlJSTextEditorWidget> editor, m_editors)
+ foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editor, m_editors)
if (editor)
editor.data()->editorDocument()->infoBar()->removeInfo(Constants::INFO_OUT_OF_SYNC);
emit disableLivePreviewRequested();
@@ -671,15 +677,15 @@ void QmlJSLiveTextPreview::setClientProxy(ClientProxy *clientProxy)
connect(m_clientProxy.data(), SIGNAL(objectTreeUpdated()),
SLOT(updateDebugIds()));
- foreach (const QWeakPointer<QmlJSEditor::QmlJSTextEditorWidget> &qmlEditor, m_editors) {
- if (qmlEditor)
- qmlEditor.data()->setUpdateSelectedElements(true);
- }
+ foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editWidget, m_editors)
+ if (editWidget)
+ connect(editWidget.data(), SIGNAL(selectedElementsChanged(QList<int>,QString)),
+ this, SLOT(changeSelectedElements(QList<int>,QString)));
} else {
- foreach (const QWeakPointer<QmlJSEditor::QmlJSTextEditorWidget> &qmlEditor, m_editors) {
- if (qmlEditor)
- qmlEditor.data()->setUpdateSelectedElements(false);
- }
+ foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editWidget, m_editors)
+ if (editWidget)
+ disconnect(editWidget.data(), SIGNAL(selectedElementsChanged(QList<int>,QString)),
+ this, SLOT(changeSelectedElements(QList<int>,QString)));
}
}
diff --git a/src/plugins/qmljsinspector/qmljslivetextpreview.h b/src/plugins/qmljsinspector/qmljslivetextpreview.h
index 6ada1e56ad..d6a50ffb05 100644
--- a/src/plugins/qmljsinspector/qmljslivetextpreview.h
+++ b/src/plugins/qmljsinspector/qmljslivetextpreview.h
@@ -35,6 +35,7 @@
#include <QObject>
#include <QWeakPointer>
+#include <texteditor/basetexteditor.h>
#include <qmljs/parser/qmljsastfwd_p.h>
#include <qmljs/qmljsdocument.h>
@@ -50,10 +51,6 @@ namespace QmlJS {
class ModelManagerInterface;
}
-namespace QmlJSEditor {
- class QmlJSTextEditorWidget;
-}
-
namespace QmlJSInspector {
namespace Internal {
@@ -115,7 +112,7 @@ private:
QmlJS::Document::Ptr m_initialDoc; //the document that was loaded by the server
QString m_filename;
- QList<QWeakPointer<QmlJSEditor::QmlJSTextEditorWidget> > m_editors;
+ QList<QWeakPointer<TextEditor::BaseTextEditorWidget> > m_editors;
bool m_applyChangesToQmlInspector;
QmlJS::Document::Ptr m_docWithUnappliedChanges;
diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp
index ea67158e79..d5e71b5425 100644
--- a/src/plugins/qmljstools/qmljsmodelmanager.cpp
+++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp
@@ -34,6 +34,7 @@
#include "qmljstoolsconstants.h"
#include "qmljsplugindumper.h"
#include "qmljsfindexportedcpptypes.h"
+#include "qmljssemanticinfo.h"
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/editormanager.h>
@@ -130,6 +131,7 @@ ModelManager::ModelManager(QObject *parent):
qRegisterMetaType<QmlJS::Document::Ptr>("QmlJS::Document::Ptr");
qRegisterMetaType<QmlJS::LibraryInfo>("QmlJS::LibraryInfo");
+ qRegisterMetaType<QmlJSTools::SemanticInfo>("QmlJSTools::SemanticInfo");
loadQmlTypeDescriptions();
diff --git a/src/plugins/qmljstools/qmljssemanticinfo.h b/src/plugins/qmljstools/qmljssemanticinfo.h
index 2a38f7bc83..86eefee666 100644
--- a/src/plugins/qmljstools/qmljssemanticinfo.h
+++ b/src/plugins/qmljstools/qmljssemanticinfo.h
@@ -101,4 +101,6 @@ private:
} // namespace QmlJSTools
+Q_DECLARE_METATYPE(QmlJSTools::SemanticInfo)
+
#endif // QMLJSSEMANTICINFO_H