checkVariable-conventions: can be disabled via classVar.
authorClaus Gittinger <cg@exept.de>
Wed, 09 Jun 2004 11:44:55 +0200
changeset 1521 3488542e7a83
parent 1520 cd58bd39b85d
child 1522 777862196320
checkVariable-conventions: can be disabled via classVar.
Parser.st
--- a/Parser.st	Tue Jun 01 14:20:46 2004 +0200
+++ b/Parser.st	Wed Jun 09 11:44:55 2004 +0200
@@ -38,7 +38,8 @@
 		AllowFunctionCallSyntaxForBlockEvaluation AllowLazyValueExtension
 		AllowVariableReferences AllowReservedWordsAsSelectors
 		AllowLocalVariableDeclarationWithInitializerExpression
-		AllowArrayIndexSyntaxExtension AllowDomainVariables'
+		AllowArrayIndexSyntaxExtension AllowDomainVariables
+		WarnAboutWrongVariableNames'
 	poolDictionaries:''
 	category:'System-Compiler'
 !
@@ -2191,7 +2192,7 @@
 checkForProperUseOfArticleInVariableName:aVariableName
     |third|
 
-    aVariableName size > 2 ifTrue:[ 
+    aVariableName size > 4 ifTrue:[ 
         (aVariableName startsWith:'an') ifTrue:[
             third := aVariableName at:3.
             third isUppercase ifTrue:[
@@ -2201,7 +2202,17 @@
                         position:tokenPosition to:source position1Based - 1.
                 ].
             ].
-        ]
+        ].
+        (aVariableName startsWith:'a') ifTrue:[
+            third := aVariableName at:2.
+            third isUppercase ifTrue:[
+                ('AEIOX' includes:third) ifTrue:[
+                    self 
+                        warnCommonMistake:('variable "' , aVariableName , '" should be named "an' , (aVariableName copyFrom:2) , '" (by english language rules)')
+                        position:tokenPosition to:source position1Based - 1.
+                ].
+            ].
+        ].
     ].
 !
 
@@ -2213,7 +2224,9 @@
 
 checkLocalVariableNameConventionsFor:aVariableName
     self checkForLowercaseVariableName:aVariableName.
-    self checkForProperUseOfArticleInVariableName:aVariableName.
+    WarnAboutWrongVariableNames == true ifTrue:[
+        self checkForProperUseOfArticleInVariableName:aVariableName.
+    ].
 !
 
 checkMethodArgumentNameConventionsFor:aVariableName
@@ -7568,7 +7581,7 @@
 !Parser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.426 2004-06-01 12:20:46 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.427 2004-06-09 09:44:55 cg Exp $'
 ! !
 
 Parser initialize!