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);
|
Interpreter::ObjectValue *scope = bind(declaringMember);
|
||||||
Check check(&interp);
|
Check check(&interp);
|
||||||
const Interpreter::Value *value = check(expression, scope);
|
const Interpreter::Value *value = check(expression, scope);
|
||||||
m_toolTip = interp.typeId(value);
|
m_toolTip = prettyPrint(value, &interp);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
QmlLookupContext context(expressionUnderCursor.expressionScopes(), doc, m_modelManager->snapshot(), typeSystem);
|
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);
|
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;
|
class IEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace QmlJS {
|
||||||
|
namespace Interpreter {
|
||||||
|
class Engine;
|
||||||
|
class Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
class ITextEditor;
|
class ITextEditor;
|
||||||
}
|
}
|
||||||
@@ -66,6 +73,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, int pos);
|
void updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, int pos);
|
||||||
|
QString prettyPrint(const QmlJS::Interpreter::Value *value, QmlJS::Interpreter::Engine *interp) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QmlModelManagerInterface *m_modelManager;
|
QmlModelManagerInterface *m_modelManager;
|
||||||
|
|||||||
Reference in New Issue
Block a user