Commit 14f0d26b authored by Andrea Scarpino's avatar Andrea Scarpino

Add an EditorIntegrator class

parent 65f7ad7a
kde4_add_library(kdevqmljsduchain SHARED
helper.cpp
parsesession.cpp
editorintegrator.cpp
debugvisitor.cpp
contextbuilder.cpp
declarationbuilder.cpp
......
......@@ -19,13 +19,13 @@
#include "contextbuilder.h"
#include "parsesession.h"
using namespace KDevelop;
ContextBuilder::ContextBuilder()
: ContextBuilderBase()
, m_session()
, m_editor(0)
, m_mapAst(false)
{
}
......@@ -34,6 +34,16 @@ RangeInRevision ContextBuilder::editorFindRange(QmlJS::AST::Node* fromNode, QmlJ
return m_session->editorFindRange(fromNode, toNode);
}
void ContextBuilder::setEditor(EditorIntegrator *editor)
{
m_editor = editor;
}
EditorIntegrator* ContextBuilder::editor() const
{
return m_editor;
}
QualifiedIdentifier ContextBuilder::identifierForNode(QmlJS::AST::IdentifierPropertyName* node)
{
return QualifiedIdentifier(node->id.toString());
......
......@@ -24,10 +24,10 @@
#include <qmljs/parser/qmljsast_p.h>
#include <qmljs/qmljsdocument.h>
#include "duchainexport.h"
#include "parsesession.h"
#include "editorintegrator.h"
class ParseSession;
class EditorIntegrator;
typedef KDevelop::AbstractContextBuilder<QmlJS::AST::Node, QmlJS::AST::IdentifierPropertyName> ContextBuilderBase;
......@@ -48,11 +48,18 @@ public:
void setParseSession(ParseSession* session);
void setEditor(EditorIntegrator *editor);
EditorIntegrator* editor() const;
using Visitor::visit;
virtual bool visit(QmlJS::AST::FunctionDeclaration* node);
protected:
ParseSession* m_session;
EditorIntegrator* m_editor;
QHash<QmlJS::AST::Node*, KDevelop::DUContext*> m_astToContext;
bool m_mapAst; // make KDevelop::AbstractContextBuilder happy
};
#endif // CONTEXTBUILDER_H
/*************************************************************************************
* Copyright (C) 2013 by Andrea Scarpino <andrea@archlinux.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#include "editorintegrator.h"
EditorIntegrator::EditorIntegrator()
{
}
void EditorIntegrator::setParseSession(ParseSession *session)
{
m_session = session;
}
ParseSession* EditorIntegrator::parseSession() const
{
return m_session;
}
/*************************************************************************************
* Copyright (C) 2013 by Andrea Scarpino <andrea@archlinux.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#ifndef QMLJSEDITORINTEGRATOR_H
#define QMLJSEDITORINTEGRATOR_H
#include "parsesession.h"
class KDEVQMLJSDUCHAIN_EXPORT EditorIntegrator
{
public:
EditorIntegrator();
void setParseSession(ParseSession *session);
ParseSession* parseSession() const;
private:
ParseSession* m_session;
};
#endif // QMLJSEDITORINTEGRATOR_H
\ No newline at end of file
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