Bug 131961 - java import : unable to import AzareusCore
Summary: java import : unable to import AzareusCore
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Slackware Linux
: NOR crash
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-06 18:29 UTC by JP Fournier
Modified: 2006-08-06 21:59 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
patch to track files already parsed (2.49 KB, patch)
2006-08-06 18:38 UTC, JP Fournier
Details

Note You need to log in before you can comment on or make changes to this bug.
Description JP Fournier 2006-08-06 18:29:50 UTC
Version:           1.5.4+ : svn 570324 (using KDE KDE 3.5.0)
Installed from:    Slackware Packages
Compiler:          gcc 
OS:                Linux

To stress test the java import I attempted to import com/aelitis/azureus/core/AzareusCore.java
from Azureus_2.4.0.2_source.zip available on sourceforge.

After 1/2 hour I killed it.  From the logs it appears that it is re-parsing the same files over and over again.  Each time a type needs to be resolved, the source file is reparsed, even it has already been parsed before.

Note quite a "crash" but close enough.

This is of no consequence for small imports, but for large dependency trees it is overly ineffcient.
Comment 1 JP Fournier 2006-08-06 18:38:45 UTC
Created attachment 17246 [details]
patch to track files already parsed

$ diff -c svn/kdesdk/umbrello/umbrello/codeimport/javaimport.cpp
kdesdk/umbrello/umbrello/codeimport/javaimport.cpp > trackAlreadyParsed.diff

- keep track of the files already parsed and don't reparse them over and over
again.	
- Time to import test file was 1 minute instead of quasi-inifinte.
Comment 2 Oliver Kellogg 2006-08-06 21:59:46 UTC
SVN commit 570457 by okellogg:

Attachment 17246 [details] from JP Fournier adds logic to keep track of files already
parsed to avoid gratuitous reparsing.
JP, I've added you as co-author to the javaimport.h, hope that's okay :)
BUG:131961


 M  +1 -0      ChangeLog  
 M  +12 -5     umbrello/codeimport/javaimport.cpp  
 M  +13 -0     umbrello/codeimport/javaimport.h  


--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #570456:570457
@@ -5,6 +5,7 @@
   instead of public (131327)
 * Python code generation not independent of diagram view (131790)
 * Java import - method parameter types not resolved correctly (131825)
+* Java import: unable to import AzareusCore (131961)
 
 Version 1.5.4
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeimport/javaimport.cpp #570456:570457
@@ -38,6 +38,7 @@
 }
 
 void JavaImport::initVars() {
+    m_parseDepth = 0;
     m_isStatic = false;
 }
 
@@ -130,19 +131,18 @@
 
 ///Spawn off an import of the specifed file
 void JavaImport::spawnImport( QString file ) {
-    static QStringList filesBeingParsed;
     // if the file is being parsed, don't bother
     //
-    if (filesBeingParsed.contains( file ) ) {
+    if (m_filesAlreadyParsed.contains( file ) ) {
         return;
     }
     if (QFile::exists(file)) {
           JavaImport importer;
           QStringList fileList;
           fileList.append( file );
-          filesBeingParsed.append( file );
+          m_filesAlreadyParsed.append( file );
           importer.importFiles( fileList ); 
-          filesBeingParsed.remove( file );
+
     }
 }
 
@@ -233,8 +233,15 @@
     // public for member vars and methods
     m_defaultCurrentAccess = Uml::Visibility::Implementation;
     m_currentAccess = m_defaultCurrentAccess;
-
+    m_parseDepth++;
     NativeImportBase::parseFile(filename);
+    m_parseDepth--;
+    if ( m_parseDepth <= 0 ) {
+        // if the user decides to clear things out and reparse, we need
+        // to honour the request, so reset things for next time.
+        m_filesAlreadyParsed.clear();
+        m_parseDepth = 0;
+    }
 }
 
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeimport/javaimport.h #570456:570457
@@ -18,6 +18,7 @@
 /**
  * Java code import
  * @author Oliver Kellogg
+ * @author JP Fournier
  * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
  */
 class JavaImport : public NativeImportBase {
@@ -86,6 +87,18 @@
     QStringList m_imports;
 
     /**
+     * Keep track of the files we have already parsed so we don't
+     * reparse the same ones over and over again.
+     */
+    QStringList m_filesAlreadyParsed;
+
+    /**
+     * Keep track of the parses so that the filesAlreadyParsed 
+     * can be reset when we're done.
+     */
+    int m_parseDepth;
+
+    /**
      * The current visibility for when the visibility is absent
      */
     Uml::Visibility m_defaultCurrentAccess;