Commit 4ecf0349 authored by Christian Kamm's avatar Christian Kamm
Browse files

QmlJS: Make 'follow symbol' work on JS functions.

Task-number: QTCREATORBUG-1757
parent 68be307b
...@@ -282,7 +282,7 @@ bool Bind::visit(FunctionDeclaration *ast) ...@@ -282,7 +282,7 @@ bool Bind::visit(FunctionDeclaration *ast)
//if (_currentObjectValue->property(ast->name->asString(), 0)) //if (_currentObjectValue->property(ast->name->asString(), 0))
// return false; // return false;
ASTFunctionValue *function = new ASTFunctionValue(ast, &_engine); ASTFunctionValue *function = new ASTFunctionValue(ast, _doc, &_engine);
_currentObjectValue->setProperty(ast->name->asString(), function); _currentObjectValue->setProperty(ast->name->asString(), function);
// build function scope // build function scope
......
...@@ -2959,8 +2959,8 @@ const Value *ASTVariableReference::value(Context *context) const ...@@ -2959,8 +2959,8 @@ const Value *ASTVariableReference::value(Context *context) const
return check(_ast->expression); return check(_ast->expression);
} }
ASTFunctionValue::ASTFunctionValue(FunctionDeclaration *ast, Engine *engine) ASTFunctionValue::ASTFunctionValue(FunctionDeclaration *ast, const Document *doc, Engine *engine)
: FunctionValue(engine), _ast(ast) : FunctionValue(engine), _doc(doc), _ast(ast)
{ {
setPrototype(engine->functionPrototype()); setPrototype(engine->functionPrototype());
...@@ -3007,6 +3007,14 @@ bool ASTFunctionValue::isVariadic() const ...@@ -3007,6 +3007,14 @@ bool ASTFunctionValue::isVariadic() const
return true; return true;
} }
bool ASTFunctionValue::getSourceLocation(QString *fileName, int *line, int *column) const
{
*fileName = _doc->fileName();
*line = _ast->identifierToken.startLine;
*column = _ast->identifierToken.startColumn;
return true;
}
QmlPrototypeReference::QmlPrototypeReference(UiQualifiedId *qmlTypeName, const QmlJS::Document *doc, QmlPrototypeReference::QmlPrototypeReference(UiQualifiedId *qmlTypeName, const QmlJS::Document *doc,
Engine *engine) Engine *engine)
: Reference(engine), : Reference(engine),
......
...@@ -769,10 +769,11 @@ private: ...@@ -769,10 +769,11 @@ private:
class QMLJS_EXPORT ASTFunctionValue: public FunctionValue class QMLJS_EXPORT ASTFunctionValue: public FunctionValue
{ {
AST::FunctionDeclaration *_ast; AST::FunctionDeclaration *_ast;
const Document *_doc;
QList<NameId *> _argumentNames; QList<NameId *> _argumentNames;
public: public:
ASTFunctionValue(AST::FunctionDeclaration *ast, Engine *engine); ASTFunctionValue(AST::FunctionDeclaration *ast, const Document *doc, Engine *engine);
virtual ~ASTFunctionValue(); virtual ~ASTFunctionValue();
AST::FunctionDeclaration *ast() const; AST::FunctionDeclaration *ast() const;
...@@ -782,6 +783,8 @@ public: ...@@ -782,6 +783,8 @@ public:
virtual const Value *argument(int) const; virtual const Value *argument(int) const;
virtual QString argumentName(int index) const; virtual QString argumentName(int index) const;
virtual bool isVariadic() const; virtual bool isVariadic() const;
virtual bool getSourceLocation(QString *fileName, int *line, int *column) const;
}; };
class QMLJS_EXPORT ASTPropertyReference: public Reference class QMLJS_EXPORT ASTPropertyReference: public Reference
......
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