KDE/kdevelop/languages/java

Adam Treat treat at kde.org
Tue Jul 25 20:27:48 UTC 2006


SVN commit 566340 by treat:

And we're parsing java files... :)

All you need to start parsing java files is to change
the line PrimaryLanguage=C++ in the global project file
to PrimaryLanguage=Java.

Right now the codemodel is not hooked up and the AST is 
not integrated.

I don't think CMake knows how to deal with .ll files, so
add the .cc file instead.

The kdevelop-pg loads the _G_contents char array in a weird way.  Need
to change this so that it uses QByteArray or however the c++ parser
does it.

I commented out a few lines in java-io.cpp that were referencing main.cpp
these methods in main.cpp need to be moved into a separate file if we
want to keep them.

Next steps would be to integrate the AST so that it inherits KDevAST and then
we need to generate an actual codemodel that inherits KDevCodeModel.  Once
this is done, we'll be able to see the codemodel in the codeview :)

Cheers,Adam

CCMAIL:jpetso at gmx.at, kdevelop-devel at kdevelop.org


 M  +1 -2      CMakeLists.txt  
 M  +10 -12    javalanguagesupport.cpp  
 M  +7 -2      javalanguagesupport.h  
 A             parsejob.cpp   [License: LGPL (v2+)]
 A             parsejob.h   [License: LGPL (v2+)]
 M  +2 -1      parser/CMakeLists.txt  
 M  +2 -2      parser/java_io.cpp  


--- trunk/KDE/kdevelop/languages/java/CMakeLists.txt #566339:566340
@@ -9,8 +9,7 @@
 
 set(kdevjavalanguagesupport_PART_SRCS
     javalanguagesupport.cpp
-#     backgroundparser.cpp
-#     parsejob.cpp
+    parsejob.cpp
 #     codedelegate.cpp
 #     codeproxy.cpp
 )
--- trunk/KDE/kdevelop/languages/java/javalanguagesupport.cpp #566339:566340
@@ -28,14 +28,12 @@
 #include <kdevprojectmodel.h>
 #include <kdevdocumentcontroller.h>
 #include <kdevbackgroundparser.h>
-#include <kdevparsejob.h>
+#include "parsejob.h"
 
 #include "javalanguagesupport.h"
 
-// #include "parser/codemodel.h"
 // #include "codeproxy.h"
 // #include "codedelegate.h"
-// #include "backgroundparser.h"
 
 #include <kdebug.h>
 
@@ -51,6 +49,7 @@
         QLatin1String( "text/x-java" );
     m_mimetypes = types.split( "," );
 
+    m_memoryPool = new parser::memory_pool_type;
     //     m_codeProxy = new CodeProxy( this );
     //     m_codeDelegate = new CodeDelegate( this );
     //     m_backgroundParser = new BackgroundParser( this );
@@ -74,7 +73,9 @@
 }
 
 JavaLanguageSupport::~JavaLanguageSupport()
-{}
+{
+    delete m_memoryPool;
+}
 
 KDevCodeModel *JavaLanguageSupport::codeModel( const KUrl &url ) const
 {
@@ -105,13 +106,13 @@
 
 KDevParseJob *JavaLanguageSupport::createParseJob( const KUrl &url )
 {
-    return 0;
+    return new ParseJob( url, this, m_memoryPool );
 }
 
 KDevParseJob *JavaLanguageSupport::createParseJob( KDevDocument *document,
         KTextEditor::SmartRange *highlight )
 {
-    return 0;
+    return new ParseJob( document, highlight, this, m_memoryPool );
 }
 
 QStringList JavaLanguageSupport::mimeTypes() const
@@ -121,17 +122,14 @@
 
 void JavaLanguageSupport::documentLoaded( KDevDocument* file )
 {
-    kDebug() << k_funcinfo << endl;
     if ( supportsDocument( file ) )
-        kDebug() << file->url() << endl;
-/*        m_backgroundParser->addDocument( file->url(), file );*/
+        KDevApi::self() ->backgroundParser() ->addDocument( file->url(), file );
 }
 
 void JavaLanguageSupport::documentClosed( KDevDocument* file )
 {
-    Q_UNUSED( file );
-    //     if ( supportsDocument( file ) )
-    //         m_backgroundParser->removeDocumentFile( file );
+    if ( supportsDocument( file ) )
+        KDevApi::self() ->backgroundParser() ->removeDocumentFile( file );
 }
 
 void JavaLanguageSupport::documentActivated( KDevDocument* file )
--- trunk/KDE/kdevelop/languages/java/javalanguagesupport.h #566339:566340
@@ -22,11 +22,16 @@
 
 #include <kdevlanguagesupport.h>
 
+#include "parser/java.h"
+#include "parser/decoder.h"
+
+#include <kdebug.h>
+
+using namespace java;
 // class CodeModel;
 // class CodeProxy;
 // class CodeDelegate;
 // class CodeAggregate;
-// class BackgroundParser;
 
 class JavaLanguageSupport : public KDevLanguageSupport
 {
@@ -54,9 +59,9 @@
 
 private:
     QStringList m_mimetypes;
+    parser::memory_pool_type *m_memoryPool;
 //     CodeProxy *m_codeProxy;
 //     CodeDelegate *m_codeDelegate;
-//     BackgroundParser *m_backgroundParser;
 //     CppHighlighting *m_highlights;
 };
 
--- trunk/KDE/kdevelop/languages/java/parser/CMakeLists.txt #566339:566340
@@ -9,7 +9,8 @@
     decoder.cpp
     java.cpp
     java_lookahead.cpp
-    java_lexer.ll
+#Hmm, I don't think cmake knows how to deal with ll file
+    java_lexer.cc
     java_io.cpp
 )
 
--- trunk/KDE/kdevelop/languages/java/parser/java_io.cpp #566339:566340
@@ -84,7 +84,7 @@
 // custom error recovery
 bool parser::yy_expected_token(int /*expected*/, std::size_t where, char const *name)
 {
-  print_token_environment(this);
+//   print_token_environment(this);
   report_problem(
     parser::error,
     std::string("Expected token ``") + name
@@ -96,7 +96,7 @@
 
 bool parser::yy_expected_symbol(int /*expected_symbol*/, char const *name)
 {
-  print_token_environment(this);
+//   print_token_environment(this);
   report_problem(
     parser::error,
     std::string("Expected symbol ``") + name




More information about the KDevelop-devel mailing list