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

Avoid analyzing classes in Manifest methods while checking ReClassesHaveNoReferencesCondition #16954

Merged
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
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 [

hernanmd marked this conversation as resolved.
Show resolved Hide resolved
^ 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
]