From 9e73f645c89817c4d3c15dd58128b2e8f7f39750 Mon Sep 17 00:00:00 2001 From: anquetil Date: Mon, 10 Jun 2024 18:16:37 +0200 Subject: [PATCH] fix #152 --- .../FamixF77ImportingContext.class.st | 14 +++ .../FamixF77PUBlockdata.class.st | 5 +- .../FamixF77PUMain.class.st | 11 ++- .../FamixF77PUProcedure.class.st | 6 +- .../FamixF77ProgramUnit.class.st | 5 +- .../FamixF77StatementFunction.class.st | 91 +++++++++++++++++++ .../FamixF77TEntityCreator.trait.st | 7 ++ .../FamixF77TWithStatements.trait.st | 87 ++++++++++++++++++ .../FamixFortran77Generator.class.st | 73 +++++++++++---- .../ManifestFamixFortran77Generator.class.st | 15 +++ 10 files changed, 287 insertions(+), 27 deletions(-) create mode 100644 src/Famix-Fortran77-Entities/FamixF77StatementFunction.class.st create mode 100644 src/Famix-Fortran77-Entities/FamixF77TWithStatements.trait.st create mode 100644 src/Famix-Fortran77-Generator/ManifestFamixFortran77Generator.class.st diff --git a/src/Famix-Fortran77-Entities/FamixF77ImportingContext.class.st b/src/Famix-Fortran77-Entities/FamixF77ImportingContext.class.st index ac9ffa9..09d911e 100644 --- a/src/Famix-Fortran77-Entities/FamixF77ImportingContext.class.st +++ b/src/Famix-Fortran77-Entities/FamixF77ImportingContext.class.st @@ -141,6 +141,13 @@ FamixF77ImportingContext >> importSourceTextAnchor [ ^ self importConcreteEntity: (self class fm3ClassNamed: #SourceTextAnchor) ] +{ #category : #importing } +FamixF77ImportingContext >> importStatementFunction [ + + + ^ self importConcreteEntity: (self class fm3ClassNamed: #StatementFunction) +] + { #category : #importing } FamixF77ImportingContext >> importType [ @@ -295,6 +302,13 @@ FamixF77ImportingContext >> shouldImportSourceTextAnchor [ ^ self shouldImport: #SourceTextAnchor ] +{ #category : #testing } +FamixF77ImportingContext >> shouldImportStatementFunction [ + + + ^ self shouldImport: #StatementFunction +] + { #category : #testing } FamixF77ImportingContext >> shouldImportType [ diff --git a/src/Famix-Fortran77-Entities/FamixF77PUBlockdata.class.st b/src/Famix-Fortran77-Entities/FamixF77PUBlockdata.class.st index e2a4936..e3ceb13 100644 --- a/src/Famix-Fortran77-Entities/FamixF77PUBlockdata.class.st +++ b/src/Famix-Fortran77-Entities/FamixF77PUBlockdata.class.st @@ -7,6 +7,7 @@ a block data for common variable ### Children | Relation | Origin | Opposite | Type | Comment | |---| +| `comments` | `FamixTWithComments` | `commentedEntity` | `FamixTComment` | List of comments for the entity| | `localVariables` | `FamixTWithLocalVariables` | `parentBehaviouralEntity` | `FamixTLocalVariable` | Variables locally defined by this behaviour.| ### Outgoing dependencies @@ -33,8 +34,8 @@ a block data for common variable Class { #name : #FamixF77PUBlockdata, #superclass : #FamixF77ProgramUnit, - #traits : 'FamixTWithAccesses + FamixTWithLocalVariables + FamixTWithStatements', - #classTraits : 'FamixTWithAccesses classTrait + FamixTWithLocalVariables classTrait + FamixTWithStatements classTrait', + #traits : 'FamixTWithAccesses + FamixTWithComments + FamixTWithLocalVariables + FamixTWithStatements + TEntityMetaLevelDependency', + #classTraits : 'FamixTWithAccesses classTrait + FamixTWithComments classTrait + FamixTWithLocalVariables classTrait + FamixTWithStatements classTrait + TEntityMetaLevelDependency classTrait', #category : #'Famix-Fortran77-Entities-Entities' } diff --git a/src/Famix-Fortran77-Entities/FamixF77PUMain.class.st b/src/Famix-Fortran77-Entities/FamixF77PUMain.class.st index ce3296b..f00c159 100644 --- a/src/Famix-Fortran77-Entities/FamixF77PUMain.class.st +++ b/src/Famix-Fortran77-Entities/FamixF77PUMain.class.st @@ -7,7 +7,9 @@ a main program ### Children | Relation | Origin | Opposite | Type | Comment | |---| +| `comments` | `FamixTWithComments` | `commentedEntity` | `FamixTComment` | List of comments for the entity| | `localVariables` | `FamixTWithLocalVariables` | `parentBehaviouralEntity` | `FamixTLocalVariable` | Variables locally defined by this behaviour.| +| `statementFunctions` | `FamixF77TWithStatements` | `parentEntity` | `FamixF77StatementFunction` | Statement functions defined in the body| | `types` | `FamixTWithTypes` | `typeContainer` | `FamixTType` | Types contained (declared) in this entity, if any. #types is declared in ContainerEntity because different kinds of container can embed types. Types are usually contained in a Famix.Namespace. But types can also be contained in a Famix.Class or Famix.Method (in Java with inner classes for example). Famix.Function can also contain some types such as structs.| ### Outgoing dependencies @@ -17,6 +19,11 @@ a main program | `outgoingInvocations` | `FamixTWithInvocations` | `sender` | `FamixTInvocation` | Outgoing invocations sent by this behaviour.| | `outgoingReferences` | `FamixTWithReferences` | `referencer` | `FamixTReference` | References from this entity to other entities.| +### Incoming dependencies +| Relation | Origin | Opposite | Type | Comment | +|---| +| `incomingInvocations` | `FamixTInvocable` | `candidates` | `FamixTInvocation` | Incoming invocations from other behaviours computed by the candidate operator.| + ### Other | Relation | Origin | Opposite | Type | Comment | |---| @@ -34,8 +41,8 @@ a main program Class { #name : #FamixF77PUMain, #superclass : #FamixF77ProgramUnit, - #traits : 'FamixTWithAccesses + FamixTWithInvocations + FamixTWithLocalVariables + FamixTWithStatements + FamixTWithTypes', - #classTraits : 'FamixTWithAccesses classTrait + FamixTWithInvocations classTrait + FamixTWithLocalVariables classTrait + FamixTWithStatements classTrait + FamixTWithTypes classTrait', + #traits : 'FamixF77TWithStatements + FamixTWithTypes', + #classTraits : 'FamixF77TWithStatements classTrait + FamixTWithTypes classTrait', #category : #'Famix-Fortran77-Entities-Entities' } diff --git a/src/Famix-Fortran77-Entities/FamixF77PUProcedure.class.st b/src/Famix-Fortran77-Entities/FamixF77PUProcedure.class.st index 1336810..f5cf674 100644 --- a/src/Famix-Fortran77-Entities/FamixF77PUProcedure.class.st +++ b/src/Famix-Fortran77-Entities/FamixF77PUProcedure.class.st @@ -7,8 +7,10 @@ a procedure ### Children | Relation | Origin | Opposite | Type | Comment | |---| +| `comments` | `FamixTWithComments` | `commentedEntity` | `FamixTComment` | List of comments for the entity| | `localVariables` | `FamixTWithLocalVariables` | `parentBehaviouralEntity` | `FamixTLocalVariable` | Variables locally defined by this behaviour.| | `parameters` | `FamixTWithParameters` | `parentBehaviouralEntity` | `FamixTParameter` | List of formal parameters declared by this behaviour.| +| `statementFunctions` | `FamixF77TWithStatements` | `parentEntity` | `FamixF77StatementFunction` | Statement functions defined in the body| | `types` | `FamixTWithTypes` | `typeContainer` | `FamixTType` | Types contained (declared) in this entity, if any. #types is declared in ContainerEntity because different kinds of container can embed types. Types are usually contained in a Famix.Namespace. But types can also be contained in a Famix.Class or Famix.Method (in Java with inner classes for example). Famix.Function can also contain some types such as structs.| ### Outgoing dependencies @@ -41,8 +43,8 @@ a procedure Class { #name : #FamixF77PUProcedure, #superclass : #FamixF77ProgramUnit, - #traits : 'FamixTHasSignature + FamixTInvocable + FamixTWithAccesses + FamixTWithInvocations + FamixTWithLocalVariables + FamixTWithParameters + FamixTWithStatements + FamixTWithTypes', - #classTraits : 'FamixTHasSignature classTrait + FamixTInvocable classTrait + FamixTWithAccesses classTrait + FamixTWithInvocations classTrait + FamixTWithLocalVariables classTrait + FamixTWithParameters classTrait + FamixTWithStatements classTrait + FamixTWithTypes classTrait', + #traits : 'FamixF77TWithStatements + FamixTHasSignature + FamixTWithParameters + FamixTWithTypes', + #classTraits : 'FamixF77TWithStatements classTrait + FamixTHasSignature classTrait + FamixTWithParameters classTrait + FamixTWithTypes classTrait', #category : #'Famix-Fortran77-Entities-Entities' } diff --git a/src/Famix-Fortran77-Entities/FamixF77ProgramUnit.class.st b/src/Famix-Fortran77-Entities/FamixF77ProgramUnit.class.st index 5cd9add..a577a26 100644 --- a/src/Famix-Fortran77-Entities/FamixF77ProgramUnit.class.st +++ b/src/Famix-Fortran77-Entities/FamixF77ProgramUnit.class.st @@ -12,7 +12,6 @@ a program unit ### Children | Relation | Origin | Opposite | Type | Comment | |---| -| `comments` | `FamixTWithComments` | `commentedEntity` | `FamixTComment` | List of comments for the entity| | `externalDeclarations` | `FamixF77ProgramUnit` | `programUnit` | `FamixF77ExternalDeclaration` | | ### Outgoing dependencies @@ -37,8 +36,8 @@ a program unit Class { #name : #FamixF77ProgramUnit, #superclass : #FamixF77NamedEntity, - #traits : 'FamixTSourceEntity + FamixTWithComments + TEntityMetaLevelDependency', - #classTraits : 'FamixTSourceEntity classTrait + FamixTWithComments classTrait + TEntityMetaLevelDependency classTrait', + #traits : 'FamixTSourceEntity', + #classTraits : 'FamixTSourceEntity classTrait', #instVars : [ '#programFile => FMOne type: #FamixF77ProgramFile opposite: #programUnits', '#externalDeclarations => FMMany type: #FamixF77ExternalDeclaration opposite: #programUnit', diff --git a/src/Famix-Fortran77-Entities/FamixF77StatementFunction.class.st b/src/Famix-Fortran77-Entities/FamixF77StatementFunction.class.st new file mode 100644 index 0000000..5ccd910 --- /dev/null +++ b/src/Famix-Fortran77-Entities/FamixF77StatementFunction.class.st @@ -0,0 +1,91 @@ +" +a statement function + +## Relations +====================== + +### Parents +| Relation | Origin | Opposite | Type | Comment | +|---| +| `parentEntity` | `FamixF77StatementFunction` | `statementFunctions` | `FamixF77TWithStatements` | Entity in which body I am defined| + +### Children +| Relation | Origin | Opposite | Type | Comment | +|---| +| `comments` | `FamixTWithComments` | `commentedEntity` | `FamixTComment` | List of comments for the entity| +| `localVariables` | `FamixTWithLocalVariables` | `parentBehaviouralEntity` | `FamixTLocalVariable` | Variables locally defined by this behaviour.| +| `parameters` | `FamixTWithParameters` | `parentBehaviouralEntity` | `FamixTParameter` | List of formal parameters declared by this behaviour.| +| `statementFunctions` | `FamixF77TWithStatements` | `parentEntity` | `FamixF77StatementFunction` | Statement functions defined in the body| +| `types` | `FamixTWithTypes` | `typeContainer` | `FamixTType` | Types contained (declared) in this entity, if any. #types is declared in ContainerEntity because different kinds of container can embed types. Types are usually contained in a Famix.Namespace. But types can also be contained in a Famix.Class or Famix.Method (in Java with inner classes for example). Famix.Function can also contain some types such as structs.| + +### Outgoing dependencies +| Relation | Origin | Opposite | Type | Comment | +|---| +| `accesses` | `FamixTWithAccesses` | `accessor` | `FamixTAccess` | Accesses to variables made by this behaviour.| +| `outgoingInvocations` | `FamixTWithInvocations` | `sender` | `FamixTInvocation` | Outgoing invocations sent by this behaviour.| +| `outgoingReferences` | `FamixTWithReferences` | `referencer` | `FamixTReference` | References from this entity to other entities.| + +### Incoming dependencies +| Relation | Origin | Opposite | Type | Comment | +|---| +| `incomingInvocations` | `FamixTInvocable` | `candidates` | `FamixTInvocation` | Incoming invocations from other behaviours computed by the candidate operator.| + +### Other +| Relation | Origin | Opposite | Type | Comment | +|---| +| `declaredType` | `FamixTTypedEntity` | `typedEntities` | `FamixTType` | Type of the entity, if any| +| `sourceAnchor` | `FamixTSourceEntity` | `element` | `FamixTSourceAnchor` | SourceAnchor entity linking to the original source code for this entity| + + +## Properties +====================== + +| Name | Type | Default value | Comment | +|---| +| `isStub` | `Boolean` | false | Flag true if the entity attributes are incomplete, either because the entity is missing or not imported.| +| `signature` | `String` | nil | Signature of the message being sent| + +" +Class { + #name : #FamixF77StatementFunction, + #superclass : #FamixF77NamedEntity, + #traits : 'FamixF77TWithStatements + FamixTHasSignature + FamixTSourceEntity + FamixTTypedEntity + FamixTWithParameters + FamixTWithTypes', + #classTraits : 'FamixF77TWithStatements classTrait + FamixTHasSignature classTrait + FamixTSourceEntity classTrait + FamixTTypedEntity classTrait + FamixTWithParameters classTrait + FamixTWithTypes classTrait', + #instVars : [ + '#parentEntity => FMOne type: #FamixF77TWithStatements opposite: #statementFunctions' + ], + #category : #'Famix-Fortran77-Entities-Entities' +} + +{ #category : #meta } +FamixF77StatementFunction class >> annotation [ + + + + + ^ self +] + +{ #category : #accessing } +FamixF77StatementFunction >> parentEntity [ + "Relation named: #parentEntity type: #FamixF77TWithStatements opposite: #statementFunctions" + + + + + ^ parentEntity +] + +{ #category : #accessing } +FamixF77StatementFunction >> parentEntity: anObject [ + + + parentEntity := anObject +] + +{ #category : #navigation } +FamixF77StatementFunction >> parentEntityGroup [ + + + ^ MooseSpecializedGroup with: self parentEntity +] diff --git a/src/Famix-Fortran77-Entities/FamixF77TEntityCreator.trait.st b/src/Famix-Fortran77-Entities/FamixF77TEntityCreator.trait.st index 844e7e7..855f9cf 100644 --- a/src/Famix-Fortran77-Entities/FamixF77TEntityCreator.trait.st +++ b/src/Famix-Fortran77-Entities/FamixF77TEntityCreator.trait.st @@ -151,6 +151,13 @@ FamixF77TEntityCreator >> newSourceTextAnchor [ ^ self add: FamixF77SourceTextAnchor new ] +{ #category : #'entity creation' } +FamixF77TEntityCreator >> newStatementFunction [ + + + ^ self add: FamixF77StatementFunction new +] + { #category : #'entity creation' } FamixF77TEntityCreator >> newType [ diff --git a/src/Famix-Fortran77-Entities/FamixF77TWithStatements.trait.st b/src/Famix-Fortran77-Entities/FamixF77TWithStatements.trait.st new file mode 100644 index 0000000..983a00e --- /dev/null +++ b/src/Famix-Fortran77-Entities/FamixF77TWithStatements.trait.st @@ -0,0 +1,87 @@ +" +A trait that factorize several interesting properties for entities with statements + +## Relations +====================== + +### Children +| Relation | Origin | Opposite | Type | Comment | +|---| +| `comments` | `FamixTWithComments` | `commentedEntity` | `FamixTComment` | List of comments for the entity| +| `localVariables` | `FamixTWithLocalVariables` | `parentBehaviouralEntity` | `FamixTLocalVariable` | Variables locally defined by this behaviour.| +| `statementFunctions` | `FamixF77TWithStatements` | `parentEntity` | `FamixF77StatementFunction` | Statement functions defined in the body| + +### Outgoing dependencies +| Relation | Origin | Opposite | Type | Comment | +|---| +| `accesses` | `FamixTWithAccesses` | `accessor` | `FamixTAccess` | Accesses to variables made by this behaviour.| +| `outgoingInvocations` | `FamixTWithInvocations` | `sender` | `FamixTInvocation` | Outgoing invocations sent by this behaviour.| +| `outgoingReferences` | `FamixTWithReferences` | `referencer` | `FamixTReference` | References from this entity to other entities.| + +### Incoming dependencies +| Relation | Origin | Opposite | Type | Comment | +|---| +| `incomingInvocations` | `FamixTInvocable` | `candidates` | `FamixTInvocation` | Incoming invocations from other behaviours computed by the candidate operator.| + +### Other +| Relation | Origin | Opposite | Type | Comment | +|---| +| `sourceAnchor` | `FamixTSourceEntity` | `element` | `FamixTSourceAnchor` | SourceAnchor entity linking to the original source code for this entity| + + +## Properties +====================== + +| Name | Type | Default value | Comment | +|---| +| `isStub` | `Boolean` | false | Flag true if the entity attributes are incomplete, either because the entity is missing or not imported.| + +" +Trait { + #name : #FamixF77TWithStatements, + #instVars : [ + '#statementFunctions => FMMany type: #FamixF77StatementFunction opposite: #parentEntity' + ], + #traits : 'FamixTInvocable + FamixTWithAccesses + FamixTWithComments + FamixTWithInvocations + FamixTWithLocalVariables + FamixTWithStatements + TEntityMetaLevelDependency', + #classTraits : 'FamixTInvocable classTrait + FamixTWithAccesses classTrait + FamixTWithComments classTrait + FamixTWithInvocations classTrait + FamixTWithLocalVariables classTrait + FamixTWithStatements classTrait + TEntityMetaLevelDependency classTrait', + #category : #'Famix-Fortran77-Entities-Traits' +} + +{ #category : #meta } +FamixF77TWithStatements classSide >> annotation [ + + + + + ^ self +] + +{ #category : #adding } +FamixF77TWithStatements >> addStatementFunction: anObject [ + + ^ self statementFunctions add: anObject +] + +{ #category : #accessing } +FamixF77TWithStatements >> statementFunctions [ + "Relation named: #statementFunctions type: #FamixF77StatementFunction opposite: #parentEntity" + + + + + ^ statementFunctions +] + +{ #category : #accessing } +FamixF77TWithStatements >> statementFunctions: anObject [ + + + statementFunctions value: anObject +] + +{ #category : #navigation } +FamixF77TWithStatements >> statementFunctionsGroup [ + + + ^ MooseSpecializedGroup withAll: self statementFunctions asSet +] diff --git a/src/Famix-Fortran77-Generator/FamixFortran77Generator.class.st b/src/Famix-Fortran77-Generator/FamixFortran77Generator.class.st index fe7d29b..eea6d39 100644 --- a/src/Famix-Fortran77-Generator/FamixFortran77Generator.class.st +++ b/src/Famix-Fortran77-Generator/FamixFortran77Generator.class.st @@ -54,7 +54,9 @@ Class { 'includedFile', 'typeUnknown', 'externalDeclaration', - 'implicit' + 'implicit', + 'statementFunction', + 'tWithStatements' ], #category : #'Famix-Fortran77-Generator' } @@ -158,12 +160,16 @@ FamixFortran77Generator >> defineClasses [ comment: self puMainEntityComment. puProcedure := builder - newClassNamed: #PUProcedure - comment: self puProcedureEntityComment. + newClassNamed: #PUProcedure + comment: self puProcedureEntityComment. puSubroutine := builder - newClassNamed: #PUSubroutine - comment: self puSubroutineEntityComment. + newClassNamed: #PUSubroutine + comment: self puSubroutineEntityComment. + + statementFunction := builder + newClassNamed: #StatementFunction + comment: self statementFunctionEntityComment. "real := builder newClassNamed: #Real comment: 'Im a real'." @@ -225,13 +231,21 @@ FamixFortran77Generator >> defineHierarchy [ programUnit --|> namedEntity. programUnit --|> #TSourceEntity. - programUnit --|> #TEntityMetaLevelDependency. - programUnit --|> #TWithComments. + + tWithStatements --|> #TWithStatements. + tWithStatements --|> #TEntityMetaLevelDependency. + tWithStatements --|> #TWithComments. + tWithStatements --|> #TWithAccesses. + tWithStatements --|> #TWithInvocations. + tWithStatements --|> #TWithLocalVariables. + tWithStatements --|> #TInvocable. puBlockdata --|> programUnit. + puBlockdata --|> #TWithStatements. + puBlockdata --|> #TEntityMetaLevelDependency. + puBlockdata --|> #TWithComments. puBlockdata --|> #TWithAccesses. puBlockdata --|> #TWithLocalVariables. - puBlockdata --|> #TWithStatements. "puBlockdata --|> #TWithTypes." puComment --|> programUnit. @@ -241,24 +255,26 @@ FamixFortran77Generator >> defineHierarchy [ puFunction --|> #TTypedEntity. puMain --|> programUnit. - puMain --|> #TWithAccesses. - puMain --|> #TWithInvocations. - puMain --|> #TWithLocalVariables. - puMain --|> #TWithStatements. + puMain --|> tWithStatements. puMain --|> #TWithTypes. puProcedure --|> programUnit. puProcedure --|> #THasSignature. - puProcedure --|> #TInvocable. - puProcedure --|> #TWithAccesses. - puProcedure --|> #TWithInvocations. - puProcedure --|> #TWithLocalVariables. + puProcedure --|> tWithStatements. puProcedure --|> #TWithParameters. - puProcedure --|> #TWithStatements. puProcedure --|> #TWithTypes. puSubroutine --|> puProcedure. + + statementFunction --|> namedEntity. + statementFunction --|> #TSourceEntity. + statementFunction --|> tWithStatements. + statementFunction --|> #TTypedEntity. + statementFunction --|> #THasSignature. + statementFunction --|> #TWithParameters. + statementFunction --|> #TWithTypes. + "real --|> typeIntrinsic." type --|> #TType. @@ -325,7 +341,22 @@ FamixFortran77Generator >> defineRelations [ ((include property: #includedBy) comment: 'File including the receiver'; source) *- ((programUnit property: #includes) comment: - 'All inclusions made by this programUnits') + 'All inclusions made by this programUnits'). + + ((tWithStatements property: #statementFunctions) + comment: 'Statement functions defined in the body') + <>-* ((statementFunction property: #parentEntity) + comment: 'Entity in which body I am defined') +] + +{ #category : #definition } +FamixFortran77Generator >> defineTraits [ + + super defineTraits. + + tWithStatements := builder + newTraitNamed: 'TWithStatements' + comment: 'A trait that factorize several interesting properties for entities with statements' ] { #category : #definition } @@ -436,6 +467,12 @@ FamixFortran77Generator >> puSubroutineEntityComment [ ^ 'a subroutine procedure' ] +{ #category : #'class comment' } +FamixFortran77Generator >> statementFunctionEntityComment [ + + ^ 'a statement function' +] + { #category : #'class comment' } FamixFortran77Generator >> typeComment [ diff --git a/src/Famix-Fortran77-Generator/ManifestFamixFortran77Generator.class.st b/src/Famix-Fortran77-Generator/ManifestFamixFortran77Generator.class.st new file mode 100644 index 0000000..7d0a0f2 --- /dev/null +++ b/src/Famix-Fortran77-Generator/ManifestFamixFortran77Generator.class.st @@ -0,0 +1,15 @@ +" +Please describe the package using the class comment of the included manifest class. The manifest class also includes other additional metadata for the package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser +" +Class { + #name : #ManifestFamixFortran77Generator, + #superclass : #PackageManifest, + #category : #'Famix-Fortran77-Generator-Manifest' +} + +{ #category : #'code-critics' } +ManifestFamixFortran77Generator class >> ruleLongMethodsRuleV1FalsePositive [ + + + ^ #(#(#(#RGMethodDefinition #(#FamixFortran77Generator #defineHierarchy #false)) #'2024-06-10T16:18:04.131591+02:00') ) +]