--- a/SmallSense__CriticsWindow.st Tue Jan 02 20:03:15 2018 +0100
+++ b/SmallSense__CriticsWindow.st Tue Jan 16 22:25:41 2018 +0100
@@ -5,7 +5,7 @@
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
-version 2.1 of the License.
+version 2.1 of the License.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -38,7 +38,7 @@
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
-version 2.1 of the License.
+version 2.1 of the License.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -53,7 +53,7 @@
!CriticsWindow class methodsFor:'help specs'!
-flyByHelpSpec
+helpSpec
"This resource specification was automatically generated
by the UIHelpTool of ST/X."
@@ -66,7 +66,7 @@
- ^ super flyByHelpSpec addPairsFrom:#(
+ ^ super helpSpec addPairsFrom:#(
#applyRuleIn
'Apply this rule on more code.'
@@ -97,80 +97,80 @@
<resource: #canvas>
- ^
+ ^
#(FullSpec
name: windowSpec
- window:
+ window:
(WindowSpec
- label: 'SmalllintRuleDetail'
- name: 'SmalllintRuleDetail'
- min: (Point 10 10)
- bounds: (Rectangle 0 0 563 384)
- backgroundColor: (Color 100.0 100.0 75.0)
- forceRecursiveBackgroundOfDefaultBackground: true
+ label: 'SmalllintRuleDetail'
+ name: 'SmalllintRuleDetail'
+ min: (Point 10 10)
+ bounds: (Rectangle 0 0 563 384)
+ backgroundColor: (Color 100.0 100.0 75.0)
+ forceRecursiveBackgroundOfDefaultBackground: true
)
- component:
+ component:
(SpecCollection
- collection: (
- (ActionButtonSpec
- label: 'closeIcon'
- name: 'Button4'
- layout: (AlignmentOrigin 0 1 0 0 1 0)
- visibilityChannel: notCloseOnLeave
- hasCharacterOrientedLabel: false
- translateLabel: true
- model: closeRequest
- )
- (HTMLViewSpec
- name: 'Rationale'
- layout: (LayoutFrame 0 0 20 0 0 1 -65 1)
- level: 0
- visibilityChannel: rationaleVisibleHolder
- hasHorizontalScrollBar: true
- hasVerticalScrollBar: true
- miniScrollerHorizontal: true
- miniScrollerVertical: true
- htmlText: ruleRationaleAndFixesHTMLHolder
- postBuildCallback: setupHTMLView:
- )
- (LinkButtonSpec
- label: 'Disable this Rule'
- name: 'Button3'
- layout: (LayoutFrame -1 0 -59 1 -16 1 -30 1)
- activeHelpKey: disableRule
- level: 0
- translateLabel: true
- labelChannel: disableRuleString
- adjust: left
- model: disableLintRule
- keepSpaceForOSXResizeHandleH: true
- )
- (LinkButtonSpec
- label: 'Apply this Rule In...'
- name: 'Button5'
- layout: (AlignmentOrigin 0 1 -59 1 1 0)
- activeHelpKey: applyRuleIn
- level: 0
- translateLabel: true
- labelChannel: applyRuleInString
- resizeForLabel: true
- adjust: left
- model: applyLintRuleIn
- keepSpaceForOSXResizeHandleH: true
- )
- (LinkButtonSpec
- name: 'Button1'
- layout: (LayoutFrame 0 0 -29 1 -16 1 0 1)
- activeHelpKey: browseRule
- level: 0
- translateLabel: true
- labelChannel: ruleNameAspect
- adjust: left
- model: browseLintRule
- keepSpaceForOSXResizeHandleH: true
- )
- )
-
+ collection: (
+ (ActionButtonSpec
+ label: 'closeIcon'
+ name: 'Button4'
+ layout: (AlignmentOrigin 0 1 0 0 1 0)
+ visibilityChannel: notCloseOnLeave
+ hasCharacterOrientedLabel: false
+ translateLabel: true
+ model: closeRequest
+ )
+ (HTMLViewSpec
+ name: 'Rationale'
+ layout: (LayoutFrame 0 0 20 0 0 1 -65 1)
+ level: 0
+ visibilityChannel: rationaleVisibleHolder
+ hasHorizontalScrollBar: true
+ hasVerticalScrollBar: true
+ miniScrollerHorizontal: true
+ miniScrollerVertical: true
+ htmlText: ruleRationaleAndFixesHTMLHolder
+ postBuildCallback: setupHTMLView:
+ )
+ (LinkButtonSpec
+ label: 'Disable this Rule'
+ name: 'Button3'
+ layout: (LayoutFrame -1 0 -59 1 -16 1 -30 1)
+ activeHelpKey: disableRule
+ level: 0
+ translateLabel: true
+ labelChannel: disableRuleString
+ adjust: left
+ model: disableLintRule
+ keepSpaceForOSXResizeHandleH: true
+ )
+ (LinkButtonSpec
+ label: 'Apply this Rule In...'
+ name: 'Button5'
+ layout: (AlignmentOrigin 0 1 -59 1 1 0)
+ activeHelpKey: applyRuleIn
+ level: 0
+ translateLabel: true
+ labelChannel: applyRuleInString
+ resizeForLabel: true
+ adjust: left
+ model: applyLintRuleIn
+ keepSpaceForOSXResizeHandleH: true
+ )
+ (LinkButtonSpec
+ name: 'Button1'
+ layout: (LayoutFrame 0 0 -29 1 -16 1 0 1)
+ activeHelpKey: browseRule
+ level: 0
+ translateLabel: true
+ labelChannel: ruleNameAspect
+ adjust: left
+ model: browseLintRule
+ keepSpaceForOSXResizeHandleH: true
+ )
+ )
+
)
)
! !
@@ -189,7 +189,7 @@
(if this app is embedded in a subCanvas)."
^ #(
- #ruleHolder
+ #ruleHolder
).
! !
@@ -248,34 +248,34 @@
cls := codeView textView editedClass.
cls notNil ifTrue:[
- pkg := cls package
- ].
+ pkg := cls package
+ ].
dialog := Tools::SearchDialog new
- currentClass:cls;
- currentPackage:pkg;
- setupToAskForMethodSearchTitle:(resources string:'Apply rule in:')
- forBrowser:nil
- searchWhat:nil searchArea:#everywhere
- withCaseIgnore:false withMatch:false
- withMethodList:false
- allowFind:false allowBuffer:false allowBrowser:true
- withTextEntry:false.
+ currentClass:cls;
+ currentPackage:pkg;
+ setupToAskForMethodSearchTitle:(resources string:'Apply rule in:')
+ forBrowser:nil
+ searchWhat:nil searchArea:#everywhere
+ withCaseIgnore:false withMatch:false
+ withMethodList:false
+ allowFind:false allowBuffer:false allowBrowser:true
+ withTextEntry:false.
[:restart|
- dialog askThenDo:[
- |classes methods keepResultList browser|
+ dialog askThenDo:[
+ |classes methods keepResultList browser|
- classes := dialog classesToSearch.
- "/ methods := dialog methodsToSearch.
- browser := Tools::NewSystemBrowser new.
- browser allButOpen.
- browser
- smalllintRun:ruleHolder value
- onEnvironment:(ClassEnvironment new
- classes:classes;
- label:'Lint on more classes').
- browser openWindow.
- ].
+ classes := dialog classesToSearch.
+ "/ methods := dialog methodsToSearch.
+ browser := Tools::NewSystemBrowser new.
+ browser allButOpen.
+ browser
+ smalllintRun:ruleHolder value
+ onEnvironment:(ClassEnvironment new
+ classes:classes;
+ label:'Lint on more classes').
+ browser openWindow.
+ ].
] valueWithRestart.
self hide.
!
@@ -309,11 +309,11 @@
"/ if multiple rules complained, an anonymous composite rule is created;
"/ then disable them all
rule isComposite ifTrue:[
- rule rules do:[:each |
- SmalltalkChecker disableRule:each class.
- ].
+ rule rules do:[:each |
+ SmalltalkChecker disableRule:each class.
+ ].
] ifFalse:[
- SmalltalkChecker disableRule:rule class.
+ SmalltalkChecker disableRule:rule class.
].
self close.
!
@@ -344,7 +344,7 @@
"return/create the 'ruleHolder' value holder (automatically generated)"
ruleHolder isNil ifTrue:[
- ruleHolder := ValueHolder with: (RBDebuggingCodeLeftInMethodsRule new)
+ ruleHolder := ValueHolder with: (RBDebuggingCodeLeftInMethodsRule new)
].
^ ruleHolder
@@ -357,16 +357,16 @@
|oldValue newValue|
ruleHolder notNil ifTrue:[
- oldValue := ruleHolder value.
- ruleHolder removeDependent:self.
+ oldValue := ruleHolder value.
+ ruleHolder removeDependent:self.
].
ruleHolder := something.
ruleHolder notNil ifTrue:[
- ruleHolder addDependent:self.
+ ruleHolder addDependent:self.
].
newValue := ruleHolder value.
oldValue ~~ newValue ifTrue:[
- self update:#value with:newValue from:ruleHolder.
+ self update:#value with:newValue from:ruleHolder.
].
!
@@ -376,29 +376,29 @@
|holder|
(holder := builder bindingAt:#ruleNameAspect) isNil ifTrue:[
- holder := BlockValue
- with:[:h |
- |text rules|
+ holder := BlockValue
+ with:[:h |
+ |text rules|
- text := ''.
- rules := h isComposite ifTrue:[ h rules ] ifFalse:[ { h } ].
- rules
- do:[:each |
- |anchor|
+ text := ''.
+ rules := h isComposite ifTrue:[ h rules ] ifFalse:[ { h } ].
+ rules
+ do:[:each |
+ |anchor|
- "/ h displayString , ' ' , (('[browse]' actionForAll:[ self browseLintRule]) colorizeAllWith:Color blue)
- anchor := ('Browse Rule Class (%1)'
- bindWith:each class name)
- asActionLinkTo:[ self browseLintRule:each ].
- text := text , anchor.
- ]
- separatedBy:[
- text := text , '<br>'
- ].
- text.
- ]
- argument: self ruleHolder.
- builder aspectAt:#ruleNameAspect put:holder.
+ "/ h displayString , ' ' , (('[browse]' actionForAll:[ self browseLintRule]) colorizeAllWith:Color blue)
+ anchor := ('Browse Rule Class (%1)'
+ bindWith:each class name)
+ asActionLinkTo:[ self browseLintRule:each ].
+ text := text , anchor.
+ ]
+ separatedBy:[
+ text := text , '<br>'
+ ].
+ text.
+ ]
+ argument: self ruleHolder.
+ builder aspectAt:#ruleNameAspect put:holder.
].
^ holder.
@@ -410,7 +410,7 @@
"return/create the 'ruleRationaleAndFixesHTMLHolder' value holder (automatically generated)"
ruleRationaleAndFixesHTMLHolder isNil ifTrue:[
- ruleRationaleAndFixesHTMLHolder := ValueHolder new.
+ ruleRationaleAndFixesHTMLHolder := ValueHolder new.
].
^ ruleRationaleAndFixesHTMLHolder
@@ -421,118 +421,118 @@
generateHTMLForRule: rule on: stream
| flattenedRules collectedFixes putCollectedFixes
- previousRuleClass already|
-
+ previousRuleClass already|
+
rule isComposite ifTrue:[
- already := Set new.
- flattenedRules := OrderedCollection new.
- rule flatten do:[:each |
- (already includes:each) ifFalse:[
- already add:each.
- flattenedRules add:each
- ].
- ].
+ already := Set new.
+ flattenedRules := OrderedCollection new.
+ rule flatten do:[:each |
+ (already includes:each) ifFalse:[
+ already add:each.
+ flattenedRules add:each
+ ].
+ ].
- "/ often, multiple instances of the same rule match in a line.
- "/ avoid, generating long lists, which all look the same.
- "/ so first, sort them by name.
- flattenedRules sort:[:a :b | a name < b name].
- "/ then in the code below, skip over repeated descriptions
+ "/ often, multiple instances of the same rule match in a line.
+ "/ avoid, generating long lists, which all look the same.
+ "/ so first, sort them by name.
+ flattenedRules sort:[:a :b | a name < b name].
+ "/ then in the code below, skip over repeated descriptions
] ifFalse:[
- flattenedRules := { rule }.
- ].
+ flattenedRules := { rule }.
+ ].
- putCollectedFixes :=
- [
- collectedFixes notEmptyOrNil ifTrue:[
- stream nextPutAll: '<p>'.
- collectedFixes size > 1 ifTrue:[
- stream nextPutAll: '<br>'.
- stream nextPutLine: 'Possible fixes:'.
- ].
- stream nextPutLine:'<ul indent="0">'.
- collectedFixes withIndexDo:[:fix :index|
- stream
- nextPutAll:'<li>';
- nextPutAll:'<a action="doit: linkActionPerformer doQuickFix:';
- nextPutAll: index printString;
- nextPut:$";
- "/ nextPutAll:' info="',(fix rule class name),'"';
- nextPut:$>;
- nextPutAll: fix label;
- nextPutAll:'</a>';
- nextPutAll:' (',(fix rule class name),')';
- nextPutAll:'</li>'.
- ].
- stream nextPutLine:'</ul>'.
- ].
- ].
-
+ putCollectedFixes :=
+ [
+ collectedFixes notEmptyOrNil ifTrue:[
+ stream nextPutAll: '<p>'.
+ collectedFixes size > 1 ifTrue:[
+ stream nextPutAll: '<br>'.
+ stream nextPutLine: 'Possible fixes:'.
+ ].
+ stream nextPutLine:'<ul indent="0">'.
+ collectedFixes withIndexDo:[:fix :index|
+ stream
+ nextPutAll:'<li>';
+ nextPutAll:'<a action="doit: linkActionPerformer doQuickFix:';
+ nextPutAll: index printString;
+ nextPut:$";
+ "/ nextPutAll:' info="',(fix rule class name),'"';
+ nextPut:$>;
+ nextPutAll: fix label;
+ nextPutAll:'</a>';
+ nextPutAll:' (',(fix rule class name),')';
+ nextPutAll:'</li>'.
+ ].
+ stream nextPutLine:'</ul>'.
+ ].
+ ].
+
previousRuleClass := nil.
collectedFixes := OrderedCollection new.
- flattenedRules
- do:[:eachRule |
- |fixesForMe editedMethod editedClass editedSelector resultMethod|
-
- editedMethod := codeView editedMethod.
+ flattenedRules
+ do:[:eachRule |
+ |fixesForMe editedMethod editedClass editedSelector resultMethod|
+
+ editedMethod := codeView editedMethod.
+
+ eachRule class == previousRuleClass ifFalse:[
+ collectedFixes notEmpty ifTrue:[
+ putCollectedFixes value.
+ collectedFixes := OrderedCollection new
+ ].
+ previousRuleClass notNil ifTrue:[
+ stream nextPutLine: '<hr>'
+ ].
+ stream
+ "/ nextPutAll:'<I>',eachRule class name,':</I><BR>';
+ nextPutAll:'<B>',eachRule name,'</B>';
+ nextPutAll:'<P>'.
+
+ (editedMethod notNil
+ and:[ eachRule result includesSelector:editedMethod selector in:editedMethod mclass ]) ifTrue:[
+ stream nextPutLine:(eachRule rationaleWithAnchorForMethod:editedMethod)
+ ] ifFalse:[
+ stream nextPutLine: eachRule rationale.
+ ].
+ ].
- eachRule class == previousRuleClass ifFalse:[
- collectedFixes notEmpty ifTrue:[
- putCollectedFixes value.
- collectedFixes := OrderedCollection new
- ].
- previousRuleClass notNil ifTrue:[
- stream nextPutLine: '<hr>'
- ].
- stream
- "/ nextPutAll:'<I>',eachRule class name,':</I><BR>';
- nextPutAll:'<B>',eachRule name,'</B>';
- nextPutAll:'<P>'.
-
- (editedMethod notNil
- and:[ eachRule result includesSelector:editedMethod selector in:editedMethod mclass ]) ifTrue:[
- stream nextPutLine:(eachRule rationaleWithAnchorForMethod:editedMethod)
- ] ifFalse:[
- stream nextPutLine: eachRule rationale.
- ].
- ].
-
- "/ Generate fixes...
- "/ BUG: because rules/transformations remember their result,
- "/ after a run over a project, there might be changes for many many different classes
- "/ in the rule's changes list.
- "/ therefore, the fixer selects only those changes which affect the current method.
- self breakPoint:#cg.
+ "/ Generate fixes...
+ "/ BUG: because rules/transformations remember their result,
+ "/ after a run over a project, there might be changes for many many different classes
+ "/ in the rule's changes list.
+ "/ therefore, the fixer selects only those changes which affect the current method.
+ self breakPoint:#cg.
- "/ was
- "/ eachRule fixes: fixer
- "/ changed to:
- editedMethod notNil ifTrue:[
- editedClass := editedMethod mclass.
- editedSelector := editedMethod selector.
- (editedClass isNil or:[editedSelector isNil]) ifTrue:[
- Transcript showCR:'CriticsWindow: code in editor is outdated'.
- ^ self
- ].
- ] ifFalse:[
- self breakPoint:#cg.
- ^ self.
- ].
- eachRule
- addFixesForClass:editedClass
- selector:editedSelector
- to:fixer.
+ "/ was
+ "/ eachRule fixes: fixer
+ "/ changed to:
+ editedMethod notNil ifTrue:[
+ editedClass := editedMethod mclass.
+ editedSelector := editedMethod selector.
+ (editedClass isNil or:[editedSelector isNil]) ifTrue:[
+ Transcript showCR:'CriticsWindow: code in editor is outdated'.
+ ^ self
+ ].
+ ] ifFalse:[
+ self breakPoint:#cg.
+ ^ self.
+ ].
+ eachRule
+ addFixesForClass:editedClass
+ selector:editedSelector
+ to:fixer.
- fixesForMe := fixer fixesForRule: eachRule.
- fixesForMe notEmptyOrNil ifTrue:[
- collectedFixes addAll:fixesForMe.
- ].
- previousRuleClass := eachRule class.
- ].
-
+ fixesForMe := fixer fixesForRule: eachRule.
+ fixesForMe notEmptyOrNil ifTrue:[
+ collectedFixes addAll:fixesForMe.
+ ].
+ previousRuleClass := eachRule class.
+ ].
+
collectedFixes notEmpty ifTrue:[
- putCollectedFixes value.
+ putCollectedFixes value.
].
"Created: / 15-12-2014 / 16:49:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -545,8 +545,8 @@
"Invoked when an object that I depend upon sends a change notification."
changedObject == ruleHolder ifTrue:[
- self updateRationaleAndFixes.
- ^ self.
+ self updateRationaleAndFixes.
+ ^ self.
].
super update:something with:aParameter from:changedObject
@@ -558,15 +558,15 @@
rule := self ruleHolder value.
rule isNil ifTrue:[
- fixer := nil.
- html := 'No rule...'.
+ fixer := nil.
+ html := 'No rule...'.
] ifFalse:[
- fixer := SmalltalkQuickFixer forView: codeView.
+ fixer := SmalltalkQuickFixer forView: codeView.
- html :=
- String streamContents:[:s|
- self generateHTMLForRule: rule on: s.
- ].
+ html :=
+ String streamContents:[:s|
+ self generateHTMLForRule: rule on: s.
+ ].
].
self ruleRationaleAndFixesHTMLHolder value: html
@@ -582,25 +582,25 @@
(anEvent isPointerEnterLeaveEvent
or:[ anEvent isFocusEvent
or:[ anEvent view notNil and:[ anEvent view isComponentOf:codeView topView ]]]) ifTrue:[
- self window raise.
+ self window raise.
].
-
+
anEvent isKeyReleaseEvent ifTrue:[
- anEvent key == #Escape ifTrue:[
- self closeRequest. "/ closeDownViews.
- ^true.
- ].
+ anEvent key == #Escape ifTrue:[
+ self closeRequest. "/ closeDownViews.
+ ^true.
+ ].
].
"/ cg: if this is a modal dialog - do not exit on leave.
"/ if used as a flyBy, set the closeOnLeave flag.
self closeOnLeave ifTrue:[
- anEvent isPointerLeaveEvent ifTrue:[
- anEvent view == self window ifTrue:[
- self closeRequest. "/ closeDownViews.
- ^true.
- ]
- ].
+ anEvent isPointerLeaveEvent ifTrue:[
+ anEvent view == self window ifTrue:[
+ self closeRequest. "/ closeDownViews.
+ ^true.
+ ]
+ ].
].
^false
@@ -614,7 +614,7 @@
postBuildWith: aBuilder
|window|
-
+
super postBuildWith:aBuilder.
window := aBuilder window.
@@ -643,8 +643,8 @@
rationalView := aView.
rationalView linkActionPerformer:self.
aView painter
- leftMargin:20;
- topMargin:5.
+ leftMargin:20;
+ topMargin:5.
"Created: / 04-08-2011 / 18:00:36 / cg"
! !
@@ -667,4 +667,3 @@
version_SVN
^ '$Id$'
! !
-