QmlJSInspector: Remove dependency to QmlJSEditor

Change-Id: I6f90bff623437b25887bdd288987c013a45029be
Reviewed-by: Aurindam Jana <aurindam.jana@nokia.com>
This commit is contained in:
Kai Koehne
2012-04-13 11:57:34 +02:00
parent 04ef376637
commit aca66125de
11 changed files with 80 additions and 67 deletions

View File

@@ -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

View File

@@ -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();

View File

@@ -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;

View File

@@ -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>

View File

@@ -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());
QTextCursor tc(qmlEditor->document());
QmlJSTools::SemanticInfo semanticInfo = getSemanticInfo(editWidget);
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,

View File

@@ -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)

View File

@@ -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" }

View File

@@ -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)));
}
}

View File

@@ -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;

View File

@@ -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();

View File

@@ -101,4 +101,6 @@ private:
} // namespace QmlJSTools
Q_DECLARE_METATYPE(QmlJSTools::SemanticInfo)
#endif // QMLJSSEMANTICINFO_H