diff --git a/src/Carp-AST/CarpExpressionNode.class.st b/src/Carp-AST/CarpExpressionNode.class.st index 43cd960..414d7f8 100644 --- a/src/Carp-AST/CarpExpressionNode.class.st +++ b/src/Carp-AST/CarpExpressionNode.class.st @@ -21,6 +21,11 @@ CarpExpressionNode >> isDefinition [ ^ false ] +{ #category : #accessing } +CarpExpressionNode >> isDefinitionPredicate [ + ^ false +] + { #category : #accessing } CarpExpressionNode >> isQuoted [ ^ parent ifNil: [ false ] ifNotNil: [ parent isQuoted ] diff --git a/src/Carp-Parser/CarpListNode.class.st b/src/Carp-Parser/CarpListNode.class.st index 74eb256..0d114e4 100644 --- a/src/Carp-Parser/CarpListNode.class.st +++ b/src/Carp-Parser/CarpListNode.class.st @@ -51,8 +51,18 @@ CarpListNode >> initialize [ { #category : #accessing } CarpListNode >> intoModel [ - ^ CarpList - contents: (expressions collect: #intoModel) + ^ self isDefinition + ifTrue: [ | binding | + binding := (CarpBinding perform: self expressions first value source asSymbol) + name: self definitionVariable intoModel. + self expressions size = 3 + ifTrue: [ binding binding: self expressions third intoModel ]. + self expressions size = 4 + ifTrue: [ binding + arguments: self expressions third intoModel; + body: self expressions fourth intoModel ]. + binding ] + ifFalse: [ CarpList contents: (expressions collect: #intoModel) ] ] { #category : #accessing } diff --git a/src/Carp/CarpBinding.class.st b/src/Carp/CarpBinding.class.st index 98a5131..40ae4b7 100644 --- a/src/Carp/CarpBinding.class.st +++ b/src/Carp/CarpBinding.class.st @@ -7,6 +7,31 @@ Class { #category : #'Carp-IDE' } +{ #category : #'instance creation' } +CarpBinding class >> def [ + ^ CarpStaticVariable new +] + +{ #category : #'instance creation' } +CarpBinding class >> defdynamic [ + ^ CarpDynamicVariable new +] + +{ #category : #'instance creation' } +CarpBinding class >> defmacro [ + ^ CarpMacro new +] + +{ #category : #'instance creation' } +CarpBinding class >> defn [ + ^ CarpStaticFunction new +] + +{ #category : #'instance creation' } +CarpBinding class >> defndynamic [ + ^ CarpDynamicFunction new +] + { #category : #accessing } CarpBinding >> bindingName [ ^ self subclassResponsibility diff --git a/src/Carp/CarpExpression.class.st b/src/Carp/CarpExpression.class.st index 887f0a5..a05f497 100644 --- a/src/Carp/CarpExpression.class.st +++ b/src/Carp/CarpExpression.class.st @@ -14,9 +14,13 @@ CarpExpression >> asElement [ { #category : #accessing } CarpExpression >> asElementWithModule: aModule [ - ^ ((GtCarpIDECoderModel code: self toCarp) - module: aModule; - expression: self) asElement + | applicationStrategy | + applicationStrategy := LeCarpApplicationStrategy new. + ^ (GtExpandableSourceCoderElement new + coderViewModel: ((GtCarpIDECoderModel code: self toCarp) + module: aModule; + carpLinkApplicationStrategy: applicationStrategy; + expression: self) asCoderViewModel) collapse ] { #category : #accessing } diff --git a/src/Carp/CarpModule.class.st b/src/Carp/CarpModule.class.st index 12418ba..92ffd35 100644 --- a/src/Carp/CarpModule.class.st +++ b/src/Carp/CarpModule.class.st @@ -84,6 +84,7 @@ CarpModule >> carpCoderStreamingMethodsFor: aView context: aPhlowContext [ ifNotNil: [ :aContents | aNewMethodCoderViewModel := aContents ] ifNil: [ aNewMethodCoder := GtCarpNewFunctionCoderModel new module: self; + carpLinkApplicationStrategy: LeCarpApplicationStrategy new; onSave: [ aButton fireEvent: BrDropdownHideWish new. coderElement initializeForModule ]. diff --git a/src/Carp/CarpModuleCoderElement.class.st b/src/Carp/CarpModuleCoderElement.class.st index ad86f76..c85a383 100644 --- a/src/Carp/CarpModuleCoderElement.class.st +++ b/src/Carp/CarpModuleCoderElement.class.st @@ -12,6 +12,18 @@ Class { #category : #'Carp-Coder' } +{ #category : #accessing } +CarpModuleCoderElement >> build [ + | application commandFactory | + application := CarpApplication uniqueInstance. + application isRunning ifFalse: [ application start ]. + commandFactory := application newCommandFactory. + + ^ commandFactory + << self module toCarp; + sendAndWait +] + { #category : #accessing } CarpModuleCoderElement >> buildContentPane [ @@ -91,6 +103,13 @@ CarpModuleCoderElement >> buildModuleLabel [ action: [ :aButton | aButton phlow spawnObject: self module toCarp ]). + aContainer addChild: (BrButton new + aptitude: BrGlamorousButtonWithIconAptitude; + icon: BrGlamorousVectorIcons refresh; + beSmallSize; + label: 'Build'; + action: [ self build ]). + ^ aContainer ] @@ -133,7 +152,8 @@ CarpModuleCoderElement >> coderViewModel: aCarpCoderViewModel [ container ifNotNil: #removeFromParent. container := self buildContentPane. - self addChildFirst: container + self addChildFirst: container. + self build ] { #category : #accessing } diff --git a/src/Carp/CarpSequence.class.st b/src/Carp/CarpSequence.class.st index ba9b097..3080df7 100644 --- a/src/Carp/CarpSequence.class.st +++ b/src/Carp/CarpSequence.class.st @@ -23,6 +23,11 @@ CarpSequence >> contents: aCollection [ contents := aCollection ] +{ #category : #accessing } +CarpSequence >> do: aBlock [ + contents do: aBlock +] + { #category : #accessing } CarpSequence >> open [ ^ self subclassResponsibility diff --git a/src/Carp/CarpSymbol.class.st b/src/Carp/CarpSymbol.class.st index fbd04c6..e2b841f 100644 --- a/src/Carp/CarpSymbol.class.st +++ b/src/Carp/CarpSymbol.class.st @@ -12,6 +12,11 @@ CarpSymbol class >> named: aString [ ^ self new name: aString ] +{ #category : #accessing } +CarpSymbol >> name [ + ^ name +] + { #category : #accessing } CarpSymbol >> name: aString [ name := aString diff --git a/src/Carp/GtCarpIDECoderModel.class.st b/src/Carp/GtCarpIDECoderModel.class.st index 9339bbe..9b30b13 100644 --- a/src/Carp/GtCarpIDECoderModel.class.st +++ b/src/Carp/GtCarpIDECoderModel.class.st @@ -7,6 +7,12 @@ Class { #category : #'Carp-Coder' } +{ #category : #accessing } +GtCarpIDECoderModel >> collapsedTextPromise [ + ^ self expression name name , ' : ' + , (self bindAndExecute: '(type ' , module name, '.', self expression name name , ')') value +] + { #category : #accessing } GtCarpIDECoderModel >> expression [ ^ expression @@ -30,7 +36,8 @@ GtCarpIDECoderModel >> initializeAddOns: addOns [ { #category : #accessing } GtCarpIDECoderModel >> remove [ - ^ module removeExpression: self expression + module removeExpression: self expression. + self bindAndExecute: module toCarp ] { #category : #accessing } @@ -38,5 +45,6 @@ GtCarpIDECoderModel >> save [ module removeExpression: expression. module addExpression: (CarpParser parse: sourceCode availableSource text) intoModel. + self bindAndExecute: module toCarp. onSave ifNotNil: [ onSave value ] ] diff --git a/src/Carp/GtCarpNewFunctionCoderModel.class.st b/src/Carp/GtCarpNewFunctionCoderModel.class.st index a22abbb..184330a 100644 --- a/src/Carp/GtCarpNewFunctionCoderModel.class.st +++ b/src/Carp/GtCarpNewFunctionCoderModel.class.st @@ -10,14 +10,11 @@ Class { { #category : #accessing } GtCarpNewFunctionCoderModel >> initializeAddOns: addOns [ - super initializeAddOns: addOns. - addOns - addMainAction: 'Save' translated - icon: BrGlamorousVectorIcons accept - action: [ :aCoderUIModel :anElement | - self save ] - id: GtMethodCoderSaveActionId. + addMainAction: 'Save' translated + icon: BrGlamorousVectorIcons accept + action: [ :aCoderUIModel :anElement | self save ] + id: GtMethodCoderSaveActionId ] { #category : #coders } @@ -32,6 +29,9 @@ GtCarpNewFunctionCoderModel >> onSave: aBlock [ { #category : #accessing } GtCarpNewFunctionCoderModel >> save [ - module addExpression: (CarpParser parse: sourceCode currentSourceText value text) intoModel. + | expression | + expression := (CarpParser parse: sourceCode currentSourceText value text) intoModel. + module addExpression: expression. + self bindAndExecute: module toCarp. onSave ifNotNil: [ onSave value ] ] diff --git a/src/Carp/LeCarpApplicationStrategy.class.st b/src/Carp/LeCarpApplicationStrategy.class.st index dd06582..0e2891b 100644 --- a/src/Carp/LeCarpApplicationStrategy.class.st +++ b/src/Carp/LeCarpApplicationStrategy.class.st @@ -13,9 +13,8 @@ LeCarpApplicationStrategy class >> strategyName [ { #category : #accessing } LeCarpApplicationStrategy >> applicationServer [ - content database isDatabase ifFalse: [ ^ nil ]. CarpApplication uniqueInstance ifNil: - [ CarpApplication uniqueInstance: (self newCarpApplicationFor: content database) ]. + [ CarpApplication uniqueInstance: self newCarpApplication ]. ^ CarpApplication uniqueInstance ] @@ -31,10 +30,10 @@ LeCarpApplicationStrategy >> applicationSettings [ ] { #category : #accessing } -LeCarpApplicationStrategy >> newCarpApplicationFor: aLeDatabase [ +LeCarpApplicationStrategy >> newCarpApplication [ ^ CarpApplication new initializeWith: - (self updatedSettings: LanguageLinkSettings carpDefaultSettings). + (self updatedSettings: LanguageLinkSettings carpDefaultSettings) ]