Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup Shout #17247

Open
wants to merge 1 commit into
base: Pharo13
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 8 additions & 55 deletions src/Shout/SHRBTextStyler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ Class {
'bracketLevel',
'classOrMetaClass',
'workspace',
'plugins',
'braceLevel',
'view',
'stylingEnabled',
'text',
'isScripting'
],
#classInstVars : [
Expand Down Expand Up @@ -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 [

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -835,7 +820,6 @@ SHRBTextStyler >> hasSymbolStartingBy: aSymbol [
SHRBTextStyler >> initialize [

super initialize.
stylingEnabled := true.
isScripting := false
]

Expand Down Expand Up @@ -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' }
Expand Down Expand Up @@ -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 ]
Expand All @@ -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)
]

Expand Down Expand Up @@ -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"
Expand Down