Commit 36f003e5 authored by Denis Steckelmacher's avatar Denis Steckelmacher

Do two parsing passes, this allows uses before definitions to work in Javascript

This will also allow uses before definitions in QML but some other problems
first need to be solved.
parent 6d808bf6
......@@ -37,6 +37,7 @@
using namespace KDevelop;
DeclarationBuilder::DeclarationBuilder(ParseSession* session)
: m_prebuilding(false)
{
m_session = session;
}
......@@ -45,8 +46,23 @@ ReferencedTopDUContext DeclarationBuilder::build(const IndexedString& url,
QmlJS::AST::Node* node,
ReferencedTopDUContext updateContext)
{
///TODO: cleanup
Q_ASSERT(m_session->url() == url);
// The declaration builder needs to run twice, so it can resolve uses of e.g. functions
// which are called before they are defined (which is easily possible, due to python's dynamic nature).
if (!m_prebuilding) {
kDebug() << "building, but running pre-builder first";
DeclarationBuilder* prebuilder = new DeclarationBuilder(m_session);
prebuilder->m_prebuilding = true;
updateContext = prebuilder->build(url, node, updateContext);
kDebug() << "pre-builder finished";
delete prebuilder;
} else {
kDebug() << "prebuilding";
}
return DeclarationBuilderBase::build(url, node, updateContext);
}
......
......@@ -129,6 +129,9 @@ private:
using DeclarationBuilderBase::setComment;
void setComment(QmlJS::AST::Node* node);
private:
bool m_prebuilding;
};
#endif // DECLARATIONBUILDER_H
......@@ -60,7 +60,6 @@ function testReturnMixedArg(arg)
*/
var recurse = function() {
/**
* "EXPECT_FAIL": { "type" : "Type recursion is not handled properly, as Declaration::abstractType has no pointer semantics (its indexed directly)" },
* "type": { "toString" : "function void ()" }
*/
var bla = recurse;
......
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