[Uml-devel] kdesdk/umbrello/umbrello/classparser

Oliver Kellogg okellogg at users.sourceforge.net
Mon Jan 3 12:05:07 UTC 2005


CVS commit by okellogg: 

flushTemplateParams(): Factor from parseClassSpecifier().
parseElaboratedTypeSpecifier(): Reimplement from TreeParser.


  M +36 -17    cpptree2uml.cpp   1.18
  M +5 -1      cpptree2uml.h   1.9


--- kdesdk/umbrello/umbrello/classparser/cpptree2uml.cpp  #1.17:1.18
@@ -11,5 +11,12 @@
  ***************************************************************************/
 
+// own header
 #include "cpptree2uml.h"
+// qt/kde includes
+#include <qfileinfo.h>
+#include <qdir.h>
+#include <qregexp.h>
+#include <kdebug.h>
+// app includes
 #include "ast_utils.h"
 #include "urlutil.h"
@@ -23,8 +30,4 @@
 #include "../class.h"
 
-#include <kdebug.h>
-#include <qfileinfo.h>
-#include <qdir.h>
-
 CppTree2Uml::CppTree2Uml( const QString& fileName, ClassImport* store )
     : m_importer( store ), m_anon( 0 ), m_nsCnt( 0 ), m_clsCnt( 0 )
@@ -332,17 +335,5 @@ void CppTree2Uml::parseClassSpecifier( C
                                                  ast->comment() );
     UMLClass *klass = (UMLClass *)o;
-
-    if (m_templateParams.count()) {
-        Umbrello::NameAndType_ListIt it;
-        for (it = m_templateParams.begin(); it != m_templateParams.end(); ++it) {
-            const Umbrello::NameAndType &nt = *it;
-            kdDebug() << "CppTree2Uml::parseClassSpecifier: adding template param: "
-                      << nt.first << endl;
-            UMLTemplate *tmpl = klass->addTemplate(nt.first);
-            tmpl->setType(nt.second);
-        }
-        m_templateParams.clear();
-    }
-
+    flushTemplateParams(klass);
     if ( ast->baseClause() )
         parseBaseClause( ast->baseClause(), klass );
@@ -393,4 +384,17 @@ void CppTree2Uml::parseEnumSpecifier( En
 }
 
+void CppTree2Uml::parseElaboratedTypeSpecifier( ElaboratedTypeSpecifierAST* typeSpec )
+{
+    // This is invoked for forward declarations.
+    /// @todo Refine - Currently only handles class foward declarations.
+    ///              - Using typeSpec->text() is probably not good, decode
+    ///                the kind() instead.
+    QString text = typeSpec->text();
+    kdDebug() << "CppTree2Uml::parseElaboratedTypeSpecifier: text is " << text << endl;
+    text.remove(QRegExp("^class\\s+"));
+    UMLObject *o = m_importer->createUMLObject( Uml::ot_Class, text, m_currentNamespace[m_nsCnt] );
+    flushTemplateParams( static_cast<UMLClass*>(o) );
+}
+
 void CppTree2Uml::parseDeclaration( GroupAST* funSpec, GroupAST* storageSpec,
                                     TypeSpecifierAST* typeSpec, InitDeclaratorAST* decl )
@@ -603,2 +607,17 @@ QStringList CppTree2Uml::scopeOfDeclarat
     return scopeOfName( d->declaratorId(), startScope );
 }
+
+void CppTree2Uml::flushTemplateParams(UMLClass *klass) {
+    if (m_templateParams.count()) {
+        Umbrello::NameAndType_ListIt it;
+        for (it = m_templateParams.begin(); it != m_templateParams.end(); ++it) {
+            const Umbrello::NameAndType &nt = *it;
+            kdDebug() << "CppTree2Uml::parseClassSpecifier: adding template param: "
+                      << nt.first << endl;
+            UMLTemplate *tmpl = klass->addTemplate(nt.first);
+            tmpl->setType(nt.second);
+        }
+        m_templateParams.clear();
+    }
+}
+

--- kdesdk/umbrello/umbrello/classparser/cpptree2uml.h  #1.8:1.9
@@ -53,5 +53,5 @@ public:
     virtual void parseClassSpecifier( ClassSpecifierAST* );
     virtual void parseEnumSpecifier( EnumSpecifierAST* );
-    //virtual void parseElaboratedTypeSpecifier( ElaboratedTypeSpecifierAST* );  // use parent method
+    virtual void parseElaboratedTypeSpecifier( ElaboratedTypeSpecifierAST* );
 
     // non-overriding (locally added) methods
@@ -68,4 +68,8 @@ private:
     QStringList scopeOfName( NameAST* id, const QStringList& scope );
     QStringList scopeOfDeclarator( DeclaratorAST* d, const QStringList& scope );
+    /**
+     * Flush template parameters pending in m_templateParams to the klass.
+     */
+    void flushTemplateParams(UMLClass *klass);
 
 private:






More information about the umbrello-devel mailing list