class: Workspace
authorStefan Vogel <sv@exept.de>
Fri, 18 Apr 2014 01:22:05 +0200
changeset 4998 000a0752dd25
parent 4997 d7d79a938088
child 5001 3bccbd160c18
class: Workspace added: #syntaxElementForSelectorUnderCursor changed: #editMenu fix DNU when selecting stuff in Workspace
Workspace.st
--- a/Workspace.st	Wed Apr 16 14:29:54 2014 +0200
+++ b/Workspace.st	Fri Apr 18 01:22:05 2014 +0200
@@ -12,17 +12,17 @@
 "{ Package: 'stx:libwidg' }"
 
 TextCollector subclass:#Workspace
-	instanceVariableNames:'doItAction codeStartPosition errorFgColor errorBgColor
-		commentStrings autoDefineWorkspaceVariables simulatedSelf
-		autoDefineVariables compilerClass allowValueDrop
-		poolsConsideredInDoIts namespaceForDoits editedMethodOrClass
-		editedClass editedMethod editedLanguage'
-	classVariableNames:'DefaultViewBackground DefaultErrorForegroundColor
-		DefaultErrorBackgroundColor DefaultWarningBackgroundColor
-		DefaultWarningForegroundColor WorkspaceVariables DoItHistory
-		Sniplets'
-	poolDictionaries:''
-	category:'Interface-Smalltalk'
+        instanceVariableNames:'doItAction codeStartPosition errorFgColor errorBgColor
+                commentStrings autoDefineWorkspaceVariables simulatedSelf
+                autoDefineVariables compilerClass allowValueDrop
+                poolsConsideredInDoIts namespaceForDoits editedMethodOrClass
+                editedClass editedMethod editedLanguage'
+        classVariableNames:'DefaultViewBackground DefaultErrorForegroundColor
+                DefaultErrorBackgroundColor DefaultWarningBackgroundColor
+                DefaultWarningForegroundColor WorkspaceVariables DoItHistory
+                Sniplets'
+        poolDictionaries:''
+        category:'Interface-Smalltalk'
 !
 
 Workspace comment:''
@@ -1865,7 +1865,7 @@
                          )>
     <resource: #programMenu>
 
-    |m sub subsub idx sensor s s2|
+    |m sub subsub idx sensor sel2 sel selectedSymbol|
 
     m := super editMenu.
     ((sensor := self sensor) notNil and:[sensor ctrlDown and:[sensor shiftDown not]]) ifTrue:[
@@ -1876,7 +1876,6 @@
     ].
 
     sub notNil ifTrue:[
-
         "
          workspaces support #browse, implementors etc. add them after paste.
         "
@@ -1929,51 +1928,55 @@
                 ]
             ].
         ] ifTrue:[
-            s := self selectionAsString.
-            s notNil ifTrue:[
-                s asSymbolIfInterned isNil ifTrue:[
-                    s2 := SystemBrowser extractSelectorFrom:s.
-                    s2 notNil ifTrue:[
-                        s2 := s2 asSymbolIfInterned.
+            sel := self selectionAsString.
+            sel notNil ifTrue:[
+                sel asSymbolIfInterned isNil ifTrue:[
+                    sel2 := SystemBrowser extractSelectorFrom:sel.
+                    sel2 notNil ifTrue:[
+                        sel2 := sel2 asSymbolIfInterned.
                     ].
                 ].
             ].
-            (s2 isNil and:[s isNil]) ifTrue:[
+            (sel2 isNil and:[sel isNil]) ifTrue:[
                 sub disableAll:#(browseImplementorsOfIt browseSendersOfIt).
             ].
             "/ a global or namespace-var selected ?
-            s isNil ifTrue:[
+            sel isNil ifTrue:[
                 sub disable:#browseReferencesToIt.
             ] ifFalse:[
-                (s asSymbolIfInterned notNil
-                and:[ (Smalltalk includesKey:s asSymbol)
-                      or:[ (NameSpace allNameSpaces contains:[:ns | ns includesKey:s asSymbol]) ]]
+                selectedSymbol := sel asSymbolIfInterned.
+                (selectedSymbol notNil
+                 and:[(Smalltalk includesKey:selectedSymbol)
+                      or:[(NameSpace allNameSpaces contains:[:ns | ns includesKey:selectedSymbol]) ]]
                 ) ifTrue:[
                     "/ a global or namespace var selected
                 ] ifFalse:[
                     |cls|
 
-                    (cls := self editedClass) notNil ifTrue:[
-                        ((cls theNonMetaclass allClassVarNames includes:s)
-                           or:[ (cls theNonMetaclass privateClassNamed:s) notNil ]) ifTrue:[
+                    cls := self editedClass.
+                    cls notNil ifTrue:[
+                        cls := cls theNonMetaclass.
+                        ((cls allClassVarNames includes:sel)
+                          or:[ (cls theNonMetaclass privateClassNamed:sel) notNil]) ifTrue:[
                             "/ a classvar or private class
                         ] ifFalse:[
                             |pool|
                             "/ is it a pool variable?
-                            pool := cls theNonMetaclass sharedPools 
-                                    detect:[:pool | pool classVarNames includes:s]
+                            pool := cls sharedPools 
+                                    detect:[:pool | pool classVarNames includes:sel]
                                     ifNone:nil.
                             pool isNil ifTrue:[
                                 "/ todo: an instvar selected?
                                 sub disable:#browseReferencesToIt.
                             ].
                         ].
+                    ] ifFalse:[
+                        sub disable:#browseReferencesToIt.
                     ].
                 ].
             ].
-            (s notNil 
-            and:[ s asSymbolIfInterned notNil
-            and:[ (SharedPool allSubclasses contains:[:pool | pool includesKey:s asSymbol]) ]]) ifFalse:[
+            (selectedSymbol notNil 
+             and:[SharedPool allSubclasses contains:[:pool | pool includesKey:selectedSymbol]]) ifFalse:[
                 sub disable:#browseSharedPoolOfIt.
             ].
         ].
@@ -1998,7 +2001,7 @@
                 ('InspectIt'    inspectIt   InspectIt))
               resources:resources  
               after:idx.
-            
+
         ].
 
         (self hasSelectionOrTextInCursorLine) ifFalse:[
@@ -2255,6 +2258,12 @@
         ]
     ].
     ^ selectedText 
+!
+
+syntaxElementForSelectorUnderCursor
+    "we do not support syntax elements, but subclasses do"
+
+    ^ nil
 ! !
 
 !Workspace methodsFor:'queries'!
@@ -2271,10 +2280,10 @@
 !Workspace class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.324 2014-04-16 12:29:54 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.325 2014-04-17 23:22:05 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.324 2014-04-16 12:29:54 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.325 2014-04-17 23:22:05 stefan Exp $'
 ! !