MCMethodDefinition.st
changeset 937 8cbc9884f0cd
parent 893 822c94cd6f8d
child 941 29ec49f55cc2
equal deleted inserted replaced
936:c4564a0396b9 937:8cbc9884f0cd
     1 "{ Package: 'stx:goodies/monticello' }"
     1 "{ Package: 'stx:goodies/monticello' }"
     2 
     2 
     3 MCDefinition subclass:#MCMethodDefinition
     3 MCDefinition subclass:#MCMethodDefinition
     4 	instanceVariableNames:'classIsMeta source category selector className timeStamp
     4 	instanceVariableNames:'classIsMeta source category selector className timeStamp'
     5 	'
       
     6 	classVariableNames:'Definitions'
     5 	classVariableNames:'Definitions'
     7 	poolDictionaries:''
     6 	poolDictionaries:''
     8 	category:'SCM-Monticello-Modeling'
     7 	category:'SCM-Monticello-Modeling'
     9 !
     8 !
    10 
     9 
    52 	(definition isNil
    51 	(definition isNil
    53 		or: [definition selector ~= aMethodReference methodSymbol]
    52 		or: [definition selector ~= aMethodReference methodSymbol]
    54 		or: [definition className ~= aMethodReference classSymbol]
    53 		or: [definition className ~= aMethodReference classSymbol]
    55 		or: [definition classIsMeta ~= aMethodReference classIsMeta]
    54 		or: [definition classIsMeta ~= aMethodReference classIsMeta]
    56 		or: [definition category ~= aMethodReference category])
    55 		or: [definition category ~= aMethodReference category])
    57 			ifTrue: [definition := self 
    56 			ifTrue: [definition := self
    58 						className: aMethodReference classSymbol
    57 						className: aMethodReference classSymbol
    59 						classIsMeta: aMethodReference classIsMeta
    58 						classIsMeta: aMethodReference classIsMeta
    60 						selector: aMethodReference methodSymbol
    59 						selector: aMethodReference methodSymbol
    61 						category: aMethodReference category
    60 						category: aMethodReference category
    62 						timeStamp: aMethodReference timeStamp
    61 						timeStamp: aMethodReference timeStamp
    63 						source: aMethodReference source.
    62 						source: aMethodReference source.
    64 					self cachedDefinitions at: aMethodReference compiledMethod put: definition].
    63 					self cachedDefinitions at: aMethodReference compiledMethod put: definition].
    65 	^ definition
    64 	^ definition
    66 	
    65 
    67 !
    66 !
    68 
    67 
    69 initialize
    68 initialize
    70     "
    69     "
    71         Smalltalk addToShutDownList: self
    70         Smalltalk addToShutDownList: self
    80 ! !
    79 ! !
    81 
    80 
    82 !MCMethodDefinition methodsFor:'accessing'!
    81 !MCMethodDefinition methodsFor:'accessing'!
    83 
    82 
    84 actualClass
    83 actualClass
    85     ^ Smalltalk 
    84     ^ Smalltalk
    86         at:(self installedClassName ? className) asSymbol
    85         at:(self installedClassName ? className) asSymbol
    87         ifPresent: [:class | 
    86         ifPresent: [:class |
    88             classIsMeta 
    87             classIsMeta
    89                 ifTrue: [class theMetaclass "classSide"] 
    88                 ifTrue: [class theMetaclass "classSide"]
    90                 ifFalse: [class]
    89                 ifFalse: [class]
    91         ]
    90         ]
    92 
    91 
    93     "Modified: / 07-09-2011 / 15:23:45 / cg"
    92     "Modified: / 07-09-2011 / 15:23:45 / cg"
    94     "Modified: / 12-08-2013 / 01:34:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    93     "Modified: / 12-08-2013 / 01:34:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   109 className
   108 className
   110 	^className
   109 	^className
   111 !
   110 !
   112 
   111 
   113 description
   112 description
   114 	^ Array	
   113 	^ Array
   115 		with: className
   114 		with: className
   116 		with: selector
   115 		with: selector
   117 		with: classIsMeta
   116 		with: classIsMeta
   118 !
   117 !
   119 
   118 
   143 
   142 
   144 source
   143 source
   145 	^ source
   144 	^ source
   146 !
   145 !
   147 
   146 
       
   147 source: something
       
   148 	source := something
       
   149 !
       
   150 
   148 timeStamp
   151 timeStamp
   149 	^ timeStamp
   152 	^ timeStamp
   150 ! !
   153 ! !
   151 
   154 
   152 !MCMethodDefinition methodsFor:'annotations'!
   155 !MCMethodDefinition methodsFor:'annotations'!
   153 
   156 
   154 printAnnotations: requests on: aStream
   157 printAnnotations: requests on: aStream
   155 	"Add a string for an annotation pane, trying to fulfill the annotation requests.
   158 	"Add a string for an annotation pane, trying to fulfill the annotation requests.
   156 	These might include anything that
   159 	These might include anything that
   157 		Preferences defaultAnnotationRequests 
   160 		Preferences defaultAnnotationRequests
   158 	might return. Which includes anything in
   161 	might return. Which includes anything in
   159 		Preferences annotationInfo
   162 		Preferences annotationInfo
   160 	To edit these, use:"
   163 	To edit these, use:"
   161 	"Preferences editAnnotations"
   164 	"Preferences editAnnotations"
   162 
   165 
   234     ].
   237     ].
   235 
   238 
   236     package := MCStXPackageQuery query.
   239     package := MCStXPackageQuery query.
   237     actualClass := self actualClass.
   240     actualClass := self actualClass.
   238     actualClass isNil ifTrue:[
   241     actualClass isNil ifTrue:[
   239         MCCannotLoadMethodError 
   242         MCCannotLoadMethodError
   240             raiseRequestWith:self
   243             raiseRequestWith:self
   241             errorString:('missing class: %1' bindWith:className).
   244             errorString:('missing class: %1' bindWith:className).
   242         ^ self "/ proceeded
   245         ^ self "/ proceeded
   243     ].
   246     ].
   244     oldMethod := actualClass compiledMethodAt: self selector.
   247     oldMethod := actualClass compiledMethodAt: self selector.
   307 				[(tokens at: tokens size-1) = #stamp:
   310 				[(tokens at: tokens size-1) = #stamp:
   308 				ifTrue: ["New format gives change stamp and unified prior pointer"
   311 				ifTrue: ["New format gives change stamp and unified prior pointer"
   309 						stamp := tokens at: tokens size]].
   312 						stamp := tokens at: tokens size]].
   310 		methodCategory := tokens after: #methodsFor: ifAbsent: ['as yet unclassifed'].
   313 		methodCategory := tokens after: #methodsFor: ifAbsent: ['as yet unclassifed'].
   311 		methodCategory = category ifFalse:
   314 		methodCategory = category ifFalse:
   312 			[methodCategory = (Smalltalk 
   315 			[methodCategory = (Smalltalk
   313 									at: #Categorizer 
   316 									at: #Categorizer
   314 									ifAbsent: [Smalltalk at: #ClassOrganizer]) 
   317 									ifAbsent: [Smalltalk at: #ClassOrganizer])
   315 										default ifTrue: [methodCategory := methodCategory, ' '].
   318 										default ifTrue: [methodCategory := methodCategory, ' '].
   316 			^ ChangeRecord new file: file position: position type: #method
   319 			^ ChangeRecord new file: file position: position type: #method
   317 						class: className category: methodCategory meta: classIsMeta stamp: stamp].
   320 						class: className category: methodCategory meta: classIsMeta stamp: stamp].
   318 		position := prevPos.
   321 		position := prevPos.
   319 		prevPos notNil ifTrue:
   322 		prevPos notNil ifTrue:
   320 			[file := sourceFilesCopy at: prevFileIndex]].
   323 			[file := sourceFilesCopy at: prevFileIndex]].
   321 		^ nil]
   324 		^ nil]
   322 			ensure: [sourceFilesCopy do: [:x | x notNil ifTrue: [x close]]]
   325 			ensure: [sourceFilesCopy do: [:x | x notNil ifTrue: [x close]]]
   323 	
   326 
   324 !
   327 !
   325 
   328 
   326 unload
   329 unload
   327         | previousVersion class |
   330         | previousVersion class |
   328 
   331 
   361 !MCMethodDefinition methodsFor:'private'!
   364 !MCMethodDefinition methodsFor:'private'!
   362 
   365 
   363 existingMethodOrNil
   366 existingMethodOrNil
   364     | actualClass |
   367     | actualClass |
   365     actualClass := self actualClass.
   368     actualClass := self actualClass.
   366     ^actualClass 
   369     ^actualClass
   367         ifNil:[nil]
   370         ifNil:[nil]
   368         ifNotNil: [actualClass compiledMethodAt:self selector]
   371         ifNotNil: [actualClass compiledMethodAt:self selector]
   369 
   372 
   370     "Modified: / 08-11-2010 / 17:41:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   373     "Modified: / 08-11-2010 / 17:41:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   371 ! !
   374 ! !
   375 initializeWithClassName: classString
   378 initializeWithClassName: classString
   376 classIsMeta: metaBoolean
   379 classIsMeta: metaBoolean
   377 selector: selectorString
   380 selector: selectorString
   378 category: catString
   381 category: catString
   379 timeStamp: timeString
   382 timeStamp: timeString
   380 source: sourceString 
   383 source: sourceString
   381         className := classString asSymbol.
   384         className := classString asSymbol.
   382         selector := selectorString asSymbol.
   385         selector := selectorString asSymbol.
   383         category := catString asSymbol.
   386         category := catString asSymbol.
   384         timeStamp := timeString.
   387         timeStamp := timeString.
   385         classIsMeta := metaBoolean.
   388         classIsMeta := metaBoolean.
   394 	^ true
   397 	^ true
   395 !
   398 !
   396 
   399 
   397 isInitializer
   400 isInitializer
   398 	^ selector = #initialize and: [classIsMeta]
   401 	^ selector = #initialize and: [classIsMeta]
   399 	
   402 
   400 !
   403 !
   401 
   404 
   402 isMethodDefinition
   405 isMethodDefinition
   403 	^true
   406 	^true
   404 !
   407 !
   406 isOverrideDefinition
   409 isOverrideDefinition
   407 
   410 
   408     | oldMethod |
   411     | oldMethod |
   409 
   412 
   410     oldMethod := self existingMethodOrNil.
   413     oldMethod := self existingMethodOrNil.
   411     ^oldMethod 
   414     ^oldMethod
   412         ifNil:[false]
   415         ifNil:[false]
   413         ifNotNil:[oldMethod package ~= MCStXPackageQuery query]
   416         ifNotNil:[oldMethod package ~= MCStXPackageQuery query]
   414 
   417 
   415     "Created: / 08-11-2010 / 17:29:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   418     "Created: / 08-11-2010 / 17:29:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   416 ! !
   419 ! !
   422 ! !
   425 ! !
   423 
   426 
   424 !MCMethodDefinition class methodsFor:'documentation'!
   427 !MCMethodDefinition class methodsFor:'documentation'!
   425 
   428 
   426 version
   429 version
   427     ^ '$Header: /cvs/stx/stx/goodies/monticello/MCMethodDefinition.st,v 1.14 2013-08-12 00:44:57 vrany Exp $'
   430     ^ '$Header: /cvs/stx/stx/goodies/monticello/MCMethodDefinition.st,v 1.15 2014-11-06 03:14:18 vrany Exp $'
   428 !
   431 !
   429 
   432 
   430 version_CVS
   433 version_CVS
   431     ^ '$Header: /cvs/stx/stx/goodies/monticello/MCMethodDefinition.st,v 1.14 2013-08-12 00:44:57 vrany Exp $'
   434     ^ '$Header: /cvs/stx/stx/goodies/monticello/MCMethodDefinition.st,v 1.15 2014-11-06 03:14:18 vrany Exp $'
   432 !
   435 !
   433 
   436 
   434 version_SVN
   437 version_SVN
   435     ^ '$Id: MCMethodDefinition.st,v 1.14 2013-08-12 00:44:57 vrany Exp $'
   438     ^ '$Id: MCMethodDefinition.st,v 1.15 2014-11-06 03:14:18 vrany Exp $'
   436 ! !
   439 ! !
   437 
   440 
   438 
   441 
   439 MCMethodDefinition initialize!
   442 MCMethodDefinition initialize!