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

63 Implement dot at end of Method with tests #99

Open
wants to merge 2 commits into
base: master
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
visiting
exampleMethod

'abc' reverse.
true ifFalse: [
'cba' reverse.
^ 1 + 1]
Original file line number Diff line number Diff line change
@@ -16,9 +16,10 @@ visitBlockNode: aNode
aNode statements do: [:statement |
(self isEmptyLineMarker: statement) ifTrue: [self newLine] ifFalse: [
self visitNode: statement.
statement ~= aNode statements last ifTrue: [
(statement ~= aNode statements last or: [config dotAtEndOfMethod and: [isMethodBlock and: [(statement isKindOf: ReturnNode) not]]]) ifTrue: [
stream nextPut: $..
self newLine]].
statement ~= aNode statements last ifTrue: [self newLine]]].
self printAllCommentsOf: statement lastStatement: statement = aNode statements last]].

isMethodBlock ifFalse: [stream nextPut: $]]
isMethodBlock ifFalse: [stream nextPut: $]].

Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
"config:" : "KD 6/15/2022 15:57",
"contents" : "tobe 3/10/2021 14:58",
"example:receiver:args:" : "tobe 3/10/2021 14:58",
"exampleMethod" : "KD 8/4/2022 10:01",
"formatTemporariesOf:isMethod:" : "KD 6/15/2022 16:11",
"indent" : "Alexander Ungefug 5/30/2022 19:04",
"indent:" : "tobe 3/10/2021 14:58",
@@ -53,7 +54,7 @@
"stream" : "tobe 3/10/2021 14:58",
"stream:" : "KD 6/15/2022 16:00",
"visitAssignmentNode:" : "tobe 3/10/2021 14:58",
"visitBlockNode:" : "KD 6/15/2022 16:11",
"visitBlockNode:" : "KD 8/4/2022 10:08",
"visitBraceNode:" : "KD 6/15/2022 16:05",
"visitCascadeNode:" : "tobe 3/10/2021 17:17",
"visitFutureNode:" : "tobe 3/10/2021 14:58",
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
dotAtEndOfMethod: aBoolean

dotAtEndOfMethod := aBoolean
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
dotAtEndOfMethod

^ dotAtEndOfMethod ifNil: [dotAtEndOfMethod := false]
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@
"class" : {
"default" : "KD 6/15/2022 16:11" },
"instance" : {
"dotAtEndOfMethod" : "KD 8/4/2022 10:08",
"dotAtEndOfMethod:" : "KD 8/4/2022 10:25",
"spaceBeforeComma" : "KD 6/15/2022 16:07",
"spaceBeforeComma:" : "YH 6/2/2022 14:16",
"spaceBeforePointInArray" : "Alexander Ungefug 6/1/2022 15:59",
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
"commentStamp" : "",
"instvars" : [
"spaceBeforeComma",
"spaceBeforePointInArray" ],
"spaceBeforePointInArray",
"dotAtEndOfMethod" ],
"name" : "PPFormatterConfig",
"pools" : [
],
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
helper
getConfigDotAtMethodEnd

^ PPFormatterConfig default dotAtEndOfMethod: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tests - dotAtMethodEnd
testDotAtMethodEnd1

self canFormat:
'test

1 + 1.'
with: self getConfigDotAtMethodEnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tests - dotAtMethodEnd
testDotAtMethodEnd2

self canFormat:
'test

^ 1 + 1'
with: self getConfigDotAtMethodEnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tests - dotAtMethodEnd
testDotAtMethodEnd3

self canFormat:
'test

[1 + 1].'
with: self getConfigDotAtMethodEnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tests - dotAtMethodEnd
testDotAtMethodEnd4

self canFormat:
'test

^ [1 + 1]'
with: self getConfigDotAtMethodEnd
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
"canFormatMethod:" : "KD 6/15/2022 16:11",
"exampleExplorerContents" : "tobe 3/11/2021 10:20",
"exampleMorphDoLayoutIn" : "tobe 3/11/2021 09:00",
"getConfigDotAtMethodEnd" : "KD 8/4/2022 10:10",
"getConfigSpacesBeforeComma" : "YH 6/2/2022 10:20",
"getConfigSpacesBeforePointInArray" : "KD 6/15/2022 15:56",
"testAllMethods" : "KD 6/15/2022 16:11",
@@ -19,6 +20,10 @@
"testCommentBetweenEmptyLines" : "tobe 3/10/2021 14:58",
"testCommentOrder" : "tobe 3/10/2021 14:58",
"testComments" : "tobe 3/10/2021 14:58",
"testDotAtMethodEnd1" : "KD 8/4/2022 10:28",
"testDotAtMethodEnd2" : "KD 8/4/2022 10:29",
"testDotAtMethodEnd3" : "KD 8/4/2022 10:29",
"testDotAtMethodEnd4" : "KD 8/4/2022 10:29",
"testEmptyLineInArray" : "tobe 3/11/2021 10:45",
"testEmptyLineInCaseOf" : "tobe 3/11/2021 10:54",
"testEmptyLinesBetweenComments" : "tobe 3/11/2021 11:35",