| Summary: | java import - importing interfaces - absent visibility treated as package instead of public | ||
|---|---|---|---|
| Product: | [Applications] umbrello | Reporter: | JP Fournier <jfournier121> | 
| Component: | general | Assignee: | Umbrello Development Group <umbrello-devel> | 
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Slackware | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
| Attachments: | patch to fix interface visibility problem | ||
| Created attachment 17123 [details]
patch to fix interface visibility problem
diff -c svn/kdesdk/umbrello/umbrello/codeimport/
kdesdk/umbrello/umbrello/codeimport/ > interfacevis.diffSVN commit 568047 by okellogg: Apply attachment 121723 [details] from JP Fournier. Note that this goes to trunk because the 3.5 branch is currently frozen for release. BUG:131327 M +6 -0 ChangeLog M +12 -6 umbrello/codeimport/javaimport.cpp M +5 -0 umbrello/codeimport/javaimport.h --- trunk/KDE/kdesdk/umbrello/ChangeLog #568046:568047 @@ -1,3 +1,9 @@ +Version 2.0 + +* Bugs/wishes from http://bugs.kde.org: +* Java import - importing interfaces - absent visibility treated as package + instead of public (131327) + Version 1.5.4 * Bugs/wishes from http://bugs.kde.org: --- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/javaimport.cpp #568046:568047 @@ -229,6 +229,11 @@ void JavaImport::parseFile(QString filename) { m_currentFileName= filename; m_imports.clear(); + // default visibility is Impl, unless we are an interface, then it is + // public for member vars and methods + m_defaultCurrentAccess = Uml::Visibility::Implementation; + m_currentAccess = m_defaultCurrentAccess; + NativeImportBase::parseFile(filename); } @@ -253,9 +258,6 @@ kError() << "importJava: unexpected: " << m_source[m_srcIndex] << endl; skipStmt(); } - // The default visibilty for java is implementation, since the absence - // of a modifier means package visibility (which maps to implementation). - m_currentAccess = Uml::Visibility::Implementation; return true; } if (keyword == "class" || keyword == "interface") { @@ -271,6 +273,10 @@ // change it. m_klass->setInterface(keyword == "interface"); m_isAbstract = m_isStatic = false; + // if no modifier is specified in an interface, then it means public + if ( m_klass->isInterface() ) { + m_defaultCurrentAccess = Uml::Visibility::Public; + } if (advance() == ";") // forward declaration return true; if (m_source[m_srcIndex] == "<") { @@ -466,8 +472,8 @@ m_isStatic, m_isAbstract, false /*isFriend*/, false /*isConstructor*/, m_comment); m_isAbstract = m_isStatic = false; - // Default visibility for java is implementation (package vis.) - m_currentAccess = Uml::Visibility::Implementation; + // reset the default visibility + m_currentAccess = m_defaultCurrentAccess; // At this point we do not know whether the method has a body or not. do { nextToken = advance(); @@ -526,7 +532,7 @@ nextToken = advance(); } // reset visibility to default - m_currentAccess = Uml::Visibility::Implementation; + m_currentAccess = m_defaultCurrentAccess; if (m_source[m_srcIndex] != ";") { kError() << "importJava: ignoring trailing items at " << name << endl; skipStmt(); --- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/javaimport.h #568046:568047 @@ -85,7 +85,12 @@ */ QStringList m_imports; + /** + * The current visibility for when the visibility is absent + */ + Uml::Visibility m_defaultCurrentAccess; + }; #endif SVN commit 569451 by okellogg:
Patch by JP Fournier fixes interface visibility problem (trunk: r568047)
CCBUG:131327
 M  +12 -6     javaimport.cpp  
 M  +5 -0      javaimport.h  
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeimport/javaimport.cpp #569450:569451
@@ -229,6 +229,11 @@
 void JavaImport::parseFile(QString filename) {
     m_currentFileName= filename;
     m_imports.clear();
+    // default visibility is Impl, unless we are an interface, then it is 
+    // public for member vars and methods
+    m_defaultCurrentAccess = Uml::Visibility::Implementation;
+    m_currentAccess = m_defaultCurrentAccess;
+
     NativeImportBase::parseFile(filename);
 }
 
@@ -253,9 +258,6 @@
             kdError() << "importJava: unexpected: " << m_source[m_srcIndex] << endl;
             skipStmt();
         }
-        // The default visibilty for java is implementation, since the absence
-        // of a modifier means package visibility (which maps to implementation).
-        m_currentAccess = Uml::Visibility::Implementation;
         return true;
     }
     if (keyword == "class" || keyword == "interface") {
@@ -271,6 +273,10 @@
         // change it.
         m_klass->setInterface(keyword == "interface");
         m_isAbstract = m_isStatic = false;
+        // if no modifier is specified in an interface, then it means public
+        if ( m_klass->isInterface() ) {
+            m_defaultCurrentAccess =  Uml::Visibility::Public;
+        }
         if (advance() == ";")   // forward declaration
             return true;
         if (m_source[m_srcIndex] == "<") {
@@ -466,8 +472,8 @@
                                    m_isStatic, m_isAbstract, false /*isFriend*/,
                                    false /*isConstructor*/, m_comment);
         m_isAbstract = m_isStatic = false;
-        // Default visibility for java is implementation (package vis.)
-        m_currentAccess = Uml::Visibility::Implementation;
+        // reset the default visibility
+        m_currentAccess = m_defaultCurrentAccess;
         // At this point we do not know whether the method has a body or not.
         do {
             nextToken = advance();
@@ -526,7 +532,7 @@
         nextToken = advance();
     }
     // reset visibility to default
-    m_currentAccess = Uml::Visibility::Implementation;
+    m_currentAccess = m_defaultCurrentAccess;
     if (m_source[m_srcIndex] != ";") {
         kdError() << "importJava: ignoring trailing items at " << name << endl;
         skipStmt();
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeimport/javaimport.h #569450:569451
@@ -85,7 +85,12 @@
      */
     QStringList m_imports;
 
+    /**
+     * The current visibility for when the visibility is absent
+     */
+    Uml::Visibility m_defaultCurrentAccess;
 
+
 };
 
 #endif
 | 
Version: svn 565677 (using KDE KDE 3.5.0) Installed from: Slackware Packages Compiler: gcc 3.4.4 OS: Linux When importing the class below, the methods are tagged as package visible, when they should be public: public interface Int7{ void update3(); void update2(); }