Commit fac977a5 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Try to get the type from a qualified-id.

parent 2443a4b3
......@@ -47,7 +47,7 @@ Check::~Check()
{
}
const Interpreter::Value *Check::operator()(AST::ExpressionNode *ast, const Interpreter::ObjectValue *scope)
const Interpreter::Value *Check::operator()(AST::Node *ast, const Interpreter::ObjectValue *scope)
{
const Interpreter::ObjectValue *previousScope = switchScope(scope);
const Interpreter::Value *result = check(ast);
......@@ -55,7 +55,7 @@ const Interpreter::Value *Check::operator()(AST::ExpressionNode *ast, const Inte
return result;
}
const Interpreter::Value *Check::check(AST::ExpressionNode *ast)
const Interpreter::Value *Check::check(AST::Node *ast)
{
const Value *previousResult = switchResult(0);
accept(ast);
......@@ -151,8 +151,31 @@ bool Check::visit(AST::UiArrayMemberList *)
return false;
}
bool Check::visit(AST::UiQualifiedId *)
bool Check::visit(AST::UiQualifiedId *ast)
{
if (! ast->name)
return false;
const Value *value = _scope->lookup(ast->name->asString());
if (! ast->next) {
_result = value;
} else {
const ObjectValue *base = value_cast<const ObjectValue *>(value);
for (AST::UiQualifiedId *it = ast->next; base && it; it = it->next) {
NameId *name = it->name;
if (! name)
break;
const Value *value = base->property(name->asString());
if (! it->next)
_result = value;
else
base = value_cast<const ObjectValue *>(value);
}
}
return false;
}
......
......@@ -48,11 +48,11 @@ public:
Check(Interpreter::Engine *engine);
virtual ~Check();
const Interpreter::Value *operator()(AST::ExpressionNode *ast, const Interpreter::ObjectValue *scope);
const Interpreter::Value *check(AST::ExpressionNode *ast);
const Interpreter::Value *operator()(AST::Node *ast, const Interpreter::ObjectValue *scope);
protected:
void accept(AST::Node *node);
const Interpreter::Value *check(AST::Node *ast);
Interpreter::Engine *switchEngine(Interpreter::Engine *engine);
const Interpreter::Value *switchResult(const Interpreter::Value *result);
......
......@@ -142,11 +142,13 @@ void QmlHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
return;
const SemanticInfo semanticInfo = edit->semanticInfo();
const Snapshot snapshot = semanticInfo.snapshot;
Document::Ptr qmlDocument = semanticInfo.document;
if (qmlDocument.isNull())
if (semanticInfo.revision() != edit->documentRevision())
return;
const Snapshot snapshot = semanticInfo.snapshot;
const Document::Ptr qmlDocument = semanticInfo.document;
if (m_helpEngineNeedsSetup && m_helpEngine->registeredDocumentations().count() > 0) {
m_helpEngine->setupData();
m_helpEngineNeedsSetup = false;
......@@ -169,10 +171,10 @@ void QmlHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
AST::UiObjectMember *declaringMember = semanticInfo.declaringMember(pos);
Interpreter::Engine interp;
Interpreter::ObjectValue *scope = Bind::scopeChainAt(qmlDocument, snapshot, &interp, declaringMember);
const Interpreter::ObjectValue *scope = Bind::scopeChainAt(qmlDocument, snapshot, &interp, declaringMember);
Check check(&interp);
const Interpreter::Value *value = check(node->expressionCast(), scope);
const Interpreter::Value *value = check(node, scope);
QStringList baseClasses;
m_toolTip = prettyPrint(value, &interp, &baseClasses);
......
......@@ -567,6 +567,16 @@ QmlJSTextEditor::~QmlJSTextEditor()
{
}
SemanticInfo QmlJSTextEditor::semanticInfo() const
{
return m_semanticInfo;
}
int QmlJSTextEditor::documentRevision() const
{
return document()->revision();
}
Core::IEditor *QmlJSEditorEditable::duplicate(QWidget *parent)
{
QmlJSTextEditor *newEditor = new QmlJSTextEditor(parent);
......
......@@ -131,7 +131,8 @@ public:
virtual void unCommentSelection();
SemanticInfo semanticInfo() const { return m_semanticInfo; }
SemanticInfo semanticInfo() const;
int documentRevision() const;
public slots:
virtual void setFontSettings(const TextEditor::FontSettings &);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment