Fix in SmallSense::Recognizer: use customized SmalltalkParser to parse smalltalk code.
SmalltalkParser can do some basic error-recovery and thus provides better
tree for completion.
"{ Package: 'jv:smallsense' }"!
!AssignmentNode methodsFor:'enumeration'!
childNamesAndValuesDo:aBlock
aBlock value: #variable value: variable.
aBlock value: #expression value: expression.
"Modified: / 26-11-2011 / 10:39:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!AssignmentNode methodsFor:'accessing-SmallSense'!
inferedType
^ expression inferedType
"Created: / 26-11-2011 / 12:38:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!AssignmentNode methodsFor:'accessing-SmallSense'!
inferedType: aSmallSenseType
^ self shouldNotImplement
"Created: / 26-11-2011 / 12:37:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ConfigurableFeatures class methodsFor:'queries-features'!
hasSmallSenseEnabled
^UserPreferences current smallSenseEnabled
"
ConfigurableFeatures hasSmallSenseEnabled
ConfigurableFeatures includesFeature:'SmallSenseEnabled'
"
"Created: / 27-11-2011 / 17:22:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!DoWhatIMeanSupport methodsFor:'code completion - smallsense'!
smallSenseCodeCompletionForClass:classOrNilArg context:contextOrNil codeView:codeViewArg
"SmallSense version of #codeCompletionForClass:context:codeView:.
When SmallSense is loaded, this method is swizzled as #codeCompletionForClass:context:codeView:.
into DoWhatIMeanSupport.
"
<swizzle: #codeCompletionForClass:context:codeView:>
| p node text items mode |
codeView := codeViewArg.
"/ The respondsTo: hack is because CVS CodeView2 has no #mode method.
mode := (codeView respondsTo:#mode) ifTrue:[codeView mode] ifFalse:[#method].
contextOrNil notNil ifTrue:[
mode := #method.
].
items := SmallSense::Recognizer
resultSetFor: mode
source: codeView contents
class: classOrNilArg
line: codeView cursorLine
column: codeView cursorCol.
items notEmptyOrNil ifTrue:[
(p := items position) notNil ifTrue:[
node := p node.
node notNil ifTrue:[
(node isVariable and:[p isInNode]) ifTrue:[
text := node name
] ifFalse:[node isMessage ifTrue:[
text := node selector
]].
].
].
].
SmallSense::CompletionWindow openForView: codeView text: text items: items.
"Created: / 19-08-2013 / 15:01:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 02-09-2013 / 12:52:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HTMLDocumentView methodsFor:'actions'!
doQuickFix: quickFixNo
| app |
app := self application.
app notNil ifTrue:[
app doQuickFix: quickFixNo
].
"Created: / 16-02-2012 / 14:18:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!MessageNode methodsFor:'enumeration'!
childNamesAndValuesDo:aBlock
aBlock value: #receiver value: receiver.
argArray notNil ifTrue:[
argArray withIndexDo:[:node :idx|
aBlock value: 'arg[' , idx printString , ']' value: node
]
]
"Modified: / 26-11-2011 / 12:10:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ParseErrorNode methodsFor:'enumeration'!
childNamesAndValuesDo:aBlock
"superclass ParseNode says that I am responsible to implement this method"
^ children do: aBlock
"Modified: / 15-08-2013 / 11:42:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ParseNode methodsFor:'enumeration'!
childNamesAndValuesDo: aBlock
"Enumerates all direct children and evaluates a block
with its name (usually instVar name) and the node itself"
^self subclassResponsibility
"Created: / 26-11-2011 / 10:38:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified (format): / 25-08-2013 / 10:32:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ParseNode methodsFor:'accessing-SmallSense'!
inferedType
| t |
t := self objectAttributeAt:#inferedType.
t isNil ifTrue:[t := SmallSense::Type unknown].
^t
"Created: / 26-11-2011 / 12:38:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 24-08-2013 / 20:46:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ParseNode methodsFor:'accessing-SmallSense'!
inferedType: aSmallSenseType
^ self objectAttributeAt:#inferedType put: aSmallSenseType
"Created: / 26-11-2011 / 12:37:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ParseNode methodsFor:'testing'!
isSelector
"return true, if this is a node for an selctors"
^ false
"Created: / 22-02-2011 / 21:44:45 / Jakub <zelenja7@fel.cvut.cz>"
! !
!PrimaryNode methodsFor:'enumeration'!
childNamesAndValuesDo:aBlock
"Initionally left blank, primary nodes have no children"
"Modified: / 26-11-2011 / 11:49:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!RBLintRule methodsFor:'accessing'!
fixes: aSmallSenseQuickFixer
"Adds all possible code fixes to given quick fixer.
Default is to do nothing, meaning that there are
no quickfixes available"
"Created: / 01-02-2012 / 12:09:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!RBTransformationRule methodsFor:'accessing'!
fixes: fixer
| changes |
changes := self changes.
changes notEmptyOrNil ifTrue:[
fixer fix
label:'Rewrite the code';
action: [ fixer apply:
((ChangeSet withAll:self changes) name: self name)
].
]
"Created: / 01-02-2012 / 12:11:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!StatementNode methodsFor:'enumeration'!
childNamesAndValuesDo:aBlock
| stmt index |
stmt := self.
index := 1.
[ stmt notNil ] whileTrue:[
aBlock value: ('statement[%1]' bindWith: index) value: stmt expression.
stmt := stmt nextStatement.
index := index + 1.
]
"Modified: / 15-02-2012 / 12:50:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!StatementNode methodsFor:'accessing-SmallSense'!
inferedType
^ expression inferedType
"Created: / 26-11-2011 / 12:38:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!StatementNode methodsFor:'accessing-SmallSense'!
inferedType: aSmallSenseType
^ self shouldNotImplement
"Created: / 26-11-2011 / 12:37:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!Tools::CodeCompletionService class methodsFor:'testing'!
smallSenseIsUsefulFor:aCodeView
"No old completion once there's SmallSense :-)"
<swizzle: #isUsefulFor:>
^ false.
"Created: / 02-09-2013 / 12:58:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!Tools::CodeHighlightingService class methodsFor:'instance creation'!
new
"return an initialized instance"
^ (SmallSenseSyntaxHighlightingService ? self) basicNew initialize.
"Created: / 27-07-2013 / 22:47:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!Tools::NavigationState methodsFor:'aspects - SmallSense'!
smallSenseSelectedClasses
<swizzle: #selectedClasses>
selectedClasses isNil ifTrue:[
selectedClasses := "SpecialValueHolder with:nil." nil asValue.
(ConfigurableFeatures includesFeature:'SmallSenseEnabled') ifTrue:[
selectedClasses onChangeEvaluate:[
selectedClasses value ? #() do:[:cls|
(Smalltalk at:#SmallSense::Manager) instance updateInfoForClass: cls.
].
]
]
].
^ selectedClasses
"Created: / 24-08-2013 / 21:53:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!UserPreferences methodsFor:'accessing-SmallSense'!
smallSenseBackgroundLintEnabled
"Return true if SmallSense background source checking is enabled"
^self at:#smallSenseBackgroundLintEnabled ifAbsent:[false]
"Created: / 30-01-2012 / 19:59:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!UserPreferences methodsFor:'accessing-SmallSense'!
smallSenseBackgroundLintEnabled: aBoolean
"Return true if SmallSense background source checking is enabled"
^self at:#smallSenseBackgroundLintEnabled put: aBoolean
"
UserPreferences current smallSenseBackgroundLintEnabled
UserPreferences current smallSenseBackgroundLintEnabled: true
UserPreferences current smallSenseBackgroundLintEnabled: false
"
"Created: / 30-01-2012 / 20:00:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!UserPreferences methodsFor:'accessing-SmallSense'!
smallSenseBackgroundTypingEnabled
"Return true if SmallSense background source checking is enabled"
^self at:#smallSenseBackgroundTypingEnabled ifAbsent:[false]
"Created: / 04-02-2012 / 21:41:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!UserPreferences methodsFor:'accessing-SmallSense'!
smallSenseBackgroundTypingEnabled: aBoolean
"Return true if SmallSense background source checking is enabled"
^self at:#smallSenseBackgroundTypingEnabled put: aBoolean
"
UserPreferences current smallSenseBackgroundTypingEnabled
UserPreferences current smallSenseBackgroundTypingEnabled: true
UserPreferences current smallSenseBackgroundTypingEnabled: false
"
"Created: / 04-02-2012 / 21:41:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!UserPreferences methodsFor:'accessing-SmallSense'!
smallSenseEnabled
"Return true if SmallSense is enabled"
^self at:#smallSenseEnabled ifAbsent:[false]
"Created: / 27-11-2011 / 17:20:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!UserPreferences methodsFor:'accessing-SmallSense'!
smallSenseEnabled: aBoolean
"enable/disable SmallSense"
^self at:#smallSenseEnabled put: aBoolean.
"
UserPreferences current smallSenseEnabled.
UserPreferences current smallSenseEnabled: true.
UserPreferences current smallSenseEnabled: false.
"
"Created: / 02-04-2012 / 11:37:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!VariableNode methodsFor:'queries'!
isGlobalOrPrivateClass
^ type == #GlobalVariable or:[type == #PrivateClass]
"Created: / 27-11-2011 / 16:31:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!jv_smallsense class methodsFor:'documentation'!
extensionsVersion_HG
^ '$Changeset: <not expanded> $'
! !