Fix in ClassPO for completing Java class names.
"{ Package: 'jv:smallsense' }"
"{ NameSpace: SmallSense }"
HierarchicalItem subclass:#PO
instanceVariableNames:'subject icon label name relevance context'
classVariableNames:'IconWidth'
poolDictionaries:''
category:'SmallSense-Core-Interface-PO'
!
!PO class methodsFor:'initialization'!
initialize
"Invoked at system start or when the class is dynamically loaded."
"/ please change as required (and remove this comment)
IconWidth := 16.
"Modified: / 18-09-2013 / 00:13:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PO class methodsFor:'Instance creation'!
subject: anObject
^self new subject: anObject
"Created: / 06-04-2011 / 21:01:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PO methodsFor:'accessing'!
context
^ context
!
context:something
something notNil ifTrue:[
context := something.
].
"Modified: / 17-10-2013 / 01:16:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
cursorColumnAfterCompleteForLanguage: language
"Answers a cursor column after completion. The number returned
is relative to the start of the text being replaced"
^ (self stringToCompleteForLanguage: language) size
"Created: / 03-10-2013 / 16:49:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 04-10-2013 / 07:48:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
icon
^nil
"Created: / 04-04-2011 / 17:25:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
label
label isNil ifTrue:[label := self name].
^label
"Created: / 07-04-2011 / 09:55:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 03-10-2013 / 16:28:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
name
^ name
!
name:something
name := something.
!
relevance
"Return relevance value, i.e., how much likely is that this
is what user wants to complete.
Relevance is an integer between 1 (least relevant) and
100 (most relevant)"
^ relevance ? 1
"Modified: / 18-01-2014 / 22:41:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
relevance: anInteger
"Set the relevance value, i.e., how much likely is that this
is what user wants to complete.
Relevance is an integer between 1 (least relevant) and
100 (most relevant)"
^ relevance := anInteger.
"Modified: / 18-01-2014 / 22:41:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
stringAlreadyWritten
"Answers a string already written in the textview"
^ context wordBeforeCursor
"Created: / 20-10-2013 / 00:14:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
stringToComplete
"Answers a string to complete"
^self name
"Created: / 05-04-2011 / 16:48:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 03-10-2013 / 16:31:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
stringToCompleteForLanguage: aProgrammingLanguage
"Answers a string to complete"
^ self stringToComplete
"Created: / 02-10-2013 / 02:32:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
subject
^ subject
!
subject:something
subject := something.
! !
!PO methodsFor:'completion'!
insert
"Insert given completion item at cursor position"
| po stringToComplete stringAlreadyWritten stringToInsert textView |
po := self.
textView := context codeView.
stringToComplete := po stringToCompleteForLanguage: context language.
stringAlreadyWritten := self stringAlreadyWritten.
stringToInsert := stringToComplete copyFrom: (stringAlreadyWritten size + 1).
textView isCodeView2 ifTrue:[textView := textView textView].
(stringToComplete startsWith: stringAlreadyWritten) ifTrue:[
context support
electricInsert:stringToInsert
ignoreKeystrokes:stringToInsert.
textView cursorCol: textView cursorCol - stringToComplete size + (po cursorColumnAfterCompleteForLanguage: context language).
] ifFalse:[
| startCol endCol |
textView undoableDo:[
endCol := textView cursorCol - 1.
startCol := textView cursorCol - stringAlreadyWritten size.
textView insertStringAtCursor: stringToComplete.
textView deleteFromLine:textView cursorLine col: startCol toLine:textView cursorLine col:endCol.
].
textView cursorCol: startCol + (po cursorColumnAfterCompleteForLanguage: context language).
].
"Created: / 17-10-2013 / 01:08:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 16-02-2014 / 00:02:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PO methodsFor:'displaying'!
displayLabel:aLabel h:lH on:aGC x:x y:y h:h
| cx iconOrNil |
cx := x.
iconOrNil := self icon.
iconOrNil notNil ifTrue:[
iconOrNil displayOn: aGC x: cx y: y + (h / 2) - (iconOrNil height / 2).
].
cx := cx + IconWidth.
super displayLabel:aLabel h:lH on:aGC x:cx y:y h:h
"Created: / 24-07-2013 / 00:22:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 18-09-2013 / 00:13:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PO methodsFor:'printing & storing'!
printOn:aStream
"append a printed representation if the receiver to the argument, aStream"
super printOn:aStream.
aStream nextPut:$(.
name printOn:aStream.
aStream nextPut:$).
"Modified: / 04-04-2011 / 12:02:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PO methodsFor:'queries'!
startsWith: prefix
^self stringToComplete startsWith: prefix
"Created: / 26-11-2011 / 19:25:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PO methodsFor:'testing'!
isSmallSenseClassPO
^ false
!
isSmallSenseConstantPO
^ false
!
isSmallSenseMethodPO
^ false
!
isSmallSenseSnippetPO
^ false
!
isSmallSenseVariablePO
^ false
! !
!PO class methodsFor:'documentation'!
version_HG
^ '$Changeset: <not expanded> $'
!
version_SVN
^ '$Id: SmallSenseResultItem.st 7825 2011-11-26 18:32:31Z vranyj1 $'
! !
PO initialize!