Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
77 changes: 77 additions & 0 deletions src/Implicit-Prefix-Matching-Tests/CoGlobalEntryTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
Class {
#name : 'CoGlobalEntryTest',
#superclass : 'TestCase',
#category : 'Implicit-Prefix-Matching-Tests',
#package : 'Implicit-Prefix-Matching-Tests'
}

{ #category : 'tests' }
CoGlobalEntryTest >> testCompletionMatchTextCaseSensitivity [

|entry|
entry := CoGlobalEntry contents: 'SpPresenter' node: nil.
entry implicitPrefix: 'sp'.
self assert: (entry completionMatchText ) equals: 'SpPresenter'
]

{ #category : 'tests' }
CoGlobalEntryTest >> testCompletionMatchTextWhenContentsEmpty [

|entry|
entry := CoGlobalEntry contents: '' node: nil.
entry implicitPrefix: 'Sp'.
self assert: (entry completionMatchText ) equals: ''
]

{ #category : 'tests' }
CoGlobalEntryTest >> testCompletionMatchTextWhenContentsShorterThanPrefix [

|entry|
entry := CoGlobalEntry contents: 'Sp' node: nil.
entry implicitPrefix: 'SpAbstract'.
self assert: (entry completionMatchText ) equals: 'Sp'
]

{ #category : 'tests' }
CoGlobalEntryTest >> testCompletionMatchTextWhenExactMatch [
"the entry and the implicit prefix are exact the same, we should return the contents"
|entry|
entry := CoGlobalEntry contents: 'Sp' node: nil.
entry implicitPrefix: 'Sp'.
self assert: (entry completionMatchText ) equals: 'Sp'
]

{ #category : 'tests' }
CoGlobalEntryTest >> testCompletionMatchTextWhenPrefixDoesNotMatchStart [

|entry|
entry := CoGlobalEntry contents: 'SpPresenter' node: nil.
entry implicitPrefix: 'Co'.
self assert: (entry completionMatchText ) equals: 'SpPresenter'
]

{ #category : 'tests' }
CoGlobalEntryTest >> testCompletionMatchTextWhenPrefixIsEmpty [

|entry|
entry := CoGlobalEntry contents: 'SpPresenter' node: nil.
entry implicitPrefix: ''.
self assert: (entry completionMatchText ) equals: 'SpPresenter'
]

{ #category : 'tests' }
CoGlobalEntryTest >> testCompletionMatchTextWhenPrefixIsNil [

|entry|
entry := CoGlobalEntry contents: 'SpPresenter' node: nil.
entry implicitPrefix: nil.
self assert: (entry completionMatchText ) equals: 'SpPresenter'
]

{ #category : 'tests' }
CoGlobalEntryTest >> testCompletionMatchTextWhenPrefixMatch [
|entry|
entry := CoGlobalEntry contents: 'SpPresenter' node: nil.
entry implicitPrefix: 'Sp'.
self assert: (entry completionMatchText ) equals: 'Presenter'
]

This file was deleted.

35 changes: 35 additions & 0 deletions src/Implicit-Prefix-Matching/CoGlobalEntry.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Extension { #name : 'CoGlobalEntry' }

{ #category : '*Implicit-Prefix-Matching' }
CoGlobalEntry >> completionMatchText [
self propertyAt: #implicitPrefix
ifPresent: [:prefix |
( prefix isNotNil and: [
prefix isNotEmpty
and: [ self contents size > prefix size
and: [ self contents beginsWith: prefix ] ]])
ifTrue: [ ^ self contents allButFirst: prefix size ]
ifFalse: [ ^ super completionMatchText ] ]
ifAbsent: [ ^'' ]
]

{ #category : '*Implicit-Prefix-Matching' }
CoGlobalEntry class >> contents: aString node: aNode implicitPrefix: aPrefix [

^ self new
contents: aString node: aNode;
implicitPrefix: aPrefix;
yourself
]

{ #category : '*Implicit-Prefix-Matching' }
CoGlobalEntry >> implicitPrefix [

^ self propertyAt: #implicitPrefix ifAbsent: [ ^'' ]
]

{ #category : '*Implicit-Prefix-Matching' }
CoGlobalEntry >> implicitPrefix: aString [

self propertyAt: #implicitPrefix put: aString
]
13 changes: 13 additions & 0 deletions src/Implicit-Prefix-Matching/CoGlobalVariableFetcher.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Extension { #name : 'CoGlobalVariableFetcher' }

{ #category : '*Implicit-Prefix-Matching' }
CoGlobalVariableFetcher >> entriesDo: aBlock [

self systemNavigation
allGlobalNamesStartingWith: filter completionString
do: [ :e |
aBlock value: ((CoGlobalEntry contents: e node: astNode implicitPrefix: '')
fetcherName: self class name;
yourself) ]
caseSensitive: NECPreferences caseSensitive
]
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ CoImplicitGlobalVariableFetcher >> entriesDo: aBlock [
completionClass package definedClasses do: [ :cls |
(cls name beginsWith: prefix , filter completionString)
ifTrue: [
aBlock value: ((NECPrefixExpandableGlobalEntry
aBlock value: ((CoGlobalEntry
contents: cls name node: astNode implicitPrefix: prefix)
fetcherName: self class name;
yourself) ] ].

super entriesDo: aBlock ]
]

Expand Down

This file was deleted.

Loading