Skip to content

Commit

Permalink
[feenkcom/gtoolkit#3574] addons should be computed in their own worker
Browse files Browse the repository at this point in the history
  • Loading branch information
syrel committed Mar 27, 2024
1 parent 7b21aa8 commit 4abd4ee
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ GtPharoMethodCoderOverridingOverriddenElement >> initialize [

self withAsyncFutureDo: [ :anElementFuture |
anElementFuture
executionConfiguration: (AsyncFutureExecutionConfiguration new
customGroup: #CoderAddOn;
lowPriority);
executionConfiguration: (GtSingleCoderViewModel addOnsExecutionConfiguration);
whenSuccess: [ :anElement :anOrigin |
self updateFromOrigin: anOrigin ];
whenError: [ :anElement :anError |
Expand Down
74 changes: 40 additions & 34 deletions src/GToolkit-Pharo-Coder-UI/GtPharoBehaviorCoderViewModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,10 @@ GtPharoBehaviorCoderViewModel >> behavior [

{ #category : #accessing }
GtPharoBehaviorCoderViewModel >> computeAddOns [
<return: #TAsyncPromise>

^ coderModel asAsyncPromise asyncThen: [ :aCoderModel |
| newAddOns pragmas |

pragmas := aCoderModel
pragmasNamed: #gtAstCoderAddOns:
inHierarchy: aCoderModel class.
newAddOns := aCoderModel newAddOns.

"extra addons"
newAddOns addAddOns: aCoderModel addOns.
"aCoderModel initializeShortcuts: newAddOns."
aCoderModel initializeAddOns: newAddOns viewModel: self.

pragmas reverseDo: [ :eachPragma |
[ aCoderModel
perform: eachPragma methodSelector
withEnoughArguments: { newAddOns . self } ]
on: Error
do: [ :anError |
"emit as a beacon signal"
anError emit.

NonInteractiveTranscript stderr
nextPut: $[;
print: eachPragma method printString;
nextPut: $];
space;
print: anError;
cr ] ].

"view model add-ons override coder model add-ons"
newAddOns addAddOns: extraAddOns.
newAddOns markAsUpdated.
newAddOns ].
^ [ self syncComputeAddOnsFor: coderModel ] asAsyncFuture
await: (self class addOnsExecutionConfiguration)
]

{ #category : #accessing }
Expand Down Expand Up @@ -102,3 +71,40 @@ GtPharoBehaviorCoderViewModel >> previews [
GtPharoBehaviorCoderViewModel >> protocols [
^ self coderModel behavior protocols
]

{ #category : #accessing }
GtPharoBehaviorCoderViewModel >> syncComputeAddOnsFor: aCoderModel [
| newAddOns pragmas |

pragmas := aCoderModel
pragmasNamed: #gtAstCoderAddOns:
inHierarchy: aCoderModel class.
newAddOns := aCoderModel newAddOns.

"extra addons"
newAddOns addAddOns: aCoderModel addOns.
"aCoderModel initializeShortcuts: newAddOns."
aCoderModel initializeAddOns: newAddOns viewModel: self.

pragmas reverseDo: [ :eachPragma |
[ aCoderModel
perform: eachPragma methodSelector
withEnoughArguments: { newAddOns . self } ]
on: Error
do: [ :anError |
"emit as a beacon signal"
anError emit.

NonInteractiveTranscript stderr
nextPut: $[;
print: eachPragma method printString;
nextPut: $];
space;
print: anError;
cr ] ].

"view model add-ons override coder model add-ons"
newAddOns addAddOns: extraAddOns.
newAddOns markAsUpdated.
^ newAddOns
]

0 comments on commit 4abd4ee

Please sign in to comment.