Class.st
changeset 562 606cbaa20296
parent 558 45138e589c7e
child 576 b9f067c9814c
--- a/Class.st	Wed Nov 15 17:05:38 1995 +0100
+++ b/Class.st	Wed Nov 15 17:06:25 1995 +0100
@@ -12,10 +12,10 @@
 
 ClassDescription subclass:#Class
 	 instanceVariableNames:'classvars comment subclasses classFilename package revision
-                history'
+		history'
 	 classVariableNames:'UpdatingChanges LockChangesFile FileOutErrorSignal
-                CatchMethodRedefinitions MethodRedefinitionSignal
-                UpdateChangeFileQuerySignal'
+		CatchMethodRedefinitions MethodRedefinitionSignal
+		UpdateChangeFileQuerySignal'
 	 poolDictionaries:''
 	 category:'Kernel-Classes'
 !
@@ -106,7 +106,7 @@
 !
 
 version
-^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.74 1995-11-15 12:13:46 cg Exp $'! !
+^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.75 1995-11-15 16:06:25 cg Exp $'! !
 
 !Class class methodsFor:'initialization'!
 
@@ -164,6 +164,64 @@
 
 ! !
 
+!Class class methodsFor:'helpers'!
+
+revisionInfoFromString:aString
+    "return a dictionary filled with revision info.
+     This extracts the relevant info from aString."
+
+    |words info nm|
+
+    info := IdentityDictionary new.
+    words := aString asCollectionOfWords.
+
+    "/
+    "/ supported formats:
+    "/
+    "/ $-Header: pathName rev date time user state $
+    "/ $-Revision: rev $
+    "/ $-Id: fileName rev date time user state $
+    "/
+
+    ((words at:1) = '$Header:') ifTrue:[
+	nm := words at:2.
+	info at:#repositoryPathName put:nm.
+	(nm endsWith:',v') ifTrue:[
+	    nm := nm copyWithoutLast:2
+	].
+	info at:#fileName put:nm asFilename baseName.
+	info at:#revision put:(words at:3).
+	info at:#date put:(words at:4).
+	info at:#time put:(words at:5).
+	info at:#user put:(words at:6).
+	info at:#state put:(words at:7).
+	^ info
+    ].
+    ((words at:1) = '$Revision:') ifTrue:[
+	info at:#revision put:(words at:2).
+	^ info
+    ].
+    ((words at:1) = '$Id:') ifTrue:[
+	info at:#fileName put:(words at:2).
+	info at:#revision put:(words at:3).
+	info at:#date put:(words at:4).
+	info at:#time put:(words at:5).
+	info at:#user put:(words at:6).
+	info at:#state put:(words at:7).
+	^ info
+    ].
+
+    "/
+    "/ mhmh - maybe its some other source code system
+    "/
+    SourceCodeManager notNil ifTrue:[
+	^ SourceCodeManager revisionInfoFromString:aString
+    ].
+    ^ nil
+
+    "Created: 15.11.1995 / 14:58:35 / cg"
+! !
+
 !Class class methodsFor:'accessing - flags'!
 
 catchMethodRedefinitions
@@ -629,28 +687,12 @@
      To check if a source corresponds to a compiled binary, compare this 
      ID with the one found in the version-methods comment."
 
-    |vsnString words|
+    |info|
 
     revision notNil ifTrue:[ ^ revision].
-    vsnString := self revisionString.
-    vsnString notNil ifTrue:[
-	words := vsnString asCollectionOfWords.
-	"/
-	"/ supported formats:
-	"/
-	"/ $-Header: pathName rev date time user state $
-	"/ $-Revision: rev $
-	"/ $-Id: fileName rev date time user state $
-	"/
-	((words at:1) = '$Header:') ifTrue:[
-	    ^ words at:3
-	].
-	((words at:1) = '$Revision:') ifTrue:[
-	    ^ words at:2 
-	].
-	((words at:1) = '$Id:') ifTrue:[
-	    ^ words at:3 
-	].
+    info := self revisionInfo.
+    info notNil ifTrue:[
+	^ info at:#revision
     ].
     ^ nil
 
@@ -659,6 +701,7 @@
     "
 
     "Created: 11.11.1995 / 14:27:20 / cg"
+    "Modified: 15.11.1995 / 14:41:43 / cg"
 !
 
 revision:aString
@@ -1911,59 +1954,59 @@
     |source sortedSelectors first privacy interrestingMethods|
 
     methodArray notNil ifTrue:[
-        interrestingMethods := OrderedCollection new.
-        methodArray do:[:aMethod |
-            (aCategory = aMethod category) ifTrue:[
-                interrestingMethods add:aMethod.
-            ]
-        ].
-        interrestingMethods notEmpty ifTrue:[
-            first := true.
-            privacy := nil.
-
-            "/
-            "/ sort by selector
-            "/
-            sortedSelectors := interrestingMethods collect:[:m | self selectorAtMethod:m].
-            sortedSelectors sortWith:interrestingMethods.
-
-            interrestingMethods do:[:aMethod |
-                first ifFalse:[
-                    privacy ~~ aMethod privacy ifTrue:[
-                        first := true.
-                        aStream space.
-                        aStream nextPutChunkSeparator.
-                    ].
-                    aStream cr; cr
-                ].
-
-                privacy := aMethod privacy.
-
-                first ifTrue:[
-                    aStream nextPutChunkSeparator.
-                    self printClassNameOn:aStream.
-                    privacy ~~ #public ifTrue:[
-                        aStream space; nextPutAll:privacy; nextPutAll:'MethodsFor:'''.
-                    ] ifFalse:[
-                        aStream nextPutAll:' methodsFor:'''.
-                    ].
-                    aCategory notNil ifTrue:[
-                        aStream nextPutAll:aCategory
-                    ].
-                    aStream nextPut:$'; nextPutChunkSeparator; cr; cr.
-                    first := false.
-                ].
-                source := aMethod source.
-                source isNil ifTrue:[
-                    FileOutErrorSignal raiseRequestWith:'no source for method'
-                ] ifFalse:[
-                    aStream nextChunkPut:source.
-                ].
-            ].
-            aStream space.
-            aStream nextPutChunkSeparator.
-            aStream cr
-        ]
+	interrestingMethods := OrderedCollection new.
+	methodArray do:[:aMethod |
+	    (aCategory = aMethod category) ifTrue:[
+		interrestingMethods add:aMethod.
+	    ]
+	].
+	interrestingMethods notEmpty ifTrue:[
+	    first := true.
+	    privacy := nil.
+
+	    "/
+	    "/ sort by selector
+	    "/
+	    sortedSelectors := interrestingMethods collect:[:m | self selectorAtMethod:m].
+	    sortedSelectors sortWith:interrestingMethods.
+
+	    interrestingMethods do:[:aMethod |
+		first ifFalse:[
+		    privacy ~~ aMethod privacy ifTrue:[
+			first := true.
+			aStream space.
+			aStream nextPutChunkSeparator.
+		    ].
+		    aStream cr; cr
+		].
+
+		privacy := aMethod privacy.
+
+		first ifTrue:[
+		    aStream nextPutChunkSeparator.
+		    self printClassNameOn:aStream.
+		    privacy ~~ #public ifTrue:[
+			aStream space; nextPutAll:privacy; nextPutAll:'MethodsFor:'''.
+		    ] ifFalse:[
+			aStream nextPutAll:' methodsFor:'''.
+		    ].
+		    aCategory notNil ifTrue:[
+			aStream nextPutAll:aCategory
+		    ].
+		    aStream nextPut:$'; nextPutChunkSeparator; cr; cr.
+		    first := false.
+		].
+		source := aMethod source.
+		source isNil ifTrue:[
+		    FileOutErrorSignal raiseRequestWith:'no source for method'
+		] ifFalse:[
+		    aStream nextChunkPut:source.
+		].
+	    ].
+	    aStream space.
+	    aStream nextPutChunkSeparator.
+	    aStream cr
+	]
     ]
 
     "Modified: 28.8.1995 / 14:30:41 / claus"
@@ -2116,9 +2159,9 @@
     |collectionOfCategories copyrightText comment cls|
 
     self isLoaded ifFalse:[
-        ^ FileOutErrorSignal 
-            raiseRequestWith:self
-                 errorString:'will not fileOut unloaded classes'
+	^ FileOutErrorSignal 
+	    raiseRequestWith:self
+		 errorString:'will not fileOut unloaded classes'
     ].
 
     "
@@ -2131,31 +2174,31 @@
      code was edited in the browser and filedOut.
     "
     ((cls := self class) selectorArray includes:#copyright) ifTrue:[
-        "
-         get the copyright methods source,
-         and insert at beginning.
-        "
-        copyrightText := (cls  compiledMethodAt:#copyright) source.
-        copyrightText isNil ifTrue:[
-            "
-             no source available - trigger an error
-            "
-            FileOutErrorSignal
-                raiseRequestWith:'no source for class ' , name , ' available. Cannot fileOut'.
-            ^ self
-        ].
-        copyrightText := copyrightText asCollectionOfLines.
-        copyrightText := copyrightText copyFrom:2 to:(copyrightText size).
-        copyrightText do:[:line | aStream nextPutAll:line. aStream cr.].
+	"
+	 get the copyright methods source,
+	 and insert at beginning.
+	"
+	copyrightText := (cls  compiledMethodAt:#copyright) source.
+	copyrightText isNil ifTrue:[
+	    "
+	     no source available - trigger an error
+	    "
+	    FileOutErrorSignal
+		raiseRequestWith:'no source for class ' , name , ' available. Cannot fileOut'.
+	    ^ self
+	].
+	copyrightText := copyrightText asCollectionOfLines.
+	copyrightText := copyrightText copyFrom:2 to:(copyrightText size).
+	copyrightText do:[:line | aStream nextPutAll:line. aStream cr.].
     ].
 
     stampIt ifTrue:[
-        "
-         first, a timestamp
-        "
-        aStream nextPutAll:(Smalltalk timeStamp).
-        aStream nextPutChunkSeparator. 
-        aStream cr; cr.
+	"
+	 first, a timestamp
+	"
+	aStream nextPutAll:(Smalltalk timeStamp).
+	aStream nextPutChunkSeparator. 
+	aStream cr; cr.
     ].
 
     "
@@ -2168,19 +2211,19 @@
      optional classInstanceVariables
     "
     self class instanceVariableString isBlank ifFalse:[
-        self fileOutClassInstVarDefinitionOn:aStream.
-        aStream nextPutChunkSeparator. 
-        aStream cr; cr
+	self fileOutClassInstVarDefinitionOn:aStream.
+	aStream nextPutChunkSeparator. 
+	aStream cr; cr
     ].
 
     "
      a comment - if any
     "
     (comment := self comment) notNil ifTrue:[
-        aStream nextPutAll:name; nextPutAll:' comment:'.
-        aStream nextPutAll:(comment storeString).
-        aStream nextPutChunkSeparator.
-        aStream cr; cr
+	aStream nextPutAll:name; nextPutAll:' comment:'.
+	aStream nextPutAll:(comment storeString).
+	aStream nextPutChunkSeparator.
+	aStream cr; cr
     ].
 
     "
@@ -2193,53 +2236,53 @@
     "
     collectionOfCategories := self class categories asSortedCollection.
     collectionOfCategories notNil ifTrue:[
-        "
-         documentation first (if any)
-        "
-        (collectionOfCategories includes:'documentation') ifTrue:[
-            self class fileOutCategory:'documentation' on:aStream.
-            aStream cr.
-        ].
-        "
-         initialization next (if any)
-        "
-        (collectionOfCategories includes:'initialization') ifTrue:[
-            self class fileOutCategory:'initialization' on:aStream.
-            aStream cr.
-        ].
-        "
-         instance creation next (if any)
-        "
-        (collectionOfCategories includes:'instance creation') ifTrue:[
-            self class fileOutCategory:'instance creation' on:aStream.
-            aStream cr.
-        ].
-        collectionOfCategories do:[:aCategory |
-            ((aCategory ~= 'documentation')
-            and:[(aCategory ~= 'initialization')
-            and:[aCategory ~= 'instance creation']]) ifTrue:[
-                self class fileOutCategory:aCategory on:aStream.
-                aStream cr
-            ]
-        ]
+	"
+	 documentation first (if any)
+	"
+	(collectionOfCategories includes:'documentation') ifTrue:[
+	    self class fileOutCategory:'documentation' on:aStream.
+	    aStream cr.
+	].
+	"
+	 initialization next (if any)
+	"
+	(collectionOfCategories includes:'initialization') ifTrue:[
+	    self class fileOutCategory:'initialization' on:aStream.
+	    aStream cr.
+	].
+	"
+	 instance creation next (if any)
+	"
+	(collectionOfCategories includes:'instance creation') ifTrue:[
+	    self class fileOutCategory:'instance creation' on:aStream.
+	    aStream cr.
+	].
+	collectionOfCategories do:[:aCategory |
+	    ((aCategory ~= 'documentation')
+	    and:[(aCategory ~= 'initialization')
+	    and:[aCategory ~= 'instance creation']]) ifTrue:[
+		self class fileOutCategory:aCategory on:aStream.
+		aStream cr
+	    ]
+	]
     ].
     "
      methods from all categories in myself
     "
     collectionOfCategories := self categories asSortedCollection.
     collectionOfCategories notNil ifTrue:[
-        collectionOfCategories do:[:aCategory |
-            self fileOutCategory:aCategory on:aStream.
-            aStream cr
-        ]
+	collectionOfCategories do:[:aCategory |
+	    self fileOutCategory:aCategory on:aStream.
+	    aStream cr
+	]
     ].
     "
      optionally an initialize message
     "
     (self class implements:#initialize) ifTrue:[
-        aStream nextPutAll:(name , ' initialize').
-        aStream nextPutChunkSeparator.
-        aStream cr
+	aStream nextPutAll:(name , ' initialize').
+	aStream nextPutChunkSeparator.
+	aStream cr
     ]
 
     "Created: 15.11.1995 / 12:53:06 / cg"
@@ -2677,47 +2720,11 @@
     "return a dictionary filled with revision info.
      This extracts the reevant info from the revisionString."
 
-    |vsnString words info nm|
-
-    info := IdentityDictionary new.
+    |vsnString|
+
     vsnString := self revisionString.
     vsnString notNil ifTrue:[
-	words := vsnString asCollectionOfWords.
-
-	"/
-	"/ supported formats:
-	"/
-	"/ $-Header: pathName rev date time user state $
-	"/ $-Revision: rev $
-	"/ $-Id: fileName rev date time user state $
-	"/
-	((words at:1) = '$Header:') ifTrue:[
-	    nm := words at:2.
-	    info at:#repositoryPathName put:nm.
-	    (nm endsWith:',v') ifTrue:[
-		nm := nm copyWithoutLast:2
-	    ].
-	    info at:#fileName put:nm asFilename baseName.
-	    info at:#revision put:(words at:3).
-	    info at:#date put:(words at:4).
-	    info at:#time put:(words at:5).
-	    info at:#user put:(words at:6).
-	    info at:#state put:(words at:7).
-	    ^ info
-	].
-	((words at:1) = '$Revision:') ifTrue:[
-	    info at:#revision put:(words at:2).
-	    ^ info
-	].
-	((words at:1) = '$Id:') ifTrue:[
-	    info at:#fileName put:(words at:2).
-	    info at:#revision put:(words at:3).
-	    info at:#date put:(words at:4).
-	    info at:#time put:(words at:5).
-	    info at:#user put:(words at:6).
-	    info at:#state put:(words at:7).
-	    ^ info
-	].
+	^ Class revisionInfoFromString:vsnString
     ].
     ^ nil
 
@@ -2727,7 +2734,22 @@
     "
 
     "Created: 11.11.1995 / 14:27:20 / cg"
-    "Modified: 14.11.1995 / 16:00:51 / cg"
+    "Modified: 15.11.1995 / 14:59:34 / cg"
+!
+
+revisionStringFromSource:aMethodSourceString
+    "extract a revision string from a methods source string"
+
+    |lines idx val|
+
+    lines := aMethodSourceString asCollectionOfLines.
+    idx := lines findFirst:[:l |
+	l withoutSpaces startsWith:'$Header'
+    ].
+    idx == 0 ifTrue:[^ nil].
+    ^ lines at:idx.
+
+    "Created: 15.11.1995 / 15:01:19 / cg"
 !
 
 revisionString
@@ -2737,7 +2759,7 @@
      If the source is not accessable or no such method exists,
      nil is returned."
 
-    |cls meta m src lines idx val|
+    |cls meta m src val|
 
     self isMeta ifTrue:[
 	meta := self. cls := meta soleInstance
@@ -2754,12 +2776,7 @@
 
     src := m source.
     src isNil ifTrue:[^ nil].
-    lines := src asCollectionOfLines.
-    idx := lines findFirst:[:l |
-	l withoutSpaces startsWith:'$Header'
-    ].
-    idx == 0 ifTrue:[^ nil].
-    ^ lines at:idx.
+    ^ self revisionStringFromSource:src 
 
     "
      Smalltalk allClassesDo:[:cls |
@@ -2771,7 +2788,7 @@
     "
 
     "Created: 29.10.1995 / 19:28:03 / cg"
-    "Modified: 11.11.1995 / 14:11:41 / cg"
+    "Modified: 15.11.1995 / 15:01:54 / cg"
 !
 
 setPrimitiveSpecsAt:index to:aString