bafolts / tplant

Typescript to plantuml
https://segmentationfaults.com/tplant/default.html
GNU General Public License v3.0
266 stars 34 forks source link

Problem parsing namespaces #81

Closed rugoncalves closed 2 years ago

rugoncalves commented 2 years ago

Problem When a namespace defines several namespaces, the output file is just the first namespace, and everything else is ignored.

Scenario Imagine defining a namespace that contains other namespaces until it has the class:

namespace very.special {
  export class Greeter {
    greeting: string;
    prefix: string = "Hello, ";
    constructor(message: string) {
      this.greeting = message;
    }
    set prefix(prefix: string) {
      this.prefix = prefix;
    }
    greet(prefix: string = "Foo"): string;
    greet(): string {
      return this.prefix + this.greeting;
    }
  }
}

When running the command line: tplant --input test/Playground/Classes/*.ts --output test/Playground/testmultinamespace.svg

The output is the following: image

All the code that is analyzed before this pattern gets added to the SVG, but after this pattern, nothing else is added.

bafolts commented 2 years ago

What is the expected output with this input? I believe the issue here is the period is unexpected in the namespace name.

rugoncalves commented 2 years ago

The expected output is the same as the output of the non-abbreviated form:

namespace very {
  namespace special {
    export class Greeter {
      greeting: string;
      prefix: string = "Hello, ";
      constructor(message: string) {
        this.greeting = message;
      }
      set prefix(prefix: string) {
        this.prefix = prefix;
      }
      greet(prefix: string = "Foo"): string;
      greet(): string {
        return this.prefix + this.greeting;
      }
    }
  }
}

That is: image

Since namespace very.special { is the abbreviation form of

namespace very {
  namespace special {

Thank you for the follow up!