#REFACTORING by exept
authorClaus Gittinger <cg@exept.de>
Fri, 31 Jul 2020 10:25:57 +0200
changeset 4692 d6ddd748f7e3
parent 4691 792a4618488c
child 4693 97bb669f500b
#REFACTORING by exept class: Scanner added: #actionToDisableWarning: changed: #skipComment #warnDollarAt: #warnOldStyleAssignmentAt: #warnParagraphAt: #warnPeriodAt: #warnPossibleIncompatibility:position:to: #warnSTXSpecialCommentAt:to: #warnUnderscoreAt:
Scanner.st
--- a/Scanner.st	Fri Jul 31 09:48:25 2020 +0200
+++ b/Scanner.st	Fri Jul 31 10:25:57 2020 +0200
@@ -1379,6 +1379,22 @@
 
 !Scanner methodsFor:'error handling'!
 
+actionToDisableWarning:warningSelector
+    "return an action for the do-not-show-again dialogs"
+
+    ^ [ 
+        |sel|
+
+        sel := warningSelector asMutator.
+        ParserFlags perform:sel with:false. 
+        parserFlags perform:sel with:false ifNotUnderstood:[]. 
+    ]
+
+    "
+     self basicNew actionToDisableWarning:#warnAboutDeadCodeAndFixMe
+    "
+!
+
 clearErrorFlag
     errorFlag := false.
 !
@@ -1841,18 +1857,18 @@
     "warn about $-character in an identifier"
 
     ignoreWarnings ifFalse:[
-	didWarnAboutDollarInIdentifier ifFalse:[
-	    parserFlags warnDollarInIdentifier ifTrue:[
-		self
-		    warning:'$-characters in identifiers/symbols are nonportable'
-		    doNotShowAgainAction:[ ParserFlags warnDollarInIdentifier:false ]
-		    position:position to:position.
-		"
-		 only warn once (per method)
-		"
-		didWarnAboutDollarInIdentifier := true
-	    ]
-	]
+        didWarnAboutDollarInIdentifier ifFalse:[
+            parserFlags warnDollarInIdentifier ifTrue:[
+                self
+                    warning:'$-characters in identifiers/symbols are nonportable'
+                    doNotShowAgainAction:(self actionToDisableWarning:#warnDollarInIdentifier)
+                    position:position to:position.
+                "
+                 only warn once (per method)
+                "
+                didWarnAboutDollarInIdentifier := true
+            ]
+        ]
     ]
 
     "Created: 7.9.1997 / 01:50:24 / cg"
@@ -1863,18 +1879,18 @@
     "warn about an oldStyle assignment"
 
     ignoreWarnings ifFalse:[
-	didWarnAboutOldStyleAssignment ifFalse:[
-	    parserFlags warnOldStyleAssignment ifTrue:[
-		self
-		    warning:'Old style assignment - please change to use '':='''
-		    doNotShowAgainAction:[ ParserFlags warnOldStyleAssignment:false ]
-		    position:position to:position.
-	    ].
-	    "
-	     only warn once (per method)
-	    "
-	    didWarnAboutOldStyleAssignment := true
-	]
+        didWarnAboutOldStyleAssignment ifFalse:[
+            parserFlags warnOldStyleAssignment ifTrue:[
+                self
+                    warning:'Old style assignment - please change to use '':='''
+                    doNotShowAgainAction:(self actionToDisableWarning:#warnOldStyleAssignment)
+                    position:position to:position.
+            ].
+            "
+             only warn once (per method)
+            "
+            didWarnAboutOldStyleAssignment := true
+        ]
     ]
 
     "Modified: 23.5.1997 / 12:16:48 / cg"
@@ -1884,20 +1900,20 @@
     "warn about §-character in an identifier"
 
     ignoreWarnings ifFalse:[
-	"/ didWarnAboutParagraphInIdentifier ifFalse:[
-	    parserFlags warnParagraphInIdentifier ifTrue:[
-		self
-		    warning:'§-characters in identifiers/symbols are nonportable'
-		    doNotShowAgainAction:[ ParserFlags warnParagraphInIdentifier:false ]
-		    position:position to:position.
-		"
-		 only warn once (per method)
-		"
-		parserFlags := parserFlags copy.
-		parserFlags warnParagraphInIdentifier:false.
-		"/ didWarnAboutParagraphInIdentifier := true
-	    ]
-	"/ ]
+        "/ didWarnAboutParagraphInIdentifier ifFalse:[
+            parserFlags warnParagraphInIdentifier ifTrue:[
+                self
+                    warning:'§-characters in identifiers/symbols are nonportable'
+                    doNotShowAgainAction:(self actionToDisableWarning:#warnParagraphInIdentifier)
+                    position:position to:position.
+                "
+                 only warn once (per method)
+                "
+                parserFlags := parserFlags copy.
+                parserFlags warnParagraphInIdentifier:false.
+                "/ didWarnAboutParagraphInIdentifier := true
+            ]
+        "/ ]
     ]
 
     "Created: / 17-11-2016 / 09:16:22 / cg"
@@ -1907,18 +1923,18 @@
     "warn about a period in an identifier"
 
     ignoreWarnings ifFalse:[
-	didWarnAboutPeriodInSymbol ifFalse:[
-	    parserFlags warnAboutPeriodInSymbol ifTrue:[
-		self
-		    warning:'Period in symbols are nonportable'
-		    doNotShowAgainAction:[ ParserFlags warnAboutPeriodInSymbol:false ]
-		    position:position to:position.
-		"
-		 only warn once (per method)
-		"
-		didWarnAboutPeriodInSymbol := true
-	    ]
-	]
+        didWarnAboutPeriodInSymbol ifFalse:[
+            parserFlags warnAboutPeriodInSymbol ifTrue:[
+                self
+                    warning:'Period in symbols are nonportable'
+                    doNotShowAgainAction:(self actionToDisableWarning:#warnAboutPeriodInSymbol)
+                    position:position to:position.
+                "
+                 only warn once (per method)
+                "
+                didWarnAboutPeriodInSymbol := true
+            ]
+        ]
     ]
 !
 
@@ -1926,13 +1942,12 @@
     "warn about a possible incompatibility with other ST systems"
 
     ignoreWarnings ifFalse:[
-	parserFlags warnPossibleIncompatibilities ifTrue:[
-	    self
-		warning:('Possible incompatibility.\\' , msg) withCRs
-		doNotShowAgainAction:[ ParserFlags warnPossibleIncompatibilities:false.
-				       parserFlags warnPossibleIncompatibilities:false ]
-		position:pos1 to:pos2.
-	]
+        parserFlags warnPossibleIncompatibilities ifTrue:[
+            self
+                warning:('Possible incompatibility.\\' , msg) withCRs
+                doNotShowAgainAction:(self actionToDisableWarning:#warnPossibleIncompatibilities)
+                position:pos1 to:pos2.
+        ]
     ]
 
     "Created: 23.5.1997 / 12:17:54 / cg"
@@ -1941,20 +1956,19 @@
 
 warnSTXSpecialCommentAt:position to:endPosition
     ignoreWarnings ifFalse:[
-	"/ dfo
-	didWarnAboutSTXSpecialComment ifFalse:[
-	    parserFlags warnSTXSpecialComment ifTrue:[
-		self
-		    warning:'End-of-line comments are a nonstandard feature of ST/X'
-		    doNotShowAgainAction:[ parserFlags warnSTXSpecialComment:false. ParserFlags warnSTXSpecials:false. ]
-		    doNotShowAgainForThisMethodAction: [ self disableWarningsOnCurrentMethodFor: #warnSTXSpecials ]
-		    position:position to:endPosition.
-		"
-		 only warn once
-		"
-		didWarnAboutSTXSpecialComment := true
-	    ]
-	]
+        didWarnAboutSTXSpecialComment ifFalse:[
+            parserFlags warnSTXSpecialComment ifTrue:[
+                self
+                    warning:'End-of-line comments are a nonstandard feature of ST/X'
+                    doNotShowAgainAction:(self actionToDisableWarning:#warnSTXSpecials)
+                    doNotShowAgainForThisMethodAction: [ self disableWarningsOnCurrentMethodFor: #warnSTXSpecials ]
+                    position:position to:endPosition.
+                "
+                 only warn once
+                "
+                didWarnAboutSTXSpecialComment := true
+            ]
+        ]
     ].
 
     "Modified: / 16-03-2012 / 18:37:11 / cg"
@@ -1964,18 +1978,18 @@
     "warn about an underscore in an identifier"
 
     ignoreWarnings ifFalse:[
-	didWarnAboutUnderscoreInIdentifier ifFalse:[
-	    parserFlags warnUnderscoreInIdentifier ifTrue:[
-		self
-		    warning:'Underscores in identifiers/symbols are nonportable'
-		    doNotShowAgainAction:[ ParserFlags warnUnderscoreInIdentifier:false ]
-		    position:position to:position.
-		"
-		 only warn once (per method)
-		"
-		didWarnAboutUnderscoreInIdentifier := true
-	    ]
-	]
+        didWarnAboutUnderscoreInIdentifier ifFalse:[
+            parserFlags warnUnderscoreInIdentifier ifTrue:[
+                self
+                    warning:'Underscores in identifiers/symbols are nonportable'
+                    doNotShowAgainAction:(self actionToDisableWarning:#warnUnderscoreInIdentifier)
+                    position:position to:position.
+                "
+                 only warn once (per method)
+                "
+                didWarnAboutUnderscoreInIdentifier := true
+            ]
+        ]
     ]
 
     "Modified: 23.5.1997 / 12:17:06 / cg"
@@ -4090,7 +4104,7 @@
                     self isDoIt ifFalse:[
                         self
                             warning:'empty comment'
-                            doNotShowAgainAction:[ ParserFlags warnAboutBadComments: false ]
+                            doNotShowAgainAction:(self actionToDisableWarning:#warnAboutBadComments)
                             position:startPos to:endPos+1.
                         parserFlags warnAboutBadComments:false.
                     ]