Skip to content

Commit

Permalink
Ported ANSI Booleans transformation Slime rule
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrichau committed Jan 7, 2024
1 parent e34bcc2 commit 002bf2e
Show file tree
Hide file tree
Showing 19 changed files with 87 additions and 21 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
group

^ 'ANSI Compatibility'
Original file line number Diff line number Diff line change
@@ -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 ] ] ] ] ]'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
name

^ 'Booleans'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
rationale

^ '#and:and: and #or:or: are not ANSI compatible.'
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "",
"super" : "GRReSlimeTransformationRule",
"category" : "Grease-Pharo110-Slime",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "GRAnsiBooleansRule",
"type" : "normal"
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "",
"super" : "GRReSlimeTransformationRule",
"category" : "Grease-Pharo110-Slime",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "GRAnsiCharactersRule",
"type" : "normal"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testing
isVisible

^ self name ~= #GRReSlimeBlockLintRule
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testing
isVisible

^ self name ~= #GRReSlimeParseTreeLintRule
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testing
isVisible

^ self name ~= #GRReSlimeTransformationRule
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "",
"super" : "ReNodeRewriteRule",
"category" : "Grease-Pharo110-Slime",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "GRReSlimeTransformationRule",
"type" : "normal"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ rules
^ (OrderedCollection new
addAll: GRReSlimeBlockLintRule allSubclasses;
addAll: GRReSlimeParseTreeLintRule allSubclasses;
" addAll: GRSlimeTransformationRule allSubclasses;"
addAll: GRReSlimeTransformationRule allSubclasses;
yourself) reject: #isAbstract
Original file line number Diff line number Diff line change
Expand Up @@ -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' ] ]
assert: (changes anySatisfy: [ :change | change parseTree = parseTree ])
description: ('{1} should be transformed' format: { parseTree selector }) ] ]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tests-transform
testAnsiBooleansRule
<expectedFailure>

| class |
class := self defineSubClassOf: #GRObject.
self compile: 'and 1 and: [ 2 ] and: [ 3 ] and: [ 4 ]' in: class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ testReferencesNotPortableClass
self compile: 'valid ^ GRObject new' in: class.
self
assertRule: GRReferencesNotPortableClassRule
matches: { class>>#invalid }.
matches: { class>>#invalid }

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ testUsesNotPortableClass
self compile: 'valid ^ GRObject new' in: class.
self
assertRule: GRReferencesNotPortableClassRule
matches: { class>>#invalid }.
matches: { class>>#invalid }

0 comments on commit 002bf2e

Please sign in to comment.