DUChain How to
Piyush
piyush.verma at gmail.com
Sun Jul 22 07:36:53 UTC 2007
I am working on implementing a DUchain for Python as a part of my SOC
project, and the work so far is available at
http://websvn.kde.org/trunk/playground/devtools/kdevelop4-extra-plugins/python/
I have found myself stuck for quite a while now, and here is the recent
patch. If you could look in the codes and help me move a few steps further i
can get on with the rest of the project easily.
The basic trouble that i am facing is with the implementation of the
contextbuilder header, as of now. The header is in the name
contextbuilder.hin the repository.
The Indentation blocks make up a context for Python, which can have as many
child contexts.
Index: pythonlanguagesupport.cpp
===================================================================
--- pythonlanguagesupport.cpp (revision 689529)
+++ pythonlanguagesupport.cpp (working copy)
@@ -66,7 +66,7 @@
void PythonLanguageSupport::documentChanged( KDevelop::IDocument* doc )
{
kDebug() << "###########--Adding document to
parser--################" << endl;
- language()->backgroundParser()->addDocument(doc->url());
+ BackgroundParser::self()->addDocument(doc->url());
}
PythonLanguageSupport::~PythonLanguageSupport()
{
Index: pythonparsejob.cpp
===================================================================
--- pythonparsejob.cpp (revision 689529)
+++ pythonparsejob.cpp (working copy)
@@ -112,6 +112,7 @@
if ( matched )
{
+ new ContextBuilder(m_session);
kDebug() << "----Parsing Succeded---"<<endl;//TODO: bind
declarations to the code model
}
else
Index: parser/contextbuilder.h
===================================================================
--- parser/contextbuilder.h (revision 689529)
+++ parser/contextbuilder.h (working copy)
@@ -29,6 +29,7 @@
#include <identifier.h>
#include <ducontext.h>
+#include <ksharedptr.h>
namespace KDevelop
{
@@ -38,6 +39,7 @@
class TopDUContext;
}
+class PythonEditorIntegrator;
class ParseSession;
namespace Python {
@@ -45,11 +47,14 @@
typedef KSharedPtr<LexedFile> LexedFilePointer;
}
+using namespace python;
+
class ContextBuilder: public python::default_visitor
{
public:
ContextBuilder(ParseSession* session);
+ ContextBuilder(PythonEditorIntegrator* editor);
virtual ~ContextBuilder ();
@@ -68,9 +73,11 @@
return m_encountered.contains(item);
}
- virtual void openContext(KDevelop::DUContext* newContext);
+// virtual void openContext(KDevelop::DUContext* newContext);
+//
+// virtual void closeContext();
- virtual void closeContext();
+ PythonEditorIntegrator* m_editor;
QSet<KDevelop::DUChainBase*> m_encountered;
QStack<KDevelop::DUContext*> m_contextStack;
Index: parser/parsesession.h
===================================================================
--- parser/parsesession.h (revision 689529)
+++ parser/parsesession.h (working copy)
@@ -26,7 +26,10 @@
#include <QtCore/QByteArray>
#include <python_parser.h>
+#include <ksharedptr.h>
+#include <ktexteditor/cursor.h>
+class LexedFile;
using namespace python;
class ParseSession
Index: parser/contextbuilder.cpp
===================================================================
--- parser/contextbuilder.cpp (revision 0)
+++ parser/contextbuilder.cpp (revision 0)
@@ -0,0 +1,24 @@
+#include <contextbuilder.h>
+#include <duchain.h>
+#include <duchainlock.h>
+
+
+using namespace KDevelop;
+using namespace python;
+
+ContextBuilder::ContextBuilder(ParseSession* session)
+{
+ kDebug() << "=====Building DUChain===="<<endl;
+
+}
+
+ContextBuilder::~ContextBuilder ()
+{
+}
+
+TopDUContext* ContextBuilder::buildContexts(const Python::LexedFilePointer&
file, ast_node *node, QList<DUContext*>* includes)
+{
+ TopDUContext* topLevelContext = 0;
+ {
+ }
+}
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt (revision 689529)
+++ CMakeLists.txt (working copy)
@@ -22,6 +22,7 @@
${KDE4_INCLUDE_DIR}/threadweaver
${CMAKE_CURRENT_BINARY_DIR}
${KDEVPLATFORM_INCLUDE_DIR}/language/duchain
+ ${KDEVPLATFORM_INCLUDE_DIR}/language/duchain/viewer
parser
)
@@ -49,10 +50,10 @@
"${CMAKE_CURRENT_SOURCE_DIR}/parser/python.g" ">rules"
"2>errors"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
- # Copy ruby_lexer.ll to the builddir, so that flex doesn't write
out
+ # Copy python_lexer.ll to the builddir, so that flex doesn't write
out
# absolute paths in the generated file when we pass them as
arguments.
# In short, I don't want stuff like
- # '#line 2 "/home/kde/build/.../ruby_lexer.cpp" in SVN.
+ # '#line 2 "/home/kde/build/.../python_lexer.cpp" in SVN.
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/python_lexer.ll"
MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/parser/python_lexer.ll"
@@ -93,6 +94,7 @@
pythonlanguagesupport.cpp
pythonparsejob.cpp
parser/parsesession.cpp
+ parser/contextbuilder.cpp
${parser_SRCS} ${parser_STAT_SRCS}
)
--
Regards,
Piyush Verma
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20070722/c1c1e636/attachment.html>
More information about the KDevelop-devel
mailing list