Bug 416178 - Java import of incomplete source code
Summary: Java import of incomplete source code
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: importer (show other bugs)
Version: Git
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-12 17:55 UTC by Oliver Kellogg
Modified: 2020-01-12 21:17 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 2.30.2 (KDE Release 19.12.2)


Attachments
org-foo-bar.tar.gz (899 bytes, application/gzip)
2020-01-12 18:00 UTC, Oliver Kellogg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Kellogg 2020-01-12 17:55:45 UTC
SUMMARY

Umbrello can do better when importing incomplete Java sources

STEPS TO REPRODUCE
1. Unpack the attachment in an empty directory of your choice
2. In Umbrello select Code -> Active Language -> Java
3. In Umbrello select Code -> Import from Directory... and navigate to the
   directory where you unpacked the attachment, then press OK

OBSERVED RESULT

Umbrello opens a dialog:

" An object with the name foo already exists in the package org.
  Please enter a new name: "

EXPECTED RESULT

No such dialog interaction is needed.
Comment 1 Oliver Kellogg 2020-01-12 18:00:06 UTC
Created attachment 125066 [details]
org-foo-bar.tar.gz

The tarfile contains a file org/bar/util/UniqueKey.java
which has a line:

  public interface UniqueKey extends org.foo.notexist.NotAvailable {

However, the file org/foo/notexist/NotAvailable.java is not contained in the tarfile.
Comment 2 Oliver Kellogg 2020-01-12 18:34:01 UTC
Git commit 616c0ec319241b8742b2e88b356e66fd63ff7b3f by Oliver Kellogg.
Committed on 12/01/2020 at 18:14.
Pushed by okellogg into branch 'release/19.12'.

Optmization in JavaImport: Skip object creation for method "void" return

umbrello/codeimport/javaimport.cpp
- In function parseStmt(), on parsing a type name (of a member of class
  or interface, or return type an operation), call resolveClass only if
  typeName is not "void".

M  +1    -1    umbrello/codeimport/javaimport.cpp

https://invent.kde.org/kde/umbrello/commit/616c0ec319241b8742b2e88b356e66fd63ff7b3f
Comment 3 Oliver Kellogg 2020-01-12 18:34:01 UTC
Git commit f23904618a4f40d54092152614a0b1df37f0b5f8 by Oliver Kellogg.
Committed on 12/01/2020 at 18:33.
Pushed by okellogg into branch 'release/19.12'.

Improve creation of generalization with parent provided as string:

umbrello/codeimport/import_utils.cpp
- In function createGeneralization(UMLClassifier*, const QString&),
  if parentName contains a scope separator then
  - split the qualified name into its parts using the scope separator
    as the divider;
  - save the last element of the split list as className and pop that
    element off the list;
  - declare local variables `parent' and `current' of type UMLPackage*;
  - iterate over the list and create each package path segment using
    the 7 argument form of Import_Utils::createUMLObject();
  - on iterating, use the variables `parent' and `current' to track
    the UML packages created, such that the path segments are assembled
    with the proper hierarchical nesting;
  - after the package creation loop, create the className object using
    the 7 argument form of Import_Utils::createUMLObject() and using
    `parent' as the parent package.

M  +25   -1    umbrello/codeimport/import_utils.cpp

https://invent.kde.org/kde/umbrello/commit/f23904618a4f40d54092152614a0b1df37f0b5f8
Comment 4 Ralf Habacker 2020-01-12 20:02:42 UTC
(In reply to Oliver Kellogg from comment #3)
> Git commit f23904618a4f40d54092152614a0b1df37f0b5f8 by Oliver Kellogg.
> BUG:416178

This bug will not be in the list of "new Umbrello 2.30 features" (https://umbrello.kde.org/news.php#itemUmbrello230releasesavailable) if this line is missing.

FIXED-IN: 2.30.2 (KDE Release 19.12.2)
Comment 5 Oliver Kellogg 2020-01-12 21:16:30 UTC
(In reply to Ralf Habacker from comment #4)
> [...]
> This bug will not be in the list of "new Umbrello 2.30 features"
> (https://umbrello.kde.org/news.php#itemUmbrello230releasesavailable) if this
> line is missing.
> 
> FIXED-IN: 2.30.2 (KDE Release 19.12.2)

Eek, I forgot that. Thanks for adding it here in the PR.
Comment 6 Oliver Kellogg 2020-01-12 21:17:00 UTC
Git commit 8c1bfa64f1c822e2853e5f248a24a00adfda6ccb by Oliver Kellogg.
Committed on 12/01/2020 at 21:16.
Pushed by okellogg into branch 'release/19.12'.

Improvement to import of incomplete Java source code:

umbrello/model_utils.cpp
- In function findUMLObject, if object names match but types are
  different then add further test:
  If the source object is a Package or a Class and the found object has
  the class-or-package stereotype applied then return the found object.

M  +10   -0    umbrello/model_utils.cpp

https://invent.kde.org/kde/umbrello/commit/8c1bfa64f1c822e2853e5f248a24a00adfda6ccb