From 29ce2b0611b51c828d69b9889909a63cf5564b47 Mon Sep 17 00:00:00 2001 From: Alistair Grant Date: Mon, 13 May 2024 14:30:55 +0200 Subject: [PATCH] [feenkcom/gtoolkit#3769] BrRBTextStyler remove TRBProgramNodeVisitor --- src/Brick-Editor/BrRBTextStyler.class.st | 75 +++++++++++++++++++++++- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/src/Brick-Editor/BrRBTextStyler.class.st b/src/Brick-Editor/BrRBTextStyler.class.st index c87b324d3..874ef488e 100644 --- a/src/Brick-Editor/BrRBTextStyler.class.st +++ b/src/Brick-Editor/BrRBTextStyler.class.st @@ -23,8 +23,6 @@ Internal Representation and Key Implementation Points. Class { #name : #BrRBTextStyler, #superclass : #BrTextStylerST80, - #traits : 'TRBProgramNodeVisitor', - #classTraits : 'TRBProgramNodeVisitor classTrait', #instVars : [ 'parentheseLevel', 'bracketLevel' @@ -347,6 +345,12 @@ BrRBTextStyler >> visitArgumentNodes: aNodeCollection [ ^aNodeCollection do: [ :each | self visitArgumentNode: each ] ] +{ #category : #visiting } +BrRBTextStyler >> visitArgumentVariableNode: anArgumentNode [ + + ^ self visitLocalVariableNode: anArgumentNode +] + { #category : #visiting } BrRBTextStyler >> visitArrayNode: anArrayNode [ @@ -378,11 +382,27 @@ BrRBTextStyler >> visitCascadeNode: aCascadeNode [ aCascadeNode semicolons do: [ :pos | self addStyle: #cascadeSeparator from: pos to: pos ] ] +{ #category : #visiting } +BrRBTextStyler >> visitClassVariableNode: aNode [ + ^ self visitLiteralVariableNode: aNode +] + +{ #category : #visiting } +BrRBTextStyler >> visitEnglobingErrorNode: anEnglobingErrorNode [ + anEnglobingErrorNode content do: [ :each | self visitNode: each ] +] + { #category : #visiting } BrRBTextStyler >> visitGlobalNode: aSelfNode [ ^ self visitVariableNode: aSelfNode ] +{ #category : #visiting } +BrRBTextStyler >> visitGlobalVariableNode: aNode [ + + ^ self visitLiteralVariableNode: aNode +] + { #category : #visiting } BrRBTextStyler >> visitInstanceVariableNode: aSelfNode [ ^ self visitVariableNode: aSelfNode @@ -408,6 +428,26 @@ BrRBTextStyler >> visitLiteralNode: aLiteralNode [ forNode: aLiteralNode ] +{ #category : #visiting } +BrRBTextStyler >> visitLiteralValueNode: aNode [ + "Redirect the message by default to #visitLiteralNode: for retrocompatibility (pharo 8)" + + ^ self visitLiteralNode: aNode +] + +{ #category : #visiting } +BrRBTextStyler >> visitLiteralVariableNode: aNode [ + "to be backward compatible, we visit for Gloabls here (there used to be no difference)" + + ^ self visitGlobalNode: aNode +] + +{ #category : #visiting } +BrRBTextStyler >> visitLocalVariableNode: aNode [ + "call visitTemporaryNode: for backward compatibility" + ^ self visitTemporaryNode: aNode +] + { #category : #'visiting rb nodes' } BrRBTextStyler >> visitMessageNode: aMessageNode [ | style link | @@ -528,6 +568,16 @@ BrRBTextStyler >> visitSequenceNode: aSequenceNode [ aSequenceNode periods do: [ :pos | self addStyle: #statementSeparator from: pos to: pos ] ] +{ #category : #'visiting - reflectivity' } +BrRBTextStyler >> visitStoreIntoTempNode: aNode [ + ^ aNode +] + +{ #category : #'visiting - reflectivity' } +BrRBTextStyler >> visitStorePopIntoTempNode: aNode [ + ^ aNode +] + { #category : #'visiting rb nodes' } BrRBTextStyler >> visitSuperNode: aSuperNode [ self @@ -535,6 +585,15 @@ BrRBTextStyler >> visitSuperNode: aSuperNode [ forNode: aSuperNode ] +{ #category : #visiting } +BrRBTextStyler >> visitTemporaryDeclarationNode: aTemporaryDeclarationNode [ + "| temp | + temp is a temporary node as we can find in the body of methods, but it can't be visited the same way. + IT redirects the message on argumentNodeVisitor as a way to keep retrocompatibility" + + ^ self visitArgumentNode: aTemporaryDeclarationNode +] + { #category : #'visiting rb nodes' } BrRBTextStyler >> visitTemporaryNode: aTemporaryNode [ | methodOrBlockTempStyle | @@ -548,6 +607,12 @@ BrRBTextStyler >> visitTemporaryNodes: aNodeCollection [ ^self visitArgumentNodes: aNodeCollection ] +{ #category : #visiting } +BrRBTextStyler >> visitTemporaryVariableNode: aNode [ + + ^ self visitLocalVariableNode: aNode +] + { #category : #'visiting rb nodes' } BrRBTextStyler >> visitThisContextNode: aThisContextNode [ self @@ -555,6 +620,12 @@ BrRBTextStyler >> visitThisContextNode: aThisContextNode [ forNode: aThisContextNode ] +{ #category : #visiting } +BrRBTextStyler >> visitUnreachableStatement: anUnreachableStatement [ + + ^ self visitEnglobingErrorNode: anUnreachableStatement +] + { #category : #'visiting rb nodes' } BrRBTextStyler >> visitVariableNode: aVariableNode [ self