Bugfix in EditService: correctly react on classHolder/methodHolder changes.
"{ Package: 'jv:smallsense' }"
"{ NameSpace: SmallSense }"
ApplicationModel subclass:#ParseNodeInspector
instanceVariableNames:'classHolder selectorHolder methodHolder nodeHolder sourceHolder
sourceView inspectorView'
classVariableNames:''
poolDictionaries:''
category:'SmallSense-Core-Interface'
!
HierarchicalItem subclass:#ParseNodeItem
instanceVariableNames:'astNode ivarName'
classVariableNames:''
poolDictionaries:''
privateIn:ParseNodeInspector
!
!ParseNodeInspector class methodsFor:'instance creation'!
node: node source: source
^self new node: node source: source
"Created: / 14-09-2011 / 17:25:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ParseNodeInspector class methodsFor:'interface opening'!
openOnClass: class selector: selector
^self new
class: class selector: selector;
open
"
SmallSenseParseNodeInspector
openOnClass: self
selector: #openOnClass:selector:
"
"Created: / 26-11-2011 / 12:30:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
openOnNode: node source: source
^self new
node: node source: source;
open
"Created: / 25-08-2013 / 10:28:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ParseNodeInspector class methodsFor:'interface specs'!
inspectorTabSpec
"This resource specification was automatically generated
by the UIPainter of ST/X."
"Do not manually edit this!! If it is corrupted,
the UIPainter may not be able to read the specification."
"
UIPainter new openOnClass:Tools::ParseNodeInspector andSelector:#inspectorTabSpec
Tools::ParseNodeInspector new openInterface:#inspectorTabSpec
"
<resource: #canvas>
^
#(FullSpec
name: inspectorTabSpec
window:
(WindowSpec
label: 'InspectorTab'
name: 'InspectorTab'
min: (Point 10 10)
bounds: (Rectangle 0 0 300 300)
)
component:
(SpecCollection
collection: (
(NonScrollableArbitraryComponentSpec
name: 'InspectorView'
layout: (LayoutFrame 0 0 0 0 0 1 0 1)
component: parseNodeInspectorView
)
)
)
)
!
sourceTabSpec
"This resource specification was automatically generated
by the UIPainter of ST/X."
"Do not manually edit this!! If it is corrupted,
the UIPainter may not be able to read the specification."
"
UIPainter new openOnClass:Tools::ParseNodeInspector andSelector:#sourceTabSpec
Tools::ParseNodeInspector new openInterface:#sourceTabSpec
"
<resource: #canvas>
^
#(FullSpec
name: sourceTabSpec
window:
(WindowSpec
label: 'SourceTab'
name: 'SourceTab'
min: (Point 10 10)
bounds: (Rectangle 0 0 300 300)
)
component:
(SpecCollection
collection: (
(TextEditorSpec
name: 'SourceView'
layout: (LayoutFrame 0 0 0 0 0 1 0 1)
model: sourceHolder
hasHorizontalScrollBar: true
hasVerticalScrollBar: true
hasKeyboardFocusInitially: false
postBuildCallback: postBuildSourceView:
)
)
)
)
"Modified: / 14-09-2011 / 17:25:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
windowSpec
"This resource specification was automatically generated
by the UIPainter of ST/X."
"Do not manually edit this!! If it is corrupted,
the UIPainter may not be able to read the specification."
"
UIPainter new openOnClass:SmallSenseParseNodeInspector andSelector:#windowSpec
SmallSenseParseNodeInspector new openInterface:#windowSpec
SmallSenseParseNodeInspector open
"
<resource: #canvas>
^
#(FullSpec
name: windowSpec
window:
(WindowSpec
label: 'Parse Tree Inspector'
name: 'Parse Tree Inspector'
min: (Point 10 10)
bounds: (Rectangle 0 0 630 322)
)
component:
(SpecCollection
collection: (
(VariableHorizontalPanelSpec
name: 'QueryTreeAndSourcePanel'
layout: (LayoutFrame 0 0 0 0 0 1 0 1)
showHandle: true
snapMode: both
handlePosition: right
component:
(SpecCollection
collection: (
(HierarchicalListViewSpec
name: 'QueryTree'
model: selectionHolder
menu: queryTreeMenu
hasHorizontalScrollBar: true
hasVerticalScrollBar: true
listModel: parseTree
useIndex: false
highlightMode: line
useDefaultIcons: false
)
(UISubSpecification
name: 'SourceSoec'
minorKey: sourceTabSpec
)
)
)
handles: (Any 0.3 1.0)
)
)
)
)
"Modified: / 26-11-2011 / 12:22:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
windowSpecWithInspector
"This resource specification was automatically generated
by the UIPainter of ST/X."
"Do not manually edit this!! If it is corrupted,
the UIPainter may not be able to read the specification."
"
UIPainter new openOnClass:Tools::ParseNodeInspector andSelector:#windowSpec
Tools::ParseNodeInspector new openInterface:#windowSpec
Tools::ParseNodeInspector open
"
<resource: #canvas>
^
#(FullSpec
name: windowSpec
window:
(WindowSpec
label: 'Parse Tree Inspector'
name: 'Parse Tree Inspector'
min: (Point 10 10)
bounds: (Rectangle 0 0 630 322)
)
component:
(SpecCollection
collection: (
(VariableHorizontalPanelSpec
name: 'QueryTreeAndSourcePanel'
layout: (LayoutFrame 0 0 0 0 0 1 0 1)
showHandle: true
snapMode: both
handlePosition: right
component:
(SpecCollection
collection: (
(HierarchicalListViewSpec
name: 'QueryTree'
model: selectionHolder
menu: queryTreeMenu
hasHorizontalScrollBar: true
hasVerticalScrollBar: true
listModel: parseTree
useIndex: false
highlightMode: line
useDefaultIcons: false
)
(NoteBookViewSpec
name: 'NoteBook'
menu: tabList
)
)
)
handles: (Any 0.3 1.0)
)
)
)
)
"Created: / 26-11-2011 / 11:41:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ParseNodeInspector class methodsFor:'list specs'!
tabList
"This resource specification was automatically generated
by the TabListEditor of ST/X."
"Do not manually edit this!! If it is corrupted,
the TabListEditor may not be able to read the specification."
"
TabListEditor new openOnClass: self andSelector:#tabList
"
<resource: #tabList>
^ #(
(TabItem
label: 'Source'
createNewBuilder: false
minorKey: sourceTabSpec
)
(TabItem
label: 'Object'
createNewBuilder: false
minorKey: inspectorTabSpec
)
)
collect:[:aTab| TabItem new fromLiteralArrayEncoding:aTab ]
"Modified: / 31-10-2007 / 12:21:19 / janfrog"
! !
!ParseNodeInspector class methodsFor:'menu specs'!
queryTreeMenu
"This resource specification was automatically generated
by the MenuEditor of ST/X."
"Do not manually edit this!! If it is corrupted,
the MenuEditor may not be able to read the specification."
"
MenuEditor new openOnClass:XQuery::QueryInspectorUI andSelector:#queryTreeMenu
(Menu new fromLiteralArrayEncoding:(XQuery::QueryInspectorUI queryTreeMenu)) startUp
"
<resource: #menu>
^
#(Menu
(
(MenuItem
label: 'Inspect AST node'
itemValue: queryTreeMenuInspectAstNode
translateLabel: true
)
)
nil
nil
)
"Created: / 12-04-2007 / 11:46:57 / janfrog"
! !
!ParseNodeInspector class methodsFor:'plugIn spec'!
aspectSelectors
"This resource specification was automatically generated
by the UIPainter of ST/X."
"Do not manually edit this. If it is corrupted,
the UIPainter may not be able to read the specification."
"Return a description of exported aspects;
these can be connected to aspects of an embedding application
(if this app is embedded in a subCanvas)."
^ #(
#model
).
! !
!ParseNodeInspector methodsFor:'accessing'!
class: class selector: selector
| mth source node parser |
mth := class >> selector.
mth isNil ifTrue:[
self error:'No such method'.
^self.
].
source := mth source.
parser := Parser parseMethod: source.
node := parser tree.
self node: node source: source.
"
SmallSenseParseNodeInspector
openOnClass: SmallSenseParseNodeInspector
selector: #class:selector:
"
"Created: / 15-02-2012 / 12:25:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
node: node source: source
self nodeHolder value: node.
self sourceHolder value: source.
"Created: / 14-09-2011 / 17:23:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
selection
| item |
(item := self selectionHolder value) notNil ifTrue:[
^item
] ifFalse:[
^nil
]
"Created: / 12-04-2007 / 12:29:08 / janfrog"
"Created: / 26-11-2011 / 11:46:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ParseNodeInspector methodsFor:'aspects'!
nodeHolder
"return/create the 'nodeHolder' value holder (automatically generated)"
nodeHolder isNil ifTrue:[
nodeHolder := ValueHolder new.
].
^ nodeHolder
!
nodeHolder:something
"set the 'nodeHolder' value holder (automatically generated)"
nodeHolder := something.
!
nodeInspectorView
inspectorView isNil ifTrue:[
inspectorView := InspectorView new
].
^ inspectorView
"Created: / 31-10-2007 / 12:20:02 / janfrog"
"Created: / 14-09-2011 / 17:24:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
parseTree
^self
aspectAt: #parseTree
ifAbsentPut:
[PluggableAdaptor on: self nodeHolder getter:
[:m|
| rootAstNodeItem hl |
rootAstNodeItem := ParseNodeItem new
ivarName: 'AST';
astNode: self nodeHolder value.
hl := HierarchicalList new
root: rootAstNodeItem;
showRoot: true.
rootAstNodeItem expand.
hl]]
"Created: / 28-03-2007 / 15:58:31 / janfrog"
"Modified: / 31-10-2007 / 12:11:46 / janfrog"
"Created: / 14-09-2011 / 17:24:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
selectionHolder
^self
aspectAt: #selectionHolder
ifAbsentPut:
[nil asValue
onChangeSend:#updateSourceViewSelection to:self;
onChangeSend:#updateInspectorView to:self;
yourself]
"Created: / 28-03-2007 / 16:46:30 / janfrog"
"Modified: / 31-10-2007 / 12:25:54 / janfrog"
"Created: / 14-09-2011 / 17:24:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
sourceHolder
"return/create the 'sourceHolder' value holder (automatically generated)"
sourceHolder isNil ifTrue:[
sourceHolder := ValueHolder new.
].
^ sourceHolder
!
sourceHolder:something
"set the 'sourceHolder' value holder (automatically generated)"
sourceHolder := something.
!
tabList
"Generated by the TabListEditor"
|list|
(list := builder bindingAt:#tabList) isNil ifTrue:[
builder aspectAt:#tabList put:(list := self class tabList).
].
^ list
"Created: / 31-10-2007 / 12:21:18 / janfrog"
! !
!ParseNodeInspector methodsFor:'callbacks - post build'!
postBuildSourceView: aView
sourceView := aView scrolledView
"Created: / 12-04-2007 / 12:28:14 / janfrog"
! !
!ParseNodeInspector methodsFor:'change & update'!
updateInspectorView
inspectorView notNil ifTrue:[
inspectorView inspect: self selection node
]
"Created: / 31-10-2007 / 12:25:25 / janfrog"
"Modified: / 26-11-2011 / 11:48:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
updateSourceViewSelection
| astNode startPosition stopPosition |
sourceView ifNil:[^self].
(astNode := self selection) ifNil:[^self].
(startPosition := astNode node startPosition)
ifNil:[^sourceView unselect].
(stopPosition := astNode node endPosition)
ifNil:[^sourceView unselect].
sourceView
selectFromCharacterPosition: startPosition
to: stopPosition.
sourceView makeCursorVisible
"Created: / 12-04-2007 / 12:29:42 / janfrog"
"Modified: / 30-08-2013 / 02:06:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ParseNodeInspector methodsFor:'menu actions'!
queryTreeMenuInspectAstNode
^self selection node inspect
"Created: / 12-04-2007 / 11:47:48 / janfrog"
"Modified: / 26-11-2011 / 12:12:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ParseNodeInspector::ParseNodeItem class methodsFor:'documentation'!
version
^'$Id: SmallSenseParseNodeInspector.st 7911 2012-02-22 09:55:48Z vranyj1 $'
! !
!ParseNodeInspector::ParseNodeItem methodsFor:'accessing'!
astNode
^ astNode
"Created: / 28-03-2007 / 15:51:49 / janfrog"
!
astNode:anAstNode
astNode := anAstNode.
"Created: / 28-03-2007 / 15:51:49 / janfrog"
!
astNodeName
^astNode class name
"Created: / 12-04-2007 / 11:29:57 / janfrog"
"Modified: / 31-10-2007 / 12:13:34 / janfrog"
"Modified: / 26-11-2011 / 10:47:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
children
children isNil ifTrue:[
children := OrderedCollection new.
astNode childNamesAndValuesDo:[:ivarName :astNode|
astNode notNil ifTrue:[
children add: (self class new
ivarName: ivarName;
astNode: astNode;
parent: self)
]
].
].
^children
"Created: / 28-03-2007 / 15:55:24 / janfrog"
"Modified: / 12-04-2007 / 11:35:24 / janfrog"
"Modified: / 26-11-2011 / 10:46:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
icon
^nil
"Created: / 31-10-2007 / 12:14:52 / janfrog"
"Modified: / 26-11-2011 / 10:47:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
ivarName
^ ivarName ? '?'
"Created: / 12-04-2007 / 11:29:28 / janfrog"
!
ivarName:something
ivarName := something.
"Created: / 12-04-2007 / 11:29:28 / janfrog"
!
label
^self ivarName ,' <', self astNodeName, '>'
"Created: / 28-03-2007 / 15:53:18 / janfrog"
"Modified: / 12-04-2007 / 11:30:23 / janfrog"
!
node
^ astNode
"Created: / 28-03-2007 / 15:51:49 / janfrog"
"Created: / 26-11-2011 / 11:48:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ParseNodeInspector class methodsFor:'documentation'!
version_HG
^ '$Changeset: <not expanded> $'
!
version_SVN
^ '$Id: SmallSenseParseNodeInspector.st 7911 2012-02-22 09:55:48Z vranyj1 $'
! !