Marcel Taeumel uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-jr.859.mcz ==================== Summary ==================== Name: Tools-jr.859 Author: jr Time: 4 August 2019, 11:23:31.139513 am UUID: da4ec759-c2aa-6040-9151-53c2942b3e88 Ancestors: Tools-mt.858 Refactor accept in MessageSet such that subclasses can override in which class the contents will be compiled. This will allow Lexicon (package Protocols) to create an override from an inherited method without switching the tool. Assumption: setClassAndSelectorIn: must provide the data of the currently selected method and it will not pretend to view a different class. Also split the contents:notifying: method since it did several things at once and was quite long. =============== Diff against Tools-mt.858 =============== Item was changed: ----- Method: MessageSet>>contents:notifying: (in category 'private') ----- contents: aString notifying: aController "Compile the code in aString. Notify aController of any syntax errors. Answer false if the compilation fails. Otherwise, if the compilation created a new method, deselect the current selection. Then answer true." + | category class oldSelector | - | category selector class oldSelector | self okayToAccept ifFalse: [^ false]. + class := self targetForContents: aString. - self setClassAndSelectorIn: [:c :os | class := c. oldSelector := os]. class ifNil: [^ false]. + self setClassAndSelectorIn: [:c :os | oldSelector := os]. + (self contents: aString specialSelector: oldSelector in: class notifying: aController) + ifTrue: [^ false]. - (oldSelector ~~ nil and: [oldSelector first isUppercase]) ifTrue: - [oldSelector = #Comment ifTrue: - [class comment: aString stamp: Utilities changeStamp. - self changed: #annotation. - self clearUserEditFlag. - ^ false]. - oldSelector = #Definition ifTrue: - ["self defineClass: aString notifying: aController." - class subclassDefinerClass - evaluate: aString - notifying: aController - logged: true. - self clearUserEditFlag. - ^ false]. - oldSelector = #Hierarchy ifTrue: - [self inform: 'To change the hierarchy, edit the class definitions'. - ^ false]]. "Normal method accept" + category := self selectedMessageCategoryName. + ^ self contents: aString + oldSelector: oldSelector + in: class + classified: category + notifying: aController! - category := class organization categoryOfElement: oldSelector. - selector := class compile: aString - classified: category - notifying: aController. - selector == nil ifTrue: [^ false]. - self noteAcceptanceOfCodeFor: selector. - selector == oldSelector ifFalse: - [self reformulateListNoting: selector]. - contents := aString copy. - self changed: #annotation. - ^ true! Item was added: + ----- Method: MessageSet>>contents:oldSelector:in:classified:notifying: (in category 'private') ----- + contents: aString oldSelector: oldSelector in: aClass classified: category notifying: aController + "Compile the code in aString. Notify aController of any syntax errors. + Answer false if the compilation fails. Otherwise, if the compilation + created a new method, deselect the current selection. Then answer true." + | selector | + selector := aClass compile: aString + classified: category + notifying: aController. + selector == nil ifTrue: [^ false]. + self noteAcceptanceOfCodeFor: selector. + selector == oldSelector ifFalse: + [self reformulateListNoting: selector]. + contents := aString copy. + self changed: #annotation. + ^ true! Item was added: + ----- Method: MessageSet>>contents:specialSelector:in:notifying: (in category 'private') ----- + contents: aString specialSelector: oldSelector in: aClass notifying: aController + "If the selector is a fake to denote a different definition than that of a method, + try to change that different object. Answer whether a special selector was found and + handled." + (oldSelector ~~ nil and: [oldSelector first isUppercase]) ifFalse: [^ false]. + oldSelector = #Comment ifTrue: + [aClass comment: aString stamp: Utilities changeStamp. + self changed: #annotation. + self clearUserEditFlag. + ^ true]. + oldSelector = #Definition ifTrue: + ["self defineClass: aString notifying: aController." + aClass subclassDefinerClass + evaluate: aString + notifying: aController + logged: true. + self clearUserEditFlag. + ^ true]. + oldSelector = #Hierarchy ifTrue: + [self inform: 'To change the hierarchy, edit the class definitions'. + ^ true]. + ^ false! Item was added: + ----- Method: MessageSet>>targetForContents: (in category 'private') ----- + targetForContents: aString + "Answer the behavior into which the contents will be accepted." + self setClassAndSelectorIn: [:c :os | ^ c]. + ^ nil "fail safe for overriding implementations of setClassAndSelectorIn:"! |
Free forum by Nabble | Edit this page |