From f1ec7fd2b2c11b3fc8f0e539face7bba5b673af9 Mon Sep 17 00:00:00 2001 From: CyrilFerlicot Date: Thu, 10 Oct 2024 16:44:26 +0200 Subject: [PATCH] Cleanup Shout - Remove #stylingEnabled: because this is never used and if we do not want to style a text, we should not give it to the styler - Remove #text ivar that is unused - Remove #plugins that are unused Fixes #16310 --- src/Shout/SHRBTextStyler.class.st | 63 ++++--------------------------- 1 file changed, 8 insertions(+), 55 deletions(-) diff --git a/src/Shout/SHRBTextStyler.class.st b/src/Shout/SHRBTextStyler.class.st index 088ac7d5071..c5dfad633c2 100644 --- a/src/Shout/SHRBTextStyler.class.st +++ b/src/Shout/SHRBTextStyler.class.st @@ -10,11 +10,8 @@ Class { 'bracketLevel', 'classOrMetaClass', 'workspace', - 'plugins', 'braceLevel', 'view', - 'stylingEnabled', - 'text', 'isScripting' ], #classInstVars : [ @@ -723,12 +720,6 @@ SHRBTextStyler class >> vintageStyleTable [ (pragma (cyan muchDarker))) ] -{ #category : 'private' } -SHRBTextStyler >> addASTTransformationPlugin: aPlugin [ - - self plugins add: aPlugin -] - { #category : 'formatting' } SHRBTextStyler >> addAttributes: attributes forNode: aNode [ @@ -756,12 +747,6 @@ SHRBTextStyler >> addAttributesFrom: attributeRuns satisfying: aTestBlock to: aT ^ aText ] -{ #category : 'accessing' } -SHRBTextStyler >> addPlugin: aPlugin [ - - self plugins add: aPlugin -] - { #category : 'formatting' } SHRBTextStyler >> addStyle: styleSymbol attribute: additionalAttribute from: start to: end [ self addAttributes: (self attributesFor: styleSymbol), {additionalAttribute} from: start to: end @@ -835,7 +820,6 @@ SHRBTextStyler >> hasSymbolStartingBy: aSymbol [ SHRBTextStyler >> initialize [ super initialize. - stylingEnabled := true. isScripting := false ] @@ -904,29 +888,19 @@ SHRBTextStyler >> parenthesisStyleName [ ifFalse: [ level asString ])) asSymbol ] -{ #category : 'private' } -SHRBTextStyler >> plugins [ - - ^ plugins ifNil: [ plugins := OrderedCollection new ] -] - { #category : 'private' } SHRBTextStyler >> privateStyle: aText [ - | compiler | + | compiler | aText ifEmpty: [ ^ self ]. compiler := classOrMetaClass compiler - source: aText asString; - receiver: (self isScripting ifTrue: [workspace ifNotNil: [:w | w doItReceiver]]); - isScripting: self isScripting; - requestor: workspace. + source: aText asString; + receiver: (self isScripting ifTrue: [ workspace ifNotNil: [ :w | w doItReceiver ] ]); + isScripting: self isScripting; + requestor: workspace. - self plugins do: [ :each | compiler addParsePlugin: each ]. - - ^ self - style: aText - ast: compiler parse + ^ self style: aText ast: compiler parse ] { #category : 'testing' } @@ -965,8 +939,8 @@ SHRBTextStyler >> resolveVariableAttributesFor: aVariableNode [ { #category : 'styling' } SHRBTextStyler >> style: aText [ + | text | aText ifEmpty: [ ^ self ]. - stylingEnabled ifFalse: [ ^ self ]. text := aText copy. self privateStyle: text. view ifNotNil: [ :view2 | view2 stylerStyled: text ] @@ -976,16 +950,13 @@ SHRBTextStyler >> style: aText [ SHRBTextStyler >> style: aText ast: ast [ aText ifEmpty: [ ^ self ]. - text := aText. charAttr := Array new: aText size withAll: (self attributesFor: #default). bracketLevel := 0. parentheseLevel := 0. braceLevel := 0. self visitNode: ast. "Second pass to ensure that all syntax errors are visible" - ast allErrorNotices do: [ :notice | - notice isSyntaxError ifTrue: [ - self addStyle: #invalid from: notice position to: notice position ] ]. + ast allErrorNotices do: [ :notice | notice isSyntaxError ifTrue: [ self addStyle: #invalid from: notice position to: notice position ] ]. ^ aText runs: (RunArray newFrom: charAttr) ] @@ -1073,24 +1044,6 @@ SHRBTextStyler >> styledTextFor: aText [ ^ self privateStyle: aText ] -{ #category : 'private' } -SHRBTextStyler >> stylingEnabled [ - - ^ stylingEnabled -] - -{ #category : 'private' } -SHRBTextStyler >> stylingEnabled: aBoolean [ - - stylingEnabled := aBoolean -] - -{ #category : 'private' } -SHRBTextStyler >> text [ - - ^ text -] - { #category : 'styling' } SHRBTextStyler >> unstyledTextFrom: aText [ "return a Text object without all styling attributes"