Skip to content

Commit

Permalink
Merge pull request #16954 from hernanmd/fix_exclude_package_manifest_…
Browse files Browse the repository at this point in the history
…from_classref_rule

Avoid analyzing classes in Manifest methods while checking ReClassesHaveNoReferencesCondition
  • Loading branch information
jecisc authored Jul 31, 2024
2 parents 8730faa + 9d05ffc commit 29bb15d
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 5 deletions.
43 changes: 43 additions & 0 deletions src/Refactoring-Core-Tests/RBClassTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,49 @@ RBClassTest >> testIsInstanceSide [

]

{ #category : 'tests - navigation' }
RBClassTest >> testIsManifest [

| pmNamespace packageManifestClass |

pmNamespace := RBNamespace new.
pmNamespace defineClass: [ :aBuilder |
aBuilder
name: #PackageManifestForRBClassTest;
superclass: PackageManifest ;
package: #'Refactory-Testing' ].
packageManifestClass := pmNamespace classNamed: #PackageManifestForRBClassTest.

self assert: packageManifestClass isManifest.
]

{ #category : 'tests - navigation' }
RBClassTest >> testIsManifestTransformationClass [

self
deny: abstractTransformationClass classSide isManifest
description: 'It tests that a transformation class is not manifest'.
self
deny: abstractTransformationClass isManifest
description: 'It tests that a transformation is not manifest'.
]

{ #category : 'tests - navigation' }
RBClassTest >> testIsManifestWhenSuperclassIsUndefined [

| pmNamespace packageManifestClass |

pmNamespace := RBNamespace new.
pmNamespace defineClass: [ :aBuilder |
aBuilder
name: #PackageManifestForRBClassTest;
superclass: nil ;
package: #'Refactory-Testing' ].
packageManifestClass := pmNamespace classNamed: #PackageManifestForRBClassTest.

self deny: packageManifestClass isManifest.
]

{ #category : 'tests - navigation' }
RBClassTest >> testIsMeta [

Expand Down
7 changes: 7 additions & 0 deletions src/Refactoring-Core/RBClass.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ RBClass >> isEmptyClass [
self selectors isEmpty]]
]

{ #category : 'testing' }
RBClass >> isManifest [

^ self superclass notNil and: [ self superclass name = #PackageManifest ]

]

{ #category : 'testing' }
RBClass >> isMeta [

Expand Down
6 changes: 6 additions & 0 deletions src/Refactoring-Core/RBMetaclass.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ RBMetaclass >> directlyDefinesPoolDictionary: aString [
^ self instanceSide directlyDefinesPoolDictionary: aString
]

{ #category : 'testing' }
RBMetaclass >> isManifest [

^ self instanceSide isManifest
]

{ #category : 'testing' }
RBMetaclass >> isMeta [
^true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ ReClassesHaveNoReferencesCondition >> violators [
classes do: [ :aClass |
| methodsReferencingClass |
methodsReferencingClass := (model methodsReferencingClass: aClass) reject: [ :each |
classes includes: each methodClass ].
(classes includes: each methodClass) or: [ each methodClass isManifest ] ].
methodsReferencingClass ifNotEmpty: [
referencingClassesDictionary
at: aClass
put: methodsReferencingClass ] ].
referencingClassesDictionary
]
referencingClassesDictionary ]
]
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ RBRemoveProtocolTransformationTest >> testTransform [
transformation := (RBAddProtocolTransformation
protocol: 'transforming'
inClass: #RBDummyEmptyClass).
transformation generateChanges.
transformation execute.

transformation := (RBRemoveProtocolTransformation
model: transformation model
protocol: 'transforming'
inClass: #RBDummyEmptyClass).
transformation generateChanges.
transformation execute.

self assert: transformation model changes changes size equals: 2
]

0 comments on commit 29bb15d

Please sign in to comment.