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

Move extensions of ClassOrganization #13856

Merged
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
3 changes: 2 additions & 1 deletion src/Calypso-SystemQueries/MethodRecategorized.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ MethodRecategorized >> shouldBeConsideredByCalypsoEnvironment [
This issue means that repackaging is not performed correctly. But repackaging will be announced with separate event MethodRepackaged. So it is safe to skip recategorization.
In future this refactoring should be fixed. All objects should be in valid state when any event is triggered"

^ (oldProtocol isExtensionProtocol and: [ self newProtocol isUnclassifiedProtocol ]) not
"The nil check happens when we remove the method."
^ (oldProtocol isExtensionProtocol and: [ self newProtocol isNotNil and: [ self newProtocol isUnclassifiedProtocol ] ]) not
]
15 changes: 13 additions & 2 deletions src/CodeExport/ClassDescription.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,26 @@ ClassDescription >> fileOutOn: aFileStream [
]

{ #category : #'*CodeExport' }
ClassDescription >> fileOutOrganizationOn: aFileStream [
ClassDescription >> fileOutProtocolsOn: aFileStream [
"File a description of the receiver's organization on aFileStream."

aFileStream
cr;
nextPut: $!;
nextChunkPut: self name , ' reorganize';
cr;
nextChunkPut: self organization stringForFileOut;
nextChunkPut: (String streamContents: [ :aStream |
self organization protocols do: [ :protocol |
aStream
nextPut: $(;
nextPutAll: protocol name printString.
protocol methodSelectors do: [ :selector |
aStream
space;
nextPutAll: selector ].
aStream
nextPut: $);
cr ] ]);
cr
]

Expand Down
18 changes: 0 additions & 18 deletions src/CodeExport/ClassOrganization.extension.st

This file was deleted.

12 changes: 6 additions & 6 deletions src/CodeImport-Tests/ChunkImportTestCase.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -137,24 +137,24 @@ ChunkImportTestCase >> testImportAClass [

{ #category : #'importing-code' }
ChunkImportTestCase >> testImportAClassCategory [

| class classOrganizationString chunk |
classOrganizationString := '(#testing testImportAMethod testImportAClass)
(#auxiliar importAClass)'.
chunk := '!{1} reorganize!'.
SystemAnnouncer uniqueInstance suspendAllWhile: [ [
SystemAnnouncer uniqueInstance suspendAllWhile: [
[
class := self importAClass.

"we write the methods we will categorize"
class compileSilently: 'testImportAClass'.
class compileSilently: 'testImportAMethod'.
class compileSilently: 'importAClass'.

CodeImporter evaluateString: (chunk format: { class name asString }), classOrganizationString.
CodeImporter evaluateString: (chunk format: { class name asString }) , classOrganizationString.
"we do not care about the order of the output just that all the elements are present"
self
assertCollection: (classOrganizationString trimBoth findTokens: String cr, ' ()') sorted
equals: (class organization stringForFileOut findTokens: String cr, ' ()') sorted.
] ensure: [ class ifNotNil: [ class removeFromSystem ] ] ]
self assert: (((String streamContents: [ :s | class fileOutProtocolsOn: s ]) findTokens: String cr , ' ()') includesAll:
(classOrganizationString trimBoth findTokens: String cr , ' ()')) ] ensure: [ class ifNotNil: [ class removeFromSystem ] ] ]
]

{ #category : #'importing-code' }
Expand Down
20 changes: 0 additions & 20 deletions src/CodeImport/ClassOrganization.extension.st

This file was deleted.

19 changes: 16 additions & 3 deletions src/CodeImport/ClassOrganizationChunk.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,23 @@ ClassOrganizationChunk >> description [

{ #category : #importing }
ClassOrganizationChunk >> importFor: aRequestor logSource: logSource [
(self existsBehavior)
ifFalse: [ self error: ('Cannot change organization of unexistent behavior {1}' format: { behaviorName asString } ) ].

self targetClass organization changeFromString: contents
| organization protocolSpecs |
self existsBehavior ifFalse: [ self error: ('Cannot change organization of unexistent behavior {1}' format: { behaviorName asString }) ].

organization := self targetClass organization.
protocolSpecs := contents parseLiterals.

organization reset.

"If nothing was scanned and I had no elements before, then default me"
(protocolSpecs isEmpty and: [ organization protocols isEmpty ]) ifTrue: [ ^ self ].

protocolSpecs do: [ :spec |
| protocolName methods |
protocolName := spec first asSymbol.
methods := spec allButFirst asSet.
organization addProtocol: (Protocol name: protocolName methodSelectors: methods) ]
]

{ #category : #testing }
Expand Down
2 changes: 1 addition & 1 deletion src/System-Changes/ChangeSet.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ ChangeSet >> fileOutPSFor: class on: stream [
cr ].
(classRecord includesChangeType: #reorganize)
ifFalse: [ ^ self ].
class fileOutOrganizationOn: stream.
class fileOutProtocolsOn: stream.
stream cr
]

Expand Down