Book a Demo

Author Topic: classBaseName empty (set parent with ctrl+i)  (Read 4680 times)

Niy

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
classBaseName empty (set parent with ctrl+i)
« on: December 15, 2011, 01:55:21 am »
Hi evryone,

I'm using EA 8.0.864 and currently trying to get some custom code generation templates to work.

My problem is, that %classBaseName% is empty for a stereotype: typedef class for which I set the parent using ctrl+i.

Quote
classBaseName
Type Hierarchy dialog: Class Name (for use where no connector exists between child and base Classes).
(%classHasParent% is not true, I did the check ^^)

Well... what am I doing wrong?

Greetz

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: classBaseName empty (set parent with ctrl+i)
« Reply #1 on: December 15, 2011, 08:52:08 am »
Hi yourself Greetz,

This is a really long shot, so don't spend a lot of time if it does not work, but...

Have you saved your model between the ctrl+i operation and running the template? If not, try saving it manually and then running the code. If that works, try forcing a save in your macro before testing the base class.

My thinking - what there is of it - is that making changes to entities via the API has no effect until you perform an Update() on the entity. This forces the model to update. Until that occurs other code cannot 'see' the change. API calls will query the model, which is not yet 'aware' of the change. A similar situation happens with collections until a Refresh() is done. These two situations are the root causes of many hard to diagnose bugs. Testing them first can save a lot of hair pulling.

David
No, you can't have it!

Niy

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: classBaseName empty (set parent with ctrl+i)
« Reply #2 on: December 16, 2011, 02:33:48 am »
Thanks --  it's the long shot ;-)
saved and reloaded and tryed again.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: classBaseName empty (set parent with ctrl+i)
« Reply #3 on: December 16, 2011, 08:14:27 am »
Maybe you should start by providing your templates (or the relevant parts of them) here so that we can see what you are doing wrong.

Niy

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: classBaseName empty (set parent with ctrl+i)
« Reply #4 on: December 16, 2011, 08:48:29 pm »
I don't think that the code is the problem, but here is my testcode:
Code: [Select]
$parent=%list="ClassBase" @separator=","%
$commaPos = %FIND($parent, ",")%
%if $commaPos != "-1"%
$parent = %LEFT($parent, $commaPos)%
%endIf%
%if $parent == ""%
/** Parentlist empty*/
%endif%
%if classHasParent != "T"%
/** classHasParent is not true */
%endIf%
%if  classBaseName == ""%
/** classBaseName is empty */
%endTemplate%

And the generated code gives all three "errormessages".

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: classBaseName empty (set parent with ctrl+i)
« Reply #5 on: December 19, 2011, 08:32:50 am »
Ok, classBaseName isn't going to work because you're not in a Class Base template.

What are the contents of your Class Base, and Linked Class Base templates. It's those templates that will determine what the list over Class Base will return.
« Last Edit: December 19, 2011, 04:55:11 pm by simonm »

Niy

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: classBaseName empty (set parent with ctrl+i)
« Reply #6 on: December 19, 2011, 08:12:00 pm »
Yeah I know that classBaseName should be empty -- but it was worth a try since the List was allways empty ;-)
And yes, my template is in "class declaration"

Class Base Name
Code: [Select]
%PI=""%
%if classStereotype != "typedef"%
%endTemplate%

%classBaseName%

%if classIsInstantiated == "T"%
<%classArguments%>
%endIf%
Linked Class Base
Code: [Select]
%if classStereotype != "typedef"%
%endTemplate%

%PI=""%
%linkParentName%