Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moose critics metamodel #1131

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/Famix-CriticBrowser-Entities/FamixCBCondition.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
## Relations
======================

### Parents
| Relation | Origin | Opposite | Type | Comment |
|---|
| `ruleContainer` | `FamixCBTRuleComponent` | `ruleComponents` | `FamixCBTRuleComposite` | Parent context, if it exists.|

### Other
| Relation | Origin | Opposite | Type | Comment |
|---|
| `parent` | `FamixCBTRuleComponent` | `children` | `FamixCBContext` | Parent context, if it exists.|
| `violations` | `FamixCBCondition` | `violatedCondition` | `FamixCBViolation` | Every violation of this condition.|


Expand Down Expand Up @@ -135,7 +139,8 @@ FamixCBCondition >> runOn: aCollection withCallback: aBlock [

{ #category : #removing }
FamixCBCondition >> runUpTree: aCollection [
self runOn: (parent runUpTree: aCollection)

self runOn: (self ruleContainer runUpTree: aCollection)
]

{ #category : #accessing }
Expand Down
63 changes: 24 additions & 39 deletions src/Famix-CriticBrowser-Entities/FamixCBContext.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
## Relations
======================

### Parents
| Relation | Origin | Opposite | Type | Comment |
|---|
| `ruleContainer` | `FamixCBTRuleComponent` | `ruleComponents` | `FamixCBTRuleComposite` | Parent context, if it exists.|

### Children
| Relation | Origin | Opposite | Type | Comment |
|---|
| `ruleComponents` | `FamixCBTRuleComposite` | `ruleContainer` | `FamixCBTRuleComponent` | Every child context or condition of this context.|

### Other
| Relation | Origin | Opposite | Type | Comment |
|---|
| `children` | `FamixCBContext` | `parent` | `FamixCBTRuleComponent` | Every child context or condition of this context.|
| `entities` | `FamixCBContext` | `contexts` | `MooseObject` | Every entity that is a part of the context.|
| `parent` | `FamixCBTRuleComponent` | `children` | `FamixCBContext` | Parent context, if it exists.|


## Properties
Expand All @@ -23,10 +31,9 @@
Class {
#name : #FamixCBContext,
#superclass : #FamixCBEntity,
#traits : 'FamixCBTRuleComponent',
#classTraits : 'FamixCBTRuleComponent classTrait',
#traits : 'FamixCBTRuleComponent + FamixCBTRuleComposite',
#classTraits : 'FamixCBTRuleComponent classTrait + FamixCBTRuleComposite classTrait',
#instVars : [
'#children => FMMany type: #FamixCBTRuleComponent opposite: #parent',
'#contextBlock => FMProperty'
],
#category : #'Famix-CriticBrowser-Entities-Entities'
Expand Down Expand Up @@ -60,13 +67,8 @@ FamixCBContext class >> named: aString on: anObject summary: aSummary [

{ #category : #adding }
FamixCBContext >> addChild: aRuleComponent [
aRuleComponent parent: self
]

{ #category : #adding }
FamixCBContext >> addChildren: anObject [
<generated>
^ self children add: anObject
aRuleComponent ruleContainer: self
]

{ #category : #adding }
Expand All @@ -75,23 +77,6 @@ FamixCBContext >> addEntity: anObject [
^ self entities add: anObject
]

{ #category : #accessing }
FamixCBContext >> children [
"Relation named: #children type: #FamixCBTRuleComponent opposite: #parent"

<generated>
<FMComment: 'Every child context or condition of this context.'>
<derived>
^ children
]

{ #category : #accessing }
FamixCBContext >> children: anObject [

<generated>
children value: anObject
]

{ #category : #accessing }
FamixCBContext >> contextBlock [

Expand Down Expand Up @@ -127,32 +112,32 @@ FamixCBContext >> entities: anObject [

{ #category : #'as yet unclassified' }
FamixCBContext >> putViolationsInto: aDictionary [
children do: [ :child | child putViolationsInto: aDictionary ]
self ruleComponents do: [ :child | child putViolationsInto: aDictionary ]

]

{ #category : #removing }
FamixCBContext >> removeChild: aRuleComponent [

(children includes: aRuleComponent) ifFalse: [ ^ self ].
children remove: aRuleComponent.
(self ruleComponents includes: aRuleComponent) ifFalse: [ ^ self ].
self ruleComponents remove: aRuleComponent.
aRuleComponent setParentToNilIfNeeded.
aRuleComponent resetExecutionOfTree
]

{ #category : #removing }
FamixCBContext >> resetExecutionOfTree [
self entities removeAll.
children do: [ :child | child resetExecutionOfTree ]

self entities removeAll.
self ruleComponents do: [ :child | child resetExecutionOfTree ]
]

{ #category : #running }
FamixCBContext >> runDownTree: aCollection withCallback: aBlock [

self entities ifEmpty: [
self entities ifEmpty: [
self runOn: aCollection withCallback: aBlock ].
children do: [ :child |
self ruleComponents do: [ :child |
child runDownTree: self entities asMooseGroup withCallback: aBlock ]
]

Expand All @@ -173,7 +158,7 @@ FamixCBContext >> runOn: aCollection withCallback: aBlock [
{ #category : #'as yet unclassified' }
FamixCBContext >> runUpTree: aCollection [

self entities ifEmpty: [ self runOn: (parent runUpTree: aCollection) ].
self entities ifEmpty: [ self runOn: (self ruleContainer runUpTree: aCollection) ].
^ self entities
]

Expand All @@ -199,8 +184,8 @@ FamixCBContext >> tagRuleResult [

| model |

model := children ifNotEmpty: [
(children first violations collect: #violatingEntity) first
model := self ruleComponents ifNotEmpty: [
(self ruleComponents first violations collect: #violatingEntity) first
mooseModel ].
children do: [ :c | c tagRuleResultInModel: model ]
self ruleComponents do: [ :c | c tagRuleResultInModel: model ]
]
7 changes: 7 additions & 0 deletions src/Famix-CriticBrowser-Entities/FamixCBEntity.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@ FamixCBEntity class >> metamodel [
<generated>
^ FamixCBModel metamodel
]

{ #category : #testing }
FamixCBEntity >> isQueryable [

<generated>
^ false
]
59 changes: 36 additions & 23 deletions src/Famix-CriticBrowser-Entities/FamixCBTRuleComponent.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ I allow a rule component to be named and summarized.
## Relations
======================

### Other
### Parents
| Relation | Origin | Opposite | Type | Comment |
|---|
| `parent` | `FamixCBTRuleComponent` | `children` | `FamixCBContext` | Parent context, if it exists.|
| `ruleContainer` | `FamixCBTRuleComponent` | `ruleComponents` | `FamixCBTRuleComposite` | Parent context, if it exists.|


## Properties
Expand All @@ -22,11 +22,11 @@ I allow a rule component to be named and summarized.
Trait {
#name : #FamixCBTRuleComponent,
#instVars : [
'#parent => FMOne type: #FamixCBContext opposite: #children',
'#ruleContainer => FMOne type: #FamixCBTRuleComposite opposite: #ruleComponents',
'#summary => FMProperty'
],
#traits : 'FamixTNamedEntity',
#classTraits : 'FamixTNamedEntity classTrait',
#traits : 'FamixTNamedEntity + TEntityMetaLevelDependency',
#classTraits : 'FamixTNamedEntity classTrait + TEntityMetaLevelDependency classTrait',
#category : #'Famix-CriticBrowser-Entities-Traits'
}

Expand All @@ -45,47 +45,60 @@ FamixCBTRuleComponent classSide >> stonAllInstVarNames [
]

{ #category : #accessing }
FamixCBTRuleComponent >> allParents [
FamixCBTRuleComponent >> parent [

self
deprecated: ''
transformWith: '`@receiver parent' -> '`@receiver ruleContainer'.

^ parent
ifNil: [ { } ]
ifNotNil: [ self allParentsIn: OrderedCollection new ]
^ self ruleContainer
]

{ #category : #accessing }
FamixCBTRuleComponent >> allParentsIn: anOrderedCollection [
FamixCBTRuleComponent >> parent: anObject [

self
deprecated: ''
transformWith:
'`@receiver parent: `@arg' -> '`@receiver ruleContainer: `@arg'.

^ parent ifNil: [ anOrderedCollection ] ifNotNil: [
anOrderedCollection add: self parent.
self parent allParentsIn: anOrderedCollection ]
^ self ruleContainer: anObject
]

{ #category : #removing }
FamixCBTRuleComponent >> removeSelfFromTree [

self ruleContainer removeChild: self
]

{ #category : #accessing }
FamixCBTRuleComponent >> parent [
"Relation named: #parent type: #FamixCBContext opposite: #children"
FamixCBTRuleComponent >> ruleContainer [
"Relation named: #ruleContainer type: #FamixCBTRuleComposite opposite: #ruleComponents"

<generated>
<FMComment: 'Parent context, if it exists.'>
^ parent
<container>
^ ruleContainer
]

{ #category : #accessing }
FamixCBTRuleComponent >> parent: anObject [
FamixCBTRuleComponent >> ruleContainer: anObject [

<generated>
parent := anObject
ruleContainer := anObject
]

{ #category : #removing }
FamixCBTRuleComponent >> removeSelfFromTree [

self parent removeChild: self
{ #category : #navigation }
FamixCBTRuleComponent >> ruleContainerGroup [
<generated>
<navigation: 'RuleContainer'>
^ MooseSpecializedGroup with: self ruleContainer
]

{ #category : #initialization }
FamixCBTRuleComponent >> setParentToNilIfNeeded [

parent ifNotNil: [ self parent: nil ]
self ruleContainer ifNotNil: [ self ruleContainer: nil ]
]

{ #category : #accessing }
Expand Down
62 changes: 62 additions & 0 deletions src/Famix-CriticBrowser-Entities/FamixCBTRuleComposite.trait.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"
I contain rule components

## Relations
======================

### Children
| Relation | Origin | Opposite | Type | Comment |
|---|
| `ruleComponents` | `FamixCBTRuleComposite` | `ruleContainer` | `FamixCBTRuleComponent` | Every child context or condition of this context.|



"
Trait {
#name : #FamixCBTRuleComposite,
#instVars : [
'#ruleComponents => FMMany type: #FamixCBTRuleComponent opposite: #ruleContainer'
],
#traits : 'TEntityMetaLevelDependency',
#classTraits : 'TEntityMetaLevelDependency classTrait',
#category : #'Famix-CriticBrowser-Entities-Traits'
}

{ #category : #meta }
FamixCBTRuleComposite classSide >> annotation [

<FMClass: #TRuleComposite super: #Object>
<package: #'Famix-CriticBrowser-Entities'>
<generated>
^ self
]

{ #category : #adding }
FamixCBTRuleComposite >> addRuleComponent: anObject [
<generated>
^ self ruleComponents add: anObject
]

{ #category : #accessing }
FamixCBTRuleComposite >> ruleComponents [
"Relation named: #ruleComponents type: #FamixCBTRuleComponent opposite: #ruleContainer"

<generated>
<FMComment: 'Every child context or condition of this context.'>
<derived>
^ ruleComponents
]

{ #category : #accessing }
FamixCBTRuleComposite >> ruleComponents: anObject [

<generated>
ruleComponents value: anObject
]

{ #category : #navigation }
FamixCBTRuleComposite >> ruleComponentsGroup [
<generated>
<navigation: 'RuleComponents'>
^ MooseSpecializedGroup withAll: self ruleComponents asSet
]
Loading
Loading