From 7e15b99fe383cefb6dfe700336ef76dd6c50b630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Chi=C8=99?= Date: Wed, 6 Nov 2024 00:09:15 +0100 Subject: [PATCH 1/2] Update tags for variable nodes [feenkcom/gtoolkit#4146] --- .../GtPharoMethodCoder.class.st | 46 ++++++++--------- .../GtPharoMethodContextCoder.class.st | 51 ++++++++++--------- ...PharoSourceCoderEvaluationContext.class.st | 14 ++--- 3 files changed, 57 insertions(+), 54 deletions(-) diff --git a/src/GToolkit-Pharo-Coder-Method/GtPharoMethodCoder.class.st b/src/GToolkit-Pharo-Coder-Method/GtPharoMethodCoder.class.st index 984bab0a..d674dded 100644 --- a/src/GToolkit-Pharo-Coder-Method/GtPharoMethodCoder.class.st +++ b/src/GToolkit-Pharo-Coder-Method/GtPharoMethodCoder.class.st @@ -220,15 +220,6 @@ GtPharoMethodCoder >> compile [ ^ self compileInContext: self evaluationContext ] -{ #category : #accessing } -GtPharoMethodCoder >> compiledMethod [ - - - ^ self existsInTheSystem - ifTrue: [ self behavior >> self selector ] - ifFalse: [ nil ] -] - { #category : #'api - actions' } GtPharoMethodCoder >> compileInContext: aGtPharoSourceCoderEvaluationContext [ "Try to compile the current source code and return true if it was successful, false otherwise" @@ -259,6 +250,15 @@ GtPharoMethodCoder >> compileInContext: aGtPharoSourceCoderEvaluationContext [ ^ true ] +{ #category : #accessing } +GtPharoMethodCoder >> compiledMethod [ + + + ^ self existsInTheSystem + ifTrue: [ self behavior >> self selector ] + ifFalse: [ nil ] +] + { #category : #'api - ast' } GtPharoMethodCoder >> computeAst: theSourceString [ ^ GtPharoParser @@ -535,20 +535,6 @@ GtPharoMethodCoder >> forExample: anExampleWithResult [ self example: anExampleWithResult ] -{ #category : #accessing } -GtPharoMethodCoder >> formatWithRequesterObject: aRequester [ - | ast | - ast := [ RBParser parseMethod: self currentSourceString ] - on: SyntaxErrorNotification - do: [ :ex | - ^ self - notifyParseError: ex errorMessage - at: ex location - requesterObject: aRequester ]. - - self currentSourceString: ast formattedCode -] - { #category : #initialize } GtPharoMethodCoder >> forMethod: aCompiledMethod [ self methodBehavior:(GtPharoCoderBehavior explicit: aCompiledMethod methodClass). @@ -571,6 +557,20 @@ GtPharoMethodCoder >> forMethod: aCompiledMethod in: aBehavior [ self protocol: aCompiledMethod category ] +{ #category : #accessing } +GtPharoMethodCoder >> formatWithRequesterObject: aRequester [ + | ast | + ast := [ RBParser parseMethod: self currentSourceString ] + on: SyntaxErrorNotification + do: [ :ex | + ^ self + notifyParseError: ex errorMessage + at: ex location + requesterObject: aRequester ]. + + self currentSourceString: ast formattedCode +] + { #category : #'gt-extensions' } GtPharoMethodCoder >> gtDiffViewFor: aView [ " diff --git a/src/GToolkit-Pharo-Coder-Method/GtPharoMethodContextCoder.class.st b/src/GToolkit-Pharo-Coder-Method/GtPharoMethodContextCoder.class.st index 1b2b4291..b59c7293 100644 --- a/src/GToolkit-Pharo-Coder-Method/GtPharoMethodContextCoder.class.st +++ b/src/GToolkit-Pharo-Coder-Method/GtPharoMethodContextCoder.class.st @@ -25,20 +25,6 @@ GtPharoMethodContextCoder >> close [ self updateSelection" ] -{ #category : #accessing } -GtPharoMethodContextCoder >> compiledMethod [ - - "The context coder should allways return the compiled method from the context - as the method from the class can be changed. In that case the context will - use its own method." - - ^ context compiledCode method - - "^ context isBlockContext - ifTrue: [ context home compiledCode ] - ifFalse: [ context compiledCode ]" -] - { #category : #'api - actions' } GtPharoMethodContextCoder >> compileInContext: aGtPharoSourceCoderEvaluationContext [ | withoutErrors compiledSuccesfully | @@ -67,6 +53,20 @@ GtPharoMethodContextCoder >> compileInContext: aGtPharoSourceCoderEvaluationCont ^ withoutErrors and: [ compiledSuccesfully ] ] +{ #category : #accessing } +GtPharoMethodContextCoder >> compiledMethod [ + + "The context coder should allways return the compiled method from the context + as the method from the class can be changed. In that case the context will + use its own method." + + ^ context compiledCode method + + "^ context isBlockContext + ifTrue: [ context home compiledCode ] + ifFalse: [ context compiledCode ]" +] + { #category : #accessing } GtPharoMethodContextCoder >> context [ @@ -82,7 +82,7 @@ GtPharoMethodContextCoder >> currentContext [ { #category : #'accessing variables' } GtPharoMethodContextCoder >> debuggerVariableNodes [ | variablesList | - + variablesList := OrderedCollection new. self instanceVariableNodesDo: [ :aNode | variablesList add: aNode ]. self temporaryVariableNodesDo: [ :aNode | variablesList add: aNode ]. @@ -91,11 +91,14 @@ GtPharoMethodContextCoder >> debuggerVariableNodes [ variablesList sort: [:node1 :node2 | node1 key < node2 key]. variablesList addFirst: (GtInspectorSelfNode hostObject: self receiver); - addLast: (GtInspectorDynamicNode hostObject: self context label: 'thisContext' value: self context). + addLast: (GtInspectorDynamicNode + hostObject: self context + label: 'thisContext' + value: self context + tag: 'stack'). self stackVariableNodesDo: [ :aNode | variablesList add: aNode ]. - ^ variablesList - + ^ variablesList ] { #category : #accessing } @@ -145,7 +148,7 @@ GtPharoMethodContextCoder >> instanceVariableNamesAndValuesDo: aBlock [ { #category : #'accessing variables' } GtPharoMethodContextCoder >> instanceVariableNodesDo: aBloc [ - self receiver class allSlots collect: [ :aSlot | + self receiver class allSlots do: [ :aSlot | aBloc value: (GtInspectorSlotNode hostObject: self receiver slot: aSlot) ] @@ -270,7 +273,8 @@ GtPharoMethodContextCoder >> stackVariableNodesDo: aBlock [ (stackPosition > 0 ifTrue: [ ' - ' , stackPosition printString ] ifFalse: [ '' ])) - value: (self context at: i)). + value: (self context at: i) + tag: 'stack'). stackPosition := stackPosition + 1 ] ] @@ -330,10 +334,9 @@ GtPharoMethodContextCoder >> updateSourceFromContext [ { #category : #'accessing variables' } GtPharoMethodContextCoder >> workspaceDoItNodesDo: aBloc [ self context gtDebuggerDoItBindings do: [:aBinding | - aBloc value: ((GtInspectorDynamicNode + aBloc value: (GtInspectorDynamicNode hostObject: self context label: aBinding key - value: aBinding value) - variableTag: 'temp'; - yourself) ] + value: aBinding value + tag: 'temporary') ] ] diff --git a/src/GToolkit-Pharo-Coder-Method/GtPharoSourceCoderEvaluationContext.class.st b/src/GToolkit-Pharo-Coder-Method/GtPharoSourceCoderEvaluationContext.class.st index 09775a72..83774222 100644 --- a/src/GToolkit-Pharo-Coder-Method/GtPharoSourceCoderEvaluationContext.class.st +++ b/src/GToolkit-Pharo-Coder-Method/GtPharoSourceCoderEvaluationContext.class.st @@ -24,13 +24,6 @@ GtPharoSourceCoderEvaluationContext >> bindingOf: aSymbol [ ^ self bindingStrategy bindingOf: aSymbol ] -{ #category : #accessing } -GtPharoSourceCoderEvaluationContext >> bindings [ - - - ^ bindingStrategy -] - { #category : #accessing } GtPharoSourceCoderEvaluationContext >> bindingStrategy [ @@ -47,6 +40,13 @@ GtPharoSourceCoderEvaluationContext >> bindingStrategy: aGtBindingStrategy [ bindingStrategy := aGtBindingStrategy ] +{ #category : #accessing } +GtPharoSourceCoderEvaluationContext >> bindings [ + + + ^ bindingStrategy +] + { #category : #hack } GtPharoSourceCoderEvaluationContext >> correctFrom: fromIndex to: toIndex with: aString [ NonInteractiveTranscript stdout From 19e8fb0ff1c8ecfb63bf44980b5b6dd640c05621 Mon Sep 17 00:00:00 2001 From: Alistair Grant Date: Wed, 6 Nov 2024 17:44:32 +0100 Subject: [PATCH 2/2] GtPharoMethodCoder>>addConvertEqualsToSameContentAsFor:to: ensure node is a message send --- .../GtPharoMethodCoder.extension.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GToolkit-Pharo-StrictSymbolComparison/GtPharoMethodCoder.extension.st b/src/GToolkit-Pharo-StrictSymbolComparison/GtPharoMethodCoder.extension.st index c40f9ea9..50b7445d 100644 --- a/src/GToolkit-Pharo-StrictSymbolComparison/GtPharoMethodCoder.extension.st +++ b/src/GToolkit-Pharo-StrictSymbolComparison/GtPharoMethodCoder.extension.st @@ -3,7 +3,7 @@ Extension { #name : #GtPharoMethodCoder } { #category : #'*GToolkit-Pharo-StrictSymbolComparison' } GtPharoMethodCoder >> addConvertEqualsToSameContentAsFor: aNode to: coderAddOns [ - aNode selector == #= ifFalse: [ ^ self ]. + (aNode isMessage and: [ aNode selector == #= ]) ifFalse: [ ^ self ]. coderAddOns addContextMenuItem: (self createLabel: ('Convert ' asRopedText,