[squeak-dev] The Inbox: Tools-ct.1130.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Feb 14 00:02:47 UTC 2022


A new version of Tools was added to project The Inbox:
http://source.squeak.org/inbox/Tools-ct.1130.mcz

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

Name: Tools-ct.1130
Author: ct
Time: 14 February 2022, 1:02:43.784188 am
UUID: e802d5d5-1c10-1146-9570-47e16bfc1f44
Ancestors: Tools-mt.1129

Fixes selection in SelectorBrowser aka Method Finder when the receiver is a brace array such as in:

	{1. 2. 3}. 1

Also simplies the reparsing logic of the example string slightly.

Inbox because of two open questions:

1) Does this break the selection of "external search results" (see #searchResult:)? It has zero senders in the Trunk and in Ocompletion.

2) Is it a bug that "Scanner new scanTokens: '{1. 2. 3}'" does not answer a single item? If yes, shall we merge this patch anyway as a general refactoring?

=============== Diff against Tools-mt.1129 ===============

Item was changed:
  ----- Method: SelectorBrowser>>markMatchingClasses (in category 'message list') -----
  markMatchingClasses
  	"If an example is used, mark classes matching the example instance with an asterisk."
  
  	| unmarkedClassList firstPartOfSelector receiverString receiver |
  
  	self flag: #mref.	"allows for old-fashioned style"
  
  	"Only 'example' queries can be marked."
  	(contents asString includes: $.) ifFalse: [^ self].
  
  	unmarkedClassList := classList copy.
  
  	"Get the receiver object of the selected statement in the message list."
+ 	firstPartOfSelector := self selectedMessageName keywords first.
- 	firstPartOfSelector := (Scanner new scanTokens: (selectorList at: selectorIndex)) second.
  	receiverString := (ReadStream on: (selectorList at: selectorIndex))
  						upToAll: firstPartOfSelector.
  	receiver := Compiler evaluate: receiverString.
  
  	unmarkedClassList do: [ :classAndMethod | | class |
  		(classAndMethod isKindOf: MethodReference) ifTrue: [
  			(receiver isKindOf: classAndMethod actualClass) ifTrue: [
  				classAndMethod stringVersion: '*', classAndMethod stringVersionDefault.
  			]
  		] ifFalse: [
  			class := Compiler evaluate:
  					((ReadStream on: classAndMethod) upToAll: firstPartOfSelector).
  			(receiver isKindOf: class) ifTrue: [
  				classList add: '*', classAndMethod.
  				classList remove: classAndMethod
  			]
  		].
  	].
  !

Item was changed:
  ----- Method: SelectorBrowser>>quickList (in category 'selector finding') -----
  quickList
  	"Compute the selectors for the single example of receiver and args, in the very top pane" 
  
  	| data result resultArray dataStrings mf dataObjects aa statements |
  	data := contents asString withBlanksTrimmed.
  	mf := MethodFinder new.
  	data := mf cleanInputs: data.	"remove common mistakes"
  	dataObjects := Compiler evaluate: '{', data, '}'. "#( data1 data2 result )"
  	statements := (Compiler new parse: 'zort ' , data in: Object notifying: nil)
  				body statements select: [:each | (each isKindOf: ReturnNode) not].
   	dataStrings := statements collect:
  				[:node | String streamContents:
  					[:strm | (node isMessage) ifTrue: [strm nextPut: $(].
  					node shortPrintOn: strm.
  					(node isMessage) ifTrue: [strm nextPut: $)].]].
  	dataObjects size < 2 ifTrue: [self inform: 'If you are giving an example of receiver, \args, and result, please put periods between the parts.\Otherwise just type one selector fragment' withCRs. ^#()].
   	dataObjects := Array with: dataObjects allButLast with: dataObjects last. "#( (data1
    data2) result )" 
  	result := mf load: dataObjects; findMessage.
  	(result first beginsWith: 'no single method') ifFalse: [
  		aa := self testObjects: dataObjects strings: dataStrings.
  		dataObjects := aa second.  dataStrings := aa third].
  	resultArray := self listFromResult: result. 
  	resultArray isEmpty ifTrue: [self inform: result first].
  
  	dataStrings size = (dataObjects first size + 1) ifTrue:
  		[resultArray := resultArray collect: [:expression | | newExp |
  		newExp := expression.
  		dataObjects first withIndexDo: [:lit :i |
  			newExp := newExp copyReplaceAll: 'data', i printString
  							with: (dataStrings at: i)].
+ 		newExp, self resultSeparator, dataStrings last]].
- 		newExp, ' --> ', dataStrings last]].
  
   	^ resultArray!

Item was added:
+ ----- Method: SelectorBrowser>>resultSeparator (in category 'private') -----
+ resultSeparator
+ 
+ 	^ ' --> '!

Item was changed:
  ----- Method: SelectorBrowser>>selectedMessageName (in category 'accessing') -----
  selectedMessageName
  	"Answer the name of the currently selected message or nil if not a known Symbol."
  
+ 	| example expression |
- 	| example tokens |
  	selectorIndex = 0 ifTrue: [^nil].
  	example := selectorList at: selectorIndex.
+ 	example isSymbol ifTrue: [^ example].
+ 	expression := example first: (example findLastOccurrenceOfString: self resultSeparator startingAt: 1) - 1.
+ 	^ expression findSelector!
- 	tokens := Scanner new scanTokens: example.
- 	tokens size = 1 ifTrue: [^ tokens first].
- 	tokens first == #'^' ifTrue: [^ nil].
- 	(tokens second includes: $:) ifTrue: [^ example findSelector].
- 	^Symbol lookup: tokens second!



More information about the Squeak-dev mailing list