--- a/SmallSense__CompletionEngine.st Tue Apr 01 18:01:57 2014 +0200
+++ b/SmallSense__CompletionEngine.st Wed Apr 02 23:42:42 2014 +0200
@@ -10,6 +10,25 @@
!
+!CompletionEngine class methodsFor:'accessing'!
+
+matcher
+ "Return a match block returning true, if given prefix matches given selector"
+
+ ^ [ :prefix :selector |
+ prefix size < 5 ifTrue:[
+ selector startsWith: prefix.
+ ] ifFalse:[
+ | part |
+
+ part := selector copyTo: (prefix size min: selector size).
+ (prefix levenshteinTo: part) < 15
+ ].
+ ].
+
+ "Created: / 02-04-2014 / 23:30:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!CompletionEngine class methodsFor:'testing'!
isAbstract
@@ -56,6 +75,13 @@
!
addMethodsStartingWith: prefix filter: filterOrNil
+ ^ self addMethodsStartingWith: prefix filter: filterOrNil matcher: CompletionEngine matcher.
+
+ "Created: / 03-10-2013 / 17:56:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 02-04-2014 / 23:30:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+addMethodsStartingWith: prefix filter: filterOrNil matcher: matcher
| selectors filter |
selectors := Dictionary new.
@@ -63,7 +89,7 @@
Smalltalk allClassesDo:[:class|
class selectorsAndMethodsDo:[:selector :mthd |
- ((selector startsWith: prefix) and:[mthd isSynthetic not and:[filter value: mthd]]) ifTrue:[
+ (mthd isSynthetic not and:[(filter value: mthd) and:[ matcher value: prefix value: selector]]) ifTrue:[
| class skip |
class := mthd mclass superclass.
@@ -92,8 +118,7 @@
class:(classes size == 1 ifTrue:[classes anElement] ifFalse:[classes])).
]
- "Created: / 03-10-2013 / 17:56:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 22-10-2013 / 12:13:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Created: / 02-04-2014 / 23:17:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!CompletionEngine methodsFor:'completion-private'!