Skip to content

Commit

Permalink
Changes for #121, #122, #124 and #13
Browse files Browse the repository at this point in the history
  • Loading branch information
eMaringolo committed Nov 28, 2022
1 parent 7aeb1ef commit 9931ee8
Show file tree
Hide file tree
Showing 15 changed files with 314 additions and 324 deletions.
8 changes: 4 additions & 4 deletions source/.configmaps
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
},
{
#conditions : [ ],
#ts : 3836967970,
#ts : 3812608505,
#comment : '',
#formatVersion : '1.1',
#applications : OrderedCollection [
Expand All @@ -67,11 +67,11 @@
},
{
#name : 'TonelWriterTests',
#versionName : 'f2be7a2-master',
#ts : 3836967969
#versionName : 'b495 + 68281 b',
#ts : 3812609757
}
],
#name : 'Test ENVY/Image Tonel',
#versionName : '1.5.6'
#versionName : 'V 11.0.0 [496]'
}
]
8 changes: 7 additions & 1 deletion source/TonelLoaderModel/TonelApplicationLoader.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ TonelApplicationLoader >> alwaysCreateEditions [
^self loader alwaysCreateEditions
]

{ #category : 'loading-internal' }
TonelApplicationLoader >> ammendApplicationClass [

self tonelApplication ammendApplicationClass
]

{ #category : 'loading-internal' }
TonelApplicationLoader >> autogenerateClassSideNewInitializers [

Expand Down Expand Up @@ -97,7 +103,6 @@ TonelApplicationLoader >> computePrerequisites [

{ #category : 'loading-internal' }
TonelApplicationLoader >> convertSharedPoolClasses [
"Enter the new method definition below and click 'Resume'."

self tonelApplication convertSharedPoolClasses
]
Expand Down Expand Up @@ -248,6 +253,7 @@ TonelApplicationLoader >> load [
[
self
convertSharedPoolClasses;
ammendApplicationClass;
checkClassExtensions;
checkSuperclasses;
checkForUnloadedApplication;
Expand Down
4 changes: 2 additions & 2 deletions source/TonelLoaderModel/TonelLoader.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -652,10 +652,10 @@ TonelLoader >> settings: anObject [
TonelLoader >> shouldLoadPrerequisiteApplication: anApplication [
"Answer whether receiver should load the prerequisite application anApplication."

^(self applications anySatisfy: [:any | any name asSymbol = anApplication name])
^(self applications anySatisfy: [:any | any identifier = anApplication name])
and:
[self loadedApplications
noneSatisfy: [:each | each name asSymbol = anApplication name]]
noneSatisfy: [:each | each identifier = anApplication name]]
]

{ #category : 'lookup' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ TonelLoaderComputedPrerequisitesStrategy >> prerequisitesFor: tonelApplication c
<EmShadowApplication>
"

^tonelApplication prerequisites
^(tonelApplication prerequisites, (tonelApplication subApplications collect: [:each | each prerequisites ])) flattened asSet asOrderedCollection

]
15 changes: 5 additions & 10 deletions source/TonelLoaderModel/TonelLoaderDefaultNamingStrategy.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,10 @@ TonelLoaderDefaultNamingStrategy >> appNameWithoutSuffix: aTonelLoaderApplicatio
| appName suffixToRemove |

appName := aTonelLoaderApplication name.
suffixToRemove := (self appSuffix isEmpty and: [self guessAppSuffix])
ifTrue: [
(appName endsWithSubCollection: 'App')
ifTrue: ['App']
ifFalse: [String new]
]
ifFalse: [
self appSuffix
].
suffixToRemove :=
(self appSuffix isEmpty and: [self guessAppSuffix])
ifTrue: [(appName endsWithSubCollection: 'App') ifTrue: ['App'] ifFalse: [String new]]
ifFalse: [self appSuffix].
^suffixToRemove isEmpty
ifTrue: [appName]
ifFalse: [appName copyFrom: 1 to: appName size - suffixToRemove size]
Expand All @@ -41,7 +36,7 @@ TonelLoaderDefaultNamingStrategy >> appSuffix: anObject [
appSuffix := anObject
]

{ #category : 'Not categorized' }
{ #category : 'accessing' }
TonelLoaderDefaultNamingStrategy >> guessAppSuffix [
"Answer whether we will guess the app suffix when trying to know the base name of a parent app.
E.g. to guess MyApplication from MyApplicationApp."
Expand Down
6 changes: 6 additions & 0 deletions source/TonelLoaderModel/TonelLoaderNamingStrategy.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ Class {
#category : 'TonelLoaderModel'
}

{ #category : 'resolving' }
TonelLoaderNamingStrategy >> appNameWithoutSuffix: aTonelLoaderApplication [

self subclassResponsibility
]

{ #category : 'resolving' }
TonelLoaderNamingStrategy >> nameForApp: aTonelLoaderApplication [

Expand Down
14 changes: 0 additions & 14 deletions source/TonelLoaderModel/TonelLoaderSettings.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Class {
#instVars : [
'appSuperGroupSetting',
'compilerWarningLevel',
'defaultAppNameSuffix',
'strategies'
],
#classVars : [
Expand Down Expand Up @@ -106,19 +105,6 @@ TonelLoaderSettings >> copyFor: aTonelLoader [
^copy
]

{ #category : 'defaults' }
TonelLoaderSettings >> defaultAppNameSuffix [

^defaultAppNameSuffix
]

{ #category : 'naming' }
TonelLoaderSettings >> defaultAppNameSuffix: aStringOrNil [
"Sets the default app name suffix used by naming strategies."

defaultAppNameSuffix := aStringOrNil
]

{ #category : 'defaults' }
TonelLoaderSettings >> defaultAppSuperGroupSetting [

Expand Down
5 changes: 2 additions & 3 deletions source/TonelLoaderModel/TonelLoaderStrategy.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Class {
{ #category : 'instance creation' }
TonelLoaderStrategy class >> for: aTonelLoader [

^self basicNew
^self new
setLoader: aTonelLoader;
yourself
]
Expand Down Expand Up @@ -43,8 +43,7 @@ TonelLoaderStrategy >> loader [
#vaVisibility : 'private' }
TonelLoaderStrategy >> setLoader: aTonelLoader [

loader := aTonelLoader.
self initialize
loader := aTonelLoader
]

{ #category : 'accessing',
Expand Down
28 changes: 24 additions & 4 deletions source/TonelLoaderModel/TonelLoaderSubApplication.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,24 @@ TonelLoaderSubApplication >> allExtendedClasses [
yourself
]

{ #category : 'loading' }
TonelLoaderSubApplication >> ammendApplicationClass [
"Renames the Application/SubApplication class
that might have a different name that the actual application created in the image
due to custom suffixes, etc."

| appNameWithoutSuffix |

appNameWithoutSuffix := self loader namingStrategy appNameWithoutSuffix: self.
self tonelDefinedClasses do: [:each |
((#(Application SubApplication) includes: each superclassIdentifier)
and: [each name = appNameWithoutSuffix])
ifTrue: [
each name: self name.
each setIdentifier: self identifier]].
self subApplications do: [:tonelSubApp | tonelSubApp ammendApplicationClass]
]

{ #category : 'querying' }
TonelLoaderSubApplication >> availableShadows [
^self emClass shadowsFor: self name
Expand Down Expand Up @@ -287,12 +305,14 @@ TonelLoaderSubApplication >> createEditionIn: parentEmApp underCondition: condit


self loader
changeUserTo: emApp manager
changeUserTo: emApp manager
for: [
emApp isEdition ifFalse: [(emApp newEdition)].
self changeCurrentUserAndSuperGroupSettingOf: emApp.
parentEmApp releaseSubApplication: emApp in: conditionCode.
].
self changeCurrentUserAndSuperGroupSettingOf: emApp].

self loader
changeUserTo: parentEmApp manager
for: [parentEmApp releaseSubApplication: emApp in: conditionCode].

^emApp
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,30 @@ TonelReaderAbstractClassDefinition >> concreteClassIn: anApp [

{ #category : 'loading-changes',
#vaVisibility : 'private' }
TonelReaderAbstractClassDefinition >> deleteRemovedClassMethodsFrom: aClass in: anApp [
TonelReaderAbstractClassDefinition >> deleteRemovedClassMethodsFrom: aClass in: anApp using: aLoader [

| methodsToRemove |
methodsToRemove := aClass class methodDictionary values select:
[:compiledMethod |
compiledMethod application = anApp and:
[self tonelMethods noneSatisfy:
[:anMCMethod |
anMCMethod isClassSide
and: [compiledMethod selector = anMCMethod selector]]]].
methodsToRemove := methodsToRemove
reject: [:each | self isArtificiallyCreatedMethod: each inApp: anApp].
methodsToRemove
do: [:compiledMethod | self removeCompiledMethod: compiledMethod from: anApp]

methodsToRemove :=
aClass class methodDictionary values select: [:compiledMethod |
compiledMethod application = anApp and: [
self tonelMethods noneSatisfy: [:anMCMethod |
anMCMethod isClassSide and: [compiledMethod selector = anMCMethod selector]]]].
methodsToRemove :=
methodsToRemove reject: [:each | self isArtificiallyCreatedMethod: each inApp: anApp].
methodsToRemove
do: [:compiledMethod | self removeCompiledMethod: compiledMethod from: anApp using: aLoader]
]

{ #category : 'loading-changes',
#vaVisibility : 'private' }
TonelReaderAbstractClassDefinition >> deleteRemovedInstanceMethodsFrom: aClass in: anApp [
TonelReaderAbstractClassDefinition >> deleteRemovedInstanceMethodsFrom: aClass in: anApp using: aLoader [

aClass methodDictionary do:
[:compiledMethod |
(compiledMethod application = anApp and:
[self tonelMethods noneSatisfy:
[:anMCMethod |
anMCMethod isClassSide not
and: [compiledMethod selector = anMCMethod selector]]])
ifTrue: [self removeCompiledMethod: compiledMethod from: anApp]]
aClass methodDictionary do: [:compiledMethod |
(compiledMethod application = anApp and: [
self tonelMethods noneSatisfy: [:anMCMethod |
anMCMethod isClassSide not and: [compiledMethod selector = anMCMethod selector]]])
ifTrue: [self removeCompiledMethod: compiledMethod from: anApp using: aLoader]]
]

{ #category : 'loading-changes',
Expand All @@ -48,13 +44,12 @@ TonelReaderAbstractClassDefinition >> deleteRemovedMethodsFrom: anApp using: aLo
(self concreteClassIn: anApp)
ifNil: [
self isSharedPool
ifFalse: [self error: ('Cannot find the concrete app for <1p>' expandMacrosWith: self name)]
]
ifFalse: [
self error: ('Cannot find the concrete app for <1p>' expandMacrosWith: self name)]]
ifNotNil: [:concreteClass |
self
deleteRemovedInstanceMethodsFrom: concreteClass in: anApp;
deleteRemovedClassMethodsFrom: concreteClass in: anApp]

deleteRemovedInstanceMethodsFrom: concreteClass in: anApp using: aLoader;
deleteRemovedClassMethodsFrom: concreteClass in: anApp using: aLoader]
]

{ #category : 'testing' }
Expand Down Expand Up @@ -158,14 +153,26 @@ TonelReaderAbstractClassDefinition >> loadDeclarationMethodsInto: anApp using: a
TonelReaderAbstractClassDefinition >> loadInto: anApp using: appLoader [
"Loads receiver into anApp using an appLoader <TonelApplicationLoader>."

| concreteClass developer ownerExists |

concreteClass := (self concreteClassIn: anApp).
ownerExists := false.
(EmClassEditions for: concreteClass in: anApp) ifNotNil: [:editionsRecord | | currentEntry |
currentEntry := editionsRecord entryAt: (concreteClass timeStampIn: anApp).
(EmUser called: currentEntry developer ifAbsent: [])
ifNil: [developer := EmUser current]
ifNotNil: [:user |
developer := user.
ownerExists := true]].
ownerExists ifFalse: [anApp ownerOf: concreteClass to: developer].

appLoader loader
changeUserTo: anApp manager
changeUserTo: developer
for: [
self
loadMethodsInto: anApp using: appLoader;
deleteRemovedMethodsFrom: anApp using: appLoader;
updateCommentIn: anApp
].
updateCommentIn: anApp]
]

{ #category : 'loading',
Expand Down Expand Up @@ -199,11 +206,9 @@ TonelReaderAbstractClassDefinition >> methodChangesIn: aClass [

{ #category : 'loading-changes',
#vaVisibility : 'private' }
TonelReaderAbstractClassDefinition >> removeCompiledMethod: compiledMethod from: emApp [
TonelReaderAbstractClassDefinition >> removeCompiledMethod: compiledMethod from: emApp using: aLoader [

TonelLoader
do: [EmInterface current removeMethods: (Array with: compiledMethod)]
withSuperUser: emApp manager
EmInterface current removeMethods: (Array with: compiledMethod)
]

{ #category : 'testing',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ TonelReaderClassDefinition >> pragmaSourceFromClassVariables [

]

{ #category : 'accessing',
#vaVisibility : 'private' }
TonelReaderClassDefinition >> setIdentifier: aSymbol [
"Sets the identifier of receiver to be aSymbol."

identifier := aSymbol
]

{ #category : 'loading',
#vaVisibility : 'private' }
TonelReaderClassDefinition >> superclassChangeIn: aClass [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ TonelReaderMethodDefinition >> hasCategoryChangesIn: aClass [
TonelReaderMethodDefinition >> hasChangesIn: aClass [
"Answer whether receiver has changes in aClass."
^((self onSideClass: aClass) methodDictionary
detect: [:ea | ea selector = self selector]
ifNone: []) notNil
^(self hasMethodDefinedIn: aClass) not
or: [(self hasCategoryChangesIn: aClass) or: [self hasSourceChangesIn: aClass]]
]
Expand Down
Loading

0 comments on commit 9931ee8

Please sign in to comment.