Bug 79648 - use KDevelop CodeModel for code import
Summary: use KDevelop CodeModel for code import
Status: RESOLVED DUPLICATE of bug 56943
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
: 92201 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-04-14 19:24 UTC by Jonathan Riddell
Modified: 2007-02-17 13:28 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Riddell 2004-04-14 19:24:30 UTC
Version:           1.2.90 (using KDE 3.2.1,  (testing/unstable))
Compiler:          gcc version 3.3.3 (Debian)
OS:          Linux (i686) release 2.4.24-xfs

With "53361 update code import code" closed for C++ it would be nice to be able to import all the other langauges that KDevelop has parsers for.
Comment 1 Oliver Kellogg 2004-04-14 21:08:53 UTC
In order to do this, it would probably be a good idea to
use the CodeModel and CodeModelTreeParser (see kdevelop/
lib/interfaces.)

That way, the parsers could remain mostly unchanged, and
we avoid having to work with different language specific
tree representations.

Added benefit: This moves us closer to Kdevelop.
Comment 2 Jonathan Riddell 2004-10-28 02:27:48 UTC
*** Bug 92201 has been marked as a duplicate of this bug. ***
Comment 3 Alan Ezust 2005-01-23 06:52:37 UTC
I see that umbrello is already using the treeparser class from kdevelop as the base class for parsing C++.

In umbrello, the derived class is called cpptree2uml as opposed to store_walker in kdevelop.

However, it seems that only the C++ import feature uses that, while the parsers for other languages are done some other way. 

I found the codemodel_treeparser in kdevelop source, but I can't find any other classes that use it. 

I was curious to see how Python is handled in Kdevelop, to see if I could at least add python support to umbrello. However, I can't find any C++ classes related to python that use the codemodel_treeparser.

There is a kde_inspect.py class which seems to permit some kind of introspection for python. I am not sure how that fits into the big picture though.

Comment 4 Oliver Kellogg 2005-01-23 21:21:56 UTC
> However, it seems that only the C++ import feature uses that
> [i.e. code model tree parser]
> while the parsers for other languages are done some other way.

I presume this is a TODO in Kdevelop. Alex, could you comment?
Comment 5 Oliver Kellogg 2005-02-03 19:30:38 UTC
Just in time for 1.4, we have code import for CORBA IDL.
Still very simple and does not yet use the Kdevelop CodeModel.
IDL import is enabled by selecting IDL as the active language.
Comment 6 Oliver Kellogg 2005-08-11 15:44:17 UTC
SVN commit 445642 by okellogg:

CCBUG:79648 - Add AdaImport. Still work in progress.


 M  +1 -0      Makefile.am  
 A             adaimport.cpp   [License: GPL (v2+)]
 A             adaimport.h   [License: GPL (v2+)]
 M  +2 -1      uml.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/Makefile.am #445641:445642
@@ -4,6 +4,7 @@
 umbrello_SOURCES = activitywidget.cpp \
 actor.cpp \
 actorwidget.cpp \
+adaimport.cpp \
 aligntoolbar.cpp \
 artifact.cpp \
 artifactwidget.cpp \
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/uml.cpp #445641:445642
@@ -50,6 +50,7 @@
 #include "infowidget.h"
 #include "cppimport.h"
 #include "idlimport.h"
+#include "adaimport.h"
 #include "docwindow.h"
 #include "codegenerator.h"
 #include "generatorinfo.h"
@@ -1415,7 +1416,7 @@
     if (firstFile.endsWith(".idl"))
         classImporter = new IDLImport();
     else if (firstFile.contains( QRegExp("\\.ad[sba]$") ))
-        /* classImporter = new AdaImport(); */;
+        classImporter = new AdaImport();
     else
         classImporter = new CppImport();  // the default.
     classImporter->importFiles(fileList);
Comment 7 Marc Collin 2005-12-30 06:38:38 UTC
that could be nice if we could import java code... and umbrello generate the class diagram
Comment 8 Oliver Kellogg 2006-01-01 01:47:06 UTC
SVN commit 492999 by okellogg: 
 
 Add Java code import (still work in progress.) 
 
  M  +1 -0      Makefile.am
  AM            javaimport.cpp   [License: GPL (v2+)]
  AM            javaimport.h   [License: GPL (v2+)]
  M  +5 -0      uml.cpp
Comment 9 Oliver Kellogg 2006-01-02 18:50:53 UTC
> ------- Additional Comment #3 From Alan Ezust 2005-01-23 06:52 -------  
> [...]
> However, it seems that only the C++ import feature uses that
> [i.e. code model tree parser]
> while the parsers for other languages are done some other way.

Currently those are hand written scanners. They are not even
"parsers" because no syntax tree is constructed.
That is possible because Umbrello uses only a fraction of the
entire grammar of a given language, only (a subset of) the
declarative statements.
Comment 10 Oliver Kellogg 2006-01-07 19:10:39 UTC
SVN commit 495324 by okellogg:

Add class PythonImport. Only imports classes and operations,
no attributes yet. Python people to the front ;)
CCBUG:79648


 M  +2 -0      Makefile.am  
 A             classimport.cpp   [License: no copyright GPL (v2+)]
 M  +5 -0      classimport.h  
 M  +2 -2      import_utils.cpp  
 A             pythonimport.cpp   [License: GPL (v2+)]
 A             pythonimport.h   [License: GPL (v2+)]


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/Makefile.am #495323:495324
@@ -17,6 +17,7 @@
 classifiercodedocument.cpp \
 classifierlistitem.cpp \
 classifierwidget.cpp \
+classimport.cpp \
 codeaccessormethod.cpp \
 codeblock.cpp \
 codeblockwithcomments.cpp \
@@ -73,6 +74,7 @@
 packagewidget.cpp \
 plugin.cpp \
 pluginloader.cpp \
+pythonimport.cpp \
 seqlinewidget.cpp \
 statewidget.cpp \
 stereotype.cpp \
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/classimport.h #495323:495324
@@ -36,6 +36,11 @@
      */
     virtual void importFiles(QStringList files) = 0;
 
+    /**
+     * Factory method.
+     */
+    static ClassImport *createImporterByFileExt(QString filename);
+
 };
 
 #endif
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/import_utils.cpp #495323:495324
@@ -118,10 +118,10 @@
         int isConst = name.contains(QRegExp("^const "));
         name.remove(QRegExp("^const\\s+"));
         QString typeName(name);
-        const int isAdorned = typeName.contains( QRegExp("[^\\w: ]") );
+        const int isAdorned = typeName.contains( QRegExp("[^\\w:\\. ]") );
         const int isPointer = typeName.contains('*');
         const int isRef = typeName.contains('&');
-        typeName.remove(QRegExp("[^\\w: ].*$"));
+        typeName.remove(QRegExp("[^\\w:\\. ].*$"));
         UMLObject *origType = umldoc->findUMLObject(typeName, Uml::ot_UMLObject, parentPkg);
         if (origType == NULL) {
             // Still not found. Create the stripped down type.
Comment 11 Oliver Kellogg 2007-02-17 09:57:46 UTC
At this point I'm not sure how much sense this would make.
Comment 12 Oliver Kellogg 2007-02-17 13:28:08 UTC

*** This bug has been marked as a duplicate of 56943 ***