Skip to content

Materialize from metamodel - #134

Draft
badetitou wants to merge 39 commits into
developmentfrom
materialize-from-metamodel
Draft

badetitou wants to merge 39 commits into
developmentfrom
materialize-from-metamodel

Conversation

@badetitou

Copy link
Copy Markdown
Member

This PR adds a materializer.
The idea is that we should be able to generate concrete classes based on a Fame Metamodel instead of the existing generator.
Thus, one could modify a metamodel and regenerate the concrete classes instead of modifying the generator.
We could also (for example) build other tools to create metamodel (like a visual one, based on FMMetamodel)

@jecisc jecisc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I stopped the suggestions for the environment because there are a lot and your agent can do it more easily than me

prop := FM3Property named: aSlot name.
prop implementingSelector: aSlot name.
prop isMultivalued: aSlot isToMany.
self haltIf: [ prop name = #modelHasProperties ].

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be careful :)

Suggested change
self haltIf: [ prop name = #modelHasProperties ].

| class |
class := FMMaterializerTestResource current clazz.
materializer materializeClass: class.
self assert: (Smalltalk globals includesKey: class name)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self assert: (Smalltalk globals includesKey: class name)
self assert: (self class environment includesKey: class name)

Smalltalk gloabls might vanish someday


materializer materializeClass: class.

getter := (Smalltalk globals at: class name)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
getter := (Smalltalk globals at: class name)
getter := (self class environment at: class name)


materializer materializeClass: class.

getter := (Smalltalk globals at: class name)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
getter := (Smalltalk globals at: class name)
getter := (self class environment at: class name)

materializer materializeClass:
FMMaterializerTestResource current anotherClass.

implementationClass := Smalltalk globals at:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
implementationClass := Smalltalk globals at:
implementationClass := self class environment at:

materializer materializeClass: superclass.
self assert: (Smalltalk globals includesKey: class name).
self
assert: (Smalltalk globals at: class name) superclass name

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert: (Smalltalk globals at: class name) superclass name
assert: (self class environment at: class name) superclass name

]

{ #category : 'accessing' }
FMMaterializerTestResource >> clazz [

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noooooooooon, not a new clazz :( With Clotlide we tried to remove those ahah

Comment on lines +44 to +68
remotePackage := FM3Package named:
'Fame-Materialize-TestResource-Remote'.
metamodel add: remotePackage.
remoteClass := FM3Class named: 'RemoteClass'.

relationRemoteClassToClass := (FM3Property named:
'remoteClassToClass') type: class.
relationClassToRemoteClass := (FM3Property named:
'classToRemoteClass') type:
remoteClass.
relationClassToRemoteClass package: remotePackage.
relationRemoteClassToClass opposite: relationClassToRemoteClass.
relationClassToRemoteClass opposite: relationRemoteClassToClass.

classRemoteProperty := (FM3Property named: self remoteNumberPropertyName)
type: FM3Number instance.
classRemoteProperty package: remotePackage.
class properties addAll: {
relationClassToRemoteClass.
classRemoteProperty }.
remoteClass properties: { relationRemoteClassToClass }.
metamodel add: remoteClass.
remoteClass package: remotePackage
]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be much more readable if we allow more characters by line

relationClassToAnotherClass := anObject
]

{ #category : 'as yet unclassified' }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

categorizations? (there are others like this, I'm just commenting one)

| slots filteredSlots |
slots := aFM3Class properties
reject: [ :property |
property type isConstant not or: [

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should introduce methods such as FM3Property>>#hasConstantType and others to make the code more readable?

Merge handwritten annotations into existing descriptions, refresh property caches, and resolve opposites deterministically. Declare the materializer packages and make its fixtures independent and deterministic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants