pharo icon indicating copy to clipboard operation
pharo copied to clipboard

ecompletion in presence of keyword

Open Ducasse opened this issue 9 months ago • 3 comments

When we have the following expression where | represents the caret

1 between: 1 an|

We get and:do:

while we would like to have between:and:

entriesDo: aBlock
	
	"We try two approaches
	
	- the first one is to see if we can take advantage that we are in the beginning of a keyword message.
	
	For example imagine that the user 
			
			x at: a p|  
			
	we are trying to propose at:put:.		 
			
	- the last one is to look globally in the method implementors and try to match. 		
	"
	
	astNode ifNotNil: [ :node | node parent ifNotNil: [ :parent | "Try first to continue the parent keyword message"
			self halt.
		(parent isMessage and: [ parent isKeyword ]) ifTrue: [
			self systemNavigation
				allSelectorsStartingWith: parent selector , filter completionString
				do: [ :e |
					aBlock value: ((NECSelectorEntry
							 contents: (e copyFrom: parent selector size + 1 to: e size)
							 node: astNode)
							 selector: e)
							 ] ] ] ].

	"Otherwise, just go wide"
	self systemNavigation
		allSelectorsStartingWith: filter completionString
		do: [ :e |
		aBlock value: (NECSelectorEntry contents: e node: astNode) ]

Ducasse avatar May 23 '25 08:05 Ducasse

and and:do: is correct because there is between:and:do: now it means that allSelectorsStartingWith: do: does not sort selectors based on size.

Ducasse avatar May 23 '25 08:05 Ducasse

Image

Ducasse avatar May 23 '25 08:05 Ducasse

Even if we sort the Symbol selectorTable the order does not change.

Ducasse avatar May 23 '25 08:05 Ducasse

I will close it for now because we do not want to sort global symbols (but this is a pity).

Ducasse avatar Jun 28 '25 13:06 Ducasse