From 002bf2e272bd5a86072a13d6b251df685e175093 Mon Sep 17 00:00:00 2001 From: Johan Brichau Date: Sun, 7 Jan 2024 20:05:55 +0100 Subject: [PATCH] Ported ANSI Booleans transformation Slime rule --- .../GRAnsiBooleansRule.class/README.md | 0 .../instance/group.st | 4 ++++ .../instance/initialize.st | 19 +++++++++++++++++++ .../GRAnsiBooleansRule.class/instance/name.st | 4 ++++ .../instance/rationale.st | 4 ++++ .../GRAnsiBooleansRule.class/properties.json | 11 +++++++++++ .../GRAnsiCharactersRule.class/README.md | 0 .../properties.json | 11 +++++++++++ .../class/isVisible.st | 4 ++++ .../class/isVisible.st | 4 ++++ .../README.md | 0 .../class/isVisible.st | 4 ++++ .../properties.json | 11 +++++++++++ .../GRReSlimeTest.class/instance/rules.st | 2 +- .../instance/runTransformation.changes..st | 14 +++++++------- .../instance/testAnsiBooleansRule.st | 2 +- .../testReferencesNotPortableClass.st | 2 +- .../instance/testUnnecessaryLastPeriodRule.st | 10 ---------- .../instance/testUsesNotPortableClass.st | 2 +- 19 files changed, 87 insertions(+), 21 deletions(-) create mode 100644 repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/README.md create mode 100644 repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/instance/group.st create mode 100644 repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/instance/initialize.st create mode 100644 repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/instance/name.st create mode 100644 repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/instance/rationale.st create mode 100644 repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/properties.json create mode 100644 repository/Grease-Pharo110-Slime.package/GRAnsiCharactersRule.class/README.md create mode 100644 repository/Grease-Pharo110-Slime.package/GRAnsiCharactersRule.class/properties.json create mode 100644 repository/Grease-Pharo110-Slime.package/GRReSlimeBlockLintRule.class/class/isVisible.st create mode 100644 repository/Grease-Pharo110-Slime.package/GRReSlimeParseTreeLintRule.class/class/isVisible.st create mode 100644 repository/Grease-Pharo110-Slime.package/GRReSlimeTransformationRule.class/README.md create mode 100644 repository/Grease-Pharo110-Slime.package/GRReSlimeTransformationRule.class/class/isVisible.st create mode 100644 repository/Grease-Pharo110-Slime.package/GRReSlimeTransformationRule.class/properties.json delete mode 100644 repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/testUnnecessaryLastPeriodRule.st diff --git a/repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/README.md b/repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/instance/group.st b/repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/instance/group.st new file mode 100644 index 00000000..f34a290f --- /dev/null +++ b/repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/instance/group.st @@ -0,0 +1,4 @@ +accessing +group + + ^ 'ANSI Compatibility' \ No newline at end of file diff --git a/repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/instance/initialize.st b/repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/instance/initialize.st new file mode 100644 index 00000000..6058ed9f --- /dev/null +++ b/repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/instance/initialize.st @@ -0,0 +1,19 @@ +initialization +initialize + + super initialize. + self + replace: '``@expr1 and: [ | `@temp2 | ``@expr2 ] and: [ | `@temp3 | ``@expr3 ]' + with: '``@expr1 and: [ | `@temp2 | ``@expr2 and: [ | `@temp3 | ``@expr3 ] ]'; + replace: '``@expr1 and: [ | `@temp2 | ``@expr2 ] and: [ | `@temp3 | ``@expr3 ] and: [ | `@temp4 | ``@expr4 ]' + with: '``@expr1 and: [ | `@temp2 | ``@expr2 and: [ | `@temp3 | ``@expr3 and: [ | `@temp4 | ``@expr4 ] ] ]'; + replace: '``@expr1 and: [ | `@temp2 | ``@expr2 ] and: [ | `@temp3 | ``@expr3 ] and: [ | `@temp4 | ``@expr4 ] and: [ | `@temp5 | ``@expr5 ]' + with: '``@expr1 and: [ | `@temp2 | ``@expr2 and: [ | `@temp3 | ``@expr3 and: [ | `@temp4 | ``@expr4 and: [ | `@temp5 | ``@expr5 ] ] ] ]'; + replace: '``@expr1 or: [ | `@temp2 | ``@expr2 ] or: [ | `@temp3 | ``@expr3 ]' + with: '``@expr1 or: [ | `@temp2 | ``@expr2 or: [ | `@temp3 | ``@expr3 ] ]'; + replace: '``@expr1 or: [ | `@temp2 | ``@expr2 ] or: [ | `@temp3 | ``@expr3 ] or: [ | `@temp4 | ``@expr4 ]' + with: '``@expr1 or: [ | `@temp2 | ``@expr2 or: [ | `@temp3 | ``@expr3 or: [ | `@temp4 | ``@expr4 ] ] ]'; + replace: '``@expr1 or: [ | `@temp2 | ``@expr2 ] or: [ | `@temp3 | ``@expr3 ] or: [ | `@temp4 | ``@expr4 ] or: [ | `@temp5 | ``@expr5 ]' + with: '``@expr1 or: [ | `@temp2 | ``@expr2 or: [ | `@temp3 | ``@expr3 or: [ | `@temp4 | ``@expr4 or: [ | `@temp5 | ``@expr5 ] ] ] ]'; + replace: '``@expr1 or: [ | `@temp2 | ``@expr2 ] or: [ | `@temp3 | ``@expr3 ] or: [ | `@temp4 | ``@expr4 ] or: [ | `@temp5 | ``@expr5 ] or: [ | `@temp6 | ``@expr6 ]' + with: '``@expr1 or: [ | `@temp2 | ``@expr2 or: [ | `@temp3 | ``@expr3 or: [ | `@temp4 | ``@expr4 or: [ | `@temp5 | ``@expr5 or: [ | `@temp6 | ``@expr6 ] ] ] ] ]' \ No newline at end of file diff --git a/repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/instance/name.st b/repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/instance/name.st new file mode 100644 index 00000000..c1c48207 --- /dev/null +++ b/repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/instance/name.st @@ -0,0 +1,4 @@ +accessing +name + + ^ 'Booleans' \ No newline at end of file diff --git a/repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/instance/rationale.st b/repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/instance/rationale.st new file mode 100644 index 00000000..b650ed54 --- /dev/null +++ b/repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/instance/rationale.st @@ -0,0 +1,4 @@ +accessing +rationale + + ^ '#and:and: and #or:or: are not ANSI compatible.' \ No newline at end of file diff --git a/repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/properties.json b/repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/properties.json new file mode 100644 index 00000000..208c1ba2 --- /dev/null +++ b/repository/Grease-Pharo110-Slime.package/GRAnsiBooleansRule.class/properties.json @@ -0,0 +1,11 @@ +{ + "commentStamp" : "", + "super" : "GRReSlimeTransformationRule", + "category" : "Grease-Pharo110-Slime", + "classinstvars" : [ ], + "pools" : [ ], + "classvars" : [ ], + "instvars" : [ ], + "name" : "GRAnsiBooleansRule", + "type" : "normal" +} \ No newline at end of file diff --git a/repository/Grease-Pharo110-Slime.package/GRAnsiCharactersRule.class/README.md b/repository/Grease-Pharo110-Slime.package/GRAnsiCharactersRule.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/Grease-Pharo110-Slime.package/GRAnsiCharactersRule.class/properties.json b/repository/Grease-Pharo110-Slime.package/GRAnsiCharactersRule.class/properties.json new file mode 100644 index 00000000..d5fe699b --- /dev/null +++ b/repository/Grease-Pharo110-Slime.package/GRAnsiCharactersRule.class/properties.json @@ -0,0 +1,11 @@ +{ + "commentStamp" : "", + "super" : "GRReSlimeTransformationRule", + "category" : "Grease-Pharo110-Slime", + "classinstvars" : [ ], + "pools" : [ ], + "classvars" : [ ], + "instvars" : [ ], + "name" : "GRAnsiCharactersRule", + "type" : "normal" +} \ No newline at end of file diff --git a/repository/Grease-Pharo110-Slime.package/GRReSlimeBlockLintRule.class/class/isVisible.st b/repository/Grease-Pharo110-Slime.package/GRReSlimeBlockLintRule.class/class/isVisible.st new file mode 100644 index 00000000..0e3a239e --- /dev/null +++ b/repository/Grease-Pharo110-Slime.package/GRReSlimeBlockLintRule.class/class/isVisible.st @@ -0,0 +1,4 @@ +testing +isVisible + + ^ self name ~= #GRReSlimeBlockLintRule \ No newline at end of file diff --git a/repository/Grease-Pharo110-Slime.package/GRReSlimeParseTreeLintRule.class/class/isVisible.st b/repository/Grease-Pharo110-Slime.package/GRReSlimeParseTreeLintRule.class/class/isVisible.st new file mode 100644 index 00000000..2d2913fb --- /dev/null +++ b/repository/Grease-Pharo110-Slime.package/GRReSlimeParseTreeLintRule.class/class/isVisible.st @@ -0,0 +1,4 @@ +testing +isVisible + + ^ self name ~= #GRReSlimeParseTreeLintRule \ No newline at end of file diff --git a/repository/Grease-Pharo110-Slime.package/GRReSlimeTransformationRule.class/README.md b/repository/Grease-Pharo110-Slime.package/GRReSlimeTransformationRule.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/Grease-Pharo110-Slime.package/GRReSlimeTransformationRule.class/class/isVisible.st b/repository/Grease-Pharo110-Slime.package/GRReSlimeTransformationRule.class/class/isVisible.st new file mode 100644 index 00000000..b84d2a50 --- /dev/null +++ b/repository/Grease-Pharo110-Slime.package/GRReSlimeTransformationRule.class/class/isVisible.st @@ -0,0 +1,4 @@ +testing +isVisible + + ^ self name ~= #GRReSlimeTransformationRule \ No newline at end of file diff --git a/repository/Grease-Pharo110-Slime.package/GRReSlimeTransformationRule.class/properties.json b/repository/Grease-Pharo110-Slime.package/GRReSlimeTransformationRule.class/properties.json new file mode 100644 index 00000000..eaa3dd3e --- /dev/null +++ b/repository/Grease-Pharo110-Slime.package/GRReSlimeTransformationRule.class/properties.json @@ -0,0 +1,11 @@ +{ + "commentStamp" : "", + "super" : "ReNodeRewriteRule", + "category" : "Grease-Pharo110-Slime", + "classinstvars" : [ ], + "pools" : [ ], + "classvars" : [ ], + "instvars" : [ ], + "name" : "GRReSlimeTransformationRule", + "type" : "normal" +} \ No newline at end of file diff --git a/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/rules.st b/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/rules.st index 8e2a8f69..58190464 100644 --- a/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/rules.st +++ b/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/rules.st @@ -4,5 +4,5 @@ rules ^ (OrderedCollection new addAll: GRReSlimeBlockLintRule allSubclasses; addAll: GRReSlimeParseTreeLintRule allSubclasses; -" addAll: GRSlimeTransformationRule allSubclasses;" + addAll: GRReSlimeTransformationRule allSubclasses; yourself) reject: #isAbstract \ No newline at end of file diff --git a/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/runTransformation.changes..st b/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/runTransformation.changes..st index 49b8b233..2bbd5df3 100644 --- a/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/runTransformation.changes..st +++ b/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/runTransformation.changes..st @@ -2,14 +2,14 @@ running-checks runTransformation: aClass changes: aCollection | expected | - expected := aCollection - collect: [ :each | RBParser parseMethod: each ]. - self run: aClass ignoring: Array new do: [ :rule :rules | - rule changes do: [ :change | + expected := aCollection collect: [ :each | RBParser parseMethod: each ]. + self run: aClass ignoring: Array new do: [ :critiques | | changes | + changes := critiques collect:[ :critique | critique change ]. + changes do: [ :change | self assert: (expected anySatisfy: [ :parseTree | change parseTree = parseTree ]) - description: change selector , ' should not be transformed' ]. + description: ('{1} should not be transformed' format: { change selector }) ]. expected do: [ :parseTree | self - assert: (rule changes anySatisfy: [ :change | change parseTree = parseTree ]) - description: parseTree selector , ' should be transformed' ] ] \ No newline at end of file + assert: (changes anySatisfy: [ :change | change parseTree = parseTree ]) + description: ('{1} should be transformed' format: { parseTree selector }) ] ] \ No newline at end of file diff --git a/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/testAnsiBooleansRule.st b/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/testAnsiBooleansRule.st index d4020fe4..fc3a5aee 100644 --- a/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/testAnsiBooleansRule.st +++ b/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/testAnsiBooleansRule.st @@ -1,6 +1,6 @@ tests-transform testAnsiBooleansRule - + | class | class := self defineSubClassOf: #GRObject. self compile: 'and 1 and: [ 2 ] and: [ 3 ] and: [ 4 ]' in: class. diff --git a/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/testReferencesNotPortableClass.st b/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/testReferencesNotPortableClass.st index dbc22862..6c1b5b23 100644 --- a/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/testReferencesNotPortableClass.st +++ b/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/testReferencesNotPortableClass.st @@ -8,4 +8,4 @@ testReferencesNotPortableClass self compile: 'valid ^ GRObject new' in: class. self assertRule: GRReferencesNotPortableClassRule - matches: { class>>#invalid }. \ No newline at end of file + matches: { class>>#invalid } \ No newline at end of file diff --git a/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/testUnnecessaryLastPeriodRule.st b/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/testUnnecessaryLastPeriodRule.st deleted file mode 100644 index d6358cc7..00000000 --- a/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/testUnnecessaryLastPeriodRule.st +++ /dev/null @@ -1,10 +0,0 @@ -tests-block -testUnnecessaryLastPeriodRule - - | class | - class := self defineSubClassOf: #GRObject. - self compile: 'invalid 1. 2.' in: class. - self compile: 'valid 1. 2' in: class. - self - assertRule: ReUnnecessaryLastPeriodRule - matches: { class>>#invalid } \ No newline at end of file diff --git a/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/testUsesNotPortableClass.st b/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/testUsesNotPortableClass.st index 2df0cfed..5699c982 100644 --- a/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/testUsesNotPortableClass.st +++ b/repository/Grease-Tests-Pharo-Slime.package/GRReSlimeTest.class/instance/testUsesNotPortableClass.st @@ -8,4 +8,4 @@ testUsesNotPortableClass self compile: 'valid ^ GRObject new' in: class. self assertRule: GRReferencesNotPortableClassRule - matches: { class>>#invalid }. \ No newline at end of file + matches: { class>>#invalid } \ No newline at end of file