forked from qt-creator/qt-creator
Changed hovering to use the new interpreter & binding code.
Done-with: Roberto Raggi
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user