Commit 5dc0911c authored by Milian Wolff's avatar Milian Wolff

Cleanup: Put ast<->context mapping into ParseSession

parent b82bc0b8
......@@ -43,12 +43,12 @@ QualifiedIdentifier ContextBuilder::identifierForNode(QmlJS::AST::IdentifierProp
void ContextBuilder::setContextOnNode(QmlJS::AST::Node* node, DUContext* context)
{
m_astToContext.insert(node, context);
m_session->setContextOnNode(node, context);
}
DUContext* ContextBuilder::contextFromNode(QmlJS::AST::Node* node)
{
return m_astToContext.value(node, 0);
return m_session->contextFromNode(node);
}
void ContextBuilder::startVisiting(QmlJS::AST::Node* node)
......@@ -99,8 +99,3 @@ Editor* ContextBuilder::editor() const
{
return m_editor.data();
}
ContextBuilder::NodeToContextHash ContextBuilder::nodeToAstMapping() const
{
return m_astToContext;
}
......@@ -69,12 +69,8 @@ public:
Editor* editor() const;
typedef QHash<QmlJS::AST::Node*, KDevelop::DUContext*> NodeToContextHash;
NodeToContextHash nodeToAstMapping() const;
protected:
ParseSession* m_session;
NodeToContextHash m_astToContext;
bool m_mapAst; // make KDevelop::AbstractContextBuilder happy
QScopedPointer<Editor> m_editor; // make KDevelop::AbstractUseBuilder happy
......
......@@ -144,3 +144,13 @@ RangeInRevision ParseSession::editorFindRange(QmlJS::AST::Node* fromNode, QmlJS:
{
return locationsToRange(fromNode->firstSourceLocation(), toNode->lastSourceLocation());
}
void ParseSession::setContextOnNode(QmlJS::AST::Node* node, DUContext* context)
{
m_astToContext.insert(node, context);
}
DUContext* ParseSession::contextFromNode(QmlJS::AST::Node* node) const
{
return m_astToContext.value(node);
}
......@@ -114,9 +114,14 @@ public:
Q_UNUSED(use);
}
void setContextOnNode(QmlJS::AST::Node* node, KDevelop::DUContext* context);
KDevelop::DUContext* contextFromNode(QmlJS::AST::Node* node) const;
private:
KDevelop::IndexedString m_url;
QmlJS::Document::MutablePtr m_doc;
typedef QHash<QmlJS::AST::Node*, KDevelop::DUContext*> NodeToContextHash;
NodeToContextHash m_astToContext;
};
#endif // PARSESESSION_H
......@@ -23,11 +23,10 @@
using namespace KDevelop;
UseBuilder::UseBuilder(ParseSession* session, const ContextBuilder::NodeToContextHash& mapping)
UseBuilder::UseBuilder(ParseSession* session)
: UseBuilderBase()
{
m_session = session;
m_astToContext = mapping;
}
bool UseBuilder::visit(QmlJS::AST::IdentifierExpression* node)
......
......@@ -28,8 +28,7 @@ typedef KDevelop::AbstractUseBuilder<QmlJS::AST::Node, QmlJS::AST::IdentifierPro
class KDEVQMLJSDUCHAIN_EXPORT UseBuilder : public UseBuilderBase
{
public:
///TODO: cleanup manual passing of mapping, push into parse session
UseBuilder(ParseSession* session, const ContextBuilder::NodeToContextHash& mapping);
UseBuilder(ParseSession* session);
protected:
using Visitor::visit;
......
......@@ -68,7 +68,6 @@ void QmlJsParseJob::run()
context = DUChainUtils::standardContextForUrl(document().toUrl());
}
ContextBuilder::NodeToContextHash mapping;
if (session.ast()) {
QReadLocker parseLock(languageSupport()->language()->parseLock());
......@@ -78,7 +77,6 @@ void QmlJsParseJob::run()
DeclarationBuilder builder(&session);
context = builder.build(document(), session.ast(), context);
mapping = builder.nodeToAstMapping();
}
if (abortRequested()) {
......@@ -93,7 +91,7 @@ void QmlJsParseJob::run()
DUChain::self()->addDocumentChain(context);
} else if ( minimumFeatures() & TopDUContext::AllDeclarationsContextsAndUses ) {
// build uses
UseBuilder useBuilder(&session, mapping);
UseBuilder useBuilder(&session);
useBuilder.buildUses(session.ast());
}
......
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