MarcoEidinger/SwiftPlantUML-Xcode-Extension

Cannot define nested types in extensions and cannot extend nested types

AlmightyBeaver opened this issue · 2 comments

Hi, I tried to create a diagram from some code where extensions are used. The created PlantUML code does not work.
Here is a minimal example:

class ClassA { }

extension ClassA {
    public final class ClassB: ObservableObject {
        var string: String = ""
        init() { }
        func test1() { }
    }
}


extension ClassA.ClassB {
    func test2() { }
}

In my original code the class ClassA { } is also in a different file, but it seems that doesn't matter.

The code above is converted to the following PlantUML code:

@startuml
' STYLE START

skinparam shadowing false
' STYLE END


class "ClassA" as ClassA << (C, DarkSeaGreen) >> {  
}
class "ClassA" as ClassA0 << (X, Orchid) extension >> {  
}
class "ClassA.ClassB" as ClassA.ClassB << (X, Orchid) extension >> { 
  ~test2() 
}

ClassA <.. ClassA0 : ext
@enduml

Planttext will show the error Bad hierarchy for class ClassA.ClassB for the code.

Thanks for reporting this and for sharing this minimal example. The example was extremely helpful to understand the problems.

I see two issues that need to be addressed in the underlying https://github.com/MarcoEidinger/SwiftPlantUML implementation:

  1. Nested types introduced in extensions are not yet supported
  2. Extending a nested type is not supported

Not sure when I will be able to fix those but I will put those on my list

Thank you! Also for the great work you do with SwiftPlantUML :)