Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 13825. Create a new sorter for the completion engine . #17473

Open
wants to merge 4 commits into
base: Pharo13
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/HeuristicCompletion-Model/CoResultSet.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Class {
#instVars : [
'results',
'fetcher',
'filter'
'filter',
'sorter'
],
#category : 'HeuristicCompletion-Model-Core',
#package : 'HeuristicCompletion-Model',
Expand Down Expand Up @@ -56,7 +57,7 @@ CoResultSet >> fetch: anInteger [

| newResults |
newResults := fetcher next: anInteger.
results addAll: newResults
results addAll: (sorter sortCompletionList: newResults)
]

{ #category : 'fetching' }
Expand Down Expand Up @@ -117,7 +118,8 @@ CoResultSet >> initialize [

super initialize.
results := OrderedCollection new.
filter := CoFilter empty
filter := CoFilter empty.
sorter := CompletionContext sorterClass new
]

{ #category : 'testing' }
Expand Down
16 changes: 16 additions & 0 deletions src/HeuristicCompletion-Tests/CoCompletionEngineTest.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Class {
#name : 'CoCompletionEngineTest',
#superclass : 'CompletionEngineTest',
#instVars : [
'oldSort'
],
#category : 'HeuristicCompletion-Tests',
#package : 'HeuristicCompletion-Tests'
}
Expand Down Expand Up @@ -28,6 +31,19 @@ CoCompletionEngineTest >> newCompletionEngine [
^ CoCompletionEngine new
]

{ #category : 'accessing' }
CoCompletionEngineTest >> setUp [
super setUp.
oldSort := CompletionContext sorterClass.
CompletionContext sorterClass: NoSorter.
]

{ #category : 'accessing' }
CoCompletionEngineTest >> tearDown [
super tearDown.
CompletionContext sorterClass: oldSort.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please tab!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's already tabed in my image ... , i don't know why it's like this here.
Uploading Capture d’écran 2024-12-01 à 18.32.52.png…

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@omarabedelkader Because you used 4 spaces instead of 1 tab

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right !
i think now it's fixed.

]

{ #category : 'tests - interaction' }
CoCompletionEngineTest >> testCmdCtrlLeft [

Expand Down
2 changes: 1 addition & 1 deletion src/NECompletion/CompletionSorter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ CompletionSorter class >> kind [

{ #category : 'tools registry' }
CompletionSorter class >> register [
CompletionContext sorterClass: AlphabeticSorter
CompletionContext sorterClass: SizeSorter
]

{ #category : 'accessing' }
Expand Down
20 changes: 20 additions & 0 deletions src/NECompletion/NoSorter.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"
I'm a class that do nothing in the suggestion list.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that does nothing


I return the list created from the compltion engine.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

completion engine


This class is created to pass the test.
"
Class {
#name : 'NoSorter',
#superclass : 'CompletionSorter',
#category : 'NECompletion-Sorting',
#package : 'NECompletion',
#tag : 'Sorting'
}

{ #category : 'sorting' }
NoSorter >> sortCompletionList: anOrderedCollection [

^ anOrderedCollection
]
20 changes: 20 additions & 0 deletions src/NECompletion/SizeSorter.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"
I'm a class that do sorting based on the size of the context itself.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does sorting


I return a list sorted by size.


"
Class {
#name : 'SizeSorter',
#superclass : 'CompletionSorter',
#category : 'NECompletion-Sorting',
#package : 'NECompletion',
#tag : 'Sorting'
}

{ #category : 'sorting' }
SizeSorter >> sortCompletionList: anOrderedCollection [

^ anOrderedCollection sort: [ :a :b | a contents size < b contents size ]
]