Skip to content

Commit

Permalink
Exporter: Make FASTBuilder an attribute instead of using it statically
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel-Darbord committed Mar 28, 2024
1 parent a36b0c9 commit d6c3ccb
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,7 @@ FamixValue2FASTJavaVisitorTest >> setUp [
type: (FamixJavaClass new name: 'String').
nullString := FamixValueOfUnknownType new
value: nil;
type: (FamixJavaClass new name: 'String').
FASTJavaBuilder new beCurrent
]

{ #category : #running }
FamixValue2FASTJavaVisitorTest >> tearDown [

FASTJavaBuilder reset.
super tearDown
type: (FamixJavaClass new name: 'String')
]

{ #category : #tests }
Expand Down
21 changes: 0 additions & 21 deletions src/Famix-Value-Exporter/FASTBuilder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,9 @@ Class {
#instVars : [
'model'
],
#classVars : [
'Current'
],
#category : #'Famix-Value-Exporter'
}

{ #category : #accessing }
FASTBuilder class >> current [

^ Current ifNil: [ Current := self new ]
]

{ #category : #'class initialization' }
FASTBuilder class >> reset [

Current := nil
]

{ #category : #accessing }
FASTBuilder >> beCurrent [

Current := self
]

{ #category : #accessing }
FASTBuilder >> model [

Expand Down
3 changes: 1 addition & 2 deletions src/Famix-Value-Exporter/FamixJavaType.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ FamixJavaType >> acceptValueVisitor: visitor forObject: object [

{ #category : #'*Famix-Value-Exporter' }
FamixJavaType >> asFASTJavaTypeExpressionOn: visitor [
"^ visitor makeClassTypeExpression: self typeName"

^ FASTJavaBuilder current referType: self
^ visitor builder referType: self
]

{ #category : #'*Famix-Value-Exporter' }
Expand Down
9 changes: 8 additions & 1 deletion src/Famix-Value-Exporter/FamixValue2FASTJavaVisitor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Class {
#name : #FamixValue2FASTJavaVisitor,
#superclass : #FamixValue2ASTVisitor,
#instVars : [
'builder',
'markedForReflection',
'constructorCache',
'staticAttributesCache'
Expand Down Expand Up @@ -41,6 +42,12 @@ FamixValue2FASTJavaVisitor >> addAttributesFrom: object asArgumentsTo: newExpres
self model ] ]) ]
]

{ #category : #initialization }
FamixValue2FASTJavaVisitor >> builder [

^ builder ifNil: [ builder := FASTJavaBuilder new model: self model ]
]

{ #category : #private }
FamixValue2FASTJavaVisitor >> constructObject: object [

Expand Down Expand Up @@ -121,7 +128,7 @@ FamixValue2FASTJavaVisitor >> makeHelper [
self model newCompilationUnit
packageDeclaration: (model newPackageDeclaration qualifiedName:
(model newQualifiedName name: 'fr.evref.modest'));
importDeclarations: FASTJavaBuilder current makeImportDeclarations;
importDeclarations: self builder makeImportDeclarations;
addImportDeclaration: (model newImportDeclaration qualifiedName:
(model newQualifiedName name: 'java.io.IOException'));
addImportDeclaration: (model newImportDeclaration qualifiedName:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Extension { #name : #FamixValueUnknownType }
{ #category : #'*Famix-Value-Exporter' }
FamixValueUnknownType >> asFASTJavaTypeExpressionOn: visitor [

^ FASTJavaBuilder current referType: self
^ visitor builder referType: self
]
2 changes: 1 addition & 1 deletion src/Famix-Value-Types/FamixValueJavaSQLDate.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ FamixValueJavaSQLDate >> value: date asFASTJavaExpressionOn: visitor [
"Call java.sql.Date#valueOf(String) to recreate this date."

^ visitor model newMethodInvocation
receiver: (FASTJavaBuilder current referType: type);
receiver: (visitor builder referType: type);
name: 'valueOf';
addArgument: (visitor model newStringLiteral primitiveValue:
date value first value value);
Expand Down

0 comments on commit d6c3ccb

Please sign in to comment.