[Pkg] Monticello Public: FixUnderscores2-mtf.1.mcz

squeak-dev-noreply at lists.squeakfoundation.org squeak-dev-noreply at lists.squeakfoundation.org
Mon Aug 10 12:47:55 UTC 2009


A new version of FixUnderscores2 was added to project Monticello Public:
http://www.squeaksource.com/mc/FixUnderscores2-mtf.1.mcz

==================== Summary ====================

Name: FixUnderscores2-mtf.1
Author: mtf
Time: 10 August 2009, 8:47:44 am
UUID: 3936eb7c-5df4-4877-bd6e-f61ad581fb4d
Ancestors: 

A tool to help monticello load packages with underscore assignments in Croquet, where they are illegal

==================== Snapshot ====================

SystemOrganization addCategory: #FixUnderscores2!

----- Method: WriteStream>>replaceFrom:to:with: (in category '*fixunderscores2') -----
replaceFrom: start to: stop with: aCollection
"replace a section of my backing collection, without moving the cursor"

	| delta oldSize |
	oldSize := stop - start + 1.
	delta := aCollection size - oldSize.
	readLimit > stop ifTrue: [readLimit := readLimit + delta].
	writeLimit > stop ifTrue: [writeLimit := writeLimit + delta].
	position > stop ifTrue: [position := position + delta].
	collection := collection copyReplaceFrom: start to: stop with: aCollection!

Notification subclass: #SourceChangedDuringLoad
	instanceVariableNames: 'method'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'FixUnderscores2'!

!SourceChangedDuringLoad commentStamp: '<historical>' prior: 0!
If signalled, the source code that Monticello ultimately loaded into the system is different from the code it was asked to load, due to one of two things:

- the presented code had syntax errors that the user corrected at load time
- the presented code had underscore assignments that were changed to := at load time

method: something to describe the method that changed. For MCPackageLoader1b, it is an MCMethodDefinition. For MCPackageLoader2, it is a MethodEditor!

----- Method: SourceChangedDuringLoad class>>method:reason: (in category 'as yet unclassified') -----
method: anObject reason: aString
	^ self new method: anObject; message: aString; yourself!

----- Method: SourceChangedDuringLoad>>method (in category 'accessing') -----
method
	"Answer the value of method"

	^ method!

----- Method: SourceChangedDuringLoad>>method: (in category 'accessing') -----
method: anObject
	"Set the value of method"

	method := anObject!

Scanner subclass: #FixUnderscores2
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'FixUnderscores2'!

!FixUnderscores2 commentStamp: '<historical>' prior: 0!
I am a utility to change underscore assignments to :=. I only understand source strings for now, and don't yet work on already loaded code. I will probably be moved to another package later (like SystemEditor)!

----- Method: FixUnderscores2 class>>test1 (in category 'as yet unclassified') -----
test1

	self assert: (self new fixUnderscores: self testString1) = self testString1Ans!

----- Method: FixUnderscores2 class>>testString1 (in category 'as yet unclassified') -----
testString1
	^ 'whoisSelectedUser
	"I_AM_NOT_Illegal"
	| who msg |
	who _ self channelUser.
	who isNil
		ifTrue: [^ nil].
	msg := IRCProtocolMessage
				command: ''W_H_O_I_S''
				arguments: (Array with: self channelName with: who asString).
	connection sendMessage: msg'!

----- Method: FixUnderscores2 class>>testString1Ans (in category 'as yet unclassified') -----
testString1Ans
	^ 'whoisSelectedUser
	"I_AM_NOT_Illegal"
	| who msg |
	who := self channelUser.
	who isNil
		ifTrue: [^ nil].
	msg := IRCProtocolMessage
				command: ''W_H_O_I_S''
				arguments: (Array with: self channelName with: who asString).
	connection sendMessage: msg'!

----- Method: FixUnderscores2>>fixUnderscores: (in category 'as yet unclassified') -----
fixUnderscores: aString
"Answer aString with _ assignments replaced with :=. Answers nil if aString has syntax errors other than underscre assignments"

[
	self scan: (ReadWriteStream with: aString) reset.
	[tokenType = #doIt] whileFalse: [
		(tokenType = #leftArrow and: [token == #'_'])
			ifTrue: [self replaceTokenWith: ':='].
		self scanToken].
	^ source contents
] on: SyntaxErrorNotification do: [^ nil]!

----- Method: FixUnderscores2>>replaceFrom:to:with: (in category 'as yet unclassified') -----
replaceFrom: start to: stop with: aCollection
"replace a section of my source stream with aCollection"

	| delta oldSize |
	oldSize := stop - start + 1.
	delta := aCollection size - oldSize.
	mark > stop ifTrue: [mark := mark + delta].
	source replaceFrom: start to: stop with: aCollection!

----- Method: FixUnderscores2>>replaceTokenWith: (in category 'as yet unclassified') -----
replaceTokenWith: aText
"replace the current token with another"

	self replaceFrom: mark
		to: mark + token size - 1
		with: aText!

----- Method: FixUnderscores2>>xUnderscore (in category 'as yet unclassified') -----
xUnderscore
"Do nothing special on underscore assignment. xUnderscore only exists in the croquet scanner"

	tokenType := #leftArrow.
	^ token := self step asSymbol!



More information about the Packages mailing list