initial checkin
class: SmallSense::ParseTreeInspector
changed:
#update:with:from:
#updateSourceViewSelection
fixed cyclic reselect due to cursor change;
Also show selector in tree.
(try inspecting the tree of:
initScope
scope _ OrderedCollection new.
currentBindings := Dictionary new.
with oldStyleAssignments disabled, to see why)
--- a/SmallSense__ParseTreeInspector.st Tue Feb 03 23:23:33 2015 +0100
+++ b/SmallSense__ParseTreeInspector.st Wed Feb 04 10:46:31 2015 +0100
@@ -558,14 +558,10 @@
update:something with:aParameter from:changedObject
"Invoked when an object that I depend upon sends a change notification."
- "stub code automatically generated - please change as required"
-
sourceView notNil ifTrue:[
- changedObject == sourceView cursorLineHolder ifTrue:[
- self updateSelectionFromCursor.
- ^ self.
- ].
- changedObject == sourceView cursorColHolder ifTrue:[
+ "/ cursor moved by user...
+ ((changedObject == sourceView cursorLineHolder)
+ or:[ changedObject == sourceView cursorColHolder ]) ifTrue:[
self updateSelectionFromCursor.
^ self.
].
@@ -612,20 +608,25 @@
updateSourceViewSelection
- | astNode startPosition stopPosition |
+ | astNode parseNode startPosition stopPosition |
+
sourceView ifNil:[^self].
(astNode := self selection) ifNil:[^self].
- astNode node isNil ifTrue:[ ^ self ].
- (startPosition := astNode node startPosition)
+ (parseNode := astNode node) isNil ifTrue:[ ^ self ].
+
+ (startPosition := parseNode startPosition)
ifNil:[^sourceView unselect].
- (stopPosition := astNode node endPosition)
+ (stopPosition := parseNode endPosition)
ifNil:[^sourceView unselect].
- sourceView
- selectFromCharacterPosition: startPosition
- to: stopPosition.
- sourceView makeCursorVisible
-
+ "/ avoid cyclic update (from changed cursor)
+ "/ (which would deselect again)
+ sourceView cursorLineHolder withoutUpdating:self do:[
+ sourceView cursorColHolder withoutUpdating:self do:[
+ sourceView selectFromCharacterPosition: startPosition to: stopPosition.
+ sourceView makeCursorVisible
+ ]
+ ]
"Created: / 12-04-2007 / 12:29:42 / janfrog"
"Modified: / 07-08-2014 / 10:21:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
@@ -643,7 +644,7 @@
!ParseTreeInspector::ParseTreeItem class methodsFor:'documentation'!
version
- ^'$Id$'
+ ^'$Header: /cvs/stx/stx/goodies/smallsense/SmallSense__ParseTreeInspector.st,v 1.2 2015-02-04 09:46:31 cg Exp $'
! !
!ParseTreeInspector::ParseTreeItem methodsFor:'accessing'!
@@ -712,18 +713,25 @@
!
label
- | label start stop |
+ | label start stop optionalSelector |
astNode isNil ifTrue:[ ^ 'No AST' ].
start := astNode startPosition.
stop := astNode endPosition.
- label := '%1 {%2} [%3..%4]'
+ astNode isMessage ifTrue:[
+ optionalSelector := ' #',astNode selector allBold.
+ ] ifFalse:[
+ optionalSelector := ''
+ ].
+ label := '%1 {%2%5} [%3..%4]'
bindWith: self ivarName
with: self astNodeName
with: start ? '?'
- with: stop ? '?'.
+ with: stop ? '?'
+ with: optionalSelector.
+
(start isNil or:[ stop isNil ]) ifTrue:[
label := label asText colorizeAllWith: Color red.
].
@@ -761,12 +769,20 @@
!ParseTreeInspector class methodsFor:'documentation'!
+version
+ ^ '$Header: /cvs/stx/stx/goodies/smallsense/SmallSense__ParseTreeInspector.st,v 1.2 2015-02-04 09:46:31 cg Exp $'
+!
+
+version_CVS
+ ^ '$Path: stx/goodies/smallsense/SmallSense__ParseTreeInspector.st, Version: 1.0, User: cg, Time: 2015-02-04T10:46:56.332+01$'
+!
+
version_HG
^ '$Changeset: <not expanded> $'
!
version_SVN
- ^ '$Id$'
+ ^ '$Id: SmallSense__ParseTreeInspector.st,v 1.2 2015-02-04 09:46:31 cg Exp $'
! !