--- a/SmallSense__EditSupport.st Tue Jan 26 21:32:58 2016 +0100
+++ b/SmallSense__EditSupport.st Tue Jan 26 21:40:42 2016 +0100
@@ -5,7 +5,7 @@
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
-version 2.1 of the License.
+version 2.1 of the License.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -39,7 +39,7 @@
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
-version 2.1 of the License.
+version 2.1 of the License.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -56,15 +56,15 @@
forLanguage: aProgrammingLanguage
aProgrammingLanguage notNil ifTrue:[
- aProgrammingLanguage isSmalltalk ifTrue:[
- ^ SmalltalkEditSupport new
- ].
- (aProgrammingLanguage askFor: #isJava) ifTrue:[
- ^ JavaEditSupport new
- ].
- (aProgrammingLanguage askFor: #isGroovy) ifTrue:[
- ^ GroovyEditSupport new
- ]
+ aProgrammingLanguage isSmalltalk ifTrue:[
+ ^ SmalltalkEditSupport new
+ ].
+ (aProgrammingLanguage askFor: #isJava) ifTrue:[
+ ^ JavaEditSupport new
+ ].
+ (aProgrammingLanguage askFor: #isGroovy) ifTrue:[
+ ^ GroovyEditSupport new
+ ]
].
^GenericEditSupport new.
@@ -117,7 +117,7 @@
!
completionEngineClass
- "Returns a code completion engine class or nil, of
+ "Returns a code completion engine class or nil, of
no completion is supported"
^ nil
@@ -136,26 +136,26 @@
!EditSupport methodsFor:'editing'!
-electricDeleteCharacterAtCol: col
+electricDeleteCharacterAtCol: col
textView deleteCharAtLine: textView cursorLine col: col
"Created: / 22-01-2014 / 21:17:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-electricDeleteCharacterAtLine:line col: col
+electricDeleteCharacterAtLine:line col: col
textView deleteCharAtLine: line col: col
"Created: / 22-01-2014 / 21:16:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-electricDo:aBlock
+electricDo:aBlock
textView completionSupport notNil ifTrue:[
- (textView completionSupport)
- stopCompletionProcess;
- closeCompletionView.
+ (textView completionSupport)
+ stopCompletionProcess;
+ closeCompletionView.
].
textView hasSelection ifTrue:[
- textView undoableDo:[ textView deleteSelection ].
+ textView undoableDo:[ textView deleteSelection ].
].
textView undoableDo:[ aBlock value. ].
backspaceIsUndo := true.
@@ -164,23 +164,23 @@
"Modified: / 22-10-2013 / 03:15:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-electricInsert:text
+electricInsert:text
self electricInsert:text advanceCursorBy:nil.
"Created: / 22-10-2013 / 11:08:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-electricInsert:stringOrLines advanceCursorBy:offsetOrNil
- ^ self
- electricInsert:stringOrLines
- advanceCursorBy:offsetOrNil
- ignoreKeystrokes:nil
+electricInsert:stringOrLines advanceCursorBy:offsetOrNil
+ ^ self
+ electricInsert:stringOrLines
+ advanceCursorBy:offsetOrNil
+ ignoreKeystrokes:nil
"Created: / 22-10-2013 / 11:56:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 19-01-2014 / 20:29:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-electricInsert:stringOrLines advanceCursorBy:offsetOrNil ignoreKeystrokes:ignoreKeystrokeSequence
+electricInsert:stringOrLines advanceCursorBy:offsetOrNil ignoreKeystrokes:ignoreKeystrokeSequence
"Insert given stringOrLines. If offsetOrNil is not nil, then
move cursor by `offsetOrNil` after the **begining** of
inserted text. If `ignoreKeystrokeSequence` is not nil and not empty, then if
@@ -191,49 +191,49 @@
`stringOrLines` could be either string or collection of strings (lines)
`offsetOrNil` could be either integer (cursor is then advanced by
- offsetOrNil characters after **begining** of inserted text)
- or point (x,y, cursor is then advanced by x lines after current
- line and by y characters after beggining of the inserted text
- (if x == 0) or at set at column y (if x ~~ 0)
+ offsetOrNil characters after **begining** of inserted text)
+ or point (x,y, cursor is then advanced by x lines after current
+ line and by y characters after beggining of the inserted text
+ (if x == 0) or at set at column y (if x ~~ 0)
`ignoreKeystrokeSequence` a sequenceable collection of keys (in a form
- as passed to #keyPress:x:y: method."
-
+ as passed to #keyPress:x:y: method."
+
| lineOffset colOffset newCursorCol newCursorLine advanceCursor |
advanceCursor := false.
offsetOrNil notNil ifTrue:[
- lineOffset := offsetOrNil isPoint ifTrue:[
- offsetOrNil x
- ] ifFalse:[ 0 ].
- colOffset := offsetOrNil isPoint ifTrue:[
- offsetOrNil y
- ] ifFalse:[
- offsetOrNil
- ].
- newCursorLine := textView cursorLine + lineOffset.
- newCursorCol := (lineOffset == 0
- ifTrue:[ textView cursorCol ]
- ifFalse:[ 0 ]) + colOffset.
- advanceCursor := true.
+ lineOffset := offsetOrNil isPoint ifTrue:[
+ offsetOrNil x
+ ] ifFalse:[ 0 ].
+ colOffset := offsetOrNil isPoint ifTrue:[
+ offsetOrNil y
+ ] ifFalse:[
+ offsetOrNil
+ ].
+ newCursorLine := textView cursorLine + lineOffset.
+ newCursorCol := (lineOffset == 0
+ ifTrue:[ textView cursorCol ]
+ ifFalse:[ 0 ]) + colOffset.
+ advanceCursor := true.
].
- self
- electricDo:[
- stringOrLines isString ifTrue:[
- "/ Simple strin
- textView insertStringAtCursor:stringOrLines.
- ] ifFalse:[
- "/ C
- textView insertLines:stringOrLines withCR:false.
- ].
- advanceCursor ifTrue:[
- (textView cursorLine ~~ newCursorLine
- or:[ textView cursorCol ~~ newCursorCol ])
- ifTrue:[ textView cursorLine:newCursorLine col:newCursorCol. ].
- ].
- ].
+ self
+ electricDo:[
+ stringOrLines isString ifTrue:[
+ "/ Simple strin
+ textView insertStringAtCursor:stringOrLines.
+ ] ifFalse:[
+ "/ C
+ textView insertLines:stringOrLines withCR:false.
+ ].
+ advanceCursor ifTrue:[
+ (textView cursorLine ~~ newCursorLine
+ or:[ textView cursorCol ~~ newCursorCol ])
+ ifTrue:[ textView cursorLine:newCursorLine col:newCursorCol. ].
+ ].
+ ].
ignoreKeystrokeSequence notEmptyOrNil ifTrue:[
- ignoreKeystrokes := ignoreKeystrokeSequence.
- ignoreKeystrokesPosition := 1.
+ ignoreKeystrokes := ignoreKeystrokeSequence.
+ ignoreKeystrokesPosition := 1.
].
"Created: / 19-01-2014 / 20:29:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -241,35 +241,35 @@
"Modified (format): / 22-01-2014 / 21:13:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-electricInsert:text ignoreKeystrokes:ignore
- self
- electricInsert:text
- advanceCursorBy:nil
- ignoreKeystrokes:ignore
+electricInsert:text ignoreKeystrokes:ignore
+ self
+ electricInsert:text
+ advanceCursorBy:nil
+ ignoreKeystrokes:ignore
"Created: / 21-01-2014 / 23:29:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-electricInsertBlockOpenedBy:openText closedBy:closeText
+electricInsertBlockOpenedBy:openText closedBy:closeText
| indent lines autoIndent |
textView completionSupport notNil ifTrue:[
- (textView completionSupport)
- stopCompletionProcess;
- closeCompletionView.
+ (textView completionSupport)
+ stopCompletionProcess;
+ closeCompletionView.
].
indent := self indentAtCursorLine.
autoIndent := textView autoIndent.
textView autoIndent:false.
[
- textView
- undoableDo:[
- lines := Array
- with:openText ? ''
- with:''
- with:((String new:indent withAll:Character space) , closeText).
- self electricInsert:lines advanceCursorBy:1 @ (indent + 5)
- ].
+ textView
+ undoableDo:[
+ lines := Array
+ with:openText ? ''
+ with:''
+ with:((String new:indent withAll:Character space) , closeText).
+ self electricInsert:lines advanceCursorBy:1 @ (indent + 5)
+ ].
] ensure:[ textView autoIndent:autoIndent ].
"Created: / 25-07-2013 / 10:41:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -297,11 +297,11 @@
view ~~ textView ifTrue:[ ^ false ].
(self keyPressIgnored: key) ifTrue:[
- ^ true.
+ ^ true.
].
key == Character space ifTrue:[
- ^ self electricInsertSnippet
+ ^ self electricInsertSnippet
].
^false
@@ -313,12 +313,12 @@
keyPressIgnored
"Advance position in keyPressIgnore buffer. Return true if position has been edvanced, false othwrwise"
ignoreKeystrokes notNil ifTrue:[
- ignoreKeystrokesPosition := ignoreKeystrokesPosition + 1.
- ignoreKeystrokesPosition > ignoreKeystrokes size ifTrue:[
- "/ Nil out instvars if there's no more keys to ignore.
- ignoreKeystrokes := ignoreKeystrokesPosition := nil.
- ].
- ^ true.
+ ignoreKeystrokesPosition := ignoreKeystrokesPosition + 1.
+ ignoreKeystrokesPosition > ignoreKeystrokes size ifTrue:[
+ "/ Nil out instvars if there's no more keys to ignore.
+ ignoreKeystrokes := ignoreKeystrokesPosition := nil.
+ ].
+ ^ true.
].
^ false.
@@ -327,19 +327,19 @@
keyPressIgnored: key
ignoreKeystrokes notNil ifTrue:[
- (ignoreKeystrokes at: ignoreKeystrokesPosition) == key ifTrue:[
- "/ Key stroke should be ignored...
- ignoreKeystrokesPosition := ignoreKeystrokesPosition + 1.
- ignoreKeystrokesPosition > ignoreKeystrokes size ifTrue:[
- "/ Nil out instvars if there's no more keys to ignore.
- ignoreKeystrokes := ignoreKeystrokesPosition := nil.
- ].
- ^ true.
- ] ifFalse:[
- "/ Nil out instvars, user typed something else!!
- ignoreKeystrokes := ignoreKeystrokesPosition := nil.
- ^ false.
- ].
+ (ignoreKeystrokes at: ignoreKeystrokesPosition) == key ifTrue:[
+ "/ Key stroke should be ignored...
+ ignoreKeystrokesPosition := ignoreKeystrokesPosition + 1.
+ ignoreKeystrokesPosition > ignoreKeystrokes size ifTrue:[
+ "/ Nil out instvars if there's no more keys to ignore.
+ ignoreKeystrokes := ignoreKeystrokesPosition := nil.
+ ].
+ ^ true.
+ ] ifFalse:[
+ "/ Nil out instvars, user typed something else!!
+ ignoreKeystrokes := ignoreKeystrokesPosition := nil.
+ ^ false.
+ ].
].
^ false.
@@ -358,12 +358,12 @@
initializeCompletion
| controller |
- UserPreferences current smallSenseCompletionEnabled ifTrue:[
- self completionEngineClass notNil ifTrue:[
- controller := self completionControllerClass for: service textView.
- controller support: self.
- service textView completionSupport: controller.
- ].
+ (UserPreferences current smallSenseCompletionEnabled == true) ifTrue:[
+ self completionEngineClass notNil ifTrue:[
+ controller := self completionControllerClass for: service textView.
+ controller support: self.
+ service textView completionSupport: controller.
+ ].
].
"Created: / 18-05-2014 / 12:40:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -387,9 +387,9 @@
line := service textView listAt: service textView cursorLine.
^ line isNil ifTrue:[
- (service textView cursorCol - 1) max: 0.
+ (service textView cursorCol - 1) max: 0.
] ifFalse:[
- (line indexOfNonSeparator - 1) max: 0.
+ (line indexOfNonSeparator - 1) max: 0.
]
"Created: / 25-07-2013 / 00:13:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -410,14 +410,14 @@
wordEnd := textView cursorCol - 1.
wordEnd > currentLine size ifTrue:[ ^ '' ].
wordEnd ~~ 0 ifTrue:[
- wordStart := wordEnd.
- [ wordStart > 0 and:[characterMatchBlock value:(currentLine at: wordStart) ] ] whileTrue:[
- wordStart := wordStart - 1.
- ].
- wordStart := wordStart + 1.
- wordStart <= wordEnd ifTrue:[
- ^ currentLine copyFrom: wordStart to: wordEnd.
- ].
+ wordStart := wordEnd.
+ [ wordStart > 0 and:[characterMatchBlock value:(currentLine at: wordStart) ] ] whileTrue:[
+ wordStart := wordStart - 1.
+ ].
+ wordStart := wordStart + 1.
+ wordStart <= wordEnd ifTrue:[
+ ^ currentLine copyFrom: wordStart to: wordEnd.
+ ].
].
^ ''
@@ -427,7 +427,7 @@
!EditSupport methodsFor:'private-scanning'!
-scanLineAt: lineNumber
+scanLineAt: lineNumber
"Scans line at given line number.
Returns and array of tokens, **excluding** EOF. Each token is represented
@@ -454,21 +454,21 @@
scanner := scannerClass for: line string.
tokenLastEndPosition := 0.
^ OrderedCollection streamContents:[:tokens |
- [
- [ token := scanner nextToken.token ~~ #EOF ] whileTrue:[
- tokens
- nextPut: token;
- nextPut: (scanner tokenName notNil ifTrue:[scanner tokenName] ifFalse:[ scanner tokenValue printString ]);
- nextPut: scanner tokenStartPosition;
- nextPut: (tokenLastEndPosition := scanner tokenEndPosition).
- ].
- ] on: Error do:[
- tokens
- nextPut: 'Error';
- nextPut: (line copyFrom: tokenLastEndPosition + 1 to: line size);
- nextPut: tokenLastEndPosition + 1;
- nextPut: line size.
- ].
+ [
+ [ token := scanner nextToken.token ~~ #EOF ] whileTrue:[
+ tokens
+ nextPut: token;
+ nextPut: (scanner tokenName notNil ifTrue:[scanner tokenName] ifFalse:[ scanner tokenValue printString ]);
+ nextPut: scanner tokenStartPosition;
+ nextPut: (tokenLastEndPosition := scanner tokenEndPosition).
+ ].
+ ] on: Error do:[
+ tokens
+ nextPut: 'Error';
+ nextPut: (line copyFrom: tokenLastEndPosition + 1 to: line size);
+ nextPut: tokenLastEndPosition + 1;
+ nextPut: line size.
+ ].
].
"Created: / 22-10-2013 / 00:31:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"