class: Parser
changed:
#correctVariable:atPosition:to:
#declareUndefinedVariable:as:
--- a/Parser.st Tue Aug 27 19:52:09 2013 +0200
+++ b/Parser.st Tue Aug 27 20:17:44 2013 +0200
@@ -58,7 +58,7 @@
!
Parser::Correction subclass:#CorrectByDeclaringIdentifierAs
- instanceVariableNames:''
+ instanceVariableNames:'lastType'
classVariableNames:''
poolDictionaries:''
privateIn:Parser
@@ -3339,9 +3339,12 @@
].
].
"/ backward compatibility (symbols) will vanish...
- ((correctIt == #declare) or:[correctIt == CorrectByDeclaringIdentifierAs ]) ifTrue:[
+ ((correctIt == #declare)
+ or:[correctIt == CorrectByDeclaringIdentifierAs
+ or:[correctIt isKindOf: CorrectByDeclaringIdentifierAs]]) ifTrue:[
"/ declare it
- (variableCorrectActionForAll == #declare
+ (((variableCorrectActionForAll == #declare)
+ or:[ correctIt isKindOf: CorrectByDeclaringIdentifierAs ])
and:[ variableTypeOfLastCorrectAction notNil ]) ifTrue:[
rslt := self declareUndefinedVariable:varName as:variableTypeOfLastCorrectAction.
^ rslt
@@ -3538,9 +3541,9 @@
endLocalsPos notNil ifTrue:[
localVarDefPosition at:2 put:(endLocalsPos + varName size + 1).
-
- methodVarNames := methodVarNames copyWith:varName.
- methodVars := methodVars copyWith:(var := Variable new name:varName).
+ "/ sigh - methodVarNames is nil if decl is empty
+ methodVarNames := (methodVarNames ? #()) copyWith:varName.
+ methodVars := (methodVars ? #()) copyWith:(var := Variable new name:varName).
] ifFalse:[
localVarDefPosition := Array with:posToInsert with:posToInsert+varName size+1+(space ifTrue:[2] ifFalse:[0]).
@@ -10703,6 +10706,15 @@
^ 'Declare As...'
! !
+!Parser::CorrectByDeclaringIdentifierAs methodsFor:'queries'!
+
+buttonLabel
+ lastType isNil ifTrue:[
+ ^ self class buttonLabel
+ ].
+ ^ 'Declare as ',lastType.
+! !
+
!Parser::CorrectByDeletingLocalIdentifier class methodsFor:'queries'!
buttonLabel
@@ -11051,7 +11063,9 @@
!Parser::PossibleCorrectionsQuery methodsFor:'queries'!
defaultResumeValue
- ^ { Parser correctByDeclaringIdentifierAs . Parser correctByInteractiveCorrection }
+ "/ returning an instance here, so it can keep some state in case it is
+ "/ reused (same for all)
+ ^ { Parser correctByDeclaringIdentifierAs new . Parser correctByInteractiveCorrection }
"
Parser possibleCorrectionsQuery query
@@ -11620,11 +11634,11 @@
!Parser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.783 2013-08-27 17:52:09 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.784 2013-08-27 18:17:44 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.783 2013-08-27 17:52:09 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.784 2013-08-27 18:17:44 cg Exp $'
!
version_SVN