Workspace.st
changeset 4675 bd3425b7222f
parent 4669 e67632377ee5
child 4677 67285ce170f9
--- a/Workspace.st	Sun Aug 25 12:58:10 2013 +0200
+++ b/Workspace.st	Sun Aug 25 18:51:13 2013 +0200
@@ -540,6 +540,20 @@
     "Modified: 27.2.1996 / 15:31:37 / cg"
 !
 
+editedClass
+    "for the code completion"
+
+    editedMethodOrClass isNil ifTrue:[^ nil].
+    ^ editedMethodOrClass isBehavior ifTrue:[editedMethodOrClass] ifFalse:[editedMethodOrClass mclass]
+!
+
+editedMethod
+    "for the code completion"
+
+    editedMethodOrClass isNil ifTrue:[^ nil].
+    ^ editedMethodOrClass isBehavior ifTrue:[nil] ifFalse:[editedMethodOrClass]
+!
+
 editedMethodOrClass
     "for the code completion"
 
@@ -647,17 +661,41 @@
      this method should return true to the compiler if user wants the error
      to be corrected; false otherwise"
 
-    |action sameForAllHolder|
+    |action sameForAllHolder possibleFixes doNotShowAgainHolder doNotShowAgainForThisMethodHolder|
+
+    "/ the declare/correct fixes are here for backward compatibility
+    "/ (in previous versions, these two were always offered as fix,
+    "/ and compilers which honor the old interface will not anwer the PossibleCorrectionsQuery)
+    possibleFixes := Parser possibleCorrectionsQuery query.
 
     sameForAllHolder := false asValue.
 
     self highlightingErrorPosition:relPos to:relEndPos do:[
+        doNotShowAgainHolder := false asValue.
+        doNotShowAgainForThisMethodHolder := false asValue.
+
         Dialog aboutToOpenBoxNotificationSignal handle:[:ex |
-            |box declareButton|
+            |box declareButton makeSpaceOnlyOnce|
 
             box := ex box.
+            makeSpaceOnlyOnce := [ box addVerticalSpace:10. makeSpaceOnlyOnce := nil ].
 
+            DoNotShowCompilerWarningAgainActionQuery isHandled ifTrue:[
+                makeSpaceOnlyOnce value.
+                box verticalPanel 
+                    add:(CheckBox 
+                            label: "addCheckBoxAtBottom:" 'Do not show this dialog again (reenable via Launcher''s settings dialog)' 
+                            model:doNotShowAgainHolder).
+            ].
+            DoNotShowCompilerWarningAgainForThisMethodActionQuery isHandled ifTrue:[
+                makeSpaceOnlyOnce value.
+                box verticalPanel
+                    add:(CheckBox
+                            label:(resources string:'Do not warn in this method (for %1 - reenable earlier via Launcher''s settings dialog)' with:ParserFlags perMethodDisableWarningTimeDuration)  
+                            model:doNotShowAgainForThisMethodHolder).
+            ].
             SameForAllNotification isHandled ifTrue:[
+                box addVerticalSpace:10.
                 box addCheckBoxAtBottom:'Same action for all' on:sameForAllHolder
             ].
 
@@ -665,12 +703,22 @@
             declareButton pressAction:declareButton controller releaseAction.
             declareButton controller beTriggerOnDown.
         ] do:[
+            |buttonLabels actions|
+
+            buttonLabels := OrderedCollection new.
+            actions := OrderedCollection new.
+            buttonLabels add:'Cancel'. actions add:#abort.
+            possibleFixes do:[:each |
+                buttonLabels add:(each buttonLabel). actions add:each.
+            ].
+            buttonLabels add:'Continue'. actions add:#continue.
+
             action := OptionBox 
                           request:aString
                           label:(resources string:'Correctable Error')
                           image:(WarningBox iconBitmap)
-                          buttonLabels:(resources array:#('Cancel' 'Declare as...' 'Correct...' 'Continue'))
-                          values:#(#abort #declare #correct #continue)
+                          buttonLabels:(resources array:buttonLabels)
+                          values:actions
                           default:#continue
                           onCancel:#abort.
         ].
@@ -679,15 +727,15 @@
     sameForAllHolder value ifTrue:[
         SameForAllNotification notify
     ].
+    action == #cancel ifTrue:[
+        ^ false
+    ].
 
-    action == #declare ifTrue:[
-        ^ action
-    ].
     action == #abort ifTrue:[
         AbortOperationRequest raise.
         ^ false
     ].
-    ^ action == #correct
+    ^ action
 
     "Modified: / 28-02-2012 / 10:42:27 / cg"
 !
@@ -1622,16 +1670,29 @@
 browseReferencesToIt
     "open a browser on all references to the selected global"
 
-    |sel|
+    |nameOfGlobal|
 
-    sel := self selectedTextOrSyntaxElement.
-    sel notEmptyOrNil ifTrue:[
+    nameOfGlobal := self selectedTextOrSyntaxElement.
+    nameOfGlobal notEmptyOrNil ifTrue:[
         self windowGroup withWaitCursorDo:[
-            (Smalltalk includesKey:sel asSymbol) ifFalse:[
-                sel := ((NameSpace allNameSpaces detect:[:ns | ns includesKey:sel asSymbol]) at:sel asSymbol) name.
-             ].
-            (UserPreferences systemBrowserClass)
-                browseReferendsOf:sel
+            |cls privateClass|
+
+            ((cls := self editedClass) notNil
+            and:[ (cls theNonMetaclass allClassVarNames includes:nameOfGlobal) ]) ifTrue:[
+                (UserPreferences systemBrowserClass)
+                    browseRefsTo:nameOfGlobal 
+                    classVars:true 
+                    in:(cls whichClassDefinesClassVar:nameOfGlobal) withAllSubclasses 
+                    modificationsOnly:false.
+            ] ifFalse:[
+                (cls notNil
+                and:[ (privateClass := cls theNonMetaclass privateClassNamed:nameOfGlobal) notNil ]) ifTrue:[
+                    (UserPreferences systemBrowserClass)
+                        browseReferendsOf:(privateClass name)
+                ] ifFalse:[
+                    (UserPreferences systemBrowserClass) browseReferendsOf:nameOfGlobal
+                ]
+            ]
         ].
     ].
 
@@ -1785,8 +1846,16 @@
                 ) ifTrue:[
                     "/ a global or namespace var selected
                 ] ifFalse:[
-                    "/ todo: an instvar selected?
-                    sub disable:#browseReferencesToIt.
+                    |cls|
+
+                    ((cls := self editedClass) notNil
+                    and:[ (cls theNonMetaclass allClassVarNames includes:s)
+                          or:[ (cls theNonMetaclass privateClassNamed:s) notNil ]]) ifTrue:[
+                        "/ a classvar or private class
+                    ] ifFalse:[
+                        "/ todo: an instvar selected?
+                        sub disable:#browseReferencesToIt.
+                    ].
                 ].
             ].
             (s notNil 
@@ -2065,10 +2134,10 @@
 !Workspace class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.270 2013-08-22 13:55:26 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.271 2013-08-25 16:51:13 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.270 2013-08-22 13:55:26 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.271 2013-08-25 16:51:13 cg Exp $'
 ! !