--- a/Parser.st Thu May 27 18:19:50 2004 +0200
+++ b/Parser.st Tue Jun 01 13:53:42 2004 +0200
@@ -2172,12 +2172,58 @@
^ nil.
!
+checkBlockArgumentNameConventionsFor:aVariableName
+ self checkLocalVariableNameConventionsFor:aVariableName.
+!
+
+checkBlockVariableNameConventionsFor:aVariableName
+ self checkLocalVariableNameConventionsFor:aVariableName.
+!
+
+checkForLowercaseVariableName:aVariableName
+ aVariableName first isUppercase ifTrue:[
+ self
+ syntaxError:('variable "' , aVariableName , '" should be lowercase (by convention)')
+ position:tokenPosition to:source position1Based - 1.
+ ].
+!
+
+checkForProperUseOfArticleInVariableName:aVariableName
+ |third|
+
+ aVariableName size > 2 ifTrue:[
+ (aVariableName startsWith:'an') ifTrue:[
+ third := aVariableName at:3.
+ third isUppercase ifTrue:[
+ ('AEIOX' includes:third) ifFalse:[
+ self
+ syntaxError:('variable "' , aVariableName , '" should be named "a' , (aVariableName copyFrom:3) , '" (by english language rules)')
+ position:tokenPosition to:source position1Based - 1.
+ ].
+ ].
+ ]
+ ].
+!
+
checkIfAllSubclassesOf:aClass implement:aSelector
(aClass subclasses
contains:[:cls | (cls implements:aSelector) not]) ifTrue:[^ false].
^ true.
!
+checkLocalVariableNameConventionsFor:aVariableName
+ self checkForLowercaseVariableName:aVariableName.
+ self checkForProperUseOfArticleInVariableName:aVariableName.
+!
+
+checkMethodArgumentNameConventionsFor:aVariableName
+ self checkLocalVariableNameConventionsFor:aVariableName.
+!
+
+checkMethodVariableNameConventionsFor:aVariableName
+ self checkLocalVariableNameConventionsFor:aVariableName.
+!
+
checkSelector:selector for:receiver inClass:cls
"check wether a method with selector exists in class cls and
that the method is not obsolete.
@@ -2233,10 +2279,14 @@
].
].
allowed ifTrue:[
- (self checkIfAllSubclassesOf:cls implement:selector) ifFalse:[
- "if not all subclasses implement the selector - this is a possible bug"
- allowed := false
- ].
+ "/ not from cg to stefan: thats wrong - if not implemented in all subclasses,
+ "/ its a bug of the subclass not a bug here - that message send here
+ "/ is perfectly correct. (it is very annoying for a framework developped to get
+ "/ error messages for bugs which are not his...
+"/ (self checkIfAllSubclassesOf:cls implement:selector) ifFalse:[
+"/ "if not all subclasses implement the selector - this is a possible bug"
+"/ allowed := false
+"/ ].
].
allowed ifFalse:[
err := 'is subclassResponsibility'
@@ -3591,6 +3641,7 @@
pos2 := tokenPosition + tokenName size - 1.
self markArgumentIdentifierFrom:tokenPosition to:pos2.
+ self checkBlockArgumentNameConventionsFor:tokenName.
arg := Variable name:tokenName.
args isNil ifTrue:[
args := Array with:arg.
@@ -3639,6 +3690,7 @@
].
pos2 := tokenPosition + tokenName size - 1.
self markLocalIdentifierFrom:tokenPosition to:pos2.
+ self checkBlockVariableNameConventionsFor:tokenName.
var := Variable name:tokenName.
vars isNil ifTrue:[
vars := Array with:var.
@@ -4017,6 +4069,7 @@
[tokenType == #Identifier] whileTrue:[
pos2 := tokenPosition + tokenName size - 1.
self markLocalIdentifierFrom:tokenPosition to:pos2.
+ self checkMethodVariableNameConventionsFor:tokenName.
var := Variable name:tokenName.
methodVars isNil ifTrue:[
@@ -4121,6 +4174,7 @@
pos2 := tokenPosition+tokenName size-1.
self markArgumentIdentifierFrom:tokenPosition to:pos2.
+ self checkMethodArgumentNameConventionsFor:tokenName.
arg := Variable name:tokenName.
methodArgs isNil ifTrue:[
methodArgs := Array with:arg.
@@ -4163,6 +4217,7 @@
self nextToken.
(tokenType ~~ #Identifier) ifTrue:[^ #Error].
self markArgumentIdentifierFrom:tokenPosition to:(tokenPosition+tokenName size-1).
+ self checkMethodArgumentNameConventionsFor:tokenName.
arg := Variable name:tokenName.
methodArgs := Array with:arg.
@@ -7513,7 +7568,7 @@
!Parser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.424 2004-05-27 16:19:50 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.425 2004-06-01 11:53:42 cg Exp $'
! !
Parser initialize!