Skip to content

Commit

Permalink
[feenkcom/gtoolkit#3942] Add GtSourceCoderEvaluationContext
Browse files Browse the repository at this point in the history
  • Loading branch information
akgrant43 committed Aug 6, 2024
1 parent 9b336c3 commit e52af5b
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 4 deletions.
18 changes: 16 additions & 2 deletions src/GToolkit-Coder-UI/GtCoderCodeExecutor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Class {
#instVars : [
'coderUIModel',
'action',
'element'
'element',
'executionStrategy'
],
#category : #'GToolkit-Coder-UI-Execution'
}
Expand Down Expand Up @@ -113,7 +114,20 @@ GtCoderCodeExecutor >> event: anObject [
GtCoderCodeExecutor >> execute [
GtCoderExecutionContextVariable
element: self element
do: [ self coderViewModel perform: action ]
do: [ | coderViewModel |
coderViewModel := self coderViewModel.
coderViewModel executionStrategy: executionStrategy.
coderViewModel perform: action ]
]

{ #category : #accessing }
GtCoderCodeExecutor >> executionStrategy [
^ executionStrategy
]

{ #category : #accessing }
GtCoderCodeExecutor >> executionStrategy: anObject [
executionStrategy := anObject
]

{ #category : #initialization }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Class {
#name : #GtSourceCoderDoItAndGoAsynchronousActionId,
#superclass : #GtCoderElementId,
#category : #'GToolkit-Coder-UI-Coder - Ids'
}

{ #category : #converting }
GtSourceCoderDoItAndGoAsynchronousActionId >> asSymbol [
^ #'source-coder--doit-and-go-asynchronous-action'
]
26 changes: 25 additions & 1 deletion src/GToolkit-Coder-UI/GtSourceCoderViewModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Class {
#superclass : #GtTextualCoderViewModel,
#instVars : [
'evaluationResult',
'evaluationStatus'
'evaluationStatus',
'executionStrategy'
],
#category : #'GToolkit-Coder-UI-Coder - Source Model'
}
Expand Down Expand Up @@ -118,6 +119,17 @@ GtSourceCoderViewModel >> doItAndGoAllSerialized [
serializationStrategy: #GtRsrStonSerializationStrategy)
]

{ #category : #'api - actions' }
GtSourceCoderViewModel >> doItAndGoAsynchronous: aTextInterval [
"Evaluate a piece of source code within an interval and inspect a result."

^ self handleCoderEvaluationUnhandledErrorDuring: [
self coder doItAndGoAsynchronousInContext: (
self evaluationContext
from: aTextInterval first
to: aTextInterval last) ]
]

{ #category : #'api - actions' }
GtSourceCoderViewModel >> doItAndGoSerialized [
"Evaluate selected source code or everything if there is nothing selected and inspect the result"
Expand Down Expand Up @@ -192,6 +204,18 @@ GtSourceCoderViewModel >> evaluationStatus: aNewStatus [
self onEvaluationStatusChanged
]

{ #category : #accessing }
GtSourceCoderViewModel >> executionStrategy [

^ executionStrategy
]

{ #category : #accessing }
GtSourceCoderViewModel >> executionStrategy: anObject [

executionStrategy := anObject
]

{ #category : #'private - event handling' }
GtSourceCoderViewModel >> handleCoderEvaluationUnhandledErrorDuring: aBlock [
^ [ GtCoderUserSnippetDynamicVariable
Expand Down
13 changes: 12 additions & 1 deletion src/GToolkit-Coder/GtSourceCoderEvaluationContext.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Class {
'sourceString',
'evaluatedInterval',
'evaluatedSourceString',
'evaluatedCode'
'evaluatedCode',
'executionStrategy'
],
#category : #'GToolkit-Coder-Coders - Evaluation'
}
Expand Down Expand Up @@ -66,6 +67,16 @@ GtSourceCoderEvaluationContext >> evaluatedSourceString: anObject [
evaluatedSourceString := anObject
]

{ #category : #accessing }
GtSourceCoderEvaluationContext >> executionStrategy [
^ executionStrategy
]

{ #category : #accessing }
GtSourceCoderEvaluationContext >> executionStrategy: anObject [
executionStrategy := anObject
]

{ #category : #'api - context' }
GtSourceCoderEvaluationContext >> from: aStartPosition to: aStopPosition [
sourceInterval := GtSourceCoderEvaluationPartialSource new
Expand Down

0 comments on commit e52af5b

Please sign in to comment.