Compare commits
10 Commits
ea5d318b62
...
master
Author | SHA1 | Date | |
---|---|---|---|
235910b863 | |||
33cb150cf0 | |||
66fe79f2bf | |||
d75b000ad1 | |||
22d00d0360 | |||
8da76b5a3f | |||
ee48ec29f0 | |||
6efcea643f | |||
7fbab0e2a0 | |||
ee5c032d90 |
@@ -8,6 +8,7 @@ class CarpProc:
|
|||||||
self.proc = diplomat.Diplomat('carp')
|
self.proc = diplomat.Diplomat('carp')
|
||||||
self._version_info = None
|
self._version_info = None
|
||||||
self.adornment_re = re.compile(".\[33m.*?\[0m")
|
self.adornment_re = re.compile(".\[33m.*?\[0m")
|
||||||
|
self.warning_re = re.compile("\[WARNING\] (.*)\n?")
|
||||||
|
|
||||||
def wait_for_boot(self):
|
def wait_for_boot(self):
|
||||||
while not self.proc.output():
|
while not self.proc.output():
|
||||||
@@ -23,11 +24,13 @@ class CarpProc:
|
|||||||
while self.proc.output() == old_output:
|
while self.proc.output() == old_output:
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
res = self.adornment_re.sub("", self.proc.output()[len(old_output):]).strip()
|
res = self.adornment_re.sub("", self.proc.output()[len(old_output):]).strip()
|
||||||
|
warnings = self.warning_re.findall(res)
|
||||||
|
res = self.warning_re.sub("", res)
|
||||||
if res.startswith("=> "):
|
if res.startswith("=> "):
|
||||||
return {'result': 'success', 'value': res[3:]}
|
return {'result': 'success', 'value': res[3:], 'warnings': warnings}
|
||||||
if not res:
|
if not res:
|
||||||
return {'result': 'success', 'value': '()'}
|
return {'result': 'success', 'value': '()', 'warnings': warnings}
|
||||||
return {'result': 'error', 'value': res}
|
return {'result': 'error', 'value': res, 'warnings': warnings}
|
||||||
|
|
||||||
def evaluate(self, statements):
|
def evaluate(self, statements):
|
||||||
assert self.proc.is_running(), "carp process has died"
|
assert self.proc.is_running(), "carp process has died"
|
||||||
|
@@ -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,6 @@ BaselineOfCarp >> baseline: spec [
|
|||||||
baseline: 'GToolkit4SmaCC'
|
baseline: 'GToolkit4SmaCC'
|
||||||
with: [ spec repository: 'github://feenkcom/gt4smacc:main/src' ].
|
with: [ spec repository: 'github://feenkcom/gt4smacc:main/src' ].
|
||||||
spec package: 'Carp' with: [ spec requires: #('GToolkit4SmaCC') ].
|
spec package: 'Carp' with: [ spec requires: #('GToolkit4SmaCC') ].
|
||||||
spec package: 'Carp-Parser' with: [ spec requires: #('GToolkit4SmaCC') ].
|
spec package: 'Carp-AST' with: [ spec requires: #('GToolkit4SmaCC') ].
|
||||||
spec package: 'Carp-AST' with: [ spec requires: #('GToolkit4SmaCC') ] ]
|
spec package: 'Carp-Parser' with: [ spec requires: #('GToolkit4SmaCC') ] ]
|
||||||
]
|
]
|
||||||
|
@@ -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
|
||||||
|
@@ -16,6 +16,16 @@ CarpExpressionNode >> acceptVisitor: anExpressionVisitor [
|
|||||||
^ anExpressionVisitor visitExpression: self
|
^ anExpressionVisitor visitExpression: self
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpExpressionNode >> isDefinition [
|
||||||
|
^ false
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpExpressionNode >> isDefinitionPredicate [
|
||||||
|
^ false
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
CarpExpressionNode >> isQuoted [
|
CarpExpressionNode >> isQuoted [
|
||||||
^ parent ifNil: [ false ] ifNotNil: [ parent isQuoted ]
|
^ parent ifNil: [ false ] ifNotNil: [ parent isQuoted ]
|
||||||
|
@@ -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,20 @@ CarpVariableNode >> acceptVisitor: anExpressionVisitor [
|
|||||||
^ anExpressionVisitor visitVariable: self
|
^ anExpressionVisitor visitVariable: self
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpVariableNode >> intoModel [
|
||||||
|
^ CarpSymbol named: self value source
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpVariableNode >> isDefinitionPredicate [
|
||||||
|
^ {'defdynamic'.
|
||||||
|
'defndynamic'.
|
||||||
|
'defmacro'.
|
||||||
|
'defn'.
|
||||||
|
'def'} includes: self value source
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
CarpVariableNode >> toPharo [
|
CarpVariableNode >> toPharo [
|
||||||
^ value source asSymbol
|
^ value source asSymbol
|
||||||
|
@@ -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 [
|
||||||
|
|
||||||
|
@@ -21,6 +21,14 @@ CarpListNode >> compositeNodeVariables [
|
|||||||
^ #( #expressions )
|
^ #( #expressions )
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpListNode >> definitionVariable [
|
||||||
|
^ (self expressions size > 1
|
||||||
|
and: [ self expressions first isDefinitionPredicate ])
|
||||||
|
ifTrue: [ self expressions second ]
|
||||||
|
ifFalse: [ nil ]
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #generated }
|
{ #category : #generated }
|
||||||
CarpListNode >> expressions [
|
CarpListNode >> expressions [
|
||||||
|
|
||||||
@@ -41,6 +49,27 @@ CarpListNode >> initialize [
|
|||||||
expressions := OrderedCollection new: 2.
|
expressions := OrderedCollection new: 2.
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpListNode >> 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 }
|
||||||
|
CarpListNode >> isDefinition [
|
||||||
|
^ self definitionVariable isNotNil
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #generated }
|
{ #category : #generated }
|
||||||
CarpListNode >> leftParen [
|
CarpListNode >> leftParen [
|
||||||
|
|
||||||
|
@@ -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
|
||||||
|
@@ -13,6 +13,11 @@ CarpApplication class >> start [
|
|||||||
^ self startWith: LanguageLinkSettings carpDefaultSettings.
|
^ self startWith: LanguageLinkSettings carpDefaultSettings.
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #'class initialization' }
|
||||||
|
CarpApplication class >> startUp: resuming [
|
||||||
|
resuming ifTrue: [ self stop ]
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
CarpApplication >> baseApplication [
|
CarpApplication >> baseApplication [
|
||||||
^ CarpApplication
|
^ CarpApplication
|
||||||
|
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 [
|
||||||
|
^ '['
|
||||||
|
]
|
@@ -7,6 +7,31 @@ Class {
|
|||||||
#category : #'Carp-IDE'
|
#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 }
|
{ #category : #accessing }
|
||||||
CarpBinding >> bindingName [
|
CarpBinding >> bindingName [
|
||||||
^ self subclassResponsibility
|
^ self subclassResponsibility
|
||||||
|
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
|
||||||
|
]
|
51
src/Carp/CarpCliOutput.class.st
Normal file
51
src/Carp/CarpCliOutput.class.st
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
Class {
|
||||||
|
#name : #CarpCliOutput,
|
||||||
|
#superclass : #Object,
|
||||||
|
#instVars : [
|
||||||
|
'text'
|
||||||
|
],
|
||||||
|
#category : #'Carp-Core'
|
||||||
|
}
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpCliOutput class >> text: aString [
|
||||||
|
^ self new text: aString
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpCliOutput >> gtExitCodeFor: aView [
|
||||||
|
<gtView>
|
||||||
|
^ aView forward
|
||||||
|
title: 'Exit Code';
|
||||||
|
priority: 2;
|
||||||
|
object: [ self text lines last asInteger ];
|
||||||
|
view: #gtLiveFor:
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpCliOutput >> gtOutputFor: aView [
|
||||||
|
<gtView>
|
||||||
|
^ aView textEditor
|
||||||
|
title: 'Output';
|
||||||
|
priority: 1;
|
||||||
|
text: [ Character lf join: (self text lines allButLast: 2) ]
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpCliOutput >> gtRawOutputFor: aView [
|
||||||
|
<gtView>
|
||||||
|
^ aView textEditor
|
||||||
|
title: 'Raw Output';
|
||||||
|
priority: 3;
|
||||||
|
text: [ self text ]
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpCliOutput >> text [
|
||||||
|
^ text
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpCliOutput >> text: aString [
|
||||||
|
text := aString
|
||||||
|
]
|
@@ -3,3 +3,8 @@ Class {
|
|||||||
#superclass : #CarpNumber,
|
#superclass : #CarpNumber,
|
||||||
#category : #'Carp-IDE'
|
#category : #'Carp-IDE'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpDouble >> suffix [
|
||||||
|
^ ''
|
||||||
|
]
|
||||||
|
68
src/Carp/CarpExecutionResult.class.st
Normal file
68
src/Carp/CarpExecutionResult.class.st
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
Class {
|
||||||
|
#name : #CarpExecutionResult,
|
||||||
|
#superclass : #Object,
|
||||||
|
#instVars : [
|
||||||
|
'value',
|
||||||
|
'warnings',
|
||||||
|
'view'
|
||||||
|
],
|
||||||
|
#category : #'Carp-Execution'
|
||||||
|
}
|
||||||
|
|
||||||
|
{ #category : #'instance creation' }
|
||||||
|
CarpExecutionResult class >> from: aCarpResult [
|
||||||
|
^ self new
|
||||||
|
value: (aCarpResult at: #value);
|
||||||
|
warnings: (aCarpResult at: #warnings)
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpExecutionResult >> gtValueFor: aView [
|
||||||
|
<gtView>
|
||||||
|
| v |
|
||||||
|
v := aView forward
|
||||||
|
title: 'Value';
|
||||||
|
priority: 1;
|
||||||
|
object: value.
|
||||||
|
view ifNotNil: [ v view: view ].
|
||||||
|
^ v
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpExecutionResult >> gtWarningsFor: aView [
|
||||||
|
<gtView>
|
||||||
|
^ aView list
|
||||||
|
title: 'Warnings';
|
||||||
|
priority: 2;
|
||||||
|
items: [ warnings ]
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpExecutionResult >> parse [
|
||||||
|
value := CarpParser parse: value
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpExecutionResult >> transformValue: aBlock [
|
||||||
|
value := aBlock value: value
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpExecutionResult >> value [
|
||||||
|
^ value
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpExecutionResult >> value: aValue [
|
||||||
|
value := aValue
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpExecutionResult >> view: aView [
|
||||||
|
view := aView
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpExecutionResult >> warnings: aCollection [
|
||||||
|
warnings := aCollection
|
||||||
|
]
|
@@ -12,6 +12,17 @@ CarpExpression >> asElement [
|
|||||||
^ (GtCarpCoderModel code: self toCarp) asElement
|
^ (GtCarpCoderModel code: self toCarp) asElement
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpExpression >> asElementWithModule: aModule [
|
||||||
|
| applicationStrategy |
|
||||||
|
applicationStrategy := LeCarpApplicationStrategy new.
|
||||||
|
^ (GtExpandableSourceCoderElement new
|
||||||
|
coderViewModel: ((GtCarpIDECoderModel code: self toCarp)
|
||||||
|
module: aModule;
|
||||||
|
carpLinkApplicationStrategy: applicationStrategy;
|
||||||
|
expression: self) asCoderViewModel) collapse
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
CarpExpression >> documentation [
|
CarpExpression >> documentation [
|
||||||
^ documentation ifNil: ['']
|
^ documentation ifNil: ['']
|
||||||
@@ -22,6 +33,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
|
||||||
@@ -78,16 +77,16 @@ CarpModule >> carpCoderStreamingMethodsFor: aView context: aPhlowContext [
|
|||||||
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;
|
||||||
|
carpLinkApplicationStrategy: LeCarpApplicationStrategy new;
|
||||||
aNewMethodCoder := GtCarpCoderModel new.
|
onSave: [ aButton fireEvent: BrDropdownHideWish new.
|
||||||
|
coderElement initializeForModule ].
|
||||||
|
|
||||||
aNewMethodCoderViewModel := aNewMethodCoder asCoderViewModel.
|
aNewMethodCoderViewModel := aNewMethodCoder asCoderViewModel.
|
||||||
aNewMethodCoderViewModel
|
aNewMethodCoderViewModel
|
||||||
@@ -96,17 +95,7 @@ CarpModule >> carpCoderStreamingMethodsFor: aView context: aPhlowContext [
|
|||||||
focused: true;
|
focused: true;
|
||||||
moveCursorAtEnd.
|
moveCursorAtEnd.
|
||||||
|
|
||||||
aNewMethodCoderHolder contents: aNewMethodCoderViewModel.
|
aNewMethodCoderHolder contents: aNewMethodCoderViewModel ].
|
||||||
|
|
||||||
aHandler := GtPharoNewMethodCodeSavedHandler new
|
|
||||||
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;
|
||||||
@@ -114,8 +103,8 @@ CarpModule >> carpCoderStreamingMethodsFor: aView context: aPhlowContext [
|
|||||||
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 +183,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
|
||||||
|
@@ -12,6 +12,17 @@ Class {
|
|||||||
#category : #'Carp-Coder'
|
#category : #'Carp-Coder'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpModuleCoderElement >> build [
|
||||||
|
| application commandFactory |
|
||||||
|
application := CarpApplication start.
|
||||||
|
commandFactory := application newCommandFactory.
|
||||||
|
|
||||||
|
^ commandFactory
|
||||||
|
<< self module toCarp;
|
||||||
|
sendAndWait
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
CarpModuleCoderElement >> buildContentPane [
|
CarpModuleCoderElement >> buildContentPane [
|
||||||
|
|
||||||
@@ -91,6 +102,13 @@ CarpModuleCoderElement >> buildModuleLabel [
|
|||||||
action: [ :aButton |
|
action: [ :aButton |
|
||||||
aButton phlow spawnObject: self module toCarp ]).
|
aButton phlow spawnObject: self module toCarp ]).
|
||||||
|
|
||||||
|
aContainer addChild: (BrButton new
|
||||||
|
aptitude: BrGlamorousButtonWithIconAptitude;
|
||||||
|
icon: BrGlamorousVectorIcons refresh;
|
||||||
|
beSmallSize;
|
||||||
|
label: 'Build';
|
||||||
|
action: [ self build ]).
|
||||||
|
|
||||||
^ aContainer
|
^ aContainer
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -133,7 +151,8 @@ CarpModuleCoderElement >> coderViewModel: aCarpCoderViewModel [
|
|||||||
|
|
||||||
container ifNotNil: #removeFromParent.
|
container ifNotNil: #removeFromParent.
|
||||||
container := self buildContentPane.
|
container := self buildContentPane.
|
||||||
self addChildFirst: container
|
self addChildFirst: container.
|
||||||
|
self build
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
|
@@ -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
|
||||||
|
]
|
@@ -19,11 +19,20 @@ CarpPostMortemDebugger >> exception: anException [
|
|||||||
exception := anException
|
exception := anException
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpPostMortemDebugger >> findTrace: inputLines [
|
||||||
|
| lines |
|
||||||
|
lines := inputLines asOrderedCollection.
|
||||||
|
[ lines isNotEmpty and: [ (lines first = 'Traceback:') not ] ]
|
||||||
|
whileTrue: [ lines removeFirst ].
|
||||||
|
^ lines
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
CarpPostMortemDebugger >> initialize [
|
CarpPostMortemDebugger >> initialize [
|
||||||
|
|
||||||
super initialize.
|
super initialize.
|
||||||
frameRegex := '(.*)\s+at.+([^:]+)\:(\d+)\:(\d+)\.' asRegexIgnoringCase.
|
frameRegex := '(.*)\s+at\s+([^:]+)\:(\d+)\:(\d+)\.' asRegexIgnoringCase.
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
@@ -40,11 +49,10 @@ CarpPostMortemDebugger >> stackFrameFromLine: aString ordinal: ordinal [
|
|||||||
| file line column source |
|
| file line column source |
|
||||||
|
|
||||||
^ (frameRegex search: aString) ifTrue:
|
^ (frameRegex search: aString) ifTrue:
|
||||||
[ file := frameRegex subexpression: 2.
|
[ source := frameRegex subexpression: 2.
|
||||||
file := frameRegex subexpression: 3.
|
file := frameRegex subexpression: 3.
|
||||||
line := frameRegex subexpression: 4.
|
line := frameRegex subexpression: 4.
|
||||||
column := frameRegex subexpression: 5.
|
column := frameRegex subexpression: 5.
|
||||||
self halt.
|
|
||||||
CarpPostMortemStackFrame new
|
CarpPostMortemStackFrame new
|
||||||
ordinal: ordinal;
|
ordinal: ordinal;
|
||||||
displayString: aString;
|
displayString: aString;
|
||||||
@@ -62,17 +70,28 @@ CarpPostMortemDebugger >> stackFrameFromLine: aString ordinal: ordinal [
|
|||||||
CarpPostMortemDebugger >> stackFrames [
|
CarpPostMortemDebugger >> stackFrames [
|
||||||
"Answer a ordered collection of stack frames.
|
"Answer a ordered collection of stack frames.
|
||||||
This is called many times by the debugger, so cache"
|
This is called many times by the debugger, so cache"
|
||||||
| ordinal |
|
|
||||||
|
|
||||||
^ stackFrames ifNil:
|
| ordinal |
|
||||||
[ ordinal := 1.
|
^ stackFrames
|
||||||
|
ifNil: [ ordinal := 1.
|
||||||
stackFrames := OrderedCollection new.
|
stackFrames := OrderedCollection new.
|
||||||
exception trace lines do: [ :line |
|
(self findTrace: exception trace lines)
|
||||||
(self stackFrameFromLine: line ordinal: ordinal) ifNotNil: [ :frame |
|
do: [ :line |
|
||||||
|
(self stackFrameFromLine: line ordinal: ordinal)
|
||||||
|
ifNotNil: [ :frame |
|
||||||
stackFrames add: frame.
|
stackFrames add: frame.
|
||||||
ordinal := ordinal + 1 ] ].
|
ordinal := ordinal + 1 ] ].
|
||||||
stackFrames ].
|
(exception trace lines last beginsWith: '[RUNTIME ERROR]')
|
||||||
|
ifTrue: [ stackFrames
|
||||||
|
add: (CarpPostMortemStackFrame new
|
||||||
|
ordinal: 1;
|
||||||
|
displayString: exception trace lines last;
|
||||||
|
exception: exception;
|
||||||
|
source: exception trace lines last;
|
||||||
|
file: 'REPL' asFileReference;
|
||||||
|
line: 0;
|
||||||
|
column: 0) ].
|
||||||
|
stackFrames ]
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
|
@@ -14,5 +14,18 @@ CarpPostMortemStackFrame >> source: aString [
|
|||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
CarpPostMortemStackFrame >> sourceText [
|
CarpPostMortemStackFrame >> sourceText [
|
||||||
^ source
|
| mySource text indexes lineNumber |
|
||||||
|
file exists
|
||||||
|
ifTrue: [ mySource := file contents.
|
||||||
|
lineNumber := line ]
|
||||||
|
ifFalse: [ ^ source asRopedText
|
||||||
|
attribute: (BlTextHighlightAttribute paint: BrGlamorousColors errorBackgroundColor)
|
||||||
|
beNotOverwritableByStyler ].
|
||||||
|
text := mySource asRopedText.
|
||||||
|
indexes := mySource gtIndexOfLineNumber: lineNumber.
|
||||||
|
indexes
|
||||||
|
ifNotNil: [ (text from: indexes key + column - 1 to: indexes value)
|
||||||
|
attribute: (BlTextHighlightAttribute paint: BrGlamorousColors errorBackgroundColor)
|
||||||
|
beNotOverwritableByStyler ].
|
||||||
|
^ text
|
||||||
]
|
]
|
||||||
|
@@ -9,6 +9,12 @@ CarpPythonProcess class >> program [
|
|||||||
^ 'python'
|
^ 'python'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpPythonProcess class >> resolveCarpPath [
|
||||||
|
"TODO: make more robust"
|
||||||
|
^ '/usr/bin/python' asFileReference
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
CarpPythonProcess >> processArguments [
|
CarpPythonProcess >> processArguments [
|
||||||
| args |
|
| args |
|
||||||
|
43
src/Carp/CarpSequence.class.st
Normal file
43
src/Carp/CarpSequence.class.st
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
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 >> do: aBlock [
|
||||||
|
contents do: aBlock
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #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).
|
||||||
|
|
||||||
|
@@ -12,6 +12,11 @@ CarpSymbol class >> named: aString [
|
|||||||
^ self new name: aString
|
^ self new name: aString
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpSymbol >> name [
|
||||||
|
^ name
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
CarpSymbol >> name: aString [
|
CarpSymbol >> name: aString [
|
||||||
name := aString
|
name := aString
|
||||||
|
199
src/Carp/CarpTypeSignature.class.st
Normal file
199
src/Carp/CarpTypeSignature.class.st
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
Class {
|
||||||
|
#name : #CarpTypeSignature,
|
||||||
|
#superclass : #Object,
|
||||||
|
#instVars : [
|
||||||
|
'signature',
|
||||||
|
'model',
|
||||||
|
'tooltipsContainer'
|
||||||
|
],
|
||||||
|
#category : #'Carp-Coder'
|
||||||
|
}
|
||||||
|
|
||||||
|
{ #category : #'instance creation' }
|
||||||
|
CarpTypeSignature class >> on: aValue using: aModel [
|
||||||
|
^ self new
|
||||||
|
fromAST: aValue;
|
||||||
|
model: aModel
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpTypeSignature >> elementsList [
|
||||||
|
| tokens verticalContainer docsRegex |
|
||||||
|
tokens := signature value source findTokens: ' () []'.
|
||||||
|
docsRegex := 'Documentation\: (.*)' asRegexIgnoringCase.
|
||||||
|
|
||||||
|
verticalContainer := BrVerticalPane new
|
||||||
|
fitContent;
|
||||||
|
padding: (BlInsets all: 10).
|
||||||
|
|
||||||
|
tokens
|
||||||
|
do: [ :each |
|
||||||
|
| res |
|
||||||
|
res := model bindAndExecuteRaw: '(info ' , each , ')'.
|
||||||
|
(docsRegex search: (res at: #value))
|
||||||
|
ifTrue: [ | docs |
|
||||||
|
docs := docsRegex subexpression: 2.
|
||||||
|
verticalContainer
|
||||||
|
addChild: (BrLabel new
|
||||||
|
aptitude: BrGlamorousLabelAptitude new
|
||||||
|
+ (GtExplainerExplanationAptitude new explanationModel: each)
|
||||||
|
+ (BrStyleCommonAptitude new
|
||||||
|
hovered: [ :aStyle |
|
||||||
|
aStyle background: BrGlamorousColors textHighlightColor.
|
||||||
|
aStyle
|
||||||
|
do: [ tooltipsContainer
|
||||||
|
text: docs;
|
||||||
|
visibility: BlVisibility visible ]
|
||||||
|
after: [ tooltipsContainer
|
||||||
|
text: '' asRopedText;
|
||||||
|
visibility: BlVisibility gone ] ]);
|
||||||
|
geometry: (BlRoundedRectangleGeometry cornerRadius: 4);
|
||||||
|
text: each;
|
||||||
|
padding: (BlInsets all: 5)) ] ].
|
||||||
|
|
||||||
|
(tokens includes: '<StaticLifetime>')
|
||||||
|
ifTrue: [ verticalContainer
|
||||||
|
addChild: (BrLabel new
|
||||||
|
aptitude: BrGlamorousLabelAptitude new
|
||||||
|
+ (GtExplainerExplanationAptitude new explanationModel: '<StaticLifetime>')
|
||||||
|
+ (BrStyleCommonAptitude new
|
||||||
|
hovered: [ :aStyle |
|
||||||
|
aStyle background: BrGlamorousColors textHighlightColor.
|
||||||
|
aStyle
|
||||||
|
do: [ tooltipsContainer
|
||||||
|
text: 'is the default static lifetime of values (this lifetime includes the entire program run).';
|
||||||
|
visibility: BlVisibility visible ]
|
||||||
|
after: [ tooltipsContainer
|
||||||
|
text: '' asRopedText;
|
||||||
|
visibility: BlVisibility gone ] ]);
|
||||||
|
geometry: (BlRoundedRectangleGeometry cornerRadius: 4);
|
||||||
|
text: '<StaticLifetime>';
|
||||||
|
padding: (BlInsets all: 5)) ].
|
||||||
|
|
||||||
|
(tokens includes: 'Fn')
|
||||||
|
ifTrue: [ verticalContainer
|
||||||
|
addChild: (BrLabel new
|
||||||
|
aptitude: BrGlamorousLabelAptitude new
|
||||||
|
+ (GtExplainerExplanationAptitude new explanationModel: 'Fn')
|
||||||
|
+ (BrStyleCommonAptitude new
|
||||||
|
hovered: [ :aStyle |
|
||||||
|
aStyle background: BrGlamorousColors textHighlightColor.
|
||||||
|
aStyle
|
||||||
|
do: [ tooltipsContainer
|
||||||
|
text: 'is the function type and is read: ' asRopedText, '(Fn [<arguments>] <return type> <lifetime>).' asRopedText glamorousCodeFont;
|
||||||
|
visibility: BlVisibility visible ]
|
||||||
|
after: [ tooltipsContainer
|
||||||
|
text: '' asRopedText;
|
||||||
|
visibility: BlVisibility gone ] ]);
|
||||||
|
geometry: (BlRoundedRectangleGeometry cornerRadius: 4);
|
||||||
|
text: 'Fn';
|
||||||
|
padding: (BlInsets all: 5)) ].
|
||||||
|
|
||||||
|
^ verticalContainer asScrollableElement
|
||||||
|
constraintsDo: [ :c |
|
||||||
|
c horizontal fitContent.
|
||||||
|
c vertical matchParent ];
|
||||||
|
background: Color white;
|
||||||
|
aptitude: BrShadowAptitude new
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpTypeSignature >> explainSignature [
|
||||||
|
| mainContainer coderElement leftContainer rightContainer rightContainerLabel leftContainerLabel tooltipsTarget coder elementsContainer editor |
|
||||||
|
mainContainer := BrHorizontalPane new
|
||||||
|
matchParent;
|
||||||
|
padding: (BlInsets all: 5).
|
||||||
|
mainContainer explainer isExplanationHolder: true.
|
||||||
|
|
||||||
|
leftContainer := BrVerticalPane new
|
||||||
|
hFitContent;
|
||||||
|
vMatchParent;
|
||||||
|
padding: (BlInsets all: 5);
|
||||||
|
margin: (BlInsets right: 20).
|
||||||
|
|
||||||
|
rightContainer := BrVerticalPane new
|
||||||
|
matchParent;
|
||||||
|
padding: (BlInsets all: 5).
|
||||||
|
|
||||||
|
tooltipsContainer := BrEditor new
|
||||||
|
text: '' asRopedText;
|
||||||
|
padding: (BlInsets all: 10);
|
||||||
|
margin: (BlInsets
|
||||||
|
top: 10
|
||||||
|
right: 0
|
||||||
|
bottom: 0
|
||||||
|
left: 0);
|
||||||
|
constraintsDo: [ :c | c horizontal matchParent ];
|
||||||
|
visibility: BlVisibility gone;
|
||||||
|
border: (BlBorder paint: BrGlamorousColors textHighlightColor width: 2);
|
||||||
|
aptitude: BrShadowAptitude + BrGlamorousEditorAptitude;
|
||||||
|
vFitContent;
|
||||||
|
background: BrGlamorousColors textHighlightColor.
|
||||||
|
|
||||||
|
tooltipsTarget := BrButton new
|
||||||
|
constraintsDo: [ :c | c ignoreByLayout ];
|
||||||
|
size: 0 @ 0;
|
||||||
|
elevation: (BlRelativeElevation elevation: 10);
|
||||||
|
geometry: BlCircleGeometry new.
|
||||||
|
|
||||||
|
elementsContainer := self elementsList.
|
||||||
|
|
||||||
|
leftContainerLabel := BrLabel new
|
||||||
|
text: ('Type Elements:' asRopedText
|
||||||
|
glamorousRegularFont;
|
||||||
|
foreground: Color gray);
|
||||||
|
aptitude: BrGlamorousLabelAptitude;
|
||||||
|
hFitContent;
|
||||||
|
margin: (BlInsets
|
||||||
|
top: 0
|
||||||
|
right: 0
|
||||||
|
bottom: 5
|
||||||
|
left: 0).
|
||||||
|
rightContainerLabel := BrLabel new
|
||||||
|
text: ('Type:' asRopedText
|
||||||
|
glamorousRegularFont;
|
||||||
|
foreground: Color gray);
|
||||||
|
aptitude: BrGlamorousLabelAptitude;
|
||||||
|
margin: (BlInsets
|
||||||
|
top: 0
|
||||||
|
right: 0
|
||||||
|
bottom: 5
|
||||||
|
left: 5).
|
||||||
|
|
||||||
|
editor := BrEditorElement new
|
||||||
|
constraintsDo: [ :c |
|
||||||
|
c horizontal matchParent.
|
||||||
|
c vertical matchParent ];
|
||||||
|
editor: (BrTextEditor new text: signature value source asRopedText glamorousCodeFont).
|
||||||
|
|
||||||
|
leftContainer addChild: leftContainerLabel.
|
||||||
|
leftContainer addChild: elementsContainer.
|
||||||
|
|
||||||
|
rightContainer addChild: rightContainerLabel.
|
||||||
|
rightContainer addChild: editor.
|
||||||
|
rightContainer addChild: tooltipsContainer.
|
||||||
|
|
||||||
|
mainContainer addChild: leftContainer.
|
||||||
|
mainContainer addChild: rightContainer.
|
||||||
|
|
||||||
|
^ mainContainer
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpTypeSignature >> fromAST: anASTNode [
|
||||||
|
signature := anASTNode
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpTypeSignature >> gtLiveFor: aView [
|
||||||
|
<gtView>
|
||||||
|
^ aView explicit
|
||||||
|
title: 'Signature';
|
||||||
|
priority: 1;
|
||||||
|
stencil: [ self explainSignature ]
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
CarpTypeSignature >> model: aModel [
|
||||||
|
model := aModel
|
||||||
|
]
|
@@ -4,7 +4,9 @@ Class {
|
|||||||
#instVars : [
|
#instVars : [
|
||||||
'pharoBindings',
|
'pharoBindings',
|
||||||
'carpLinkApplicationStrategy',
|
'carpLinkApplicationStrategy',
|
||||||
'exception'
|
'exception',
|
||||||
|
'application',
|
||||||
|
'commandFactory'
|
||||||
],
|
],
|
||||||
#category : #'Carp-Coder'
|
#category : #'Carp-Coder'
|
||||||
}
|
}
|
||||||
@@ -28,10 +30,12 @@ GtCarpCoderModel >> bindAndExecute: sourceString [
|
|||||||
|
|
||||||
<gtIgnoreConstraint: #GtRBAcceptVisitorCalledFromNonVisitingMethods>
|
<gtIgnoreConstraint: #GtRBAcceptVisitorCalledFromNonVisitingMethods>
|
||||||
<remoteDebuggerSignal>
|
<remoteDebuggerSignal>
|
||||||
| carpSource trimmedSource ast varNames lastStatement application commandFactory res |
|
| 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 '
|
||||||
@@ -41,21 +45,25 @@ GtCarpCoderModel >> bindAndExecute: sourceString [
|
|||||||
carpSource := self
|
carpSource := self
|
||||||
sourceFrom: trimmedSource asString
|
sourceFrom: trimmedSource asString
|
||||||
returnedVarNames: varNames.
|
returnedVarNames: varNames.
|
||||||
|
res := self bindAndExecuteRaw: sourceString.
|
||||||
|
|
||||||
|
(res at: #result) = 'success' ifTrue: [ ^ CarpExecutionResult from: res ].
|
||||||
|
exception := PharoLinkRemoteError new
|
||||||
|
application: application;
|
||||||
|
command: commandFactory command;
|
||||||
|
trace: (res at: #value).
|
||||||
|
exception signal
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
GtCarpCoderModel >> bindAndExecuteRaw: sourceString [
|
||||||
application := carpLinkApplicationStrategy applicationServer.
|
application := carpLinkApplicationStrategy applicationServer.
|
||||||
application isRunning ifFalse: [ application start ].
|
application isRunning ifFalse: [ application start ].
|
||||||
commandFactory := application newCommandFactory.
|
commandFactory := application newCommandFactory.
|
||||||
|
|
||||||
res := commandFactory
|
^ commandFactory
|
||||||
<< carpSource;
|
<< sourceString;
|
||||||
sendAndWait.
|
sendAndWait
|
||||||
|
|
||||||
(res at: #result) = 'success' ifTrue: [ ^ res at: #value ].
|
|
||||||
exception := (PharoLinkRemoteError new
|
|
||||||
application: application;
|
|
||||||
command: commandFactory command;
|
|
||||||
trace: (res at: #value)).
|
|
||||||
exception signal
|
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
@@ -78,9 +86,11 @@ GtCarpCoderModel >> exception [
|
|||||||
GtCarpCoderModel >> initializeAddOns: addOns [
|
GtCarpCoderModel >> initializeAddOns: addOns [
|
||||||
super initializeAddOns: addOns.
|
super initializeAddOns: addOns.
|
||||||
|
|
||||||
addOns addStyler: (GtCoderAstSmaCCParserStyler new smaccStyler: CarpParser gtStyler).
|
|
||||||
|
|
||||||
addOns
|
addOns
|
||||||
|
addStyler: (GtCoderAstSmaCCParserStyler new smaccStyler: CarpParser gtStyler).
|
||||||
|
|
||||||
|
application
|
||||||
|
ifNotNil: [ addOns
|
||||||
addMainAction: 'Evaluate' translated
|
addMainAction: 'Evaluate' translated
|
||||||
icon: BrGlamorousVectorIcons play
|
icon: BrGlamorousVectorIcons play
|
||||||
action: [ :aCoderUIModel :anElement |
|
action: [ :aCoderUIModel :anElement |
|
||||||
@@ -98,15 +108,54 @@ GtCarpCoderModel >> initializeAddOns: addOns [
|
|||||||
element: anElement;
|
element: anElement;
|
||||||
execute ]
|
execute ]
|
||||||
id: GtSourceCoderDoItAndGoActionId.
|
id: GtSourceCoderDoItAndGoActionId.
|
||||||
|
addOns
|
||||||
|
addMainAction: 'Expand Macros' translated
|
||||||
|
icon: BrGlamorousVectorIcons repair
|
||||||
|
action: [ :aCoderUIModel :anElement |
|
||||||
|
| source |
|
||||||
|
source := '(expand ''' , sourceCode currentSourceText value text , ')'.
|
||||||
|
anElement phlow
|
||||||
|
spawnObject: ((self bindAndExecute: source) parse view: #gtSourceFor:) ]
|
||||||
|
id: #'source-coder--macro-expand-action'.
|
||||||
|
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: ((self bindAndExecuteRaw: source) at: 'value')) ]
|
||||||
|
id: #'source-coder--build-and-run-action'.
|
||||||
|
addOns
|
||||||
|
addMainAction: 'Infer Type' translated
|
||||||
|
icon: BrGlamorousVectorIcons inspect
|
||||||
|
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
|
||||||
|
ifNotNil: [ addOns
|
||||||
addShortcut: GtSourceCoderDoItShortcut new;
|
addShortcut: GtSourceCoderDoItShortcut new;
|
||||||
addShortcut: GtSourceCoderDoItAndInspectShortcut new
|
addShortcut: GtSourceCoderDoItAndInspectShortcut new ]
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
GtCarpCoderModel >> inspectTypeSpawningOn: aPhlow [
|
||||||
|
| source ast |
|
||||||
|
source := sourceCode currentSourceText value text.
|
||||||
|
ast := CarpParser parse: source.
|
||||||
|
|
||||||
|
(ast expressions size = 1 and: [ ast expressions first isDefinition ])
|
||||||
|
ifTrue: [ self bindAndExecute: source asString.
|
||||||
|
source := ast expressions first definitionVariable value source ].
|
||||||
|
|
||||||
|
source := '(def *type-infer-this* ' , source
|
||||||
|
, ') (defdynamic *type-infer-result* (type *type-infer-this*)) (def *type-infer-this* 0) *type-infer-result*'.
|
||||||
|
aPhlow spawnObject: ((self bindAndExecute: source) parse transformValue: [:aValue | CarpTypeSignature on: aValue expressions first using: self])
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
@@ -121,7 +170,8 @@ GtCarpCoderModel >> pharoBindings: anObject [
|
|||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
GtCarpCoderModel >> primitiveEvaluate: aSourceString inContext: aGtSourceCoderEvaluationContext onFailDo: anEvaluationFailBlock [
|
GtCarpCoderModel >> primitiveEvaluate: aSourceString inContext: aGtSourceCoderEvaluationContext onFailDo: anEvaluationFailBlock [
|
||||||
^ (CarpParser parse: (self bindAndExecute: aSourceString)) expressions first toPharo
|
^ (self bindAndExecute: aSourceString) parse
|
||||||
|
transformValue: [ :aValue | aValue expressions first toPharo ]
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
|
50
src/Carp/GtCarpIDECoderModel.class.st
Normal file
50
src/Carp/GtCarpIDECoderModel.class.st
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
Class {
|
||||||
|
#name : #GtCarpIDECoderModel,
|
||||||
|
#superclass : #GtCarpNewFunctionCoderModel,
|
||||||
|
#instVars : [
|
||||||
|
'expression'
|
||||||
|
],
|
||||||
|
#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
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #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.
|
||||||
|
self bindAndExecute: module toCarp
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
GtCarpIDECoderModel >> save [
|
||||||
|
module removeExpression: expression.
|
||||||
|
module
|
||||||
|
addExpression: (CarpParser parse: sourceCode availableSource text) intoModel.
|
||||||
|
self bindAndExecute: module toCarp.
|
||||||
|
onSave ifNotNil: [ onSave value ]
|
||||||
|
]
|
40
src/Carp/GtCarpNewFunctionCoderModel.class.st
Normal file
40
src/Carp/GtCarpNewFunctionCoderModel.class.st
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
Class {
|
||||||
|
#name : #GtCarpNewFunctionCoderModel,
|
||||||
|
#superclass : #GtCarpCoderModel,
|
||||||
|
#instVars : [
|
||||||
|
'module',
|
||||||
|
'onSave'
|
||||||
|
],
|
||||||
|
#category : #'Carp-Coder'
|
||||||
|
}
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
GtCarpNewFunctionCoderModel >> initializeAddOns: addOns [
|
||||||
|
addOns
|
||||||
|
addStyler: (GtCoderAstSmaCCParserStyler new smaccStyler: CarpParser gtStyler).
|
||||||
|
|
||||||
|
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 [
|
||||||
|
| expression |
|
||||||
|
expression := (CarpParser parse: sourceCode currentSourceText value text) intoModel.
|
||||||
|
module addExpression: expression.
|
||||||
|
self bindAndExecute: module toCarp.
|
||||||
|
onSave ifNotNil: [ onSave value ]
|
||||||
|
]
|
@@ -13,9 +13,6 @@ LeCarpApplicationStrategy class >> strategyName [
|
|||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
LeCarpApplicationStrategy >> applicationServer [
|
LeCarpApplicationStrategy >> applicationServer [
|
||||||
|
|
||||||
content database isDatabase ifFalse: [ ^ nil ].
|
|
||||||
CarpApplication uniqueInstance ifNil:
|
|
||||||
[ CarpApplication uniqueInstance: (self newCarpApplicationFor: content database) ].
|
|
||||||
^ CarpApplication uniqueInstance
|
^ CarpApplication uniqueInstance
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -27,32 +24,5 @@ LeCarpApplicationStrategy >> applicationSettings [
|
|||||||
^ CarpApplication isRunning ifTrue:
|
^ CarpApplication isRunning ifTrue:
|
||||||
[ CarpApplication uniqueInstance settings ]
|
[ CarpApplication uniqueInstance settings ]
|
||||||
ifFalse:
|
ifFalse:
|
||||||
[ self updatedSettings: CarpApplication defaultSettings ]
|
[ CarpApplication defaultSettings ]
|
||||||
]
|
|
||||||
|
|
||||||
{ #category : #accessing }
|
|
||||||
LeCarpApplicationStrategy >> newCarpApplicationFor: aLeDatabase [
|
|
||||||
|
|
||||||
^ CarpApplication new initializeWith:
|
|
||||||
(self updatedSettings: LanguageLinkSettings carpDefaultSettings).
|
|
||||||
|
|
||||||
]
|
|
||||||
|
|
||||||
{ #category : #accessing }
|
|
||||||
LeCarpApplicationStrategy >> updatedSettings: applicationCarpSettings [
|
|
||||||
"Update the supplied settings with the lepiter configuration"
|
|
||||||
|
|
||||||
| lepiterCarpSettings lepiterDatabase carpDir |
|
|
||||||
lepiterDatabase := content database.
|
|
||||||
(lepiterDatabase isKindOf: LeNullDatabase)
|
|
||||||
ifTrue: [ ^ applicationCarpSettings ].
|
|
||||||
lepiterCarpSettings := lepiterDatabase properties carpLinkSettings.
|
|
||||||
lepiterCarpSettings directory
|
|
||||||
ifNotNil: [ :relativeDir |
|
|
||||||
carpDir := lepiterDatabase localStoreRootDirectory resolve: relativeDir.
|
|
||||||
applicationCarpSettings workingDirectory: carpDir ]. "lepiterCarpSettings carpPath ifNotNil:
|
|
||||||
[ :carpPath | applicationCarpSettings serverExecutable: carpPath ]."
|
|
||||||
applicationCarpSettings serverDebugMode: lepiterCarpSettings serverDebugMode.
|
|
||||||
|
|
||||||
^ applicationCarpSettings
|
|
||||||
]
|
]
|
||||||
|
@@ -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