Skip to content
Open
Show file tree
Hide file tree
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
Expand Up @@ -3,7 +3,7 @@ baseline: spec
<baseline>

spec for: #'pharo6.x' do: [ spec package: 'MatchTool' ].
spec for: #'pharo7.x' do: [
spec for: #(#'pharo7.x' #'pharo8.x') do: [
spec package: 'MatchTool'.
spec package: 'MatchTool-Pharo7' with: [ spec requires: 'MatchTool' ] ].

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ initialize
self changed: #isForMethod: with: { bool } ].

self
beForCode;
aboutToStyle: true.
2 changes: 1 addition & 1 deletion MatchTool.package/MatchTextModel.class/properties.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"commentStamp" : "YuriyTymchuk 7/28/2016 23:41",
"super" : "TextModel",
"super" : "CodePresenter",
"category" : "MatchTool-ExtraSpec",
"classinstvars" : [ ],
"pools" : [ ],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
api
extent
initialExtent

^ 800 @ 400
6 changes: 2 additions & 4 deletions MatchTool.package/MatchTool.class/instance/initializeLists.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@ initializeLists
displayBlock: [ :assoc | assoc key formattedCode ].
matchMap
disable;
allowToSelect: false;
displayBlock: [ :assoc |
{assoc key formattedCode.
assoc value formattedCode} ]
addColumn: (StringTableColumn evaluated: [:assoc | assoc key formattedCode]);
addColumn: (StringTableColumn evaluated: [:assoc | assoc value formattedCode]).
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
initialization
initializePresenter
matchExpression
beForPatternCode;
whenCodeEdited: [ self disableLists ];
whenMethodStateChangedDo: [ self disableLists ];
whenMethodActivatedDo: [ self matchMethodActivated ].

testExpression
whenCodeEdited: [ self disableLists ];
whenMethodStateChangedDo: [ self disableLists ];
whenMethodDeactivatedDo: [ self testMethodDeactivated ].

executeButton action: [ self performMatching ].
helpButton action: [ HelpBrowser openOn: MatchToolHelp ].

resultList
whenSelectedItemChanged: [ :assoc |
self selectedResultsItemChanged: assoc ];
whenListChanged:
[ :newItems | self resultsChanged: newItems ].
whenSelectionChangedDo: [ :selection |
[ :assoc | self selectedResultsItemChanged: assoc ]
cull: selection selectedItem ];
whenModelChangedDo: [ :newItems | self resultsChanged: newItems ]
11 changes: 4 additions & 7 deletions MatchTool.package/MatchTool.class/instance/initializeWidgets.st
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
initialization
initializeWidgets
self instantiateWidgets.

matchExpression
title: 'Pattern code';
beForPatternCode.
beForPatternCode.
testExpression title: 'Test code'.

executeButton
icon: #smallDoIt asIcon;
icon:
(self iconNamed: #smallDoIt);
label: 'Match';
shortcut: Character cr meta.

helpButton
icon: (#questionIcon asIcon scaledToSize: 22 @ 22);
icon: ((self iconNamed: #questionIcon) scaledToSize: 22 @ 22);
shortcut: $h meta.

self initializeLists.
self initializeFocusOrder
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ instantiateWidgets
resultList := self newList.
executeButton := self newButton.
helpButton := self newButton.
matchMap := self newMultiColumnList
matchMap := self newTable
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
initialization
resultsChanged: newItems
matchMap items: #().
resultList resetSelection.
resultList unselectAll.
^ newItems
ifEmpty: [ resultList borderColor: Color red ]
ifNotEmpty: [ resultList borderColor: Color green ]
2 changes: 1 addition & 1 deletion MatchTool.package/MatchTool.class/properties.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"commentStamp" : "YuriyTymchuk 7/24/2016 10:38",
"super" : "ComposableModel",
"super" : "ComposablePresenter",
"category" : "MatchTool",
"classinstvars" : [ ],
"pools" : [ ],
Expand Down
8 changes: 4 additions & 4 deletions MatchTool.package/MatchToolHelp.class/class/listPatterns.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ listPatterns

^ HelpTopic
title: '(`@) List Pattern Nodes'
contents: 'To have a complete flexibility there is a possibility to use at sign (@) before the name of a pattern not which turns the node into a “list pattern node”. These node can match more than a single entity. For example
contents: 'To have complete flexibility there is the possibility to use the at sign (@) before the name of a pattern node which turns the node into a “list pattern node”. These nodes can match more than a single entity. For example

`@expr isPatternVariable

Expand All @@ -30,18 +30,18 @@ Similarly you can match a list of temporary variables:
`@method: `@args
| `temp `@temps |

This will match any method with one or more temporary variables and without any statement. The first temporary variable will be mapped to `temp the rest ones — to `@temps.
This will match any method with one or more temporary variables and without any statement. The first temporary variable will be mapped to `temp the remaining ones — to `@temps.


Finally you can have a list of statements:

[ `.@Statements.
`var := `@object ]

this expression will match a block which has an assignment of an expression to a variable as a last statement. It can be preceded by any number of other statement (including 0).
this expression will match a block which has an assignment of an expression to a variable as its last statement. It can be preceded by any number of other statement (including 0).


The list patterns does not make any sense for literal nodes i.e. `#@literal.


P.S. In the end it does not matter whether you will write `.@Statement or `@.Statement. But I like to put @ closer to the variable name as the character is larger itself and the name looks nicer this way.'
P.S. In the end it does not matter whether you write `.@Statement or `@.Statement. But I like to put @ closer to the variable name as the character is larger itself and the name looks nicer this way.'
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ namingImportant

^ HelpTopic
title: 'Naming is Important'
contents: 'The pattern nodes are that so you can match anything in their place. But their naming is also important as the code get’s mapped to them by name. For example:
contents: 'The pattern nodes work so they can match anything that fits. But their naming is important as the code get’s mapped to them by name. For example:

`block value: `@expression value: `@expression

will match only those “value:value:” messages that have exactly the same expressions as both argument. It is like that because we used the same pattern variable name.'
will match only those “value:value:” messages that have exactly the same expressions as both arguments. It is like that because we used the same pattern variable name.'
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ patternCodeIntro

^ HelpTopic
title: 'Pattern Code Introduction'
contents: 'Pattern code is very similar to an ordinary Smalltalk code, but allows to specify some “wildcards”. The purpose is fairly simple. Imagine that you have a piece of code
contents: 'Pattern code is very similar to ordinary Smalltalk code, but allows to specify some “wildcards”. The purpose is fairly simple. Imagine that you have a piece of code

car isNil ifTrue: [ ^ self ].

You can positively compare it with the same piece of code for equality, but won’t it be cool if you could compare something similar, but ignoring the fact that the receiver it named “car”? With pattern rules you can do exactly that. Consider the following code and notice backtick before car:
You can positively compare it with the same piece of code for equality, but won’t it be cool if you could compare something similar, but ignoring the fact that the receiver is named “car”? With pattern rules you can do exactly that. Consider the following code and notice the backtick before car:

`car isNil ifTrue: [ ^ self ].

Now this expression can match any other expression where “isNil ifTrue: [ ^ self ]” is sent to any variable (or literal). With such power you can find all the usages of “isNil ifTrue:” and replace them with “ifNil”.
Now this expression can match any other expression where “isNil ifTrue: [ ^ self ]” is sent to any variable (or literal). With such power you can find all the users of “isNil ifTrue:” and replace them with “ifNil”.

The following sections will go over different kinds of wildcards (pattern nodes).'
8 changes: 4 additions & 4 deletions MatchTool.package/MatchToolHelp.class/class/uiExplanation.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ uiExplanation

The main window consist of 3 columns.

Fists column consists of two code areas. The top one should be used to enter a *match code* also known as pattern code, while the bottom one should be used for entering a plain Smalltalk code as a *test sample*. Both text areas can be switched into a "method mode" when they will parse the entered text as it is method, otherwise they expect the entered code to be an expression.
The first column consists of two code areas. The top one should be used to enter a *match code* also known as pattern code, while the bottom one should be used for entering plain Smalltalk code as a *test sample*. Both text areas can be switched into a "method mode" when they will parse the entered text as it is method, otherwise they expect the entered code to be an expression.

Second column contains **result of matching**, **help button** and the main **execute button** (with a "cmd(ctrl)+enter" shortcut) on top of it. After the button is pressed, both match code and test code are accepted and if there are no errors the matching is performed. MatchTool searches for the match pattern in all the test sample and list the detected matches in the result list. Clicking on the items from the result list highlights the matched interval in the test sample code area and shows the **match map** of the pattern code in the third column.
The second column contains the **result of matching**, **help button** and the main **execute button** (with a "cmd(ctrl)+enter" shortcut) on top of it. After the button is pressed, both match code and test code are accepted and if there are no errors the matching is performed. MatchTool searches for the match pattern in all the test sample and lists the detected matches in the result list. Clicking on the items from the result list highlights the matched interval in the test sample code area and shows the **match map** of the pattern code in the third column.

Match map probably needs more explanation. Imagine you have a pattern

`item printOn: `@expr

While it will match a test sample

url printOn: FileStream stdout
url printOn: (ZnCharacterWriteStream on: Stdio stdout)

the match map list will tell you that <`item> was mapped to <url> while <`@expr> was mapped to <FileStream stdout>.'
the match map list will tell you that <`item> was mapped to <url> while <`@expr> was mapped to <(ZnCharacterWriteStream on: Stdio stdout)>.'
2 changes: 1 addition & 1 deletion MatchTool.package/MatchToolHelp.class/class/whatNext.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ whatNext

^ HelpTopic
title: 'What Next?'
contents: 'At the moment you can create quality rule that use pattern expression to detect and even automatically fix violations. If you are interested in implementing new rules based on the pattern code I recommend you to read the documentation about Renraku, the quality model. Just DoIt:
contents: 'At the moment you can create quality rules that use pattern expressions to detect and even automatically fix violations. If you are interested in implementing new rules based on the pattern code I recommend you to read the documentation about Renraku, the quality model. Just DoIt:

HelpBrowser openOn: RenrakuHelp

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"commentStamp" : "YuriyTymchuk 7/28/2016 23:11",
"super" : "ComposableModel",
"super" : "ComposablePresenter",
"category" : "MatchTool",
"classinstvars" : [ ],
"pools" : [ ],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
initialize-release
updateMode
self textArea shoutStyler styler
beForSmalltalkCode;
beForExpression.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
initialize-release
updateTextAreaWhenPlugged
super updateTextAreaWhenPlugged.

updateMode
self textArea shoutStyler styler
beForSmalltalkCode;
beForMethod.

self restyleTextArea.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
initialize-release
updateMode
self textArea shoutStyler styler
beForMatchCode;
beForExpression

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
initialize-release
updateMode
self textArea shoutStyler styler
beForMatchCode;
beForMethod.

This file was deleted.

3 changes: 3 additions & 0 deletions MatchTool.package/MchToolMode.class/instance/updateMode.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
initialize-release
updateMode
self subclassResponsibility
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
initialize-release
updateTextAreaWhenPlugged
self withShoutStyler.
self textArea shoutStyler beForMatchTool.
self textArea shoutStyler beForMatchTool.
self updateMode.
self restyleTextArea