Method.st
changeset 22372 72db331204d4
parent 22188 1b876830c38e
child 22443 0670bf503559
--- a/Method.st	Tue Nov 21 13:15:19 2017 +0100
+++ b/Method.st	Tue Nov 21 13:15:24 2017 +0100
@@ -103,10 +103,10 @@
         source          <String>        the source itself (if sourcePosition isNil)
                                         or the fileName where the source is found
 
-        sourcePosition  <Integer>       the position of the methods chunk in the file
-
-        category        <Symbol>        the methods category
-        package         <Symbol>        the package, in which the methods was defined
+        sourcePosition  <Integer>       the position of the method's chunk in the file
+
+        category        <Symbol>        the method's category
+        package         <Symbol>        the package, in which the method was defined
         mclass          <Class>         the class in which I am defined
         indexed slots                   literals
 
@@ -462,38 +462,41 @@
 !Method methodsFor:'accessing'!
 
 category
-    "return the methods category or nil"
+    "return the method's category or nil"
 
     ^ category
+
+    "Modified (comment): / 21-11-2017 / 13:03:48 / cg"
 !
 
 category:aStringOrSymbol
-    "set the methods category"
+    "set the method's category"
 
     |newCategory oldCategory cls|
 
     aStringOrSymbol notNil ifTrue:[
-	newCategory := aStringOrSymbol.
-	newCategory ~= (oldCategory := category) ifTrue:[
-	    self setCategory:newCategory.
-
-	    cls := self mclass.
-	    cls notNil ifTrue:[
-		cls addChangeRecordForMethodCategory:self category:newCategory.
-		self changed:#category with:oldCategory.            "/ will vanish
-		cls changed:#organization with:self selector.       "/ will vanish
-		Smalltalk changed:#methodCategory with:(Array with:cls with:self with:oldCategory).
-	    ]
-	]
+        newCategory := aStringOrSymbol.
+        newCategory ~= (oldCategory := category) ifTrue:[
+            self setCategory:newCategory.
+
+            cls := self mclass.
+            cls notNil ifTrue:[
+                cls addChangeRecordForMethodCategory:self category:newCategory.
+                self changed:#category with:oldCategory.            "/ will vanish
+                cls changed:#organization with:self selector.       "/ will vanish
+                Smalltalk changed:#methodCategory with:(Array with:cls with:self with:oldCategory).
+            ]
+        ]
     ]
 
     "Modified: / 25-09-2007 / 16:15:24 / cg"
+    "Modified (comment): / 21-11-2017 / 13:03:52 / cg"
 !
 
 comment
     "return the method's comment.
      This is done by searching for and returning the first comment
-     from the methods source (excluding any double-quotes).
+     from the method's source (excluding any double-quotes).
      Returns nil if there is no comment (or source is not available)."
 
     |src parserClass|
@@ -510,6 +513,7 @@
 
     "Modified: / 23-02-1998 / 10:26:08 / stefan"
     "Modified: / 01-06-2012 / 23:03:57 / cg"
+    "Modified (comment): / 21-11-2017 / 13:03:59 / cg"
 !
 
 getMclass
@@ -530,17 +534,21 @@
 getSource
     "low-level access to the source instance-variable.
      For internal (compiler) use only.
-     This is NOT always the methods source string"
+     This is NOT always the method's source string"
 
     ^ source
+
+    "Modified (comment): / 21-11-2017 / 13:04:03 / cg"
 !
 
 getSourcePosition
     "low-level access to the sourcePosition instance-variable.
      For internal (compiler) use only.
-     This is NOT always the methods sourcePosition"
+     This is NOT always the method's sourcePosition"
 
     ^ sourcePosition
+
+    "Modified (comment): / 21-11-2017 / 13:04:07 / cg"
 !
 
 localSourceFilename:aFileName position:aNumber
@@ -576,20 +584,22 @@
 !
 
 makeLocalStringSource
-    "assure that the methods source code is stored locally as a string
+    "assure that the method's source code is stored locally as a string
      within the method (as opposed to an external string, which is accessed
      by reading the source code file).
      This is required, when a method's package is changed, to assure that its
      sourceCode is not lost."
 
     source notNil ifTrue:[
-	sourcePosition notNil ifTrue:[
-	    "/ this looks wierd - but (self source) will retrieve the external source
-	    "/ (from the file) and store it. So afterwards, we will have the string and
-	    "/ sourcePosition will be nil
-	    self source:(self source)
-	]
+        sourcePosition notNil ifTrue:[
+            "/ this looks wierd - but (self source) will retrieve the external source
+            "/ (from the file) and store it. So afterwards, we will have the string and
+            "/ sourcePosition will be nil
+            self source:(self source)
+        ]
     ].
+
+    "Modified (comment): / 21-11-2017 / 13:04:13 / cg"
 !
 
 mclass:aClass
@@ -774,13 +784,14 @@
 !
 
 setCategory:aStringOrSymbol
-    "set the methods category (without change notification)"
+    "set the method's category (without change notification)"
 
     aStringOrSymbol notNil ifTrue:[
-	category := aStringOrSymbol asSymbol
+        category := aStringOrSymbol asSymbol
     ]
 
-    "Modified: / 13.11.1998 / 23:55:05 / cg"
+    "Modified: / 13-11-1998 / 23:55:05 / cg"
+    "Modified (comment): / 21-11-2017 / 13:05:26 / cg"
 !
 
 setPackage:aSymbol
@@ -882,11 +893,13 @@
 !
 
 source:aString
-    "set the methods sourcestring"
+    "set the method's sourcestring"
 
     self assert:(aString isText not).   "/ will break monticello-binary-data-writing
     source := aString.
     sourcePosition := nil
+
+    "Modified (comment): / 21-11-2017 / 13:05:59 / cg"
 !
 
 sourceFilename
@@ -897,11 +910,13 @@
 !
 
 sourceFilename:aFileName position:aNumber
-    "set the methods sourcefile/position"
+    "set the method's sourcefile/position"
 
     self assert:(aFileName isText not).   "/ will break monticello-binary-data-writing
     source := aFileName.
     sourcePosition := aNumber
+
+    "Modified (comment): / 21-11-2017 / 13:06:03 / cg"
 !
 
 sourceLineNumber
@@ -1055,7 +1070,6 @@
     "Modified (format): / 18-11-2011 / 14:47:06 / cg"
 ! !
 
-
 !Method methodsFor:'accessing-visibility'!
 
 isIgnored
@@ -1243,7 +1257,7 @@
 !
 
 privacy:aSymbol
-    "set the methods access rights (privacy) from a symbol;
+    "set the method's access rights (privacy) from a symbol;
      Currently, this must be one of #private, #protected, #public or #ignored.
 
      Notice: method privacy is a nonstandard feature, not supported
@@ -1260,22 +1274,23 @@
     oldPrivacy := self privacy.
 
     (self setPrivacy:aSymbol flushCaches:true) ifTrue:[
-	|myClass mySelector|
-
-	myClass := self mclass.
-	mySelector := self selector.
-
-	self changed:#privacy.                                       "/ will vanish
-	myClass notNil ifTrue:[
-	    mySelector notNil ifTrue:[
-		myClass changed:#methodPrivacy with:mySelector.      "/ will vanish
-		Smalltalk changed:#privacyOfMethod with:(Array with:myClass with:self with:oldPrivacy).
-		myClass addChangeRecordForMethodPrivacy:self.
-	    ]
-	]
+        |myClass mySelector|
+
+        myClass := self mclass.
+        mySelector := self selector.
+
+        self changed:#privacy.                                       "/ will vanish
+        myClass notNil ifTrue:[
+            mySelector notNil ifTrue:[
+                myClass changed:#methodPrivacy with:mySelector.      "/ will vanish
+                Smalltalk changed:#privacyOfMethod with:(Array with:myClass with:self with:oldPrivacy).
+                myClass addChangeRecordForMethodPrivacy:self.
+            ]
+        ]
     ]
 
     "Modified: / 23-11-2006 / 17:03:20 / cg"
+    "Modified (comment): / 21-11-2017 / 13:05:14 / cg"
 !
 
 restricted:aBoolean
@@ -1317,10 +1332,10 @@
 !
 
 setPrivacy:aSymbol
-    "set the methods access rights (privacy) from a symbol;
+    "set the method's access rights (privacy) from a symbol;
      Currently, this must be one of #private, #protected, #public or #ignored.
-     #setPrivacy: simply sets the attribute. When changing methods, that
-     have already been called, #privacy: should be used.
+     #setPrivacy: simply sets the attribute. 
+     When changing methods which have already been called, #privacy: should be used.
 
      Notice: method privacy is a nonstandard feature, not supported
      by other smalltalk implementations and not specified in the ANSI spec.
@@ -1332,6 +1347,8 @@
      It may change or even vanish (if it shows to be not useful)."
 
     ^ self setPrivacy:aSymbol flushCaches:true
+
+    "Modified (comment): / 21-11-2017 / 13:05:54 / cg"
 !
 
 setPrivacy:aSymbol flushCaches:doFlush
@@ -1523,11 +1540,13 @@
     "/
     temporaryMethod source:newSource.
     "/
-    "/ don't forget the methods class & package ...
+    "/ don't forget the method's class & package ...
     "/
     temporaryMethod setPackage:package.
     temporaryMethod mclass:(self getMclass).
     ^ temporaryMethod
+
+    "Modified (comment): / 21-11-2017 / 13:03:45 / cg"
 ! !
 
 !Method methodsFor:'copying'!
@@ -2923,8 +2942,8 @@
 !
 
 methodArgAndVarNames
-    "return a collection with the methods argument and variable names.
-     Uses Parser to parse methods source and extract the names.
+    "return a collection with the method's argument and variable names.
+     Uses Parser to parse the method's source and extract the names.
      Returns an empty collection if the source is not available, or some other
      syntax/parse error occurred.
      For methods with no args and no vars, an empty collection is returned."
@@ -2934,19 +2953,21 @@
     parserClass := self parserClass.
     sourceString := self source.
     (parserClass notNil and:[sourceString notNil]) ifTrue:[
-	parser := parserClass parseMethodArgAndVarSpecificationSilent:sourceString.
-	(parser isNil or:[parser == #Error]) ifTrue:[^ #()].
-	argNames := parser methodArgs.
-	varNames := parser methodVars.
-	argNames isNil ifTrue:[^ varNames ? #()].
-	varNames isNil ifTrue:[^ argNames ? #()].
-	^ (argNames , varNames)
+        parser := parserClass parseMethodArgAndVarSpecificationSilent:sourceString.
+        (parser isNil or:[parser == #Error]) ifTrue:[^ #()].
+        argNames := parser methodArgs.
+        varNames := parser methodVars.
+        argNames isNil ifTrue:[^ varNames ? #()].
+        varNames isNil ifTrue:[^ argNames ? #()].
+        ^ (argNames , varNames)
     ].
     ^ #()
 
     "
      (Method compiledMethodAt:#printOn:) methodArgAndVarNames
     "
+
+    "Modified (comment): / 21-11-2017 / 13:04:33 / cg"
 !
 
 methodArgAndVarNamesInContext: context
@@ -2962,8 +2983,8 @@
 !
 
 methodArgNames
-    "return a collection with the methods argument names.
-     Uses Parser to parse methods source and extract the names."
+    "return a collection with the method's argument names.
+     Uses Parser to parse the method's source and extract the names."
 
     ^ self parse:#'parseMethodSpecificationSilent:' return:#methodArgs or:nil
 
@@ -2971,11 +2992,12 @@
      (Method compiledMethodAt:#printOn:) methodArgNames
     "
 
-    "Modified: 31.10.1995 / 14:36:46 / cg"
+    "Modified: / 31-10-1995 / 14:36:46 / cg"
+    "Modified (comment): / 21-11-2017 / 13:04:44 / cg"
 !
 
 methodComment
-    "return the methods first comment, nil if there is none.
+    "return the method's first comment, nil if there is none.
      This is a somewhat stupid implementation."
 
     |text line nQuote index qIndex qIndex2 comment|
@@ -2986,36 +3008,38 @@
     line := (text at:2).
     nQuote := line occurrencesOf:(Character doubleQuote).
     (nQuote == 2) ifTrue:[
-	qIndex := line indexOf:(Character doubleQuote).
-	qIndex2 := line indexOf:(Character doubleQuote) startingAt:(qIndex + 1).
-	^ line copyFrom:(qIndex + 1) to:(qIndex2 - 1)
+        qIndex := line indexOf:(Character doubleQuote).
+        qIndex2 := line indexOf:(Character doubleQuote) startingAt:(qIndex + 1).
+        ^ line copyFrom:(qIndex + 1) to:(qIndex2 - 1)
     ].
     (nQuote == 1) ifTrue:[
-	qIndex := line indexOf:(Character doubleQuote).
-	comment := line copyFrom:(qIndex + 1).
-	(line indexOf:$/ startingAt:qIndex) == (qIndex+1) ifTrue:[
-	    "/ an EOL comment
-	    ^ (comment copyFrom:2) withoutSeparators
-	].
-
-	"/ not an EOL comment
-	index := 3.
-	line := text at:index.
-	nQuote := line occurrencesOf:(Character doubleQuote).
-	[nQuote ~~ 1] whileTrue:[
-	    comment := comment , Character cr asString , line withoutSpaces.
-	    index := index + 1.
-	    line := text at:index.
-	    nQuote := line occurrencesOf:(Character doubleQuote)
-	].
-	qIndex := line indexOf:(Character doubleQuote).
-	^ comment , Character cr asString , (line copyTo:(qIndex - 1)) withoutSpaces
+        qIndex := line indexOf:(Character doubleQuote).
+        comment := line copyFrom:(qIndex + 1).
+        (line indexOf:$/ startingAt:qIndex) == (qIndex+1) ifTrue:[
+            "/ an EOL comment
+            ^ (comment copyFrom:2) withoutSeparators
+        ].
+
+        "/ not an EOL comment
+        index := 3.
+        line := text at:index.
+        nQuote := line occurrencesOf:(Character doubleQuote).
+        [nQuote ~~ 1] whileTrue:[
+            comment := comment , Character cr asString , line withoutSpaces.
+            index := index + 1.
+            line := text at:index.
+            nQuote := line occurrencesOf:(Character doubleQuote)
+        ].
+        qIndex := line indexOf:(Character doubleQuote).
+        ^ comment , Character cr asString , (line copyTo:(qIndex - 1)) withoutSpaces
     ].
     ^ nil
 
     "
      (Method compiledMethodAt:#methodComment) methodComment
     "
+
+    "Modified (comment): / 21-11-2017 / 13:04:50 / cg"
 !
 
 methodDefinitionTemplate
@@ -3039,8 +3063,8 @@
 !
 
 methodVarNames
-    "return a collection with the methods local-variable names.
-     Uses Parser to parse methods source and extract the names."
+    "return a collection with the method's local-variable names.
+     Uses Parser to parse the method's source and extract the names."
 
     ^ self parse:#'parseMethodArgAndVarSpecificationSilent:' return:#methodVars or:nil
 
@@ -3048,7 +3072,8 @@
      (Method compiledMethodAt:#printOn:) methodVarNames
     "
 
-    "Modified: 31.10.1995 / 14:36:49 / cg"
+    "Modified: / 31-10-1995 / 14:36:49 / cg"
+    "Modified (comment): / 21-11-2017 / 13:04:59 / cg"
 !
 
 modificationTime
@@ -3416,21 +3441,23 @@
 
 resourceType
     "ST-80 compatibility:
-     return the methods first resource specs key.
+     return the method's first resource specs key.
      Returns either nil, or a single symbol."
 
     |resources|
 
     (resources := self resources) notNil ifTrue:[
-	resources keysAndValuesDo:[:key :val|
-	    ^ key
-	].
+        resources keysAndValuesDo:[:key :val|
+            ^ key
+        ].
     ].
     ^ nil
+
+    "Modified (comment): / 21-11-2017 / 13:05:19 / cg"
 !
 
 resources
-    "return the methods resource spec; either nil or a collection of symbols."
+    "return the method's resource spec; either nil or a collection of symbols."
 
     | resources |
 
@@ -3445,6 +3472,7 @@
 
     "Modified: / 16-07-2010 / 11:49:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 18-11-2011 / 14:48:41 / cg"
+    "Modified (comment): / 21-11-2017 / 13:05:22 / cg"
 !
 
 selector
@@ -3777,7 +3805,6 @@
     "Created: / 23-07-2012 / 11:16:36 / cg"
 ! !
 
-
 !Method methodsFor:'source management'!
 
 revisionInfo
@@ -3850,21 +3877,21 @@
 documentation
 "
     In earlier times, Method>>who returned an array filled
-    with the methods class and selector.
+    with the method's class and selector.
     This was done, since a smalltalk method cannot return multiple
     values, but 2 values had to be returned from that method.
     Thus, the who-interface was used as:
-	info := <someMethod> who.
-	class := info at:1.
-	sel := info at:2.
+        info := <someMethod> who.
+        class := info at:1.
+        sel := info at:2.
 
     Sure, this is ugly coding style, and the system has been changed to return
     an object (an instance of MethodWhoInfo) which responds to the two
     messages: #methodClass and #methodSelector.
     This allows to write things much more intuitive:
-	info := <someMethod> who.
-	class := info methodClass.
-	sel := info methodSelector.
+        info := <someMethod> who.
+        class := info methodClass.
+        sel := info methodSelector.
 
     However, to be backward compatible, the returned object still responds to
     the #at: message, but only allows inices of 1 and 2 to be used.
@@ -3873,10 +3900,10 @@
     classes.
 
     [author:]
-	Claus Gittinger
+        Claus Gittinger
 
     [see also:]
-	Method
+        Method
 "
 ! !