Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SpCodePresenter>>#evaluate:onCompileError:onError: that does not consider interaction model's bindings when evaluating code #1549

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 25 additions & 21 deletions src/Spec2-Code/SpCodePresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ SpCodePresenter >> environment: anEnvironment [
]

{ #category : 'command support' }
SpCodePresenter >> evaluate: aString onCompileError: compileErrorBlock onError: errorBlock [
SpCodePresenter >> evaluate: aString onCompileError: compileErrorBlock onError: errorBlock [
"evaluate aString.
evaluate compileErrorBlock if there are compilation errors.
evaluate errorBlock is anything happens *during* evaluation (code compiled, but it does not
Expand All @@ -438,28 +438,32 @@ SpCodePresenter >> evaluate: aString onCompileError: compileErrorBlock onError:
anything.
Instead, the on:do: will catch all errors happening while executing the code once it is
compiled. "

| result oldBindings |

^ [
self announcer announce: (SpCodeWillBeEvaluatedAnnouncement newContent: aString).
oldBindings := self interactionModel bindings copy.
result := self interactionModel compiler
source: aString;
environment: self environment;
failBlock: [
self announcer announce: (SpCodeEvaluationFailedAnnouncement newContent: aString).
^ compileErrorBlock value ];
evaluate.
oldBindings size = self interactionModel bindings size
ifFalse: [ self withAdapterDo: [ :anAdapter | anAdapter refreshStyling ] ].
self announcer announce: (SpCodeEvaluationSucceedAnnouncement newContent: aString).
result ]
on: Error
do: [ :e |
self announcer announce: (SpCodeEvaluationFailedAnnouncement
newContent: aString
error: e).
errorBlock value: e ]
self announcer announce:
(SpCodeWillBeEvaluatedAnnouncement newContent: aString).
oldBindings := self interactionModel bindings copy.
result := self interactionModel compiler
source: aString;
environment: self environment;
bindings: self interactionModel bindings;
failBlock: [
self announcer announce:
(SpCodeEvaluationFailedAnnouncement newContent:
aString).
^ compileErrorBlock value ];
evaluate.
oldBindings size = self interactionModel bindings size ifFalse: [
self withAdapterDo: [ :anAdapter | anAdapter refreshStyling ] ].
self announcer announce:
(SpCodeEvaluationSucceedAnnouncement newContent: aString).
result ]
on: Error
do: [ :e |
self announcer announce:
(SpCodeEvaluationFailedAnnouncement newContent: aString error: e).
errorBlock value: e ]
]

{ #category : 'private - bindings' }
Expand Down
Loading