Variable passing goes ackward

0 votes
asked Feb 4, 2016 in bug by anonymous

Hi,

If I define a variable:

!define ENTITY_NAME Order

And I pass this into a macro:

!definelong ENTITY(NAME)
    class NAME
    NAME --|> Illuminate.Database.Eloquent.Model : extends
    NAME : #fillable : array
!enddefinelong

ENTITY(ENTITY_NAME)

It goes OK.

But if the macro has this signature:

!definelong CONTROLLER(NAME)
    NAME##Controller -up---|> App.Http.Controllers.Controller : extends
    NAME##Controller : +NAME
    NAME##Controller : +__construct( NAME##RepositoryInterface )
    NAME##Controller : +index()
    NAME##Controller : +create()
    NAME##Controller : +store()
    NAME##Controller : +show()
    NAME##Controller : +edit()
    NAME##Controller : +update()
    NAME##Controller : +destroy()
!enddefinelong

CONTROLLER(ENTITY_NAME)

I get unexpected results similar to:
 

Order##RepositoryInterface

or

ENTITY_NAMERepositoryInterface

Both are undesired and not to work with.

I hope you can help.

Thanks.

 

1 Answer

0 votes
answered Feb 4, 2016 by plantuml (134,510 points)
 
Best answer

Hello,

Thanks for the report. Which version of PlantUML are you using ?

With last version, the following example:

@startuml

!definelong CONTROLLER(NAME)
    NAME##Controller -up---|> App.Http.Controllers.Controller : extends
    NAME##Controller : +NAME
    NAME##Controller : +__construct( NAME##RepositoryInterface )
    NAME##Controller : +index()
    NAME##Controller : +create()
    NAME##Controller : +store()
    NAME##Controller : +show()
    NAME##Controller : +edit()
    NAME##Controller : +update()
    NAME##Controller : +destroy()
!enddefinelong

CONTROLLER(FOO)
CONTROLLER(NAME)

@enduml

prints as:

which looks ok.

Could you considere upgrading ?

commented Feb 5, 2016 by anonymous
Actually, I use PHP Storm and it's PlantUML integration plugin. The plugin version is 1.8.1 and it supports 8027.

I hope this plugin will keep up with the latest and greatest of PlantUML.
commented Feb 5, 2016 by plantuml (134,510 points)
There is something easy you can do : download the last version of plantuml.jar from http://plantuml.com/download.html

Quit PHP Storm, then copy this file and erase the existing plantuml.jar file from PHP Storm plugin with this newer version .You can make a backup copy just-in-case, but this should really work after a restart.
commented Feb 5, 2016 by anonymous
Hmmm.... I've done like you suggested. PHP Storm does not fail, so the trick works.

But, the result is still not desired.

I'll explain some more. Maybe you can figure this out.

I have a config.iuml and there I define ENTITY_NAME:

!define ENTITY_NAME Order

In another file I include this config.iuml.

I defined the macro, and the macro is working. Except the part where I inject the parameter.

If I now do this:

CONTROLLER(ENTITY_NAME)

It will show the diagram but with ENTITY_NAMEController, ENTITY_NAMERepositoryInterface etc.

If I do this:

CONTROLLER(ENTITY_NAME##), I get almost what I desire:

Order##Controller and Order##RepositoryInterface etc. But it throws an error about that.

If I use just one # I get similar results, but with one # (duh). So, it translates the ENTITY_NAME correctly, only it does not like the ##.

So, it is actually somewhere in the middle.

To reproduce macros.iuml:

@startuml

!definelong CONTROLLER(NAME)
    NAME##Controller -up---|> App.Http.Controllers.Controller : extends
    NAME##Controller : +NAME
    NAME##Controller : +__construct( NAME##RepositoryInterface )
    NAME##Controller : +index()
    NAME##Controller : +create()
    NAME##Controller : +store()
    NAME##Controller : +show()
    NAME##Controller : +edit()
    NAME##Controller : +update()
    NAME##Controller : +destroy()
!enddefinelong

@enduml

config.iuml :

@startuml

!define ENTITY_NAME Order

@enduml

controller.iuml :

@startuml

!include config.iuml
!include macros.iuml

CONTROLLER(ENTITY_NAME)

@enduml
commented Feb 5, 2016 by plantuml (134,510 points)
Ok.
The situation is more complex than expected.
First, I suggest that we create a single file that shows the issue.
The issue is not related to include, but is related to macro definition order.

Do you agree that the issue is that the two following examples did not give the same result:

@startuml
!definelong CONTROLLER(NAME)
    NAME##Controller -up---|> App.Http.Controllers.Controller : extends
    NAME##Controller : +NAME
    NAME##Controller : +__construct( NAME##RepositoryInterface )
    NAME##Controller : +index()
!enddefinelong
!define ENTITY_NAME Order

CONTROLLER(ENTITY_NAME);
@enduml

and

@startuml
!define ENTITY_NAME Order
!definelong CONTROLLER(NAME)
    NAME##Controller -up---|> App.Http.Controllers.Controller : extends
    NAME##Controller : +NAME
    NAME##Controller : +__construct( NAME##RepositoryInterface )
    NAME##Controller : +index()
!enddefinelong

CONTROLLER(ENTITY_NAME);
@enduml

Thanks!
...