Skip to content

Conversation

@fichtelmann
Copy link

@fichtelmann fichtelmann commented Jul 28, 2023

I've added the implemented methods of a struct to the PUML output.
The visibility of fields and methods is also respected.

The output of my test file:

pub struct MyStruct {
    pub public_field: i32,
    private_field: i32,
    second_struct: SecondStruct,
}

impl MyStruct {
    pub fn new(public_field: i32, private_field: i32, second_struct: SecondStruct) -> Self {
        MyStruct {
            public_field,
            private_field,
            second_struct
        }
    }

    pub fn get_private_field(&self) -> i32 {
        self.private_field
    }

    fn increment_private_field(&mut self) {
        self.private_field += 1;
    }
}

pub struct SecondStruct {
    pub second_public_field: i32,
    second_private_field: i32,
}

impl SecondStruct {
    pub fn get_second_private_field(&self) -> i32 {
        self.second_private_field
    }
}
```

results in this PUML output now:

```puml
@startuml

class "MyStruct" {
    + public_field: i32
    - private_field: i32
    - second_struct: SecondStruct
    + new(public_field: i32, private_field: i32, second_struct: SecondStruct)
    + get_private_field()
    - increment_private_field()
}

class "SecondStruct" {
    + second_public_field: i32
    - second_private_field: i32
    + get_second_private_field()
}
"MyStruct" <-- "SecondStruct"



@enduml
```

Kay Fichtelmann added 2 commits July 28, 2023 10:15
The impl of a struct gets parsed too and add all the methods and their parameters to Entity.fields.
The visibility of fields and methods is respect in the PUML.
The Entity class was extended by a Visibility enum to assign the particular visibility by parsing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant