diff --git a/packages/PoppyPrint-Core.package/PPFormatter.class/instance/exampleMethod.st b/packages/PoppyPrint-Core.package/PPFormatter.class/instance/exampleMethod.st new file mode 100644 index 0000000..c422c4b --- /dev/null +++ b/packages/PoppyPrint-Core.package/PPFormatter.class/instance/exampleMethod.st @@ -0,0 +1,7 @@ +visiting +exampleMethod + + 'abc' reverse. + true ifFalse: [ + 'cba' reverse. + ^ 1 + 1] \ No newline at end of file diff --git a/packages/PoppyPrint-Core.package/PPFormatter.class/instance/visitBlockNode..st b/packages/PoppyPrint-Core.package/PPFormatter.class/instance/visitBlockNode..st index 68e8ced..01f8be2 100644 --- a/packages/PoppyPrint-Core.package/PPFormatter.class/instance/visitBlockNode..st +++ b/packages/PoppyPrint-Core.package/PPFormatter.class/instance/visitBlockNode..st @@ -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: $]] \ No newline at end of file + isMethodBlock ifFalse: [stream nextPut: $]]. + \ No newline at end of file diff --git a/packages/PoppyPrint-Core.package/PPFormatter.class/methodProperties.json b/packages/PoppyPrint-Core.package/PPFormatter.class/methodProperties.json index 7b76b79..aa75a6b 100644 --- a/packages/PoppyPrint-Core.package/PPFormatter.class/methodProperties.json +++ b/packages/PoppyPrint-Core.package/PPFormatter.class/methodProperties.json @@ -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", diff --git a/packages/PoppyPrint-Core.package/PPFormatterConfig.class/instance/dotAtEndOfMethod..st b/packages/PoppyPrint-Core.package/PPFormatterConfig.class/instance/dotAtEndOfMethod..st new file mode 100644 index 0000000..4cf53d8 --- /dev/null +++ b/packages/PoppyPrint-Core.package/PPFormatterConfig.class/instance/dotAtEndOfMethod..st @@ -0,0 +1,4 @@ +accessing +dotAtEndOfMethod: aBoolean + + dotAtEndOfMethod := aBoolean \ No newline at end of file diff --git a/packages/PoppyPrint-Core.package/PPFormatterConfig.class/instance/dotAtEndOfMethod.st b/packages/PoppyPrint-Core.package/PPFormatterConfig.class/instance/dotAtEndOfMethod.st new file mode 100644 index 0000000..e6f0625 --- /dev/null +++ b/packages/PoppyPrint-Core.package/PPFormatterConfig.class/instance/dotAtEndOfMethod.st @@ -0,0 +1,4 @@ +accessing +dotAtEndOfMethod + + ^ dotAtEndOfMethod ifNil: [dotAtEndOfMethod := false] \ No newline at end of file diff --git a/packages/PoppyPrint-Core.package/PPFormatterConfig.class/methodProperties.json b/packages/PoppyPrint-Core.package/PPFormatterConfig.class/methodProperties.json index d1250b6..77ae637 100644 --- a/packages/PoppyPrint-Core.package/PPFormatterConfig.class/methodProperties.json +++ b/packages/PoppyPrint-Core.package/PPFormatterConfig.class/methodProperties.json @@ -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", diff --git a/packages/PoppyPrint-Core.package/PPFormatterConfig.class/properties.json b/packages/PoppyPrint-Core.package/PPFormatterConfig.class/properties.json index 8d7bee4..8d4d232 100644 --- a/packages/PoppyPrint-Core.package/PPFormatterConfig.class/properties.json +++ b/packages/PoppyPrint-Core.package/PPFormatterConfig.class/properties.json @@ -7,7 +7,8 @@ "commentStamp" : "", "instvars" : [ "spaceBeforeComma", - "spaceBeforePointInArray" ], + "spaceBeforePointInArray", + "dotAtEndOfMethod" ], "name" : "PPFormatterConfig", "pools" : [ ], diff --git a/packages/PoppyPrint-Tests.package/PPFormatterTest.class/instance/getConfigDotAtMethodEnd.st b/packages/PoppyPrint-Tests.package/PPFormatterTest.class/instance/getConfigDotAtMethodEnd.st new file mode 100644 index 0000000..1804f12 --- /dev/null +++ b/packages/PoppyPrint-Tests.package/PPFormatterTest.class/instance/getConfigDotAtMethodEnd.st @@ -0,0 +1,4 @@ +helper +getConfigDotAtMethodEnd + + ^ PPFormatterConfig default dotAtEndOfMethod: true \ No newline at end of file diff --git a/packages/PoppyPrint-Tests.package/PPFormatterTest.class/instance/testDotAtMethodEnd1.st b/packages/PoppyPrint-Tests.package/PPFormatterTest.class/instance/testDotAtMethodEnd1.st new file mode 100644 index 0000000..4df2bb7 --- /dev/null +++ b/packages/PoppyPrint-Tests.package/PPFormatterTest.class/instance/testDotAtMethodEnd1.st @@ -0,0 +1,8 @@ +tests - dotAtMethodEnd +testDotAtMethodEnd1 + + self canFormat: +'test + + 1 + 1.' + with: self getConfigDotAtMethodEnd \ No newline at end of file diff --git a/packages/PoppyPrint-Tests.package/PPFormatterTest.class/instance/testDotAtMethodEnd2.st b/packages/PoppyPrint-Tests.package/PPFormatterTest.class/instance/testDotAtMethodEnd2.st new file mode 100644 index 0000000..a41b0db --- /dev/null +++ b/packages/PoppyPrint-Tests.package/PPFormatterTest.class/instance/testDotAtMethodEnd2.st @@ -0,0 +1,8 @@ +tests - dotAtMethodEnd +testDotAtMethodEnd2 + + self canFormat: +'test + + ^ 1 + 1' + with: self getConfigDotAtMethodEnd diff --git a/packages/PoppyPrint-Tests.package/PPFormatterTest.class/instance/testDotAtMethodEnd3.st b/packages/PoppyPrint-Tests.package/PPFormatterTest.class/instance/testDotAtMethodEnd3.st new file mode 100644 index 0000000..32a22dc --- /dev/null +++ b/packages/PoppyPrint-Tests.package/PPFormatterTest.class/instance/testDotAtMethodEnd3.st @@ -0,0 +1,8 @@ +tests - dotAtMethodEnd +testDotAtMethodEnd3 + + self canFormat: +'test + + [1 + 1].' + with: self getConfigDotAtMethodEnd \ No newline at end of file diff --git a/packages/PoppyPrint-Tests.package/PPFormatterTest.class/instance/testDotAtMethodEnd4.st b/packages/PoppyPrint-Tests.package/PPFormatterTest.class/instance/testDotAtMethodEnd4.st new file mode 100644 index 0000000..eea12b3 --- /dev/null +++ b/packages/PoppyPrint-Tests.package/PPFormatterTest.class/instance/testDotAtMethodEnd4.st @@ -0,0 +1,8 @@ +tests - dotAtMethodEnd +testDotAtMethodEnd4 + + self canFormat: +'test + + ^ [1 + 1]' + with: self getConfigDotAtMethodEnd \ No newline at end of file diff --git a/packages/PoppyPrint-Tests.package/PPFormatterTest.class/methodProperties.json b/packages/PoppyPrint-Tests.package/PPFormatterTest.class/methodProperties.json index 0031466..1f5dad1 100644 --- a/packages/PoppyPrint-Tests.package/PPFormatterTest.class/methodProperties.json +++ b/packages/PoppyPrint-Tests.package/PPFormatterTest.class/methodProperties.json @@ -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",