MarcoEidinger / SwiftPlantUML-Xcode-Extension

Xcode Extension for generating class diagrams from Swift code (powered by PlantUML)
https://github.com/MarcoEidinger/SwiftPlantUML
MIT License
432 stars 23 forks source link

Cannot define nested types in extensions and cannot extend nested types #26

Closed AlmightyBeaver closed 1 year ago

AlmightyBeaver commented 1 year ago

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.

MarcoEidinger commented 1 year ago

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

AlmightyBeaver commented 1 year ago

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