Added build & run, macro expansion, and other actions
This commit is contained in:
@@ -4,7 +4,9 @@ Class {
|
||||
#instVars : [
|
||||
'pharoBindings',
|
||||
'carpLinkApplicationStrategy',
|
||||
'exception'
|
||||
'exception',
|
||||
'application',
|
||||
'commandFactory'
|
||||
],
|
||||
#category : #'Carp-Coder'
|
||||
}
|
||||
@@ -28,7 +30,7 @@ GtCarpCoderModel >> bindAndExecute: sourceString [
|
||||
|
||||
<gtIgnoreConstraint: #GtRBAcceptVisitorCalledFromNonVisitingMethods>
|
||||
<remoteDebuggerSignal>
|
||||
| carpSource trimmedSource ast varNames lastStatement application commandFactory res |
|
||||
| res trimmedSource ast varNames lastStatement carpSource |
|
||||
trimmedSource := SmaCCString on: sourceString trimRight.
|
||||
ast := CarpParser parse: trimmedSource. "The variables to be returned are names that are in pharoBindings"
|
||||
varNames := pharoBindings bindingNames asSet. "Assign the final statement to snippetResult"
|
||||
@@ -41,14 +43,7 @@ GtCarpCoderModel >> bindAndExecute: sourceString [
|
||||
carpSource := self
|
||||
sourceFrom: trimmedSource asString
|
||||
returnedVarNames: varNames.
|
||||
|
||||
application := carpLinkApplicationStrategy applicationServer.
|
||||
application isRunning ifFalse: [ application start ].
|
||||
commandFactory := application newCommandFactory.
|
||||
|
||||
res := commandFactory
|
||||
<< carpSource;
|
||||
sendAndWait.
|
||||
res := self bindAndExecuteRaw: sourceString.
|
||||
|
||||
(res at: #result) = 'success' ifTrue: [ ^ res at: #value ].
|
||||
exception := (PharoLinkRemoteError new
|
||||
@@ -58,6 +53,17 @@ GtCarpCoderModel >> bindAndExecute: sourceString [
|
||||
exception signal
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GtCarpCoderModel >> bindAndExecuteRaw: sourceString [
|
||||
application := carpLinkApplicationStrategy applicationServer.
|
||||
application isRunning ifFalse: [ application start ].
|
||||
commandFactory := application newCommandFactory.
|
||||
|
||||
^ commandFactory
|
||||
<< sourceString;
|
||||
sendAndWait
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GtCarpCoderModel >> carpLinkApplicationStrategy: anApplicationStrategy [
|
||||
carpLinkApplicationStrategy := anApplicationStrategy
|
||||
@@ -77,9 +83,10 @@ GtCarpCoderModel >> exception [
|
||||
{ #category : #accessing }
|
||||
GtCarpCoderModel >> initializeAddOns: addOns [
|
||||
super initializeAddOns: addOns.
|
||||
|
||||
addOns addStyler: (GtCoderAstSmaCCParserStyler new smaccStyler: CarpParser gtStyler).
|
||||
|
||||
|
||||
addOns
|
||||
addStyler: (GtCoderAstSmaCCParserStyler new smaccStyler: CarpParser gtStyler).
|
||||
|
||||
addOns
|
||||
addMainAction: 'Evaluate' translated
|
||||
icon: BrGlamorousVectorIcons play
|
||||
@@ -98,6 +105,23 @@ GtCarpCoderModel >> initializeAddOns: addOns [
|
||||
element: anElement;
|
||||
execute ]
|
||||
id: GtSourceCoderDoItAndGoActionId.
|
||||
addOns
|
||||
addMainAction: 'Expand Macros' translated
|
||||
icon: BrGlamorousVectorIcons repair
|
||||
action: [ :aCoderUIModel :anElement |
|
||||
| source |
|
||||
source := '(expand ''' , sourceCode currentSourceText value text , ')'.
|
||||
anElement phlow
|
||||
spawnObject: (CarpParser parse: (aCoderUIModel coder bindAndExecute: source)) ].
|
||||
addOns
|
||||
addMainAction: 'Build and Run' translated
|
||||
icon: BrGlamorousVectorIcons refresh
|
||||
action: [ :aCoderUIModel :anElement |
|
||||
| source |
|
||||
source := '' , sourceCode currentSourceText value text , '(build) (run)'.
|
||||
anElement phlow
|
||||
spawnObject: (CarpCliOutput text: ((aCoderUIModel coder bindAndExecuteRaw: source) at: 'value')) ]
|
||||
id: #'source-coder--macro-expand-action'
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
Reference in New Issue
Block a user