I am working on implementing a DUchain for Python as a part of my SOC project, and the work so far is available at <a href="http://websvn.kde.org/trunk/playground/devtools/kdevelop4-extra-plugins/python/">http://websvn.kde.org/trunk/playground/devtools/kdevelop4-extra-plugins/python/
</a><br>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.<br>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.h in the repository.<br>The Indentation blocks make up a context for Python, which can have as many child contexts.<br><br>Index: pythonlanguagesupport.cpp<br>===================================================================
<br>--- pythonlanguagesupport.cpp   (revision 689529)<br>+++ pythonlanguagesupport.cpp   (working copy)<br>@@ -66,7 +66,7 @@<br> void PythonLanguageSupport::documentChanged( KDevelop::IDocument* doc )<br> {<br>         kDebug() << "###########--Adding document to parser--################" << endl;
<br>-        language()->backgroundParser()->addDocument(doc->url());<br>+        BackgroundParser::self()->addDocument(doc->url());<br> }<br> PythonLanguageSupport::~PythonLanguageSupport()<br> {<br>Index: 
pythonparsejob.cpp<br>===================================================================<br>--- pythonparsejob.cpp  (revision 689529)<br>+++ pythonparsejob.cpp  (working copy)<br>@@ -112,6 +112,7 @@<br><br>     if ( matched )
<br>     {<br>+        new ContextBuilder(m_session);<br>         kDebug() << "----Parsing Succeded---"<<endl;//TODO: bind declarations to the code model<br>     }<br>     else<br>Index: parser/contextbuilder.h
<br>===================================================================<br>--- parser/contextbuilder.h     (revision 689529)<br>+++ parser/contextbuilder.h     (working copy)<br>@@ -29,6 +29,7 @@<br><br> #include <identifier.h
><br> #include <ducontext.h><br>+#include <ksharedptr.h><br><br> namespace KDevelop<br> {<br>@@ -38,6 +39,7 @@<br> class TopDUContext;<br> }<br><br>+class PythonEditorIntegrator;<br> class ParseSession;<br>
<br> namespace Python {<br>@@ -45,11 +47,14 @@<br>     typedef KSharedPtr<LexedFile> LexedFilePointer;<br> }<br><br>+using namespace python;<br>+<br> class ContextBuilder: public python::default_visitor<br> {<br><br>
 public:<br>     ContextBuilder(ParseSession* session);<br>+    ContextBuilder(PythonEditorIntegrator* editor);<br><br>     virtual ~ContextBuilder ();<br><br>@@ -68,9 +73,11 @@<br>         return m_encountered.contains(item);
<br>     }<br><br>-    virtual void openContext(KDevelop::DUContext* newContext);<br>+//     virtual void openContext(KDevelop::DUContext* newContext);<br>+//<br>+//     virtual void closeContext();<br><br>-    virtual void closeContext();
<br>+    PythonEditorIntegrator* m_editor;<br><br>     QSet<KDevelop::DUChainBase*> m_encountered;<br>     QStack<KDevelop::DUContext*> m_contextStack;<br>Index: parser/parsesession.h<br>===================================================================
<br>--- parser/parsesession.h       (revision 689529)<br>+++ parser/parsesession.h       (working copy)<br>@@ -26,7 +26,10 @@<br> #include <QtCore/QByteArray><br><br> #include <python_parser.h><br>+#include <
ksharedptr.h><br>+#include <ktexteditor/cursor.h><br><br>+class LexedFile;<br> using namespace python;<br><br> class ParseSession<br>Index: parser/contextbuilder.cpp<br>===================================================================
<br>--- parser/contextbuilder.cpp   (revision 0)<br>+++ parser/contextbuilder.cpp   (revision 0)<br>@@ -0,0 +1,24 @@<br>+#include <contextbuilder.h><br>+#include <duchain.h><br>+#include <duchainlock.h><br>
+<br>+<br>+using namespace KDevelop;<br>+using namespace python;<br>+<br>+ContextBuilder::ContextBuilder(ParseSession* session)<br>+{<br>+    kDebug() << "=====Building DUChain===="<<endl;<br>+<br>+}
<br>+<br>+ContextBuilder::~ContextBuilder ()<br>+{<br>+}<br>+<br>+TopDUContext* ContextBuilder::buildContexts(const Python::LexedFilePointer& file, ast_node *node, QList<DUContext*>* includes)<br>+{<br>+    TopDUContext* topLevelContext = 0;
<br>+    {<br>+    }<br>+}<br>Index: CMakeLists.txt<br>===================================================================<br>--- CMakeLists.txt      (revision 689529)<br>+++ CMakeLists.txt      (working copy)<br>@@ -22,6 +22,7 @@
<br>     ${KDE4_INCLUDE_DIR}/threadweaver<br>     ${CMAKE_CURRENT_BINARY_DIR}<br>     ${KDEVPLATFORM_INCLUDE_DIR}/language/duchain<br>+    ${KDEVPLATFORM_INCLUDE_DIR}/language/duchain/viewer<br>     parser<br> )<br><br>@@ -49,10 +50,10 @@
<br>                     "${CMAKE_CURRENT_SOURCE_DIR}/parser/python.g" ">rules" "2>errors"<br>             WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"<br>         )<br>-        # Copy ruby_lexer.ll to the builddir, so that flex doesn't write out
<br>+        # Copy python_lexer.ll to the builddir, so that flex doesn't write out<br>         # absolute paths in the generated file when we pass them as arguments.<br>         # In short, I don't want stuff like
<br>-        # '#line 2 "/home/kde/build/.../ruby_lexer.cpp" in SVN.<br>+        # '#line 2 "/home/kde/build/.../python_lexer.cpp" in SVN.<br>         add_custom_command(<br>             OUTPUT  "${CMAKE_CURRENT_BINARY_DIR}/python_lexer.ll"
<br>             MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/parser/python_lexer.ll"<br>@@ -93,6 +94,7 @@<br>     pythonlanguagesupport.cpp<br>     pythonparsejob.cpp<br>     parser/parsesession.cpp<br>+    parser/contextbuilder.cpp
<br>     ${parser_SRCS} ${parser_STAT_SRCS}<br> )<br><br><br><br>-- <br>Regards,<br>Piyush Verma<br>