yoshimkd / swift-auto-diagram

A Ruby script that scans all swift code from the specified folders and files and automatically generates an entity diagram (similar to a class diagram) which can be viewed in a browser.
MIT License
496 stars 57 forks source link

The script don't show the extensions. #23

Closed jaouahbi closed 5 years ago

jaouahbi commented 5 years ago

I have created a demo project with a extension of AppDelegate and some other classes and its extensions, and the script don't show the extensions.

extension AppDelegate {

var some : String {
    return "some"
}

}

class ClassA0 {

var a1 : String?
var a2 : String?

func doItInBase() -> Bool {
    return true
}

}

class ClassA1 : ClassA0 {

var ad1 : String?
var ad2 : String?

override func doItInBase() -> Bool {
    return true
}

}

class ClassB1 {

var b1 : String?
var b2 : String?

}

class ClassC1 : ClassA1 { override func doItInBase() -> Bool { return super.doItInBase() }

}

extension ClassA0 {

var ab1 : String? {
    return nil
}
var ab2 : String? {
    return nil
}

func doItInBase2() -> Bool {
    return true
}
func doItInBase3() -> Bool {
    return true
}

}

extension ClassA1 {

var a1ext1 : String? {
    return nil
}
var a1ext2 : String? {
    return nil
}

}

extension ClassA1 {

var a1ext3 : String? {
    return nil
}
var a1ext4 : String? {
    return nil
}
func doIt() -> Bool {
    return true
}

}

extension ClassB1 {

var b1ext1 : String? {
    return nil
}
var b1ext2 : String? {
    return nil
}

}

extension ClassB1 {

var b1ext3 : String? {
    return nil
}
var b1ext4 : String? {
    return nil
}
func doIt() -> Bool {
    return true
}

}

Command used: ruby generateEntityDiagram.rb -v /swift-auto-diagram_bug/swift-auto-diagram_bug

Output: output_bug

jaouahbi commented 5 years ago

This commit break the extensions

https://github.com/yoshimkd/swift-auto-diagram/commit/546c42a95c51423a2a3ad257f199a39136b99def

the old one regular expression works fine with extensions.

extensionRegex = /extension\s+(?!(var|open|public|internal|fileprivate|private|func))(?\w+)(?([^{])?)(?{(?>[^{}]|\g)})/

yoshimkd commented 5 years ago

Hello @jaouahbi,

Thank you for your interest in the project and reporting this issue. I committed a fix for it on master: https://github.com/yoshimkd/swift-auto-diagram/commit/ddaf2c4320fbeb5cddbfd0f2822fe6fc85d4ed9c. Let me know if this fixes the problem for you as well.

Best Regards, Jovan

jaouahbi commented 5 years ago

Works perfect, btw i have found other errors, when I manage to reproduce them correctly and locate their source, I will let you know