Author Topic: CodeGen - ImportSection fail for new language  (Read 1710 times)

RIL

  • EA User
  • **
  • Posts: 142
  • Karma: +3/-0
  • -- There's always a solution --
    • View Profile
CodeGen - ImportSection fail for new language
« on: July 25, 2013, 10:32:47 am »
Hi all,

I made a code generator template for Go based on Delphi, but for some reason the "Import Section" ("uses") doesn't seem to work for Go with the exact same template code as for Delphi.

Delphi generates this code for a given model:

uses MLStringIdentifier, Language, AmClass;

but nothing at all for Go. :(

Template code for Delphi is:
Code: [Select]
$imports = %fileImports%
$uses = %WRAP_LINES($imports, "50", "     ")%
%if $uses != ""%
uses %TRIM_LEFT($uses, "     ")%;\n
%endIf%

Template code for Go:
Code: [Select]
$imports = %fileImports%
$uses = %WRAP_LINES($imports, "50", "     ")%
%if $uses != ""%
import  ( %TRIM_LEFT($uses, "     ")% )\n
%endIf%

Any ideas? Is something in EA "hard coded" as to recognize dependencies only if Delphi language is set for classes, or what in the world can be the cause for EA (well, %fileImports%) not being aware of any dependencies in the Go-case?

// Rolf
-- There's always a solution --

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 7731
  • Karma: +103/-18
    • View Profile
Re: CodeGen - ImportSection fail for new language
« Reply #1 on: July 26, 2013, 08:47:44 am »
Yes, fileImports and classImports both are coded specifically to handle the known languages.

However, you can use a list over "Import" to achieve the same goal.

The following is derived from a combination of the PHP Import Section Template and your Go template.

Code: [Select]
$imports = %list="Import" @separator=", " importFromAggregation=="T" or importFromAssociation=="T" or importFromAtt=="T" or importFromDependency=="T" or importFromGeneralization=="T" or importFromMeth=="T" or importFromParam=="T" or importFromRealization=="T"%
$imports = %REMOVE_DUPLICATES($imports, ", ")%
$uses = %WRAP_LINES($imports, "50", "     ")%
%if $uses != ""%
import  ( %TRIM_LEFT($uses, "     ")% )\n
%endIf%

I imagine that the Import template would look something like
Code: [Select]
%importClassName%
Eve

support@sparxsystems.com