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

simplify-conditionals #2166

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 21 additions & 36 deletions src/Fame-GT/FMMetaModel.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,28 @@ FMMetaModel >> gtInspectorClassesIn: composite [
<gtInspectorPresentationOrder: 0>
^ composite fastList
title: 'Classes';
display: [ self classes sorted: [:x :y | x fullName < y fullName] ];
format: [ :each |
each isAbstract
ifTrue: [ Text string: each fullName attribute: TextEmphasis italic ]
ifFalse: [ Text fromString: each fullName ] ];
tags: [ :each |
each package isNil
ifTrue: [ #() ]
ifFalse: [ each package name ] ];
morphicSelectionAct: [ :list | list selection implementingClass browse ]
icon: GLMUIThemeExtraIcons glamorousBrowse
on: $b
entitled: 'Browse implementation'
display: [ self classes sorted: [ :x :y | x fullName < y fullName ] ];
format: [ :each | each isAbstract ifTrue: [ Text string: each fullName attribute: TextEmphasis italic ] ifFalse: [ Text fromString: each fullName ] ];
tags: [ :each | each package ifNil: [ #() ] ifNotNil: [ each package name ] ];
morphicSelectionAct: [ :list | list selection implementingClass browse ]
icon: GLMUIThemeExtraIcons glamorousBrowse
on: $b
entitled: 'Browse implementation'
]

{ #category : #'*Fame-GT' }
FMMetaModel >> gtInspectorHierarchiesIn: composite [
<gtInspectorPresentationOrder: 2>
^ composite tree
title: 'Hierarchies';
display: [ (self classes select: [ :each | each superclass = FM3Class object ]) sorted: [:x :y | x fullName < y fullName] ];
children: [ :c | c subclasses sorted: [:x :y | x fullName < y fullName] ];
format: [ :each |
each isAbstract
ifTrue: [ Text string: each fullName attribute: TextEmphasis italic ]
ifFalse: [ Text fromString: each fullName ] ];
tags: [ :each |
each package isNil
ifTrue: [ #() ]
ifFalse: [ each package name ] ];
morphicSelectionAct: [ :list | list selection implementingClass browse ]
icon: GLMUIThemeExtraIcons glamorousBrowse
on: $b
entitled: 'Browse implementation'
display: [ (self classes select: [ :each | each superclass = FM3Class object ]) sorted: [ :x :y | x fullName < y fullName ] ];
children: [ :c | c subclasses sorted: [ :x :y | x fullName < y fullName ] ];
format: [ :each | each isAbstract ifTrue: [ Text string: each fullName attribute: TextEmphasis italic ] ifFalse: [ Text fromString: each fullName ] ];
tags: [ :each | each package ifNil: [ #() ] ifNotNil: [ each package name ] ];
morphicSelectionAct: [ :list | list selection implementingClass browse ]
icon: GLMUIThemeExtraIcons glamorousBrowse
on: $b
entitled: 'Browse implementation'
]

{ #category : #'*Fame-GT' }
Expand All @@ -55,16 +43,13 @@ FMMetaModel >> gtInspectorPropertiesIn: composite [
<gtInspectorPresentationOrder: 5>
^ composite table
title: 'Properties';
display: [ self properties sorted: [:x :y | x fullName < y fullName] ];
column: 'Name' evaluated: [ :each | each gtDisplayString ] tags: [ :each |
each package isNil
ifTrue: [ #() ]
ifFalse: [ each package name ] ];
display: [ self properties sorted: [ :x :y | x fullName < y fullName ] ];
column: 'Name' evaluated: [ :each | each gtDisplayString ] tags: [ :each | each package ifNil: [ #() ] ifNotNil: [ each package name ] ];
column: 'Type' evaluated: [ :each | each gtTypeString ];
morphicSelectionAct: [ :list | list selection implementingClass browse ]
icon: GLMUIThemeExtraIcons glamorousBrowse
on: $b
entitled: 'Browse implementation'
morphicSelectionAct: [ :list | list selection implementingClass browse ]
icon: GLMUIThemeExtraIcons glamorousBrowse
on: $b
entitled: 'Browse implementation'
]

{ #category : #'*Fame-GT' }
Expand Down
12 changes: 4 additions & 8 deletions src/Fame-ImportExport/FMAbstractCodeGenerator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ FMAbstractCodeGenerator >> annotationStringForProperty: property [
]

{ #category : #'compiling-names' }
FMAbstractCodeGenerator >> categoryNameFor: fameClass [
^self defaultCategory isNil
ifTrue: [ fameClass package name asString ]
ifFalse: [ self defaultCategory ]
FMAbstractCodeGenerator >> categoryNameFor: fameClass [
^ self defaultCategory ifNil: [ fameClass package name asString ] ifNotNil: [ self defaultCategory ]
]

{ #category : #'compiling-names' }
Expand Down Expand Up @@ -259,10 +257,8 @@ FMAbstractCodeGenerator >> visitClass: fameClass [
]

{ #category : #visiting }
FMAbstractCodeGenerator >> visitClassDone: fameClass [
instVarNames do: [ :symbol |
(rbClass whoDefinesInstanceVariable: symbol) isNil
ifTrue: [ rbClass addInstanceVariable: symbol ]].
FMAbstractCodeGenerator >> visitClassDone: fameClass [
instVarNames do: [ :symbol | (rbClass whoDefinesInstanceVariable: symbol) ifNil: [ rbClass addInstanceVariable: symbol ] ].
self compileInitialize: initializeSource contents
]

Expand Down
4 changes: 1 addition & 3 deletions src/Famix-Compatibility-Entities/FAMIXPackage.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ FAMIXPackage >> extensionMethods [

{ #category : #'Moose-Hismo' }
FAMIXPackage >> historicalUniqueName [
^ (self parentPackage isNil
ifTrue: [ self name ]
ifFalse: [ self parentPackage historicalUniqueName , '.' , self name ]) asSymbol
^ (self parentPackage ifNil: [ self name ] ifNotNil: [ self parentPackage historicalUniqueName , '.' , self name ]) asSymbol
]

{ #category : #'Famix-Smalltalk' }
Expand Down
5 changes: 2 additions & 3 deletions src/Famix-Compatibility-Entities/FAMIXTypeAlias.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ FAMIXTypeAlias >> allSuperclassesDo: aBlock [
FAMIXTypeAlias >> realType [
"The alias type is just an alias.
The real type is the one provided by the aliasedType "
^ self aliasedType isNil
ifTrue: [nil]
ifFalse: [self aliasedType realType]

^ self aliasedType ifNil: [ nil ] ifNotNil: [ self aliasedType realType ]
]
6 changes: 3 additions & 3 deletions src/Famix-Traits/FamixTAccess.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ FamixTAccess >> isAccess [

{ #category : #accessing }
FamixTAccess >> isRead [
<FMProperty: #isRead type: #Boolean> <derived>
<FMProperty: #isRead type: #Boolean>
<derived>
<FMComment: 'Read access'>

^ isWrite isNil ifTrue: [ false ] ifFalse: [ isWrite not ]
^ isWrite ifNil: [ false ] ifNotNil: [ isWrite not ]
]

{ #category : #accessing }
Expand Down
1 change: 0 additions & 1 deletion src/Famix-Traits/FamixTAnnotationInstance.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Trait {
'#annotatedEntity => FMOne type: #FamixTWithAnnotationInstances opposite: #annotationInstances'
],
#traits : 'TEntityMetaLevelDependency + TDependencyQueries',
#classTraits : 'TEntityMetaLevelDependency classTrait + TDependencyQueries classTrait',
#category : #'Famix-Traits-AnnotationInstance'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Trait {
'#value => FMProperty'
],
#traits : 'TEntityMetaLevelDependency + TDependencyQueries',
#classTraits : 'TEntityMetaLevelDependency classTrait + TDependencyQueries classTrait',
#category : #'Famix-Traits-AnnotationInstanceAttribute'
}

Expand Down
1 change: 0 additions & 1 deletion src/Famix-Traits/FamixTAssociation.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Trait {
'#previous => FMOne type: #FamixTAssociation opposite: #next'
],
#traits : 'FamixTSourceEntity + TAssociationMetaLevelDependency',
#classTraits : 'FamixTSourceEntity classTrait + TAssociationMetaLevelDependency classTrait',
#category : #'Famix-Traits-Association'
}

Expand Down
1 change: 0 additions & 1 deletion src/Famix-Traits/FamixTAttribute.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Trait {
'#parentType => FMOne type: #FamixTWithAttributes opposite: #attributes'
],
#traits : 'FamixTStructuralEntity',
#classTraits : 'FamixTStructuralEntity classTrait',
#category : #'Famix-Traits-Attribute'
}

Expand Down
1 change: 0 additions & 1 deletion src/Famix-Traits/FamixTClass.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ A class is typically scoped in a namespace. To model nested or anonymous classes
Trait {
#name : #FamixTClass,
#traits : 'FamixTNamedEntity - {#mooseNameOn:} + FamixTWithMethods + FamixTWithInheritances + FamixTWithAttributes + FamixTType + FamixTPackageable + FamixTInvocationsReceiver + FamixTWithComments',
#classTraits : 'FamixTNamedEntity classTrait + FamixTWithMethods classTrait + FamixTWithInheritances classTrait + FamixTWithAttributes classTrait + FamixTType classTrait + FamixTPackageable classTrait + FamixTInvocationsReceiver classTrait + FamixTWithComments classTrait',
#category : #'Famix-Traits-Class'
}

Expand Down
1 change: 0 additions & 1 deletion src/Famix-Traits/FamixTCohesionCouplingMetrics.trait.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Trait {
#name : #FamixTCohesionCouplingMetrics,
#traits : 'FamixTPackage',
#classTraits : 'FamixTPackage classTrait',
#category : #'Famix-Traits-Package'
}

Expand Down
1 change: 0 additions & 1 deletion src/Famix-Traits/FamixTFile.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Trait {
'#entities => FMMany type: #FamixTWithFiles opposite: #containerFiles'
],
#traits : 'FamixTFileSystemEntity',
#classTraits : 'FamixTFileSystemEntity classTrait',
#category : #'Famix-Traits-File'
}

Expand Down
1 change: 0 additions & 1 deletion src/Famix-Traits/FamixTFileInclude.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Trait {
'#target => FMOne type: #FamixTWithFileIncludes opposite: #incomingIncludeRelations'
],
#traits : 'FamixTAssociation',
#classTraits : 'FamixTAssociation classTrait',
#category : #'Famix-Traits-FileInclude'
}

Expand Down
1 change: 0 additions & 1 deletion src/Famix-Traits/FamixTFolder.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Trait {
'#childrenFileSystemEntities => FMMany type: #FamixTFileSystemEntity opposite: #parentFolder'
],
#traits : 'FamixTFileSystemEntity',
#classTraits : 'FamixTFileSystemEntity classTrait',
#category : #'Famix-Traits-File'
}

Expand Down
1 change: 0 additions & 1 deletion src/Famix-Traits/FamixTFunction.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Trait {
'#functionOwner => FMOne type: #FamixTWithFunctions opposite: #functions'
],
#traits : 'FamixTHasSignature + FamixTNamedEntity + FamixTTypedEntity',
#classTraits : 'FamixTHasSignature classTrait + FamixTNamedEntity classTrait + FamixTTypedEntity classTrait',
#category : #'Famix-Traits-Behavioral'
}

Expand Down
1 change: 0 additions & 1 deletion src/Famix-Traits/FamixTGlobalVariable.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Trait {
'#parentScope => FMOne type: #FamixTWithGlobalVariables opposite: #globalVariables'
],
#traits : 'FamixTStructuralEntity',
#classTraits : 'FamixTStructuralEntity classTrait',
#category : #'Famix-Traits-GlobalVariable'
}

Expand Down
1 change: 0 additions & 1 deletion src/Famix-Traits/FamixTImplicitVariable.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Trait {
'#parentBehaviouralEntity => FMOne type: #FamixTWithImplicitVariables opposite: #implicitVariables'
],
#traits : 'FamixTStructuralEntity',
#classTraits : 'FamixTStructuralEntity classTrait',
#category : #'Famix-Traits-ImplicitVariable'
}

Expand Down
1 change: 0 additions & 1 deletion src/Famix-Traits/FamixTInheritance.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Trait {
'#superclass => FMOne type: #FamixTWithInheritances opposite: #subInheritances'
],
#traits : 'FamixTAssociation',
#classTraits : 'FamixTAssociation classTrait',
#category : #'Famix-Traits-Inheritance'
}

Expand Down
1 change: 0 additions & 1 deletion src/Famix-Traits/FamixTInvocation.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Trait {
'#sender => FMOne type: #FamixTWithInvocations opposite: #outgoingInvocations'
],
#traits : 'FamixTAssociation',
#classTraits : 'FamixTAssociation classTrait',
#category : #'Famix-Traits-Invocation'
}

Expand Down
1 change: 0 additions & 1 deletion src/Famix-Traits/FamixTLocalVariable.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Trait {
'#parentBehaviouralEntity => FMOne type: #FamixTWithLocalVariables opposite: #localVariables'
],
#traits : 'FamixTStructuralEntity',
#classTraits : 'FamixTStructuralEntity classTrait',
#category : #'Famix-Traits-LocalVariable'
}

Expand Down
1 change: 0 additions & 1 deletion src/Famix-Traits/FamixTMethod.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Trait {
'#parentType => FMOne type: #FamixTWithMethods opposite: #methods'
],
#traits : 'FamixTHasSignature + FamixTInvocable + FamixTSourceEntity + FamixTTypedEntity + FamixTWithAccesses + FamixTWithClassScope + FamixTWithImplicitVariables + FamixTWithInvocations + FamixTWithLocalVariables + FamixTWithParameters + FamixTWithReferences',
#classTraits : 'FamixTHasSignature classTrait + FamixTInvocable classTrait + FamixTSourceEntity classTrait + FamixTTypedEntity classTrait + FamixTWithAccesses classTrait + FamixTWithClassScope classTrait + FamixTWithImplicitVariables classTrait + FamixTWithInvocations classTrait + FamixTWithLocalVariables classTrait + FamixTWithParameters classTrait + FamixTWithReferences classTrait',
#category : #'Famix-Traits-Behavioral'
}

Expand Down
1 change: 0 additions & 1 deletion src/Famix-Traits/FamixTParameter.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Trait {
'#parentBehaviouralEntity => FMOne type: #FamixTWithParameters opposite: #parameters'
],
#traits : 'FamixTStructuralEntity',
#classTraits : 'FamixTStructuralEntity classTrait',
#category : #'Famix-Traits-Parameter'
}

Expand Down
1 change: 0 additions & 1 deletion src/Famix-Traits/FamixTReference.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Trait {
'#target => FMOne type: #FamixTReferenceable opposite: #incomingReferences'
],
#traits : 'FamixTAssociation',
#classTraits : 'FamixTAssociation classTrait',
#category : #'Famix-Traits-Reference'
}

Expand Down
1 change: 0 additions & 1 deletion src/Famix-Traits/FamixTSourceEntity.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Trait {
'#isStub => FMProperty'
],
#traits : 'FamixTWithSourceAnchor + FamixTWithSourceLanguage + FamixTWithComments',
#classTraits : 'FamixTWithSourceAnchor classTrait + FamixTWithSourceLanguage classTrait + FamixTWithComments classTrait',
#category : #'Famix-Traits-Traits'
}

Expand Down
1 change: 0 additions & 1 deletion src/Famix-Traits/FamixTStructuralEntity.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ FAMIXStructuralEntity is the abstract superclass for basic data structure in the
Trait {
#name : #FamixTStructuralEntity,
#traits : 'FamixTNamedEntity + FamixTAccessible + FamixTInvocationsReceiver + FamixTTypedEntity',
#classTraits : 'FamixTNamedEntity classTrait + FamixTAccessible classTrait + FamixTInvocationsReceiver classTrait + FamixTTypedEntity classTrait',
#category : #'Famix-Traits-Traits'
}

Expand Down
1 change: 0 additions & 1 deletion src/Famix-Traits/FamixTTraitUsage.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Trait {
'#user => FMOne type: #FamixTTraitUser opposite: #outgoingTraitUsages'
],
#traits : 'FamixTAssociation',
#classTraits : 'FamixTAssociation classTrait',
#category : #'Famix-Traits-Trait'
}

Expand Down
1 change: 0 additions & 1 deletion src/Famix-Traits/FamixTType.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Trait {
'#typedEntities => FMMany type: #FamixTTypedEntity opposite: #declaredType'
],
#traits : 'FamixTReferenceable',
#classTraits : 'FamixTReferenceable classTrait',
#category : #'Famix-Traits-Type'
}

Expand Down
19 changes: 7 additions & 12 deletions src/Famix-Traits/FamixTWithMethods.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -236,24 +236,21 @@ FamixTWithMethods >> tightClassCohesion [
self flag: #TODO.
^ self
lookUpPropertyNamed: #tightClassCohesion
computedAs: [
| tcc accessDictionary nom |
computedAs: [ | tcc accessDictionary nom |
tcc := 0.
accessDictionary := Dictionary new.
self
methods do: [ :eachMethod |
self methods
do: [ :eachMethod |
eachMethod accesses
do: [ :eachAccess |
| var |
var := eachAccess variable.
var isAttribute
ifTrue: [
| varName accessedFrom |
ifTrue: [ | varName accessedFrom |
varName := var name.
accessedFrom := accessDictionary at: varName ifAbsent: [ ].
accessedFrom isNil
ifTrue: [
accessedFrom := Set new.
accessedFrom
ifNil: [ accessedFrom := Set new.
accessDictionary at: varName put: accessedFrom ].
accessedFrom add: eachMethod name ] ] ].
accessDictionary values
Expand All @@ -262,9 +259,7 @@ FamixTWithMethods >> tightClassCohesion [
size := each size.
tcc := tcc + (size * (size - 1) / 2) ].
nom := self numberOfMethods.
tcc := (nom = 0 or: [ nom = 1 ])
ifFalse: [ tcc / (nom * (nom - 1) / 2) ]
ifTrue: [ 0 ].
tcc := (nom = 0 or: [ nom = 1 ]) ifFalse: [ tcc / (nom * (nom - 1) / 2) ] ifTrue: [ 0 ].
tcc asFloat ]
]

Expand Down
6 changes: 2 additions & 4 deletions src/Moose-Core/MooseAbstractGroup.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,8 @@ MooseAbstractGroup >> entityNamed: aMooseName ifAbsent: aBlock [
{ #category : #'public interface' }
MooseAbstractGroup >> entityNamed: aMooseName ifAbsent: aBlock ifPresent: anotherBlock [
| entity |
entity := self entityStorage at: aMooseName ifAbsent: [nil].
^ entity isNil
ifTrue: [aBlock value]
ifFalse: [anotherBlock value: entity]
entity := self entityStorage at: aMooseName ifAbsent: [ nil ].
^ entity ifNil: [ aBlock value ] ifNotNil: [ anotherBlock value: entity ]
]

{ #category : #'public interface' }
Expand Down
6 changes: 3 additions & 3 deletions src/Moose-Core/MooseObject.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ MooseObject >> mooseName [
MooseObject >> mooseNameOn: aStream [
"Hook to customize the rendered text of an entity. Do not specialize mooseName, but change/specialize this method if necessary."

self mooseID isNil
ifTrue: [ aStream nextPutAll: 'nil mooseID!!!' ]
ifFalse: [ self name ifNil: [ aStream print: self mooseID ] ifNotNil: [ aStream nextPutAll: self name ] ]
self mooseID
ifNil: [ aStream nextPutAll: 'nil mooseID!!!' ]
ifNotNil: [ self name ifNil: [ aStream print: self mooseID ] ifNotNil: [ aStream nextPutAll: self name ] ]
]

{ #category : #accessing }
Expand Down
5 changes: 2 additions & 3 deletions src/Moose-DistributionMap/AbstractDistributionMap.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ AbstractDistributionMap >> defaultTitle [
{ #category : #'element-titles' }
AbstractDistributionMap >> elementTitleBlock [
"by default the title is just the title"
^ elementTitleBlock isNil
ifTrue: [self defaultElementTitleFormattingBlock]
ifFalse: [elementTitleBlock]

^ elementTitleBlock ifNil: [ self defaultElementTitleFormattingBlock ] ifNotNil: [ elementTitleBlock ]
]

{ #category : #'element-titles' }
Expand Down