Skip to content

Commit

Permalink
Merge pull request #41 from moosetechnology/refactoring
Browse files Browse the repository at this point in the history
Refactoring a bit how indentation is handled
  • Loading branch information
NicolasAnquetil authored Dec 11, 2023
2 parents 527bdf4 + 86cabf8 commit 17d7a16
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/FAST-Core-Visitor/FASTTExporter.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ It offers two features:
Trait {
#name : #FASTTExporter,
#instVars : [
'indent',
'operatorsPrecedence',
'expressionContextOperator',
'outputStream'
'outputStream',
'indentLevel'
],
#category : #'FAST-Core-Visitor'
}
Expand Down Expand Up @@ -133,8 +133,13 @@ FASTTExporter >> expressionContextOperator [
{ #category : #outputting }
FASTTExporter >> indent [

indent ifNil: [ ^indent := 1 ].
^indent := indent + 1
^indentLevel := self indentLevel + 1
]

{ #category : #accessing }
FASTTExporter >> indentLevel [

^ indentLevel ifNil: [ indentLevel := 0 ]
]

{ #category : #outputting }
Expand Down Expand Up @@ -220,8 +225,7 @@ FASTTExporter >> outputExpression: aBlock withOperator: operator [
FASTTExporter >> outputIndentPrefix [
"prints indentation spaces"

indent ifNil: [ indent := 0 ].
self spaces: (indent * 2)
self spaces: (self indentLevel * 2)

]

Expand Down Expand Up @@ -260,9 +264,8 @@ FASTTExporter >> spaces: n [
{ #category : #outputting }
FASTTExporter >> unindent [

indent ifNil: [ ^indent := 0 ].
(indent <= 0) ifTrue: [ ^indent := 0 ].
^indent := indent - 1
(self indentLevel <= 0) ifTrue: [ ^indentLevel := 0 ].
^indentLevel := self indentLevel - 1
]

{ #category : #outputting }
Expand Down

0 comments on commit 17d7a16

Please sign in to comment.