ContextInspectorView.st
author claus
Fri, 12 Aug 1994 01:38:38 +0200
changeset 34 d904237f7c44
child 37 50f59bad66b1
permissions -rw-r--r--
Initial revision

"{ Package: 'Programming Tools' }"

"
 COPYRIGHT (c) 1993 by Claus Gittinger
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

InspectorView subclass:#ContextInspectorView
         instanceVariableNames:'inspectedContext'
         classVariableNames:''
         poolDictionaries:''
         category:'Interface-Inspector'
!

ContextInspectorView comment:'
COPYRIGHT (c) 1993 by Claus Gittinger
              All Rights Reserved

$Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.1 1994-08-11 23:38:38 claus Exp $
'!

!ContextInspectorView class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1993 by Claus Gittinger
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

version
"
$Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.1 1994-08-11 23:38:38 claus Exp $
"
!

documentation
"
    a modified Inspector for Contexts (used in Debugger)
"
! !

!ContextInspectorView methodsFor:'accessing'!

inspect:con
    "set the context to be inspected"

    |aList homeContext method names rec sel implementorClass argNames varNames|

    realized ifFalse:[^ self].

    inspectedObject := nil.
    inspectedContext := con.
    con isNil ifTrue:[
        inspectedValues := nil.
        listView contents:nil.
        ^ self
    ].

    homeContext := con methodHome.
    rec := homeContext receiver.
    sel := homeContext selector.

    implementorClass := homeContext searchClass whichClassImplements:sel.
    implementorClass notNil ifTrue:[
        method := implementorClass compiledMethodAt:sel.
        names := method methodArgAndVarNames
    ].

    "create dummy names (if there is no source available)"
    names isNil ifTrue:[
        names := OrderedCollection new.
        1 to:homeContext nargs do:[:index |
            names add:('mArg' , index printString)
        ].
        1 to:homeContext nvars do:[:index |
            names add:('mVar' , index printString)
        ].
    ].

    aList := OrderedCollection new.

    "
     stupid: should find the block via the contexts
     method-home and put real names in here
    "
    con isBlockContext ifTrue:[
        argNames := (1 to:(con nargs)) collect:[:i | 'arg' , i printString].
        aList addAll:argNames.
        varNames := (1 to:(con nvars)) collect:[:i | 'var' , i printString].
        aList addAll:varNames.
        aList addAll:names.
        inspectedValues := (Array withAll:(con argsAndVars)) , homeContext argsAndVars
    ] ifFalse:[
        aList addAll:names.
        inspectedValues := homeContext argsAndVars
    ].
    listView contents:aList.

    workspace contents:nil.
"
    self setDoitActionIn:workspace for:con.
"
    workspace doItAction:[:theCode |
        Compiler evaluate:theCode
                       in:con
                 receiver:nil
                notifying:workspace
                   ifFail:nil
    ]
!

release
    "release inspected object"

    inspectedContext := nil.
    super release
! !

!ContextInspectorView methodsFor:'private'!

setDoitActionIn:aWorkspace for:aContext
    aWorkspace doItAction:[:theCode |
        Compiler evaluate:theCode
                       in:aContext
                 receiver:nil
                notifying:aWorkspace
                   ifFail:nil
    ]
! !

!ContextInspectorView methodsFor:'user actions'!

doAccept:theText
    |value|

    selectedLine notNil ifTrue:[
        value := Compiler evaluate:theText
                          receiver:inspectedObject 
                         notifying:workspace.

        "yes, you can do that with a context"
        inspectedContext at:selectedLine put:value.
    ].
! !