Access to package-name from ClassConcept?

Hi,

is it possible to change the package-name of some class derived from ClassConcept dynamically (UseCase: User defines the package-name f.e. via String)? This information is currently automatically derived from the according Solution.

Thx,

Mirko

5 comments
Comment actions Permalink

Mirko,

It's not possible. In MPS we have model.fqName to a package correspondance.

Regards,

Konstantin

0
Comment actions Permalink

Konstantin,

Thanks.

And "model.fqName" is read-only? If yes, is it subject of a change in the future? As the classes within MPS are kept in an AST too, a change of the package-name shouldn't be a problem...

Mirko

0
Comment actions Permalink

Mirko,

It's possible to change a model's fqName but we never tried doing this during generation.

Could you describe your use case in detail. Why do you need to generate code to different packages?

Regards,

Konstantin

0
Comment actions Permalink

Hi Konstantin,

i defined (or better: tried to ;-)) a language from where i can define the overall structure/architecture of an application:

  • layers -> horizontal building blocks, f.e. 3-Tier
  • sections -> vertical building blocks, f.e. authentication, management and so on
  • modules -> section x layers, f.e. the database-part of the authentication-section (each module defines its layer(s) and section(s))

Each of the module should become a base-package-name. The idea behind that, is to give the User the ability to define dependencies between those modules. Now i can generate f.e. checking-rules for possible dependency-violations (f.e. for AspectJ). In the next step the idea would be to define more fine-grained Objects (for ease of understanding lets say: Database-Entities). Those Entities are to be defined within a MPS-Solution-File (the overall Entity-Module) defining database-dependencies (f.e. foreign-keys), constraints and so on (just the database-stuff ;-)).

After all, i normally would come out with a big Entity-Model somewhere in the Solution-Area of MPS, which i than want to partition into parts by assigning them an owning Module. This Assignment should than led to an adaption of the Package-Name of the generated Entities to the one of the according Module. An Entity than f.e. could only define sub-packages relative to the Module-package defined earlier.

In that way a want to create more languages that define other aspects of an application (f.e. Aggregates in the meaning of DomainDrivenDesign). But because of the overall Structuring defined by the architecture (you know: the layers-/sections-/modules-stuff) i would always always come up with the need of defining the generation-package dynamically (avoiding huge re-structurings in Solutions -> only change the affiliation to some module... voila ;-)).

Don't know if that approach conflicts with the "MPS-way"... maybe you can help...

Anyway, the tool is realy great stuff!

Mirko

0
Comment actions Permalink

Mirko,

There are several ways you can do what you want in MPS.

First, you can create several models for each architectural part in your solution. Then the required package name will be used automatically. I recommend you this way.

Second, you can complete generation in two stages. First generate your code as one model, and them separate resulting nodes in two several models which text will be generated. This solution will use unducomented API compatibility with which we might break in the future. You can take a look at an example of this in the packaging language's plugin model.

Regards,

Konstantin

0

Please sign in to leave a comment.