| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471 | 
							- Smalltalk current createPackage: 'Compiler-Tests' properties: #{}!
 
- TestCase subclass: #ImporterTest
 
- 	instanceVariableNames: ''
 
- 	category: 'Compiler-Tests'!
 
- !ImporterTest methodsFor: 'private'!
 
- chunkString
 
- 	^'!!Object methodsFor: ''importer test method''!!
 
- importerTestMethod
 
- 	^''success''
 
- !! !!
 
- '
 
- !
 
- bigChunkString
 
- 	^'Smalltalk current createPackage: ''Cypress-Definitions'' properties: #{}!!
 
- Object subclass: #CypressSnapshot
 
- 	instanceVariableNames: ''definitions''
 
- 	package: ''Cypress-Definitions''!!
 
- !!CypressSnapshot methodsFor: ''not yet classified''!!
 
- definitions: aDefinitions
 
- 	definitions := aDefinitions
 
- !!
 
- definitions
 
- 	^definitions
 
- !! !!
 
- !!CypressSnapshot class methodsFor: ''not yet classified''!!
 
- definitions: aDefinitions
 
- 	^(self new) definitions: aDefinitions
 
- !! !!
 
- Object subclass: #CypressPackage
 
- 	instanceVariableNames: ''name''
 
- 	package: ''Cypress-Definitions''!!
 
- !!CypressPackage methodsFor: ''not yet classified''!!
 
- = other
 
- 	^ other species = self species and: [other name sameAs: name]
 
- !!
 
- name
 
- 	^ name
 
- !!
 
- name: aString
 
- 	name := aString
 
- !!
 
- snapshot
 
- 	| package definitions name  |
 
- 	package := Package named: self name.
 
- 	definitions := OrderedCollection new.
 
- 	package sortedClasses do: [:cls |
 
-         	definitions add: cls asCypressClassDefinition.
 
-                 cls methodDictionary values do: [:method |
 
- 			(method category match: ''^\*'') ifFalse: [ 
 
- 				definitions add: method asCypressMethodDefinition ]].
 
-                 cls class methodDictionary values do: [:method |
 
- 			(method category match: ''^\*'') ifFalse: [ 
 
- 				definitions add: method asCypressMethodDefinition ]]].
 
- 	name := package name.
 
- 	Smalltalk current classes, (Smalltalk current classes collect: [:each | each class]) do: [:each |
 
- 		each methodDictionary values do: [:method |
 
- 			method category = (''*'', name) ifTrue: [
 
- 				definitions add: method asCypressMethodDefinition ]]].
 
- 	^ CypressSnapshot definitions: definitions
 
- !!
 
- printString
 
- 	^super printString, ''('', name, '')''
 
- !! !!
 
- Object subclass: #CypressDefinition
 
- 	instanceVariableNames: ''''
 
- 	package: ''Cypress-Definitions''!!
 
- !!CypressDefinition methodsFor: ''not yet classified''!!
 
- = aDefinition
 
- 	^(aDefinition isKindOf: CypressDefinition) and: [self isRevisionOf: aDefinition]
 
- !!
 
- isRevisionOf: aDefinition
 
- 	^ (aDefinition isKindOf: CypressDefinition) and: [aDefinition description = self description]
 
- !!
 
- description
 
- 	self subclassResponsibility
 
- !!
 
- isSameRevisionAs: aDefinition
 
- 	^ self = aDefinition
 
- !! !!
 
- Object subclass: #CypressPatch
 
- 	instanceVariableNames: ''operations''
 
- 	package: ''Cypress-Definitions''!!
 
- !!CypressPatch methodsFor: ''not yet classified''!!
 
- fromBase: baseSnapshot toTarget: targetSnapshot
 
- 	| base target |	
 
- 	operations := OrderedCollection new.
 
- 	base := CypressDefinitionIndex definitions: baseSnapshot definitions.
 
- 	target := CypressDefinitionIndex definitions: targetSnapshot definitions.
 
- 	
 
- 	target definitions do:
 
- 		[:t |
 
- 		base
 
- 			definitionLike: t
 
- 			ifPresent: [:b | (b isSameRevisionAs: t) ifFalse: [operations add: (CypressModification of: b to: t)]]
 
- 			ifAbsent: [operations add: (CypressAddition of: t)]].
 
- 		
 
- 	base definitions do:
 
- 		[:b |
 
- 		target
 
- 			definitionLike: b
 
- 			ifPresent: [:t | ]
 
- 			ifAbsent: [operations add: (CypressRemoval of: b)]]
 
- !!
 
- operations
 
- 	^operations
 
- !! !!
 
- !!CypressPatch class methodsFor: ''not yet classified''!!
 
- fromBase: baseSnapshot toTarget: targetSnapshot
 
- 	^ (self new)
 
- 		fromBase: baseSnapshot
 
- 		toTarget: targetSnapshot
 
- !! !!
 
- Object subclass: #CypressDefinitionIndex
 
- 	instanceVariableNames: ''definitionMap''
 
- 	package: ''Cypress-Definitions''!!
 
- !!CypressDefinitionIndex methodsFor: ''not yet classified''!!
 
- add: aDefinition
 
- 	^ self definitionMap at: aDefinition description put: aDefinition
 
- !!
 
- addAll: aCollection
 
- 	aCollection do: [:ea | self add: ea]
 
- !!
 
- definitionLike: aDefinition ifPresent: foundBlock ifAbsent: errorBlock
 
- 	| definition |
 
- 	definition := self definitionMap at: aDefinition description ifAbsent: [].
 
- 	^ definition
 
- 		ifNil: errorBlock
 
- 		ifNotNil: [foundBlock value: definition]
 
- !!
 
- definitions
 
- 	^self definitionMap values
 
- !!
 
- definitionMap
 
- 	definitionMap ifNil: [ definitionMap := Dictionary new ].
 
- 	^ definitionMap
 
- !!
 
- remove: aDefinition
 
- 	self definitionMap removeKey: aDefinition description ifAbsent: []
 
- !! !!
 
- !!CypressDefinitionIndex class methodsFor: ''not yet classified''!!
 
- definitions: aCollection
 
- 	^ self new addAll: aCollection
 
- !! !!
 
- Object subclass: #CypressPatchOperation
 
- 	instanceVariableNames: ''''
 
- 	package: ''Cypress-Definitions''!!
 
- CypressDefinition subclass: #CypressClassDefinition
 
- 	instanceVariableNames: ''name superclassName category comment instVarNames classInstVarNames''
 
- 	package: ''Cypress-Definitions''!!
 
- !!CypressClassDefinition methodsFor: ''not yet classified''!!
 
- name: aClassName superclassName: aSuperclassName category: aCategory instVarNames: anInstanceVariableNames classInstVarNames: aClassInstanceVariableNames comment: aComment
 
- 	name := aClassName.
 
- 	superclassName := aSuperclassName.
 
- 	category := aCategory.
 
- 	instVarNames := anInstanceVariableNames.
 
- 	classInstVarNames := aClassInstanceVariableNames.
 
- 	comment := aComment
 
- !!
 
- = aDefinition
 
- 	^(super = aDefinition)
 
- 		and: [superclassName = aDefinition superclassName
 
- 		and: [category = aDefinition category
 
- 		and: [instVarNames = aDefinition instVarNames
 
- 		and: [classInstVarNames = aDefinition classInstVarNames
 
- 		and: [comment = aDefinition comment]]]]]
 
- !!
 
- superclassName
 
- 	^superclassName
 
- !!
 
- name
 
- 	^name
 
- !!
 
- category
 
- 	^category
 
- !!
 
- comment
 
- 	^comment
 
- !!
 
- description
 
- 	^ Array with: name
 
- !!
 
- instVarNames
 
- 	^instVarNames
 
- !!
 
- classInstVarNames
 
- 	^classInstVarNames
 
- !! !!
 
- !!CypressClassDefinition class methodsFor: ''not yet classified''!!
 
- name: aClassName 
 
- superclassName: aSuperclassName
 
- category: aCategory
 
- instVarNames: anInstanceVariableNames
 
- classInstVarNames: aClassInstanceVariableNames
 
- comment: aComment
 
- 	^(self new) 
 
- 		name: aClassName 
 
- 		superclassName: aSuperclassName
 
- 		category: aCategory
 
- 		instVarNames: anInstanceVariableNames
 
- 		classInstVarNames: aClassInstanceVariableNames
 
- 		comment: aComment
 
- !! !!
 
- CypressDefinition subclass: #CypressMethodDefinition
 
- 	instanceVariableNames: ''classIsMeta source category selector className''
 
- 	package: ''Cypress-Definitions''!!
 
- !!CypressMethodDefinition methodsFor: ''not yet classified''!!
 
- className: aName classIsMeta: isMetaclass selector: aSelector category: aCategory source: aSource
 
- 	className := aName.
 
- 	classIsMeta := isMetaclass.
 
- 	selector := aSelector.
 
- 	category := aCategory.
 
- 	source := aSource.
 
- !!
 
- = aDefinition
 
-     ^ super = aDefinition
 
-         and: [ aDefinition source = self source
 
-                 and: [ aDefinition category = self category ] ]
 
- !!
 
- source
 
- 	^source
 
- !!
 
- category
 
- 	^category
 
- !!
 
- description
 
- 	^ Array	
 
- 		with: className
 
- 		with: selector
 
- 		with: classIsMeta
 
- !! !!
 
- !!CypressMethodDefinition class methodsFor: ''not yet classified''!!
 
- className: aName
 
- classIsMeta: isMetaclass
 
- selector: aSelector
 
- category: aCategory
 
- source: aSource
 
- 	^(self new)
 
- 		className: aName
 
- 		classIsMeta: isMetaclass
 
- 		selector: aSelector
 
- 		category: aCategory
 
- 		source: aSource
 
- !! !!
 
- CypressPatchOperation subclass: #CypressAddition
 
- 	instanceVariableNames: ''definition''
 
- 	package: ''Cypress-Definitions''!!
 
- !!CypressAddition methodsFor: ''not yet classified''!!
 
- definition: aDefinition
 
- 	definition := aDefinition
 
- !! !!
 
- !!CypressAddition class methodsFor: ''not yet classified''!!
 
- of: aDefinition
 
- 	^ self new definition: aDefinition
 
- !! !!
 
- CypressPatchOperation subclass: #CypressModification
 
- 	instanceVariableNames: ''obsoletion modification''
 
- 	package: ''Cypress-Definitions''!!
 
- !!CypressModification methodsFor: ''not yet classified''!!
 
- base: base target: target
 
- 	obsoletion := base.
 
- 	modification := target.
 
- !! !!
 
- !!CypressModification class methodsFor: ''not yet classified''!!
 
- of: base to: target
 
- 	^ self new base: base target: target
 
- !! !!
 
- CypressPatchOperation subclass: #CypressRemoval
 
- 	instanceVariableNames: ''definition''
 
- 	package: ''Cypress-Definitions''!!
 
- !!CypressRemoval methodsFor: ''not yet classified''!!
 
- definition: aDefinition
 
- 	definition := aDefinition
 
- !! !!
 
- !!CypressRemoval class methodsFor: ''not yet classified''!!
 
- of: aDefinition
 
- 	^ self new definition: aDefinition
 
- !! !!
 
- !!Object methodsFor: ''*Cypress-Definitions''!!
 
- species
 
- 	^self class
 
- !! !!
 
- !!Class methodsFor: ''*Cypress-Definitions''!!
 
- asCypressClassDefinition
 
- 	^CypressClassDefinition
 
- 		name: self name
 
- 		superclassName: self superclass name
 
- 		category: self category 
 
- 		instVarNames: self instanceVariableNames
 
- 		classInstVarNames: self class instanceVariableNames
 
- 		comment: self comment
 
- !! !!
 
- !!CompiledMethod methodsFor: ''*Cypress-Definitions''!!
 
- asCypressMethodDefinition
 
- 	^CypressMethodDefinition 
 
-         	className: self methodClass name
 
- 		classIsMeta: self methodClass isMetaclass
 
- 		selector: self selector
 
- 		category: self category
 
- 		source: self source
 
- !! !!
 
- !!CharacterArray methodsFor: ''*Cypress-Definitions''!!
 
- sameAs: aString
 
- 	^self asUppercase = aString asUppercase
 
- !! !!
 
- '
 
- ! !
 
- !ImporterTest methodsFor: 'running'!
 
- setUp
 
- 	super setUp.
 
- 	self cleanUp
 
- !
 
- tearDown
 
- 	super tearDown.
 
- 	self cleanUp
 
- !
 
- cleanUp
 
- 	(Object methodDictionary includesKey: #importerTestMethod)
 
- 		ifTrue: [ Object removeCompiledMethod: (Object methodAt: #importerTestMethod)].
 
- ! !
 
- !ImporterTest methodsFor: 'tests'!
 
- testBigChunkString
 
- 	"importer does not correctly add extension methods.
 
- 	 After loading in AmberProjectImporter, the following import fails...get a MNU from `CypressPackage new species`:
 
-     		AmberProjectImporter
 
- 			importSTPackage: 'Cypress-Definitions' 
 
- 			prefix: 'tests/'.
 
- 		CypressPackage new species. 
 
- 	WARNING this guy isn't cleaned up automatically"
 
- 	Importer new import: self bigChunkString readStream.
 
- 	CypressPackage new species.
 
- !
 
- testChunkString
 
- 	Importer new import: self chunkString readStream.
 
- 	self assert: (Object methodDictionary includesKey: 'importerTestMethod').
 
- 	self assert: (Object new importerTestMethod = 'success').
 
- ! !
 
- !Object methodsFor: '*Compiler-Tests'!
 
- importerLoadMethod
 
- 	^'success'
 
- ! !
 
 
  |