diff --git a/src/plugins/qmljseditor/qmlhoverhandler.cpp b/src/plugins/qmljseditor/qmlhoverhandler.cpp index 7b2d9666f21312d8e410a89d476beb4d8eab15c8..1ab41a544fb17168396f17fd7cb8ebd34a4ea5e4 100644 --- a/src/plugins/qmljseditor/qmlhoverhandler.cpp +++ b/src/plugins/qmljseditor/qmlhoverhandler.cpp @@ -202,7 +202,7 @@ void QmlHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in Interpreter::ObjectValue *scope = bind(declaringMember); Check check(&interp); const Interpreter::Value *value = check(expression, scope); - m_toolTip = interp.typeId(value); + m_toolTip = prettyPrint(value, &interp); #if 0 QmlLookupContext context(expressionUnderCursor.expressionScopes(), doc, m_modelManager->snapshot(), typeSystem); @@ -241,3 +241,22 @@ void QmlHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in m_toolTip = QString(QLatin1String("<nobr>No help available for \"%1\"")).arg(symbolName); } } + +QString QmlHoverHandler::prettyPrint(const QmlJS::Interpreter::Value *value, QmlJS::Interpreter::Engine *interp) const +{ + if (!value) + return QString(); + + if (const Interpreter::ObjectValue *objectValue = value->asObjectValue()) { + QString className = objectValue->className(); + + while (objectValue && objectValue->prototype() && className.isEmpty()) { + objectValue = objectValue->prototype(); + className = objectValue->className(); + } + + return className; + } + + return interp->typeId(value); +} diff --git a/src/plugins/qmljseditor/qmlhoverhandler.h b/src/plugins/qmljseditor/qmlhoverhandler.h index 7d3012b398eb28d78c738f0b3c367e701488c281..abfabe6071f6944b7f0b296b2c6ffe996686d23c 100644 --- a/src/plugins/qmljseditor/qmlhoverhandler.h +++ b/src/plugins/qmljseditor/qmlhoverhandler.h @@ -43,6 +43,13 @@ namespace Core { class IEditor; } +namespace QmlJS { + namespace Interpreter { + class Engine; + class Value; + } +} + namespace TextEditor { class ITextEditor; } @@ -66,6 +73,7 @@ private slots: private: void updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, int pos); + QString prettyPrint(const QmlJS::Interpreter::Value *value, QmlJS::Interpreter::Engine *interp) const; private: QmlModelManagerInterface *m_modelManager;