--- a/Annotation.st Fri Jul 02 08:13:17 2010 +0100
+++ b/Annotation.st Sat Jul 10 20:45:10 2010 +0100
@@ -50,10 +50,20 @@
!Annotation class methodsFor:'instance creation'!
-key: key arguments: arguments
- ^ Annotation::Unknown new key: key arguments: arguments
+key: key arguments: arguments
+
+ ^(self respondsTo: key)
+ ifTrue:
+ [self
+ perform: key
+ withArguments: arguments]
+ ifFalse:
+ [Annotation::Unknown new
+ key: key
+ arguments: arguments]
"Created: / 19-05-2010 / 16:47:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 02-07-2010 / 16:22:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
namespace: aString
@@ -65,6 +75,13 @@
!Annotation methodsFor:'accessing'!
+first
+
+ ^self key
+
+ "Created: / 10-07-2010 / 21:38:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
key
^#namespace:
@@ -105,6 +122,12 @@
"Created: / 20-05-2010 / 11:15:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!Annotation methodsFor:'testing'!
+
+isUnknown
+ ^ false
+! !
+
!Annotation::NameSpace methodsFor:'accessing'!
key
@@ -206,8 +229,14 @@
"Modified: / 20-05-2010 / 11:15:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!Annotation::Unknown methodsFor:'testing'!
+
+isUnknown
+ ^ true
+! !
+
!Annotation class methodsFor:'documentation'!
version_SVN
- ^ '$Id: Annotation.st 10524 2010-05-20 13:35:23Z vranyj1 $'
+ ^ '$Id: Annotation.st 10538 2010-07-10 19:45:10Z vranyj1 $'
! !
--- a/Method.st Fri Jul 02 08:13:17 2010 +0100
+++ b/Method.st Sat Jul 10 20:45:10 2010 +0100
@@ -347,17 +347,48 @@
index := self annotationIndexOf: key.
index ifNil:[^nil].
- ^annotations at: index.
+ ^self annotationAtIndex: index.
"
(Object >> #yourself) annotationAt: #namespace:
"
"Created: / 19-05-2010 / 16:16:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 02-07-2010 / 22:35:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
annotations
+
+ annotations ifNotNil:[^annotations].
+
+ (self hasResource and:[annotations isNil])
+ ifTrue:[self parseAnnotations].
+
^ annotations
+
+ "Modified: / 10-07-2010 / 21:21:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+annotations: anObject
+ "set the annotations"
+
+ self setAnnotations: anObject.
+ "iterate over annotations just to invoke
+ annotationAtIndex: which lazyliyinitialize annotations
+ and send #annotatesMethod:"
+ self annotationsDo:[:annotation|]
+
+ "Created: / 02-07-2010 / 22:38:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+annotationsDo: aBlock
+
+ self annotations ifNil:[^nil].
+ 1 to: annotations size do:
+ [:i|aBlock value: (self annotationAtIndex: i)].
+
+ "Created: / 02-07-2010 / 22:33:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 10-07-2010 / 21:22:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
category
@@ -1731,30 +1762,40 @@
!Method methodsFor:'private'!
+annotationAtIndex: index
+
+ | annotation |
+ self annotations.
+ annotations ifNil:[^nil].
+ annotation := annotations at: index.
+ annotation isArray ifTrue:[
+ annotation := Annotation
+ key: annotation first
+ arguments: annotation second.
+ annotation isUnknown ifFalse:[
+ annotations at: index put: annotation.
+ annotation annotatesMethod: self
+ ].
+ ].
+ ^annotation
+
+ "Created: / 02-07-2010 / 22:30:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 10-07-2010 / 21:23:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
annotationIndexOf: key
- annotations ifNil:[^nil].
+ self annotations ifNil:[^nil].
annotations keysAndValuesDo:
[:index :annotationOrArray|
- annotationOrArray isArray ifTrue:
- [annotationOrArray first == key ifTrue:
- [|annotation|
- annotation := Annotation
- perform: annotationOrArray first
- withArguments: annotationOrArray second
- ifNotUnderstood:
- [Annotation
- key: annotationOrArray first
- arguments: annotationOrArray second].
- annotations at: index put: annotation.
- annotation annotatesMethod: self.
- ^index]]
- ifFalse:[annotationOrArray key == key ifTrue:[^index]]].
+ annotationOrArray isArray
+ ifTrue: [annotationOrArray first == key ifTrue:[^index]]
+ ifFalse:[annotationOrArray key == key ifTrue:[^index]]].
^nil.
"Created: / 19-05-2010 / 16:40:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 20-05-2010 / 11:20:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 10-07-2010 / 21:23:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
cacheSourceStream:aStream
@@ -2603,6 +2644,29 @@
"
!
+parseAnnotations
+
+ "return the methods annotations."
+
+ |src parser|
+
+ src := self source.
+ src isNil ifTrue:[
+ ^ nil "/ actually: dont know
+ ].
+
+ self parserClass isNil ifTrue:[
+ ^ nil
+ ].
+ parser := self parserClass parseMethod: src.
+ (parser isNil or: [parser == #Error]) ifTrue:[
+ ^ nil "/ actually error
+ ].
+ ^ parser annotations.
+
+ "Created: / 10-07-2010 / 21:16:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
parseResources
"return the methods resource spec; either nil or a collection of symbols."
@@ -3187,7 +3251,7 @@
!Method class methodsFor:'documentation'!
version
- ^ '$Id: Method.st 10535 2010-07-01 19:50:00Z vranyj1 $'
+ ^ '$Id: Method.st 10538 2010-07-10 19:45:10Z vranyj1 $'
!
version_CVS
@@ -3195,7 +3259,7 @@
!
version_SVN
- ^ '$Id: Method.st 10535 2010-07-01 19:50:00Z vranyj1 $'
+ ^ '$Id: Method.st 10538 2010-07-10 19:45:10Z vranyj1 $'
! !
Method initialize!
--- a/NamespaceAwareLookup.st Fri Jul 02 08:13:17 2010 +0100
+++ b/NamespaceAwareLookup.st Sat Jul 10 20:45:10 2010 +0100
@@ -34,14 +34,15 @@
"
! !
+
!NamespaceAwareLookup class methodsFor:'accessing'!
instance
- Instance ifNil:[Instance := self basicNew].
^Instance
"Created: / 20-05-2010 / 11:18:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 10-07-2010 / 21:12:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!NamespaceAwareLookup methodsFor:'lookup'!
@@ -107,5 +108,7 @@
!NamespaceAwareLookup class methodsFor:'documentation'!
version_SVN
- ^ '$Id: NamespaceAwareLookup.st 10524 2010-05-20 13:35:23Z vranyj1 $'
+ ^ '$Id: NamespaceAwareLookup.st 10538 2010-07-10 19:45:10Z vranyj1 $'
! !
+
+NamespaceAwareLookup initialize!