List Info

Thread: DUChain How to




DUChain How to
user name
2007-07-22 02:36:53
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.h in 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 )
 {
  ; &nbsp; &nbsp; &nbsp; kDebug() << "###########--Adding document to parser--################" << endl;
-&nbsp;   ; &nbsp;  language()->backgroundParser()->addDocument(doc->url());
+ &nbsp; &nbsp; &nbsp;  BackgroundParser::self()->addDocument(doc->url());
 }
 PythonLanguageSupport::~PythonLanguageSupport()
&nbsp;{
Index: pythonparsejob.cpp
===================================================================
--- pythonparsejob.cpp&nbsp; (revision 689529)
+++ pythonparsejob.cpp&nbsp; (working copy)
-112,6 +112,7

 &nbsp; &nbsp; if ( matched )
   ;  {
+ &nbsp;   ; &nbsp; new ContextBuilder(m_session);
 ; &nbsp; &nbsp; &nbsp;  kDebug() << "----Parsing Succeded---"<<endl;//TODO: bind declarations to the code model
&nbsp; &nbsp;  }
 &nbsp; &nbsp; else
Index: parser/contextbuilder.h
===================================================================
--- parser/contextbuilder.h &nbsp; &nbsp; (revision 689529)
+++ parser/contextbuilder.h &nbsp; &nbsp; (working copy)
-29,6 +29,7

 #include <identifier.h >;
 #include <ducontext.h>
+#include <ksharedptr.h>

 namespace KDevelop
&nbsp;{
-38,6 +39,7
 class TopDUContext;
 }

+class PythonEditorIntegrator;
 class ParseSession;

&nbsp;namespace Python {
-45,11 +47,14
 &nbsp; &nbsp; typedef KSharedPtr<LexedFile> LexedFilePointer;
&nbsp;}

+using namespace python;
+
 class ContextBuilder: public python::default_visitor
 {

 public:
 ; &nbsp;  ContextBuilder(ParseSession* session);
+ &nbsp;  ContextBuilder(PythonEditorIntegrator* editor);

  ; &nbsp; virtual ~ContextBuilder ();

-68,9 +73,11
 &nbsp; &nbsp; &nbsp;   return m_encountered.contains(item);
  ; &nbsp; }

  ; virtual void openContext(KDevelop:UContext* newContext);
+// ; &nbsp;  virtual void openContext(KDevelop:UContext* newContext);
+//
+//&nbsp;   ; virtual void closeContext();

-&nbsp; &nbsp; virtual void closeContext();
+&nbsp; &nbsp; PythonEditorIntegrator* m_editor;

 &nbsp; &nbsp; QSet<KDevelop:UChainBase*> m_encountered;
   ;  QStack<KDevelop:UContext*&gt; m_contextStack;
Index: parser/parsesession.h
===================================================================
--- parser/parsesession.h  ; &nbsp; &nbsp; (revision 689529)
+++ parser/parsesession.h  ; &nbsp; &nbsp; (working copy)
-26,7 +26,10
 #include <QtCore/QByteArray>

 ;#include <python_parser.h&gt;
+#include < ksharedptr.h>;
+#include <ktexteditor/cursor.h>

+class LexedFile;
 using namespace python;

&nbsp;class ParseSession
Index: parser/contextbuilder.cpp
===================================================================
--- parser/contextbuilder.cpp &nbsp; (revision 0)
+++ parser/contextbuilder.cpp &nbsp; (revision 0)
-0,0 +1,24
+#include <contextbuilder.h&gt;
+#include <duchain.h>
+#include <duchainlock.h>
+
+
+using namespace KDevelop;
+using namespace python;
+
+ContextBuilder::ContextBuilder(ParseSession* session)
+{
+ &nbsp;  kDebug() << "=====Building DUChain===="<<endl;
+
+}
+
+ContextBuilder::~ContextBuilder ()
+{
+}
+
+TopDUContext* ContextBuilder::buildContexts(const Python::LexedFilePointer& file, ast_node *node, QList<DUContext*&gt;* includes)
+{
+ &nbsp;  TopDUContext* topLevelContext = 0;
+&nbsp; &nbsp; {
+ &nbsp;  }
+}
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt &nbsp;   ; (revision 689529)
+++ CMakeLists.txt &nbsp;   ; (working copy)
-22,6 +22,7
 &nbsp;   ${KDE4_INCLUDE_DIR}/threadweaver
 &nbsp; &nbsp; ${CMAKE_CURRENT_BINARY_DIR}
&nbsp; &nbsp;  ${KDEVPLATFORM_INCLUDE_DIR}/language/duchain
+ &nbsp;  ${KDEVPLATFORM_INCLUDE_DIR}/language/duchain/viewer
&nbsp; &nbsp;  parser
&nbsp;)

-49,10 +50,10
 &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; "${CMAKE_CURRENT_SOURCE_DIR}/parser/python.g"; ">rules" "2>;errors&quot;
 &nbsp; &nbsp;   ; &nbsp; &nbsp;  WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
&nbsp; &nbsp; &nbsp;   ; )
- &nbsp;   ; &nbsp; # Copy ruby_lexer.ll to the builddir, so that flex doesn't write out
+&nbsp; &nbsp; &nbsp;   # Copy python_lexer.ll to the builddir, so that flex doesn't write out
   ; &nbsp; &nbsp;  # absolute paths in the generated file when we pass them as arguments.
 &nbsp; &nbsp; &nbsp; &nbsp; # In short, I don't want stuff like
-&nbsp; &nbsp;   ;  # '#line 2 "/home/kde/build/.../ruby_lexer.cpp&quot; in SVN.
+&nbsp; &nbsp; &nbsp; &nbsp; # '#line 2 "/home/kde/build/.../python_lexer.cpp&quot; in SVN.
 ; &nbsp; &nbsp; &nbsp;  add_custom_command(
&nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp; OUTPUT&nbsp; "${CMAKE_CURRENT_BINARY_DIR}/python_lexer.ll";
 &nbsp;   ; &nbsp; &nbsp; &nbsp;  MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/parser/python_lexer.ll"
-93,6 +94,7
 &nbsp; &nbsp; pythonlanguagesupport.cpp
   ;  pythonparsejob.cpp
&nbsp; &nbsp;  parser/parsesession.cpp
+ &nbsp;  parser/contextbuilder.cpp
&nbsp; &nbsp;  ${parser_SRCS} ${parser_STAT_SRCS}
&nbsp;)



--
Regards,
Piyush Verma
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )