Skip to content

Commit

Permalink
Fix var name of constructor argument in helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel-Darbord committed Jul 2, 2024
1 parent f8f1504 commit 93a3159
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ FamixValueOfObjectAttribute >> mooseNameOn: aStream [
ifNil: [ '<attribute>' ]) << $=.
value printValueOn: aStream
]

{ #category : #'*Famix-Value-Entities-Extensions' }
FamixValueOfObjectAttribute >> varName [

^ self attribute
ifNotNil: [ :attribute | attribute name ]
ifNil: [ value varName ]
]
8 changes: 0 additions & 8 deletions src/Famix-Value-Entities/FamixValueOfObjectAttribute.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,3 @@ FamixValueOfObjectAttribute >> value: anObject [
<generated>
value := anObject
]

{ #category : #generate }
FamixValueOfObjectAttribute >> varName [

^ self attribute
ifNotNil: [ :attribute | attribute name ]
ifNil: [ value varName ]
]
6 changes: 4 additions & 2 deletions src/Famix-Value-Exporter/FamixValue2FASTJavaVisitor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ FamixValue2FASTJavaVisitor >> addAttributesFrom: object asArgumentsTo: newExpres
object value
detect: [ :objAttribute | "find the matching value attribute"
objAttribute attribute == paramAttribute ]
ifFound: [ :objAttribute |
self makeVariableExpression: objAttribute value ]
ifFound: [ :objAttribute | "dispatch for var naming context"
objectExportStrategy
makeVariableExpression: objAttribute value
on: self ]
ifNone: [ "the object does not have the attribute set"
paramAttribute declaredType asFASTJavaDefaultValueOn:
self model ] ]) ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,11 @@ FamixValueHelperObjectExportStrategy >> makeSetterInvocationsFor: attributes on:
named: attribute varName ]
ifNil: [ visitor makeReflectionSetterInvocation: attribute ] ]
]

{ #category : #ast }
FamixValueHelperObjectExportStrategy >> makeVariableExpression: value on: visitor [
"Used when constructing an object to correctly name the argument variable.
For helpers, the var name is the same as the helper method parameter."

^ visitor model newVariableExpression name: value varName
]
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ FamixValueInlineObjectExportStrategy >> export: object on: visitor [
(visitor filterAttributesToSet: object relevantAttributes for: object)
do: [ :attribute | visitor visitObjectAttribute: attribute ]
]

{ #category : #ast }
FamixValueInlineObjectExportStrategy >> makeVariableExpression: value on: visitor [
"Used when constructing an object to correctly name the argument variable.
When inline, the visitor can handle naming the variable on its own."

^ visitor makeVariableExpression: value
]

0 comments on commit 93a3159

Please sign in to comment.