Commit d0587367 authored by Milian Wolff's avatar Milian Wolff

extend test, run context builder

parent a7b6f3f8
......@@ -25,7 +25,7 @@ using namespace KDevelop;
ContextBuilder::ContextBuilder()
: ContextBuilderBase()
, m_session(0)
, m_session()
{
}
......@@ -63,3 +63,8 @@ TopDUContext* ContextBuilder::newTopContext(const RangeInRevision& range, Parsin
}
return ContextBuilderBase::newTopContext(range, file);
}
void ContextBuilder::setParseSession(ParseSession* session)
{
m_session = session;
}
......@@ -44,6 +44,8 @@ public:
virtual KDevelop::TopDUContext* newTopContext(const KDevelop::RangeInRevision& range,
KDevelop::ParsingEnvironmentFile* file = 0);
void setParseSession(ParseSession* session);
protected:
ParseSession* m_session;
QHash<QmlJS::AST::Node*, KDevelop::DUContext*> m_astToContext;
......
......@@ -22,6 +22,7 @@
#include "testcontexts.h"
#include "../parsesession.h"
#include "../contextbuilder.h"
#include <qtest_kde.h>
......@@ -45,10 +46,17 @@ void TestContexts::cleanupTestCase()
void TestContexts::testFunctionContext()
{
ParseSession session(IndexedString("functionContext.js"), "function foo() {}");
const IndexedString file("functionContext.js");
ParseSession session(file, "function foo() {}");
QVERIFY(session.ast());
qDebug() << session.language();
QCOMPARE(session.language(), QmlJS::Document::JavaScriptLanguage);
ContextBuilder builder;
builder.setParseSession(&session);
ReferencedTopDUContext top = builder.build(file, session.ast());
QVERIFY(top);
}
#include "testcontexts.moc"
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