From 1b40bdd3c3973e1754c4649ce757539e9a97488a Mon Sep 17 00:00:00 2001 From: Benoit Verhaeghe Date: Wed, 5 Jun 2024 15:13:12 +0200 Subject: [PATCH 1/6] use refactoring of Famix2Java to only extends required method --- src/Carrefour-Exporter/CRFExporter.class.st | 69 ++++----------------- 1 file changed, 12 insertions(+), 57 deletions(-) diff --git a/src/Carrefour-Exporter/CRFExporter.class.st b/src/Carrefour-Exporter/CRFExporter.class.st index 90da14c..44418b9 100644 --- a/src/Carrefour-Exporter/CRFExporter.class.st +++ b/src/Carrefour-Exporter/CRFExporter.class.st @@ -9,62 +9,17 @@ Class { } { #category : #accessing } -CRFExporter >> visitMethod: aMethod [ +CRFExporter >> printStatementBlockOf: aMethod [ - aMethod isStub ifTrue: [ ^ self ]. - self printMethodAnnotations: aMethod. - self indent. - aMethod isPrivate ifTrue: [ self << 'private ' ]. - aMethod isProtected ifTrue: [ self << 'protected ' ]. - aMethod isPublic ifTrue: [ self << 'public ' ]. - aMethod isClassSide ifTrue: [ self << 'static ' ]. - "Printing return type for method" - aMethod declaredType ifNotNil: [ :declaredType | - self printDeclaredType: declaredType. - currentStream << String space ]. - "Printing name + parameters of method" - (aMethod name = '' or: [ - aMethod isAnInitializer and: [ aMethod isConstructor not ] ]) - ifFalse: [ - self - << aMethod name; - << '('. - (aMethod parameters sorted: [ :p :p2 | - p sourceAnchor startPos < p2 sourceAnchor startPos ]) - do: [ :parameter | parameter accept: self clone ] - separatedBy: [ self << ', ' ]. - self << ')' ] - ifTrue: [ self << 'static' ]. - "print exception" - ((aMethod withMethodsOverriding collect: [ :m | - m thrownExceptions , m declaredExceptions ]) flattened asSet - asOrderedCollection sorted: #name ascending) ifNotEmpty: [ - :exceptions | - self << ' throws '. - exceptions - do: [ :exception | self << exception name ] - separatedBy: [ self << ', ' ] ]. - - "Printing body of method if class is not abstract or an interface" - ((aMethod atScope: FamixTClass) anyOne isInterface or: [ - aMethod isAbstract isNotNil and: [ aMethod isAbstract ] ]) - ifTrue: [ self << ';' ] - ifFalse: [ - aMethod fast - ifNotNil: [ :fastMethod | - | fastJavaExporterVisitor | - fastJavaExporterVisitor := FASTJavaExportVisitor new - outputStream: self currentStream; - indentSize: tabulationSize; - yourself. - self << ' '. - 1 to: tabs do: [ :tab | fastJavaExporterVisitor indent ]. - fastMethod statementBlock accept: fastJavaExporterVisitor ] - ifNil: [ - self << ' {'. - self eol. - self << aMethod bodySourceText. - self - eol; - <<| '}' ] ] + aMethod fast + ifNotNil: [ :fastMethod | + | fastJavaExporterVisitor | + fastJavaExporterVisitor := FASTJavaExportVisitor new + outputStream: self currentStream; + indentSize: tabulationSize; + yourself. + self << ' '. + 1 to: tabs do: [ :tab | fastJavaExporterVisitor indent ]. + fastMethod statementBlock accept: fastJavaExporterVisitor ] + ifNil: [ super printStatementBlockOf: aMethod ] ] From f275be3633617ac9bcd0620e819c8ba1135016ee Mon Sep 17 00:00:00 2001 From: Nicolas Anquetil Date: Thu, 25 Jul 2024 10:18:12 +0200 Subject: [PATCH 2/6] Update README.md --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 460150a..5f24319 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,36 @@ Metacello new load ``` +## Use + +Carrefour links entities in a FAST model to entities in a Famix model. +It is composed of 2 parts: +- Carrefour meta-model +- Binder + +Steps: +1. Generate the FAST model of a Famix entity (eg. a FamixMethod) +2. Bind the nodes in the FAST model to entities in the Famix model with method `#bindFASTModel` + +### Carrefour meta-model + +Does not do much, "import" entities from *language dependent* Famix meta-model and *language dependent* FAST meta-model and adds relations between them. + +### Generating the FAST model + +Done by a *language dependent* parser. +Each FamixEntity should know how to do it by implementing `#getFASTModel` + +### Binding + +Done by visiting the FAST model (an AST). +Again needs a *language dependent* visitor. + +For Java, there are 2 methods: +- `#bindFastModel:fromFamixMethodEntity:` that visit root *method* of the FAST model +- `#bindFastModel:fromFamixClassEntity:` that visit root *class* of the FAST model + + ## Developers ### Update tests From a6efc0b815d1c5e849b409db7e6a340151ad150e Mon Sep 17 00:00:00 2001 From: Nicolas Anquetil Date: Thu, 25 Jul 2024 16:34:08 +0200 Subject: [PATCH 3/6] Update README.md --- README.md | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5f24319..bacdd25 100644 --- a/README.md +++ b/README.md @@ -25,27 +25,24 @@ It is composed of 2 parts: - Binder Steps: -1. Generate the FAST model of a Famix entity (eg. a FamixMethod) -2. Bind the nodes in the FAST model to entities in the Famix model with method `#bindFASTModel` +1. Generate the FAST model of a Famix entity (eg. a FamixMethod) with `#getFASTModel` +2. Bind the nodes in the FAST model to entities in the Famix model with `bindFASTModel:` ### Carrefour meta-model -Does not do much, "import" entities from *language dependent* Famix meta-model and *language dependent* FAST meta-model and adds relations between them. +Does not do much, adds relations between (language dependent) Famix entities and (language dependent) FAST entities. ### Generating the FAST model Done by a *language dependent* parser. -Each FamixEntity should know how to do it by implementing `#getFASTModel` +Each concerned FamixEntity should know how to do it by implementing `#getFASTModel`. +For example in Java, this method is implemented by `FamixJavaMethod` and all the "strucutred types" (`FamixJavaClass`, `FamixJavaEnum`, `FamixJavaException`). ### Binding Done by visiting the FAST model (an AST). Again needs a *language dependent* visitor. - -For Java, there are 2 methods: -- `#bindFastModel:fromFamixMethodEntity:` that visit root *method* of the FAST model -- `#bindFastModel:fromFamixClassEntity:` that visit root *class* of the FAST model - +It is implemented in `bindFASTModel:` ## Developers From edf97b5742f3aa8f374f6c01b0324fe8d164e920 Mon Sep 17 00:00:00 2001 From: Nicolas Anquetil Date: Thu, 25 Jul 2024 17:48:02 +0200 Subject: [PATCH 4/6] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index bacdd25..cc1daea 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,11 @@ Done by visiting the FAST model (an AST). Again needs a *language dependent* visitor. It is implemented in `bindFASTModel:` +Bindings need to be created between (class names are only indicative, they do not really exist in any Famix or FAST meta-model): +- FamixMethod and FASTBehaviouralEntity +- FamixStructuralEntity and FASTVariableDeclarator + FASTExpression + FASTAssignement +- FamixInvocation and FASTExpression + ## Developers ### Update tests From 3194fcf0446998406e1ee5282717498db5358b3f Mon Sep 17 00:00:00 2001 From: Nicolas Anquetil Date: Fri, 26 Jul 2024 09:44:29 +0200 Subject: [PATCH 5/6] Update README.md --- README.md | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index cc1daea..31cef6c 100644 --- a/README.md +++ b/README.md @@ -22,33 +22,31 @@ Metacello new Carrefour links entities in a FAST model to entities in a Famix model. It is composed of 2 parts: - Carrefour meta-model -- Binder - -Steps: -1. Generate the FAST model of a Famix entity (eg. a FamixMethod) with `#getFASTModel` -2. Bind the nodes in the FAST model to entities in the Famix model with `bindFASTModel:` +- Binder with two main steps involved: + 1. Generate the FAST model of a Famix entity (eg. a FamixMethod) with `#getFASTModel` + 2. Bind the nodes in the FAST model to entities in the Famix model with `bindFASTModel:` ### Carrefour meta-model -Does not do much, adds relations between (language dependent) Famix entities and (language dependent) FAST entities. +Represents relations between Famix entities and FAST entities. + +The relations are typically between: +- FamixMethod and FASTBehaviouralEntity +- FamixStructuralEntity and FASTVariableDeclarator, FASTExpression, or FASTAssignement +- FamixInvocation and FASTFunctionCall or FASTMessageSend +Note: *class names are only indicative, they do not really exist in any Famix or FAST meta-model* ### Generating the FAST model Done by a *language dependent* parser. Each concerned FamixEntity should know how to do it by implementing `#getFASTModel`. -For example in Java, this method is implemented by `FamixJavaMethod` and all the "strucutred types" (`FamixJavaClass`, `FamixJavaEnum`, `FamixJavaException`). +For example in Java, this method is implemented by `FamixJavaMethod` and all the main "structured types" (`FamixJavaClass`, `FamixJavaEnum`, `FamixJavaException`). ### Binding -Done by visiting the FAST model (an AST). -Again needs a *language dependent* visitor. +Done by visiting the FAST model (an AST) and looking for corresponding Famix entities to each FAST entity. It is implemented in `bindFASTModel:` -Bindings need to be created between (class names are only indicative, they do not really exist in any Famix or FAST meta-model): -- FamixMethod and FASTBehaviouralEntity -- FamixStructuralEntity and FASTVariableDeclarator + FASTExpression + FASTAssignement -- FamixInvocation and FASTExpression - ## Developers ### Update tests From 3898add075fd839dce583b21aa201ca007625fb0 Mon Sep 17 00:00:00 2001 From: Benoit Verhaeghe Date: Fri, 26 Jul 2024 11:42:46 +0200 Subject: [PATCH 6/6] fix baseline to load last version of FAST --- .../BaselineOfCarrefour.class.st | 19 ++++++++++--------- src/BaselineOfCarrefour/package.st | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/BaselineOfCarrefour/BaselineOfCarrefour.class.st b/src/BaselineOfCarrefour/BaselineOfCarrefour.class.st index d589275..f6149ed 100644 --- a/src/BaselineOfCarrefour/BaselineOfCarrefour.class.st +++ b/src/BaselineOfCarrefour/BaselineOfCarrefour.class.st @@ -1,10 +1,11 @@ Class { - #name : #BaselineOfCarrefour, - #superclass : #BaselineOf, - #category : #BaselineOfCarrefour + #name : 'BaselineOfCarrefour', + #superclass : 'BaselineOf', + #category : 'BaselineOfCarrefour', + #package : 'BaselineOfCarrefour' } -{ #category : #baselines } +{ #category : 'baselines' } BaselineOfCarrefour >> baseline: spec [ spec @@ -17,7 +18,7 @@ BaselineOfCarrefour >> baseline: spec [ self defineGroups: spec ] ] -{ #category : #baselines } +{ #category : 'baselines' } BaselineOfCarrefour >> customProjectAttributes [ ^ RPackageOrganizer default packages @@ -26,13 +27,13 @@ BaselineOfCarrefour >> customProjectAttributes [ ifNone: [ #( #NeedsTinyLogger ) ] ] -{ #category : #baselines } +{ #category : 'baselines' } BaselineOfCarrefour >> defineDependencies: spec [ spec baseline: 'FASTJava' with: [ spec loads: #( 'all' ); - repository: 'github://moosetechnology/FAST-Java:v3.0.5/src' ]. + repository: 'github://moosetechnology/FAST-Java:v3.0.7/src' ]. spec baseline: 'Famix2Java' with: [ @@ -43,12 +44,12 @@ BaselineOfCarrefour >> defineDependencies: spec [ with: [ spec repository: 'github://jecisc/TinyLogger:v1.x.x/src' ] ] ] -{ #category : #baselines } +{ #category : 'baselines' } BaselineOfCarrefour >> defineGroups: spec [ spec group: 'generator' with: #('Carrefour-Model-Generator') ] -{ #category : #baselines } +{ #category : 'baselines' } BaselineOfCarrefour >> definePackages: spec [ spec diff --git a/src/BaselineOfCarrefour/package.st b/src/BaselineOfCarrefour/package.st index 965878d..b93a913 100644 --- a/src/BaselineOfCarrefour/package.st +++ b/src/BaselineOfCarrefour/package.st @@ -1 +1 @@ -Package { #name : #BaselineOfCarrefour } +Package { #name : 'BaselineOfCarrefour' }