--- a/Parser.st Tue Feb 28 15:04:14 2012 +0100
+++ b/Parser.st Tue Feb 28 15:14:34 2012 +0100
@@ -1694,19 +1694,23 @@
selectorInExpression:aString
"parse an expression - return the selector. Even malformed expressions
- (such as missing receiver or missing arg are parsed.
+ (such as missing receiver or missing arg) are parsed.
Used for the SystemBrowsers implementors/senders query-box initial text.
Returns nil if unparsable."
- |tree parser sel|
-
- (aString size == 0) ifTrue:[^ nil].
+ |stringParsed tree expression parser sel|
+
+ stringParsed := aString withoutSeparators.
+ stringParsed isEmpty ifTrue:[^ nil].
+ (stringParsed startsWith:'^') ifTrue:[
+ stringParsed := stringParsed copyFrom:2.
+ ].
Error
handle:[:ex | ]
do:[
tree := self withSelf:nil
- parseExpression:aString
+ parseExpression:stringParsed
notifying:nil
ignoreErrors:true
ignoreWarnings:true.
@@ -1719,8 +1723,8 @@
(tree notNil and:[tree ~~ #Error]) ifTrue:[
(tree isAssignment
or:[tree isReturnNode]) ifTrue:[
- tree expression isMessage ifTrue:[
- tree := tree expression
+ (expression := tree expression) isMessage ifTrue:[
+ tree := expression
]
].
tree isMessage ifTrue:[
@@ -1731,7 +1735,7 @@
"
mhmh, try expression without receiver
"
- parser := self for:(ReadStream on:aString).
+ parser := self for:(ReadStream on:stringParsed).
parser ignoreErrors:true.
Error
handle:[:ex | ]
@@ -1753,7 +1757,7 @@
Parser selectorInExpression:'a := foo at:1 put:5'
"
- "Modified: 17.12.1996 / 12:12:47 / cg"
+ "Modified (comment): / 28-02-2012 / 10:11:15 / cg"
!
withSelf:anObject parseExpression:aString notifying:someOne
@@ -2440,6 +2444,7 @@
self
warning:('Plausibility Check\' withCRs, note)
doNotShowAgainAction:[ parserFlags warnPlausibilityChecks:false. ParserFlags warnPlausibilityChecks:false ]
+ doNotShowAgainForThisMethodAction: [ self disableWarningsOnCurrentMethodFor: #warnPlausibilityChecks ]
position:startPosition to:endPosition.
].
].
@@ -3877,7 +3882,7 @@
isSyntaxHighlighter ifFalse:[
err := err , '\\This is a warning from the compiler - the code has not yet been executed/compiled.'.
- self class doNotShowCompilerWarningAgainActionQuery handle:[:ex |
+ DoNotShowCompilerWarningAgainActionQuery handle:[:ex |
parserFlags warnAboutPossiblyUnimplementedSelectors:false.
ParserFlags warnAboutPossiblyUnimplementedSelectors:false.
ex proceed.
@@ -3893,7 +3898,7 @@
^ aSelectorString
"Modified: / 05-09-1995 / 17:02:11 / claus"
- "Modified: / 23-08-2010 / 19:24:49 / cg"
+ "Modified: / 28-02-2012 / 08:35:15 / cg"
!
typeOfNode:aNode
@@ -3983,6 +3988,12 @@
].
!
+disableWarningsOnCurrentMethodFor:flagName
+ ParserFlags disableFlag:flagName forClass:classToCompileFor selector:selector
+
+ "Created: / 28-02-2012 / 14:44:31 / cg"
+!
+
errorMessageForUndefined:aName
|idx implementors|
@@ -4225,61 +4236,80 @@
].
!
+warnSTXSpecialCommentAt:position to:endPosition
+ (ParserFlags isFlag:#warnSTXSpecials enabledForClass:classToCompileFor selector:selector) ifFalse:[^ self].
+ super warnSTXSpecialCommentAt:position to:endPosition
+
+ "Created: / 28-02-2012 / 14:55:36 / cg"
+!
+
warnUnused:aNameCollection
"report an unused method variable"
- |msg answer lineLength first|
-
- (ignoreErrors not
- and:[ignoreWarnings not
- and:[parserFlags warnUnusedVars]]) ifTrue:[
- msg := 'Unused method variable(s): '.
- lineLength := msg size.
- first := true.
- aNameCollection asSortedCollection do:[:name|
- first ifTrue:[ first := false ] ifFalse:[msg := msg , ', '].
- msg := msg , ('"',name allBold,'"').
- lineLength := lineLength + 2 + name size + 1.
- lineLength > 60 ifTrue:[
- msg := msg , '\' withCRs.
- lineLength := 0.
- ].
- ].
-
- (requestor isNil or:[requestor isStream]) ifTrue:[
- self showErrorMessage:('Warning: ', msg) position:nil.
- ] ifFalse:[
- self class doNotShowCompilerWarningAgainActionQuery handle:[:ex |
+ |msg answer lineLength first queries|
+
+ ignoreErrors ifTrue:[^ self].
+ ignoreWarnings ifTrue:[^ self].
+ parserFlags warnUnusedVars ifFalse:[^ self].
+
+ (ParserFlags isFlag:#warnUnusedVars enabledForClass:classToCompileFor selector:selector)
+ ifFalse:[^ self].
+
+ msg := 'Unused method variable(s): '.
+ lineLength := msg size.
+ first := true.
+ aNameCollection asSortedCollection do:[:name|
+ first ifTrue:[ first := false ] ifFalse:[msg := msg , ', '].
+ msg := msg , ('"',name allBold,'"').
+ lineLength := lineLength + 2 + name size + 1.
+ lineLength > 60 ifTrue:[
+ msg := msg , '\' withCRs.
+ lineLength := 0.
+ ].
+ ].
+
+ (requestor isNil or:[requestor isStream]) ifTrue:[
+ self showErrorMessage:('Warning: ', msg) position:nil.
+ ] ifFalse:[
+ queries := DoNotShowCompilerWarningAgainActionQuery.
+ (self isDoIt not
+ and:[ classToCompileFor notNil
+ and:[ selector notNil ]]) ifTrue:[
+ queries := queries , DoNotShowCompilerWarningAgainForThisMethodActionQuery.
+ ].
+ queries handle:[:ex |
+ ex signal == DoNotShowCompilerWarningAgainActionQuery ifTrue:[
parserFlags warnUnusedVars:false.
ParserFlags warnUnusedVars:false.
- ex proceed.
- ] do:[
- answer := requestor
- unusedVariableWarning:msg
- position:(localVarDefPosition first) to:(localVarDefPosition last) from:self.
- ].
- answer == true ifTrue:[
- "/ delete the definitions ...
- aNameCollection do:[:eachName |
- self deleteDefinitionOf:eachName in:(localVarDefPosition first) to:(localVarDefPosition last).
- ].
- RestartCompilationSignal raise
- ].
- ].
-
- Tools::ToDoListBrowser notNil ifTrue:[
- "/ experimental
- self
- notifyTodo:msg position:(localVarDefPosition first)
- className:(self classToCompileFor name) selector:selector
- severity:#warning priority:#low
- equalityParameter:nil
- checkAction:nil.
- ].
-
- ].
-
- "Modified: / 07-07-2010 / 15:53:19 / cg"
+ ] ifFalse:[
+ self disableWarningsOnCurrentMethodFor: #warnUnusedVars
+ ].
+ ex proceed.
+ ] do:[
+ answer := requestor
+ unusedVariableWarning:msg
+ position:(localVarDefPosition first) to:(localVarDefPosition last) from:self.
+ ].
+ answer == true ifTrue:[
+ "/ delete the definitions ...
+ aNameCollection do:[:eachName |
+ self deleteDefinitionOf:eachName in:(localVarDefPosition first) to:(localVarDefPosition last).
+ ].
+ RestartCompilationSignal raise
+ ].
+ ].
+
+ Tools::ToDoListBrowser notNil ifTrue:[
+ "/ experimental
+ self
+ notifyTodo:msg position:(localVarDefPosition first)
+ className:(self classToCompileFor name) selector:selector
+ severity:#warning priority:#low
+ equalityParameter:nil
+ checkAction:nil.
+ ].
+
+ "Modified: / 28-02-2012 / 14:55:07 / cg"
! !
!Parser methodsFor:'evaluating expressions'!
@@ -7232,7 +7262,7 @@
(assignmentAllowed := parserFlags allowAssignmentToBlockArgument) ifTrue:[
self warning:'assignment to block argument' position:pos1 to:pos2.
] ifFalse:[
- self class doNotShowCompilerWarningAgainActionQuery handle:[:ex |
+ DoNotShowCompilerWarningAgainActionQuery handle:[:ex |
parserFlags allowAssignmentToBlockArgument:true.
ParserFlags allowAssignmentToBlockArgument:true.
ex proceed.
@@ -7250,7 +7280,7 @@
(assignmentAllowed := parserFlags allowAssignmentToPoolVariable) ifTrue:[
self warning:'assignment to pool variable' position:pos1 to:pos2.
] ifFalse:[
- self class doNotShowCompilerWarningAgainActionQuery handle:[:ex |
+ DoNotShowCompilerWarningAgainActionQuery handle:[:ex |
parserFlags allowAssignmentToPoolVariable:true.
ParserFlags allowAssignmentToPoolVariable:true.
ex proceed.
@@ -7311,7 +7341,7 @@
"Modified: / 20-08-2011 / 23:32:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 05-10-2011 / 15:36:55 / az"
- "Modified: / 14-02-2012 / 10:03:36 / cg"
+ "Modified: / 28-02-2012 / 08:35:11 / cg"
!
primary_lazyValue
@@ -10661,11 +10691,11 @@
!Parser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.704 2012-02-14 10:21:37 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.705 2012-02-28 14:14:34 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.704 2012-02-14 10:21:37 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.705 2012-02-28 14:14:34 cg Exp $'
!
version_SVN