Improvements in background lint checker
authorJan Vrany <jan.vrany@fit.cvut.cz>
Fri, 17 Feb 2012 01:48:18 +0000
changeset 17 8443d79a77ac
parent 16 900fdba78fb2
child 18 cebd9550b288
Improvements in background lint checker
Make.proto
Make.spec
SmallSenseChecker.st
SmallSenseCriticsWindow.st
SmallSenseQuickFixer.st
SmallSenseService.st
SmallSenseUnacceptedMethodEnvironment.st
abbrev.stc
bc.mak
extensions.st
libInit.cc
smallsense.rc
--- a/Make.proto	Thu Feb 16 18:18:09 2012 +0000
+++ b/Make.proto	Fri Feb 17 01:48:18 2012 +0000
@@ -1,7 +1,7 @@
 # $Header$
 #
 # DO NOT EDIT
-# automagically generated from the projectDefinition: stx_libtool_smallsense at 2012-02-16 18:17:37.408.
+# automagically generated from the projectDefinition: stx_libtool_smallsense at 2012-02-17 00:57:39.657.
 #
 # Warning: once you modify this file, do not rerun
 # stmkmp or projectDefinition-build again - otherwise, your changes are lost.
@@ -182,3 +182,4 @@
 
 # ENDMAKEDEPEND --- do not remove this line
 
+
--- a/Make.spec	Thu Feb 16 18:18:09 2012 +0000
+++ b/Make.spec	Fri Feb 17 01:48:18 2012 +0000
@@ -1,7 +1,7 @@
 # $Header$
 #
 # DO NOT EDIT
-# automagically generated from the projectDefinition: stx_libtool_smallsense at 2012-02-16 18:17:36.884.
+# automagically generated from the projectDefinition: stx_libtool_smallsense at 2012-02-17 00:57:39.130.
 #
 # Warning: once you modify this file, do not rerun
 # stmkmp or projectDefinition-build again - otherwise, your changes are lost.
@@ -131,3 +131,4 @@
 
 
 
+
--- a/SmallSenseChecker.st	Thu Feb 16 18:18:09 2012 +0000
+++ b/SmallSenseChecker.st	Fri Feb 17 01:48:18 2012 +0000
@@ -34,25 +34,34 @@
 checkClass: aClass 
 
     "Nothing to do, SmallSense checker checks only methods"
+    context selectedClass: aClass.
 
     "Created: / 16-02-2012 / 16:12:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-checkMethodsForClass: aClass 
-    context selectedClass: aClass.
+checkMethodsForClass: aClass
 
-    ^environment selectorsForClass: aClass do: [:each | 
-        context selector: each.
-        rule checkMethod: context.
-        methodBlock value
-    ]
+    rule flattened do:[:each|
+        [
+            environment selectorsForClass: aClass do: [:sel|
+                context selector: sel.
+                each checkMethod: context.
+            ]
+        ] on: Error do:[:ex|
+            SmallSenseService debugging ifTrue:[
+                SmallSenseService debugging: false.
+                ex pass.
+            ]
+        ]
+    ].
 
     "Modified: / 24-08-2010 / 21:32:39 / Jan Vrany <enter your email here>"
-    "Created: / 16-02-2012 / 16:15:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 17-02-2012 / 00:50:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !SmallSenseChecker class methodsFor:'documentation'!
 
 version_SVN
-    ^ '$Id: SmallSenseChecker.st 7899 2012-02-16 18:18:09Z vranyj1 $'
+    ^ '$Id: SmallSenseChecker.st 7902 2012-02-17 01:48:18Z vranyj1 $'
 ! !
+
--- a/SmallSenseCriticsWindow.st	Thu Feb 16 18:18:09 2012 +0000
+++ b/SmallSenseCriticsWindow.st	Fri Feb 17 01:48:18 2012 +0000
@@ -2,7 +2,7 @@
 
 ApplicationModel subclass:#SmallSenseCriticsWindow
 	instanceVariableNames:'ruleHolder ruleRationaleAndFixesHTMLHolder rationalView fixer
-		entered'
+		entered codeView'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'SmallSense-Interface'
@@ -99,6 +99,14 @@
 
 !SmallSenseCriticsWindow methodsFor:'accessing'!
 
+codeView
+    ^ codeView
+!
+
+codeView:aCodeView2
+    codeView := aCodeView2.
+!
+
 rule
 
     ^self ruleHolder value.
@@ -227,7 +235,7 @@
         fixer := nil.
         html :=  'No rule...'.
     ] ifFalse:[
-        fixer := SmallSenseQuickFixer for: rule.
+        fixer := SmallSenseQuickFixer for: rule view: codeView.
         html := String streamContents:[:s|
                     s nextPutAll: rule rationale ; cr.
                     fixer printHtmlOn: s.
@@ -299,5 +307,6 @@
 !SmallSenseCriticsWindow class methodsFor:'documentation'!
 
 version_SVN
-    ^ '$Id: SmallSenseCriticsWindow.st 7899 2012-02-16 18:18:09Z vranyj1 $'
+    ^ '$Id: SmallSenseCriticsWindow.st 7902 2012-02-17 01:48:18Z vranyj1 $'
 ! !
+
--- a/SmallSenseQuickFixer.st	Thu Feb 16 18:18:09 2012 +0000
+++ b/SmallSenseQuickFixer.st	Fri Feb 17 01:48:18 2012 +0000
@@ -1,7 +1,7 @@
 "{ Package: 'stx:libtool/smallsense' }"
 
 Object subclass:#SmallSenseQuickFixer
-	instanceVariableNames:'rule fixes'
+	instanceVariableNames:'view rule fixes'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'SmallSense-Lint'
@@ -22,6 +22,13 @@
     ^self new initializeForRule: rule.
 
     "Created: / 01-02-2012 / 12:06:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+for: rule view: view
+
+    ^self new initializeForRule: rule view: view
+
+    "Created: / 17-02-2012 / 00:21:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !SmallSenseQuickFixer methodsFor:'adding'!
@@ -42,12 +49,13 @@
 
 !SmallSenseQuickFixer methodsFor:'initialization'!
 
-initializeForRule: anRBLintRule
+initializeForRule: anRBLintRule view: aCodeView2
     rule := anRBLintRule.
+    view := aCodeView2.
     fixes := OrderedCollection new: 3.
     rule fixes: self.
 
-    "Created: / 01-02-2012 / 12:06:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 17-02-2012 / 00:20:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !SmallSenseQuickFixer methodsFor:'performing fixes'!
@@ -88,10 +96,19 @@
 
 !SmallSenseQuickFixer methodsFor:'utilities'!
 
-apply: changes
-    | changesToApply |
+apply: allChanges
+    | changes |
 
-    changesToApply := Tools::ChangeSetBrowser2 confirmChanges: changes.
+    changes := Tools::ChangeSetBrowser2 confirmChanges: allChanges.
+    changes isEmptyOrNil ifTrue:[ ^ self ].
+    (changes size == 1 and:[view reallyModified]) ifTrue:[
+        view contents: changes anElement source clear: false.
+    ] ifFalse:[
+        | browser |
+
+
+        self halt.
+    ]
 
     "Created: / 16-02-2012 / 14:46:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
@@ -132,5 +149,6 @@
 !SmallSenseQuickFixer class methodsFor:'documentation'!
 
 version_SVN
-    ^ '$Id: SmallSenseQuickFixer.st 7899 2012-02-16 18:18:09Z vranyj1 $'
+    ^ '$Id: SmallSenseQuickFixer.st 7902 2012-02-17 01:48:18Z vranyj1 $'
 ! !
+
--- a/SmallSenseService.st	Thu Feb 16 18:18:09 2012 +0000
+++ b/SmallSenseService.st	Fri Feb 17 01:48:18 2012 +0000
@@ -61,6 +61,12 @@
 
 !SmallSenseService class methodsFor:'accessing'!
 
+debugging
+    ^Debugging == true
+
+    "Created: / 17-02-2012 / 00:48:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 debugging: aBoolean
 
     Debugging := aBoolean
@@ -409,6 +415,7 @@
 
     SmallSenseCriticsWindow new
         rule: ann rule;
+        codeView: codeView;
         allButOpen;
         openWindowAt: Screen current pointerPosition.
 
@@ -439,7 +446,8 @@
 !SmallSenseService class methodsFor:'documentation'!
 
 version_SVN
-    ^ '$Id: SmallSenseService.st 7899 2012-02-16 18:18:09Z vranyj1 $'
+    ^ '$Id: SmallSenseService.st 7902 2012-02-17 01:48:18Z vranyj1 $'
 ! !
 
 SmallSenseService initialize!
+
--- a/SmallSenseUnacceptedMethodEnvironment.st	Thu Feb 16 18:18:09 2012 +0000
+++ b/SmallSenseUnacceptedMethodEnvironment.st	Fri Feb 17 01:48:18 2012 +0000
@@ -84,7 +84,8 @@
 !SmallSenseUnacceptedMethodEnvironment class methodsFor:'documentation'!
 
 version_SVN
-    ^ '$Id: SmallSenseUnacceptedMethodEnvironment.st 7899 2012-02-16 18:18:09Z vranyj1 $'
+    ^ '$Id: SmallSenseUnacceptedMethodEnvironment.st 7902 2012-02-17 01:48:18Z vranyj1 $'
 ! !
 
 SmallSenseUnacceptedMethodEnvironment initialize!
+
--- a/abbrev.stc	Thu Feb 16 18:18:09 2012 +0000
+++ b/abbrev.stc	Fri Feb 17 01:48:18 2012 +0000
@@ -42,3 +42,4 @@
 SmallSenseQuickFixer SmallSenseQuickFixer stx:libtool/smallsense 'SmallSense-Lint' 0
 SmallSenseSettingsAppl SmallSenseSettingsAppl stx:libtool/smallsense 'SmallSense-Interface' 1
 SmallSenseChecker SmallSenseChecker stx:libtool/smallsense 'SmallSense-Lint' 0
+
--- a/bc.mak	Thu Feb 16 18:18:09 2012 +0000
+++ b/bc.mak	Fri Feb 17 01:48:18 2012 +0000
@@ -1,7 +1,7 @@
 # $Header$
 #
 # DO NOT EDIT
-# automagically generated from the projectDefinition: stx_libtool_smallsense at 2012-02-16 18:17:37.541.
+# automagically generated from the projectDefinition: stx_libtool_smallsense at 2012-02-17 00:57:39.922.
 #
 # Warning: once you modify this file, do not rerun
 # stmkmp or projectDefinition-build again - otherwise, your changes are lost.
@@ -120,3 +120,4 @@
 $(OUTDIR)extensions.$(O): extensions.st $(INCLUDE_TOP)\stx\libcomp\ParseNode.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libcomp\AssignmentNode.$(H) $(INCLUDE_TOP)\stx\libcomp\BlockNode.$(H) $(INCLUDE_TOP)\stx\libcomp\MessageNode.$(H) $(INCLUDE_TOP)\stx\libcomp\ParseErrorNode.$(H) $(INCLUDE_TOP)\stx\libcomp\PrimaryNode.$(H) $(INCLUDE_TOP)\stx\libcomp\StatementNode.$(H) $(INCLUDE_TOP)\stx\libtool\Tools__NavigationState.$(H) $(INCLUDE_TOP)\stx\libtool\Tools__VariableList.$(H) $(INCLUDE_TOP)\stx\libtool\Tools__BrowserList.$(H) $(INCLUDE_TOP)\stx\libtool\Tools__NavigatorModel.$(H) $(INCLUDE_TOP)\stx\libview2\ApplicationModel.$(H) $(INCLUDE_TOP)\stx\libview2\Model.$(H) $(INCLUDE_TOP)\stx\libbasic\UserPreferences.$(H) $(INCLUDE_TOP)\stx\libbasic\IdentityDictionary.$(H) $(INCLUDE_TOP)\stx\libbasic\Dictionary.$(H) $(INCLUDE_TOP)\stx\libbasic\Set.$(H) $(INCLUDE_TOP)\stx\libbasic\Collection.$(H) $(INCLUDE_TOP)\stx\libcomp\VariableNode.$(H) $(INCLUDE_TOP)\stx\libbasic\ConfigurableFeatures.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\lint\RBLintRule.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\lint\RBTransformationRule.$(H) $(INCLUDE_TOP)\stx\libhtml\HTMLDocumentView.$(H) $(INCLUDE_TOP)\stx\libhtml\HTMLDocumentFrame.$(H) $(INCLUDE_TOP)\stx\libview\View.$(H) $(INCLUDE_TOP)\stx\libview\SimpleView.$(H) $(INCLUDE_TOP)\stx\libview\DisplaySurface.$(H) $(INCLUDE_TOP)\stx\libview\GraphicsMedium.$(H) $(INCLUDE_TOP)\stx\libview\DeviceGraphicsContext.$(H) $(INCLUDE_TOP)\stx\libview\GraphicsContext.$(H) $(STCHDR)
 
 # ENDMAKEDEPEND --- do not remove this line
+
--- a/extensions.st	Thu Feb 16 18:18:09 2012 +0000
+++ b/extensions.st	Fri Feb 17 01:48:18 2012 +0000
@@ -161,12 +161,16 @@
 !RBTransformationRule methodsFor:'accessing'!
 
 fixes: fixer
+    | changes |
 
-    fixer fix
-        label:'Rewrite the code';
-        action: [ fixer apply: 
-            ((ChangeSet withAll:self changes) name: self name)
-        ].
+    changes := self changes.
+    changes notEmptyOrNil ifTrue:[
+        fixer fix
+            label:'Rewrite the code';
+            action: [ fixer apply: 
+                ((ChangeSet withAll:self changes) name: self name)
+            ].
+    ]
 
     "Created: / 01-02-2012 / 12:11:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
@@ -299,5 +303,5 @@
 !stx_libtool_smallsense class methodsFor:'documentation'!
 
 extensionsVersion_SVN
-    ^ '$Id: extensions.st 7899 2012-02-16 18:18:09Z vranyj1 $'
-! !
\ No newline at end of file
+    ^ '$Id: extensions.st 7902 2012-02-17 01:48:18Z vranyj1 $'
+! !
--- a/libInit.cc	Thu Feb 16 18:18:09 2012 +0000
+++ b/libInit.cc	Fri Feb 17 01:48:18 2012 +0000
@@ -67,3 +67,4 @@
 _stx_137libtool_137smallsense_extensions_Init(pass,__pRT__,snd);
 __END_PACKAGE__();
 }
+
--- a/smallsense.rc	Thu Feb 16 18:18:09 2012 +0000
+++ b/smallsense.rc	Fri Feb 17 01:48:18 2012 +0000
@@ -25,7 +25,7 @@
       VALUE "LegalCopyright", "Copyright Claus Gittinger 1988-2011\nCopyright eXept Software AG 1998-2011\0"
       VALUE "ProductName", "Smalltalk/X\0"
       VALUE "ProductVersion", "6.2.1.1\0"
-      VALUE "ProductDate", "Thu, 16 Feb 2012 18:17:43 GMT\0"
+      VALUE "ProductDate", "Fri, 17 Feb 2012 00:57:44 GMT\0"
     END
 
   END
@@ -35,3 +35,4 @@
     VALUE "Translation", 0x409, 0x4E4 // U.S. English, Windows Multilingual
   END
 END
+