Add coder
This commit is contained in:
@@ -103,14 +103,14 @@
|
|||||||
"__type" : "time",
|
"__type" : "time",
|
||||||
"time" : {
|
"time" : {
|
||||||
"__type" : "dateAndTime",
|
"__type" : "dateAndTime",
|
||||||
"dateAndTimeString" : "2022-04-17T19:36:14.725535+02:00"
|
"dateAndTimeString" : "2022-06-13T22:57:31.662829+02:00"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"uid" : {
|
"uid" : {
|
||||||
"__type" : "uid",
|
"__type" : "uid",
|
||||||
"uidString" : "yC3J0D6ZDQCd0ZgmDqn2mw=="
|
"uidString" : "yC3J0D6ZDQCd0ZgmDqn2mw=="
|
||||||
},
|
},
|
||||||
"code" : "'Example' asCarpModule\r\taddExpression: (CarpStaticFunction\r\t\t\t named: 'example' asCarpSymbol\r\t\t\t withArguments: { \r\t\t\t\t\t 'x' asCarpSymbol.\r\t\t\t\t\t 'y' asCarpSymbol }\r\t\t\t andBody: (CarpCall function: '+' asCarpSymbol arguments: { \r\t\t\t\t\t\t\t 'x' asCarpSymbol.\r\t\t\t\t\t\t\t 'y' asCarpSymbol }));\r\taddExpression: (CarpDynamicVariable\r\t\t\t named: 'dyn-example' asCarpSymbol\r\t\t\t binding: 1 asCarpInteger);\r\ttoCarp"
|
"code" : "'Example' asCarpModule\r\taddExpression: (CarpStaticFunction\r\t\t\t named: 'example' asCarpSymbol\r\t\t\t withArguments: { \r\t\t\t\t\t 'x' asCarpSymbol.\r\t\t\t\t\t 'y' asCarpSymbol }\r\t\t\t andBody: {}'+' asCarpSymbol arguments: { \r\t\t\t\t\t\t\t 'x' asCarpSymbol.\r\t\t\t\t\t\t\t 'y' asCarpSymbol }));\r\taddExpression: (CarpDynamicVariable\r\t\t\t named: 'dyn-example' asCarpSymbol\r\t\t\t binding: 1 asCarpInteger);\r\ttoCarp"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type" : "textSnippet",
|
"__type" : "textSnippet",
|
||||||
@@ -248,7 +248,7 @@
|
|||||||
"__type" : "time",
|
"__type" : "time",
|
||||||
"time" : {
|
"time" : {
|
||||||
"__type" : "dateAndTime",
|
"__type" : "dateAndTime",
|
||||||
"dateAndTimeString" : "2022-04-17T19:40:10.759445+02:00"
|
"dateAndTimeString" : "2022-04-17T19:40:21.249005+02:00"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"uid" : {
|
"uid" : {
|
||||||
@@ -258,7 +258,7 @@
|
|||||||
"paragraphStyle" : {
|
"paragraphStyle" : {
|
||||||
"__type" : "textStyle"
|
"__type" : "textStyle"
|
||||||
},
|
},
|
||||||
"string" : "In the next chapter, we will use this code generator in our newly created coder"
|
"string" : "In the next chapter named [[A coder of one’s own]], we will use this code generator in our newly created coder."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@@ -103,14 +103,14 @@
|
|||||||
"__type" : "time",
|
"__type" : "time",
|
||||||
"time" : {
|
"time" : {
|
||||||
"__type" : "dateAndTime",
|
"__type" : "dateAndTime",
|
||||||
"dateAndTimeString" : "2022-04-17T19:36:14.725535+02:00"
|
"dateAndTimeString" : "2022-06-13T22:57:42.883096+02:00"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"uid" : {
|
"uid" : {
|
||||||
"__type" : "uid",
|
"__type" : "uid",
|
||||||
"uidString" : "yC3J0D6ZDQCd0ZgmDqn2mw=="
|
"uidString" : "yC3J0D6ZDQCd0ZgmDqn2mw=="
|
||||||
},
|
},
|
||||||
"code" : "'Example' asCarpModule\r\taddExpression: (CarpStaticFunction\r\t\t\t named: 'example' asCarpSymbol\r\t\t\t withArguments: { \r\t\t\t\t\t 'x' asCarpSymbol.\r\t\t\t\t\t 'y' asCarpSymbol }\r\t\t\t andBody: (CarpCall function: '+' asCarpSymbol arguments: { \r\t\t\t\t\t\t\t 'x' asCarpSymbol.\r\t\t\t\t\t\t\t 'y' asCarpSymbol }));\r\taddExpression: (CarpDynamicVariable\r\t\t\t named: 'dyn-example' asCarpSymbol\r\t\t\t binding: 1 asCarpInteger);\r\ttoCarp"
|
"code" : "'Example' asCarpModule\r\taddExpression: (CarpStaticFunction\r\t\t\t named: 'example' asCarpSymbol\r\t\t\t withArguments: { \r\t\t\t\t\t 'x' asCarpSymbol.\r\t\t\t\t\t 'y' asCarpSymbol }\r\t\t\t andBody: {'+' asCarpSymbol .\r\t\t\t\t\t\t\t 'x' asCarpSymbol.\r\t\t\t\t\t\t\t 'y' asCarpSymbol } asCarpCall);\r\taddExpression: (CarpDynamicVariable\r\t\t\t named: 'dyn-example' asCarpSymbol\r\t\t\t binding: 1 asCarpInteger);\r\ttoCarp"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type" : "textSnippet",
|
"__type" : "textSnippet",
|
||||||
|
@@ -13,6 +13,11 @@ CarpCharacterNode >> acceptVisitor: anExpressionVisitor [
|
|||||||
^ anExpressionVisitor visitCharacter: self
|
^ anExpressionVisitor visitCharacter: self
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpCharacterNode >> intoModel [
|
||||||
|
^ CarpCharacter character: self value source asCharacter
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
CarpCharacterNode >> toPharo [
|
CarpCharacterNode >> toPharo [
|
||||||
^ value source asCharacter
|
^ value source asCharacter
|
||||||
|
@@ -13,6 +13,11 @@ CarpNumberNode >> acceptVisitor: anExpressionVisitor [
|
|||||||
^ anExpressionVisitor visitNumber: self
|
^ anExpressionVisitor visitNumber: self
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpNumberNode >> intoModel [
|
||||||
|
^ CarpDouble number: self value source asNumber
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
CarpNumberNode >> toPharo [
|
CarpNumberNode >> toPharo [
|
||||||
^ value source asInteger
|
^ value source asInteger
|
||||||
|
@@ -39,6 +39,12 @@ CarpStartNode >> initialize [
|
|||||||
expressions := OrderedCollection new: 2.
|
expressions := OrderedCollection new: 2.
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpStartNode >> intoModel [
|
||||||
|
self assert: self expressions size = 1.
|
||||||
|
^ self expressions first intoModel
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
CarpStartNode >> toPharo [
|
CarpStartNode >> toPharo [
|
||||||
^ expressions collect: #toPharo
|
^ expressions collect: #toPharo
|
||||||
|
@@ -13,6 +13,11 @@ CarpStringNode >> acceptVisitor: anExpressionVisitor [
|
|||||||
^ anExpressionVisitor visitString: self
|
^ anExpressionVisitor visitString: self
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpStringNode >> intoModel [
|
||||||
|
^ CarpStringExpression contents: self value source
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
CarpStringNode >> toPharo [
|
CarpStringNode >> toPharo [
|
||||||
^ value source
|
^ value source
|
||||||
|
@@ -13,6 +13,11 @@ CarpVariableNode >> acceptVisitor: anExpressionVisitor [
|
|||||||
^ anExpressionVisitor visitVariable: self
|
^ anExpressionVisitor visitVariable: self
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpVariableNode >> intoModel [
|
||||||
|
^ CarpSymbol named: self value source
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
CarpVariableNode >> isDefinitionPredicate [
|
CarpVariableNode >> isDefinitionPredicate [
|
||||||
^ {'defdynamic'.
|
^ {'defdynamic'.
|
||||||
|
@@ -41,6 +41,11 @@ CarpArrayNode >> initialize [
|
|||||||
expressions := OrderedCollection new: 2.
|
expressions := OrderedCollection new: 2.
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpArrayNode >> intoModel [
|
||||||
|
^ CarpArray contents: (expressions collect: #intoModel)
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #generated }
|
{ #category : #generated }
|
||||||
CarpArrayNode >> leftBracket [
|
CarpArrayNode >> leftBracket [
|
||||||
|
|
||||||
|
@@ -26,6 +26,11 @@ CarpDerefNode >> derefGlyph: aSmaCCToken [
|
|||||||
derefGlyph := aSmaCCToken
|
derefGlyph := aSmaCCToken
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpDerefNode >> intoModel [
|
||||||
|
^ CarpCall function: 'deref' arguments: {value intoModel}
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #generated }
|
{ #category : #generated }
|
||||||
CarpDerefNode >> nodeVariables [
|
CarpDerefNode >> nodeVariables [
|
||||||
|
|
||||||
|
@@ -49,6 +49,12 @@ CarpListNode >> initialize [
|
|||||||
expressions := OrderedCollection new: 2.
|
expressions := OrderedCollection new: 2.
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpListNode >> intoModel [
|
||||||
|
^ CarpList
|
||||||
|
contents: (expressions collect: #intoModel)
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
CarpListNode >> isDefinition [
|
CarpListNode >> isDefinition [
|
||||||
^ self definitionVariable isNotNil
|
^ self definitionVariable isNotNil
|
||||||
|
@@ -27,6 +27,15 @@ CarpMapNode >> initialize [
|
|||||||
pairs := OrderedCollection new: 2.
|
pairs := OrderedCollection new: 2.
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpMapNode >> intoModel [
|
||||||
|
^ CarpMap
|
||||||
|
contents: (pairs
|
||||||
|
flatCollect: [ :p |
|
||||||
|
{p key intoModel.
|
||||||
|
p value intoModel} ])
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #generated }
|
{ #category : #generated }
|
||||||
CarpMapNode >> leftBrace [
|
CarpMapNode >> leftBrace [
|
||||||
|
|
||||||
|
@@ -14,6 +14,14 @@ CarpModuleOrTypeNode >> acceptVisitor: anExpressionVisitor [
|
|||||||
^ anExpressionVisitor visitModuleOrType: self
|
^ anExpressionVisitor visitModuleOrType: self
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpModuleOrTypeNode >> intoModel [
|
||||||
|
^ CarpSymbol
|
||||||
|
named: ('.'
|
||||||
|
join: {module source.
|
||||||
|
value source})
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #generated }
|
{ #category : #generated }
|
||||||
CarpModuleOrTypeNode >> module [
|
CarpModuleOrTypeNode >> module [
|
||||||
|
|
||||||
|
@@ -14,6 +14,11 @@ CarpRefCallNode >> acceptVisitor: anExpressionVisitor [
|
|||||||
^ anExpressionVisitor visitRefCall: self
|
^ anExpressionVisitor visitRefCall: self
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpRefCallNode >> intoModel [
|
||||||
|
^ CarpCall function: '~' arguments: {value intoModel}
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #generated }
|
{ #category : #generated }
|
||||||
CarpRefCallNode >> nodeVariables [
|
CarpRefCallNode >> nodeVariables [
|
||||||
|
|
||||||
|
@@ -14,6 +14,11 @@ CarpRefNode >> acceptVisitor: anExpressionVisitor [
|
|||||||
^ anExpressionVisitor visitRef: self
|
^ anExpressionVisitor visitRef: self
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpRefNode >> intoModel [
|
||||||
|
^ CarpCall function: 'ref' arguments: {value intoModel}
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #generated }
|
{ #category : #generated }
|
||||||
CarpRefNode >> nodeVariables [
|
CarpRefNode >> nodeVariables [
|
||||||
|
|
||||||
|
@@ -14,6 +14,11 @@ CarpUnquoteNode >> acceptVisitor: anExpressionVisitor [
|
|||||||
^ anExpressionVisitor visitUnquote: self
|
^ anExpressionVisitor visitUnquote: self
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpUnquoteNode >> intoModel [
|
||||||
|
^ CarpCall function: 'unquote' arguments: {value intoModel}
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
CarpUnquoteNode >> isQuoted [
|
CarpUnquoteNode >> isQuoted [
|
||||||
^ false
|
^ false
|
||||||
|
15
src/Carp/CarpArray.class.st
Normal file
15
src/Carp/CarpArray.class.st
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
Class {
|
||||||
|
#name : #CarpArray,
|
||||||
|
#superclass : #CarpSequence,
|
||||||
|
#category : #'Carp-IDE'
|
||||||
|
}
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpArray >> close [
|
||||||
|
^ ']'
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpArray >> open [
|
||||||
|
^ '['
|
||||||
|
]
|
28
src/Carp/CarpCharacter.class.st
Normal file
28
src/Carp/CarpCharacter.class.st
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
Class {
|
||||||
|
#name : #CarpCharacter,
|
||||||
|
#superclass : #CarpLiteral,
|
||||||
|
#instVars : [
|
||||||
|
'character'
|
||||||
|
],
|
||||||
|
#category : #'Carp-IDE'
|
||||||
|
}
|
||||||
|
|
||||||
|
{ #category : #'instance creation' }
|
||||||
|
CarpCharacter class >> character: aCharacter [
|
||||||
|
^ self new character: aCharacter
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpCharacter >> character [
|
||||||
|
^ character
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpCharacter >> character: aCharacter [
|
||||||
|
character := aCharacter
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpCharacter >> toCarp [
|
||||||
|
^ '\', self character
|
||||||
|
]
|
@@ -3,3 +3,8 @@ Class {
|
|||||||
#superclass : #CarpNumber,
|
#superclass : #CarpNumber,
|
||||||
#category : #'Carp-IDE'
|
#category : #'Carp-IDE'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpDouble >> suffix [
|
||||||
|
^ ''
|
||||||
|
]
|
||||||
|
@@ -12,6 +12,13 @@ CarpExpression >> asElement [
|
|||||||
^ (GtCarpCoderModel code: self toCarp) asElement
|
^ (GtCarpCoderModel code: self toCarp) asElement
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpExpression >> asElementWithModule: aModule [
|
||||||
|
^ ((GtCarpIDECoderModel code: self toCarp)
|
||||||
|
module: aModule;
|
||||||
|
expression: self) asElement
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
CarpExpression >> documentation [
|
CarpExpression >> documentation [
|
||||||
^ documentation ifNil: ['']
|
^ documentation ifNil: ['']
|
||||||
@@ -22,6 +29,24 @@ CarpExpression >> documentation: aString [
|
|||||||
documentation := aString
|
documentation := aString
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpExpression >> gtCoderFor: aView [
|
||||||
|
<gtView>
|
||||||
|
^ aView explicit
|
||||||
|
title: 'Code';
|
||||||
|
priority: 1;
|
||||||
|
stencil: [ self asElement ]
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpExpression >> gtTextFor: aView [
|
||||||
|
<gtView>
|
||||||
|
^ aView textEditor
|
||||||
|
title: 'String';
|
||||||
|
priority: 2;
|
||||||
|
text: [ self toCarp ]
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #converting }
|
{ #category : #converting }
|
||||||
CarpExpression >> toCarp [
|
CarpExpression >> toCarp [
|
||||||
^ self subclassResponsibility
|
^ self subclassResponsibility
|
||||||
|
15
src/Carp/CarpList.class.st
Normal file
15
src/Carp/CarpList.class.st
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
Class {
|
||||||
|
#name : #CarpList,
|
||||||
|
#superclass : #CarpSequence,
|
||||||
|
#category : #'Carp-IDE'
|
||||||
|
}
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpList >> close [
|
||||||
|
^ ')'
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpList >> open [
|
||||||
|
^ '('
|
||||||
|
]
|
15
src/Carp/CarpMap.class.st
Normal file
15
src/Carp/CarpMap.class.st
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
Class {
|
||||||
|
#name : #CarpMap,
|
||||||
|
#superclass : #CarpSequence,
|
||||||
|
#category : #'Carp-IDE'
|
||||||
|
}
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpMap >> close [
|
||||||
|
^ '}'
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpMap >> open [
|
||||||
|
^ '{'
|
||||||
|
]
|
@@ -67,8 +67,7 @@ CarpModule >> carpCoderCommentsFor: aView [
|
|||||||
{ #category : #coders }
|
{ #category : #coders }
|
||||||
CarpModule >> carpCoderStreamingMethodsFor: aView context: aPhlowContext [
|
CarpModule >> carpCoderStreamingMethodsFor: aView context: aPhlowContext [
|
||||||
<gtModuleView>
|
<gtModuleView>
|
||||||
| aMethodsCoder aMethodsCoderViewModel aNewMethodCoderHolder |
|
| aMethodsCoder aMethodsCoderViewModel aNewMethodCoderHolder coderElement |
|
||||||
|
|
||||||
aNewMethodCoderHolder := ValueHolder new.
|
aNewMethodCoderHolder := ValueHolder new.
|
||||||
|
|
||||||
^ aView explicit
|
^ aView explicit
|
||||||
@@ -76,46 +75,35 @@ CarpModule >> carpCoderStreamingMethodsFor: aView context: aPhlowContext [
|
|||||||
title: 'Methods';
|
title: 'Methods';
|
||||||
disableAsync;
|
disableAsync;
|
||||||
actionDropdownButtonDo: [ :aDrodownAction |
|
actionDropdownButtonDo: [ :aDrodownAction |
|
||||||
aDrodownAction dropdown
|
aDrodownAction dropdown
|
||||||
icon: BrGlamorousVectorIcons add;
|
icon: BrGlamorousVectorIcons add;
|
||||||
tooltip: 'Add new expression';
|
tooltip: 'Add new function';
|
||||||
content: [ :aButton |
|
content: [ :aButton |
|
||||||
| aNewMethodCoder aNewMethodCoderViewModel aHandler |
|
| aNewMethodCoder aNewMethodCoderViewModel aHandler |
|
||||||
|
|
||||||
aNewMethodCoderHolder contents
|
aNewMethodCoderHolder contents
|
||||||
ifNotNil: [ :aContents |
|
ifNotNil: [ :aContents | aNewMethodCoderViewModel := aContents ]
|
||||||
aNewMethodCoderViewModel := aContents ]
|
ifNil: [ aNewMethodCoder := GtCarpNewFunctionCoderModel new
|
||||||
ifNil: [
|
module: self;
|
||||||
|
onSave: [ aButton fireEvent: BrDropdownHideWish new.
|
||||||
aNewMethodCoder := GtCarpCoderModel new.
|
coderElement initializeForModule ].
|
||||||
|
|
||||||
aNewMethodCoderViewModel := aNewMethodCoder asCoderViewModel.
|
aNewMethodCoderViewModel := aNewMethodCoder asCoderViewModel.
|
||||||
aNewMethodCoderViewModel
|
aNewMethodCoderViewModel
|
||||||
withoutHeader;
|
withoutHeader;
|
||||||
expanded: true;
|
expanded: true;
|
||||||
focused: true;
|
focused: true;
|
||||||
moveCursorAtEnd.
|
moveCursorAtEnd.
|
||||||
|
|
||||||
aNewMethodCoderHolder contents: aNewMethodCoderViewModel.
|
|
||||||
|
|
||||||
aHandler := GtPharoNewMethodCodeSavedHandler new
|
aNewMethodCoderHolder contents: aNewMethodCoderViewModel ].
|
||||||
methodsCoderViewModel: aMethodsCoderViewModel;
|
|
||||||
element: aButton;
|
|
||||||
methodCoderHolder: aNewMethodCoderHolder.
|
|
||||||
|
|
||||||
aNewMethodCoderViewModel weak
|
|
||||||
when: GtMethodCoderSaved
|
|
||||||
send: #onAnnouncement:
|
|
||||||
to: aHandler ].
|
|
||||||
|
|
||||||
(GtExpandedOnlyCoderElement new coderViewModel: aNewMethodCoderViewModel)
|
(GtExpandedOnlyCoderElement new coderViewModel: aNewMethodCoderViewModel)
|
||||||
hExact: 300;
|
hExact: 300;
|
||||||
vFitContent;
|
vFitContent;
|
||||||
background: Color white;
|
background: Color white;
|
||||||
padding: (BlInsets all: 5);
|
padding: (BlInsets all: 5);
|
||||||
addAptitude: BrGlamorousFocusableShadowAptitude new ];
|
addAptitude: BrGlamorousFocusableShadowAptitude new ];
|
||||||
name: #'button--add-new-expression'];
|
name: #'button--add-new-expression' ];
|
||||||
stencil: [ CarpStreamingMethodsCoderElement forModule: self ]
|
stencil: [ coderElement := CarpStreamingMethodsCoderElement forModule: self ]
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #coders }
|
{ #category : #coders }
|
||||||
@@ -194,6 +182,11 @@ CarpModule >> name: aString [
|
|||||||
name := aString
|
name := aString
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpModule >> removeExpression: anExpression [
|
||||||
|
expressions remove: anExpression
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
CarpModule >> removeUse: aString [
|
CarpModule >> removeUse: aString [
|
||||||
uses remove: aString
|
uses remove: aString
|
||||||
|
@@ -19,6 +19,15 @@ CarpModuleCoder >> asCoderViewModel [
|
|||||||
^ CarpModuleCoderViewModel new coder: self
|
^ CarpModuleCoderViewModel new coder: self
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpModuleCoder >> coderName [
|
||||||
|
"Return a short textual name of the coder.
|
||||||
|
For example, class coder would return a class name, package coder returns a package name."
|
||||||
|
<return: #String>
|
||||||
|
|
||||||
|
^ self module name
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #'instance creation' }
|
{ #category : #'instance creation' }
|
||||||
CarpModuleCoder >> module [
|
CarpModuleCoder >> module [
|
||||||
^ module
|
^ module
|
||||||
|
@@ -49,5 +49,5 @@ CarpNamedFunction >> toCarp [
|
|||||||
aStream << '(' << self bindingName << ' ' << self name toCarp
|
aStream << '(' << self bindingName << ' ' << self name toCarp
|
||||||
<< ' ['.
|
<< ' ['.
|
||||||
arguments do: [ :anArgument | aStream << anArgument toCarp << ' ' ].
|
arguments do: [ :anArgument | aStream << anArgument toCarp << ' ' ].
|
||||||
aStream << '] ' << self body toCarp << ')' ]
|
aStream ensureNoSpace << '] ' << self body toCarp << ')' ]
|
||||||
]
|
]
|
||||||
|
10
src/Carp/CarpPattern.class.st
Normal file
10
src/Carp/CarpPattern.class.st
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
Class {
|
||||||
|
#name : #CarpPattern,
|
||||||
|
#superclass : #CarpStringExpression,
|
||||||
|
#category : #'Carp-IDE'
|
||||||
|
}
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpPattern >> toCarp [
|
||||||
|
^ '#', super toCarp
|
||||||
|
]
|
38
src/Carp/CarpSequence.class.st
Normal file
38
src/Carp/CarpSequence.class.st
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
Class {
|
||||||
|
#name : #CarpSequence,
|
||||||
|
#superclass : #CarpLiteral,
|
||||||
|
#instVars : [
|
||||||
|
'elements',
|
||||||
|
'contents'
|
||||||
|
],
|
||||||
|
#category : #'Carp-IDE'
|
||||||
|
}
|
||||||
|
|
||||||
|
{ #category : #'instance creation' }
|
||||||
|
CarpSequence class >> contents: aCollection [
|
||||||
|
^ self new contents: aCollection
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpSequence >> close [
|
||||||
|
^ self subclassResponsibility
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpSequence >> contents: aCollection [
|
||||||
|
contents := aCollection
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpSequence >> open [
|
||||||
|
^ self subclassResponsibility
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpSequence >> toCarp [
|
||||||
|
|
||||||
|
^ String streamContents: [ :aStream |
|
||||||
|
aStream << self open.
|
||||||
|
contents do: [ :anArgument | aStream << anArgument toCarp << ' ' ].
|
||||||
|
aStream ensureNoSpace << self close]
|
||||||
|
]
|
@@ -26,7 +26,7 @@ CarpStreamingMethodsCoderElement >> initialize [
|
|||||||
itemType: [ :anItemTypeFactory :anItemObject |
|
itemType: [ :anItemTypeFactory :anItemObject |
|
||||||
anItemObject ];
|
anItemObject ];
|
||||||
itemStencil: [ :anItem |
|
itemStencil: [ :anItem |
|
||||||
anItem asElement id: GtSourceCoderId ];
|
(anItem asElementWithModule: module) id: GtSourceCoderId ];
|
||||||
itemsProvider:
|
itemsProvider:
|
||||||
(BrListStreamItemsProvider new stream: AsyncEmptyStream new).
|
(BrListStreamItemsProvider new stream: AsyncEmptyStream new).
|
||||||
|
|
||||||
|
@@ -33,7 +33,9 @@ GtCarpCoderModel >> bindAndExecute: sourceString [
|
|||||||
| res trimmedSource ast varNames lastStatement carpSource |
|
| res trimmedSource ast varNames lastStatement carpSource |
|
||||||
trimmedSource := SmaCCString on: sourceString trimRight.
|
trimmedSource := SmaCCString on: sourceString trimRight.
|
||||||
ast := CarpParser parse: trimmedSource. "The variables to be returned are names that are in pharoBindings"
|
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"
|
varNames := pharoBindings
|
||||||
|
ifNil: [ Set new ]
|
||||||
|
ifNotNil: [ pharoBindings bindingNames asSet ]. "Assign the final statement to snippetResult"
|
||||||
lastStatement := ast expressions last.
|
lastStatement := ast expressions last.
|
||||||
trimmedSource
|
trimmedSource
|
||||||
insert: '(defdynamic snippetResult '
|
insert: '(defdynamic snippetResult '
|
||||||
@@ -46,10 +48,10 @@ GtCarpCoderModel >> bindAndExecute: sourceString [
|
|||||||
res := self bindAndExecuteRaw: sourceString.
|
res := self bindAndExecuteRaw: sourceString.
|
||||||
|
|
||||||
(res at: #result) = 'success' ifTrue: [ ^ CarpExecutionResult from: res ].
|
(res at: #result) = 'success' ifTrue: [ ^ CarpExecutionResult from: res ].
|
||||||
exception := (PharoLinkRemoteError new
|
exception := PharoLinkRemoteError new
|
||||||
application: application;
|
application: application;
|
||||||
command: commandFactory command;
|
command: commandFactory command;
|
||||||
trace: (res at: #value)).
|
trace: (res at: #value).
|
||||||
exception signal
|
exception signal
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -87,56 +89,58 @@ GtCarpCoderModel >> initializeAddOns: addOns [
|
|||||||
addOns
|
addOns
|
||||||
addStyler: (GtCoderAstSmaCCParserStyler new smaccStyler: CarpParser gtStyler).
|
addStyler: (GtCoderAstSmaCCParserStyler new smaccStyler: CarpParser gtStyler).
|
||||||
|
|
||||||
addOns
|
application
|
||||||
addMainAction: 'Evaluate' translated
|
ifNotNil: [ addOns
|
||||||
icon: BrGlamorousVectorIcons play
|
addMainAction: 'Evaluate' translated
|
||||||
action: [ :aCoderUIModel :anElement |
|
icon: BrGlamorousVectorIcons play
|
||||||
GtCoderCodeExecutor doIt
|
action: [ :aCoderUIModel :anElement |
|
||||||
coderViewModel: aCoderUIModel;
|
GtCoderCodeExecutor doIt
|
||||||
element: anElement;
|
coderViewModel: aCoderUIModel;
|
||||||
execute ]
|
element: anElement;
|
||||||
id: GtSourceCoderDoItActionId.
|
execute ]
|
||||||
addOns
|
id: GtSourceCoderDoItActionId.
|
||||||
addMainAction: 'Inspect' translated
|
addOns
|
||||||
icon: BrGlamorousVectorIcons playinspect
|
addMainAction: 'Inspect' translated
|
||||||
action: [ :aCoderUIModel :anElement |
|
icon: BrGlamorousVectorIcons playinspect
|
||||||
GtCoderCodeExecutor doItAndGo
|
action: [ :aCoderUIModel :anElement |
|
||||||
coderViewModel: aCoderUIModel;
|
GtCoderCodeExecutor doItAndGo
|
||||||
element: anElement;
|
coderViewModel: aCoderUIModel;
|
||||||
execute ]
|
element: anElement;
|
||||||
id: GtSourceCoderDoItAndGoActionId.
|
execute ]
|
||||||
addOns
|
id: GtSourceCoderDoItAndGoActionId.
|
||||||
addMainAction: 'Expand Macros' translated
|
addOns
|
||||||
icon: BrGlamorousVectorIcons repair
|
addMainAction: 'Expand Macros' translated
|
||||||
action: [ :aCoderUIModel :anElement |
|
icon: BrGlamorousVectorIcons repair
|
||||||
| source |
|
action: [ :aCoderUIModel :anElement |
|
||||||
source := '(expand ''' , sourceCode currentSourceText value text , ')'.
|
| source |
|
||||||
anElement phlow
|
source := '(expand ''' , sourceCode currentSourceText value text , ')'.
|
||||||
spawnObject: ((self bindAndExecute: source) parse view: #gtSourceFor:) ]
|
anElement phlow
|
||||||
id: #'source-coder--macro-expand-action'.
|
spawnObject: ((self bindAndExecute: source) parse view: #gtSourceFor:) ]
|
||||||
addOns
|
id: #'source-coder--macro-expand-action'.
|
||||||
addMainAction: 'Build and Run' translated
|
addOns
|
||||||
icon: BrGlamorousVectorIcons refresh
|
addMainAction: 'Build and Run' translated
|
||||||
action: [ :aCoderUIModel :anElement |
|
icon: BrGlamorousVectorIcons refresh
|
||||||
| source |
|
action: [ :aCoderUIModel :anElement |
|
||||||
source := '' , sourceCode currentSourceText value text , '(build) (run)'.
|
| source |
|
||||||
anElement phlow
|
source := '' , sourceCode currentSourceText value text , '(build) (run)'.
|
||||||
spawnObject: (CarpCliOutput text: ((self bindAndExecuteRaw: source) at: 'value')) ]
|
anElement phlow
|
||||||
id: #'source-coder--build-and-run-action'.
|
spawnObject: (CarpCliOutput text: ((self bindAndExecuteRaw: source) at: 'value')) ]
|
||||||
addOns
|
id: #'source-coder--build-and-run-action'.
|
||||||
addMainAction: 'Infer Type' translated
|
addOns
|
||||||
icon: BrGlamorousVectorIcons inspect
|
addMainAction: 'Infer Type' translated
|
||||||
action: [ :aCoderUIModel :anElement | self inspectTypeSpawningOn: anElement phlow]
|
icon: BrGlamorousVectorIcons inspect
|
||||||
id: #'source-coder--type-infer-action'
|
action: [ :aCoderUIModel :anElement | self inspectTypeSpawningOn: anElement phlow ]
|
||||||
|
id: #'source-coder--type-infer-action' ]
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
GtCarpCoderModel >> initializeShortcuts: addOns [
|
GtCarpCoderModel >> initializeShortcuts: addOns [
|
||||||
super initializeShortcuts: addOns.
|
super initializeShortcuts: addOns.
|
||||||
|
|
||||||
addOns
|
application
|
||||||
addShortcut: GtSourceCoderDoItShortcut new;
|
ifNotNil: [ addOns
|
||||||
addShortcut: GtSourceCoderDoItAndInspectShortcut new
|
addShortcut: GtSourceCoderDoItShortcut new;
|
||||||
|
addShortcut: GtSourceCoderDoItAndInspectShortcut new ]
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
|
42
src/Carp/GtCarpIDECoderModel.class.st
Normal file
42
src/Carp/GtCarpIDECoderModel.class.st
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
Class {
|
||||||
|
#name : #GtCarpIDECoderModel,
|
||||||
|
#superclass : #GtCarpNewFunctionCoderModel,
|
||||||
|
#instVars : [
|
||||||
|
'expression'
|
||||||
|
],
|
||||||
|
#category : #'Carp-Coder'
|
||||||
|
}
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
GtCarpIDECoderModel >> expression [
|
||||||
|
^ expression
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
GtCarpIDECoderModel >> expression: anExpression [
|
||||||
|
expression := anExpression
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
GtCarpIDECoderModel >> initializeAddOns: addOns [
|
||||||
|
super initializeAddOns: addOns.
|
||||||
|
|
||||||
|
addOns
|
||||||
|
addMainAction: 'Remove' translated
|
||||||
|
icon: BrGlamorousVectorIcons remove
|
||||||
|
action: [ :aCoderUIModel :anElement | self remove ]
|
||||||
|
id: GtMethodCoderSaveActionId
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
GtCarpIDECoderModel >> remove [
|
||||||
|
^ module removeExpression: self expression
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
GtCarpIDECoderModel >> save [
|
||||||
|
module removeExpression: expression.
|
||||||
|
module
|
||||||
|
addExpression: (CarpParser parse: sourceCode availableSource text) intoModel.
|
||||||
|
onSave ifNotNil: [ onSave value ]
|
||||||
|
]
|
37
src/Carp/GtCarpNewFunctionCoderModel.class.st
Normal file
37
src/Carp/GtCarpNewFunctionCoderModel.class.st
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
Class {
|
||||||
|
#name : #GtCarpNewFunctionCoderModel,
|
||||||
|
#superclass : #GtCarpCoderModel,
|
||||||
|
#instVars : [
|
||||||
|
'module',
|
||||||
|
'onSave'
|
||||||
|
],
|
||||||
|
#category : #'Carp-Coder'
|
||||||
|
}
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
GtCarpNewFunctionCoderModel >> initializeAddOns: addOns [
|
||||||
|
super initializeAddOns: addOns.
|
||||||
|
|
||||||
|
addOns
|
||||||
|
addMainAction: 'Save' translated
|
||||||
|
icon: BrGlamorousVectorIcons accept
|
||||||
|
action: [ :aCoderUIModel :anElement |
|
||||||
|
self save ]
|
||||||
|
id: GtMethodCoderSaveActionId.
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #coders }
|
||||||
|
GtCarpNewFunctionCoderModel >> module: aModule [
|
||||||
|
module := aModule
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
GtCarpNewFunctionCoderModel >> onSave: aBlock [
|
||||||
|
onSave := aBlock
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
GtCarpNewFunctionCoderModel >> save [
|
||||||
|
module addExpression: (CarpParser parse: sourceCode currentSourceText value text) intoModel.
|
||||||
|
onSave ifNotNil: [ onSave value ]
|
||||||
|
]
|
@@ -1,11 +1,11 @@
|
|||||||
Extension { #name : #ByteString }
|
Extension { #name : #String }
|
||||||
|
|
||||||
{ #category : #'*Carp' }
|
{ #category : #'*Carp' }
|
||||||
ByteString >> asCarpModule [
|
String >> asCarpModule [
|
||||||
^ CarpModule named: self
|
^ CarpModule named: self
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'*Carp' }
|
{ #category : #'*Carp' }
|
||||||
ByteString >> asCarpSymbol [
|
String >> asCarpSymbol [
|
||||||
^ CarpSymbol named: self
|
^ CarpSymbol named: self
|
||||||
]
|
]
|
Reference in New Issue
Block a user