Swizzling refactored.
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 07 Oct 2014 15:22:01 +0100
changeset 289 5c2cffd3c13c
parent 288 83eb74f41cd2
child 290 428b0d4e2725
child 292 9b594076c9b6
child 359 c9f69a8e441c
Swizzling refactored. * swizzling method is required to have name in form stx_goodies_smallsense_<original selector> * old method is saved to package __swizzled__ under selector <original package>_<original selector>. This way it could be called by the swizzled method. * old method is shadowed by a new method that forwards to swizzling method.
Make.proto
abbrev.stc
bc.mak
extensions.st
smallsense.rc
stx_goodies_smallsense.st
--- a/Make.proto	Sat May 10 11:31:11 2014 +0100
+++ b/Make.proto	Tue Oct 07 15:22:01 2014 +0100
@@ -34,7 +34,7 @@
 # add the path(es) here:,
 # ********** OPTIONAL: MODIFY the next lines ***
 # LOCALINCLUDES=-Ifoo -Ibar
-LOCALINCLUDES= -I$(INCLUDE_TOP)/stx/goodies/refactoryBrowser/helpers -I$(INCLUDE_TOP)/stx/goodies/refactoryBrowser/lint -I$(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser -I$(INCLUDE_TOP)/stx/goodies/regex -I$(INCLUDE_TOP)/stx/goodies/sunit -I$(INCLUDE_TOP)/stx/libbasic -I$(INCLUDE_TOP)/stx/libbasic2 -I$(INCLUDE_TOP)/stx/libbasic3 -I$(INCLUDE_TOP)/stx/libcomp -I$(INCLUDE_TOP)/stx/libhtml -I$(INCLUDE_TOP)/stx/libjava -I$(INCLUDE_TOP)/stx/libjava/tools -I$(INCLUDE_TOP)/stx/libtool -I$(INCLUDE_TOP)/stx/libview -I$(INCLUDE_TOP)/stx/libview2 -I$(INCLUDE_TOP)/stx/libwidg -I$(INCLUDE_TOP)/stx/libwidg2
+LOCALINCLUDES= -I$(INCLUDE_TOP)/stx/goodies/refactoryBrowser/helpers -I$(INCLUDE_TOP)/stx/goodies/refactoryBrowser/lint -I$(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser -I$(INCLUDE_TOP)/stx/goodies/regex -I$(INCLUDE_TOP)/stx/libbasic -I$(INCLUDE_TOP)/stx/libbasic2 -I$(INCLUDE_TOP)/stx/libbasic3 -I$(INCLUDE_TOP)/stx/libcomp -I$(INCLUDE_TOP)/stx/libhtml -I$(INCLUDE_TOP)/stx/libjava -I$(INCLUDE_TOP)/stx/libjava/tools -I$(INCLUDE_TOP)/stx/libtool -I$(INCLUDE_TOP)/stx/libview -I$(INCLUDE_TOP)/stx/libview2 -I$(INCLUDE_TOP)/stx/libwidg -I$(INCLUDE_TOP)/stx/libwidg2
 
 
 # if you need any additional defines for embedded C code,
@@ -134,7 +134,6 @@
 	cd ../../libview && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd ../../libview2 && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd ../refactoryBrowser/browser && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
-	cd ../sunit && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd ../../libwidg && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd ../refactoryBrowser/lint && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd ../../libhtml && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
--- a/abbrev.stc	Sat May 10 11:31:11 2014 +0100
+++ b/abbrev.stc	Tue Oct 07 15:22:01 2014 +0100
@@ -1,8 +1,6 @@
 # automagically generated by the project definition
 # this file is needed for stc to be able to compile modules independently.
 # it provides information about a classes filename, category and especially namespace.
-SmallSense::AbstractTestCase SmallSense__AbstractTestCase stx:goodies/smallsense 'SmallSense-Tests' 1
-SmallSense::BaseTestClass SmallSense__BaseTestClass stx:goodies/smallsense 'SmallSense-Tests-Obsolete' 1
 SmallSense::CodeHighlightingService SmallSense__CodeHighlightingService stx:goodies/smallsense 'SmallSense-Core-Services' 0
 SmallSense::CodeNavigationService SmallSense__CodeNavigationService stx:goodies/smallsense 'SmallSense-Core-Services' 0
 SmallSense::CompletionContext SmallSense__CompletionContext stx:goodies/smallsense 'SmallSense-Core' 0
@@ -14,7 +12,6 @@
 SmallSense::EditService SmallSense__EditService stx:goodies/smallsense 'SmallSense-Core-Services' 0
 SmallSense::EditSupport SmallSense__EditSupport stx:goodies/smallsense 'SmallSense-Core-Services' 0
 SmallSense::Info SmallSense__Info stx:goodies/smallsense 'SmallSense-Smalltalk-Types-Info' 0
-SmallSense::JavaCompletionEngineEnvironmentResource SmallSense__JavaCompletionEngineEnvironmentResource stx:goodies/smallsense 'SmallSense-Tests' 1
 SmallSense::Manager SmallSense__Manager stx:goodies/smallsense 'SmallSense-Smalltalk-Types-Info' 0
 SmallSense::PO SmallSense__PO stx:goodies/smallsense 'SmallSense-Core-Interface-PO' 0
 SmallSense::ParseTreeIndex SmallSense__ParseTreeIndex stx:goodies/smallsense 'SmallSense-Core-Index' 0
@@ -32,9 +29,7 @@
 SmallSense::SmalltalkQuickFixer SmallSense__SmalltalkQuickFixer stx:goodies/smallsense 'SmallSense-Smalltalk-Lint' 0
 SmallSense::SmalltalkSyntaxHighlighter SmallSense__SmalltalkSyntaxHighlighter stx:goodies/smallsense 'SmallSense-Smalltalk' 3
 SmallSense::SmalltalkUnacceptedMethodEnvironment SmallSense__SmalltalkUnacceptedMethodEnvironment stx:goodies/smallsense 'SmallSense-Smalltalk-Lint' 0
-SmallSense::TestCase SmallSense__TestCase stx:goodies/smallsense 'SmallSense-Tests-Obsolete' 1
 SmallSense::TokenPatternMatcher SmallSense__TokenPatternMatcher stx:goodies/smallsense 'SmallSense-Utils-Matcher' 0
-SmallSense::TokenPatternMatcherTests SmallSense__TokenPatternMatcherTests stx:goodies/smallsense 'SmallSense-Tests' 1
 SmallSense::TokenPatternParser SmallSense__TokenPatternParser stx:goodies/smallsense 'SmallSense-Utils-Matcher' 0
 SmallSense::TokenPatternToken SmallSense__TokenPatternToken stx:goodies/smallsense 'SmallSense-Utils-Matcher' 0
 SmallSense::TokenPatternTokenSet SmallSense__TokenPatternTokenSet stx:goodies/smallsense 'SmallSense-Utils-Matcher' 0
@@ -46,37 +41,42 @@
 SmallSense::ClassInfo SmallSense__ClassInfo stx:goodies/smallsense 'SmallSense-Smalltalk-Types-Info' 0
 SmallSense::ClassPO SmallSense__ClassPO stx:goodies/smallsense 'SmallSense-Core-Interface-PO' 0
 SmallSense::ClassType SmallSense__ClassType stx:goodies/smallsense 'SmallSense-Smalltalk-Types' 0
-SmallSense::CompletionEngineTests SmallSense__CompletionEngineTests stx:goodies/smallsense 'SmallSense-Tests' 1
 SmallSense::ConstantPO SmallSense__ConstantPO stx:goodies/smallsense 'SmallSense-Core-Interface-PO' 0
-SmallSense::EditSupportTests SmallSense__EditSupportTests stx:goodies/smallsense 'SmallSense-Tests' 1
-SmallSense::FinderTests SmallSense__FinderTests stx:goodies/smallsense 'SmallSense-Tests-Obsolete' 1
 SmallSense::GenericEditSupport SmallSense__GenericEditSupport stx:goodies/smallsense 'SmallSense-Core-Services' 0
 SmallSense::JavaEditSupport SmallSense__JavaEditSupport stx:goodies/smallsense 'SmallSense-Java' 0
 SmallSense::JavaImportPO SmallSense__JavaImportPO stx:goodies/smallsense 'SmallSense-Java-Interface-PO' 0
 SmallSense::MethodBindingPO SmallSense__MethodBindingPO stx:goodies/smallsense 'SmallSense-Java-Interface-PO' 0
 SmallSense::MethodInfo SmallSense__MethodInfo stx:goodies/smallsense 'SmallSense-Smalltalk-Types-Info' 0
 SmallSense::MethodPO SmallSense__MethodPO stx:goodies/smallsense 'SmallSense-Core-Interface-PO' 0
-SmallSense::RecognizerTests SmallSense__RecognizerTests stx:goodies/smallsense 'SmallSense-Tests-Obsolete' 1
 SmallSense::SmalltalkCompletionEngine SmallSense__SmalltalkCompletionEngine stx:goodies/smallsense 'SmallSense-Smalltalk' 0
 SmallSense::SmalltalkEditSupport SmallSense__SmalltalkEditSupport stx:goodies/smallsense 'SmallSense-Smalltalk' 0
 SmallSense::SmalltalkInferencer SmallSense__SmalltalkInferencer stx:goodies/smallsense 'SmallSense-Smalltalk-Types-Inference' 0
 SmallSense::SmalltalkParseNodeFinder SmallSense__SmalltalkParseNodeFinder stx:goodies/smallsense 'SmallSense-Smalltalk' 0
-SmallSense::SmalltalkParserTests SmallSense__SmalltalkParserTests stx:goodies/smallsense 'SmallSense-Tests-Obsolete' 1
 SmallSense::SnippetPO SmallSense__SnippetPO stx:goodies/smallsense 'SmallSense-Core-Interface-PO' 0
 SmallSense::UnionType SmallSense__UnionType stx:goodies/smallsense 'SmallSense-Smalltalk-Types' 0
 SmallSense::UnknownType SmallSense__UnknownType stx:goodies/smallsense 'SmallSense-Smalltalk-Types' 1
 SmallSense::VariableBindingPO SmallSense__VariableBindingPO stx:goodies/smallsense 'SmallSense-Java-Interface-PO' 0
 SmallSense::VariablePO SmallSense__VariablePO stx:goodies/smallsense 'SmallSense-Core-Interface-PO' 0
 SmallSense::AbstractJavaCompletionEngineSimple SmallSense__AbstractJavaCompletionEngineSimple stx:goodies/smallsense 'SmallSense-Java' 2
-SmallSense::AbstractJavaCompletionEngineTests SmallSense__AbstractJavaCompletionEngineTests stx:goodies/smallsense 'SmallSense-Tests' 1
 SmallSense::GroovyEditSupport SmallSense__GroovyEditSupport stx:goodies/smallsense 'SmallSense-Groovy' 0
 SmallSense::JavaCompletionEngine SmallSense__JavaCompletionEngine stx:goodies/smallsense 'SmallSense-Java' 0
 SmallSense::JavaConstructorPO SmallSense__JavaConstructorPO stx:goodies/smallsense 'SmallSense-Java-Interface-PO' 0
+SmallSense::MethodKeywordRestPO SmallSense__MethodKeywordRestPO stx:goodies/smallsense 'SmallSense-Core-Interface-PO' 0
+SmallSense::JavaCompletionEngineSimple SmallSense__JavaCompletionEngineSimple stx:goodies/smallsense 'SmallSense-Java' 2
+SmallSense::GroovyCompletionEngineSimple SmallSense__GroovyCompletionEngineSimple stx:goodies/smallsense 'SmallSense-Groovy' 2
+SmallSense::AbstractJavaCompletionEngineTests SmallSense__AbstractJavaCompletionEngineTests stx:goodies/smallsense 'SmallSense-Tests' 1
+SmallSense::AbstractTestCase SmallSense__AbstractTestCase stx:goodies/smallsense 'SmallSense-Tests' 1
+SmallSense::BaseTestClass SmallSense__BaseTestClass stx:goodies/smallsense 'SmallSense-Tests-Obsolete' 1
+SmallSense::CompletionEngineTests SmallSense__CompletionEngineTests stx:goodies/smallsense 'SmallSense-Tests' 1
+SmallSense::EditSupportTests SmallSense__EditSupportTests stx:goodies/smallsense 'SmallSense-Tests' 1
+SmallSense::FinderTests SmallSense__FinderTests stx:goodies/smallsense 'SmallSense-Tests-Obsolete' 1
+SmallSense::GroovyCompletionEngineSimpleTests SmallSense__GroovyCompletionEngineSimpleTests stx:goodies/smallsense 'SmallSense-Tests' 1
+SmallSense::JavaCompletionEngineEnvironmentResource SmallSense__JavaCompletionEngineEnvironmentResource stx:goodies/smallsense 'SmallSense-Tests' 1
+SmallSense::JavaCompletionEngineTests SmallSense__JavaCompletionEngineTests stx:goodies/smallsense 'SmallSense-Tests' 1
 SmallSense::JavaEditSupportTests SmallSense__JavaEditSupportTests stx:goodies/smallsense 'SmallSense-Tests' 1
-SmallSense::MethodKeywordRestPO SmallSense__MethodKeywordRestPO stx:goodies/smallsense 'SmallSense-Core-Interface-PO' 0
+SmallSense::RecognizerTests SmallSense__RecognizerTests stx:goodies/smallsense 'SmallSense-Tests-Obsolete' 1
 SmallSense::SmalltalkCompletionEngineTests SmallSense__SmalltalkCompletionEngineTests stx:goodies/smallsense 'SmallSense-Tests' 1
 SmallSense::SmalltalkEditSupportTests SmallSense__SmalltalkEditSupportTests stx:goodies/smallsense 'SmallSense-Tests' 1
-SmallSense::GroovyCompletionEngineSimpleTests SmallSense__GroovyCompletionEngineSimpleTests stx:goodies/smallsense 'SmallSense-Tests' 1
-SmallSense::JavaCompletionEngineSimple SmallSense__JavaCompletionEngineSimple stx:goodies/smallsense 'SmallSense-Java' 2
-SmallSense::JavaCompletionEngineTests SmallSense__JavaCompletionEngineTests stx:goodies/smallsense 'SmallSense-Tests' 1
-SmallSense::GroovyCompletionEngineSimple SmallSense__GroovyCompletionEngineSimple stx:goodies/smallsense 'SmallSense-Groovy' 2
+SmallSense::SmalltalkParserTests SmallSense__SmalltalkParserTests stx:goodies/smallsense 'SmallSense-Tests-Obsolete' 1
+SmallSense::TestCase SmallSense__TestCase stx:goodies/smallsense 'SmallSense-Tests-Obsolete' 1
+SmallSense::TokenPatternMatcherTests SmallSense__TokenPatternMatcherTests stx:goodies/smallsense 'SmallSense-Tests' 1
--- a/bc.mak	Sat May 10 11:31:11 2014 +0100
+++ b/bc.mak	Tue Oct 07 15:22:01 2014 +0100
@@ -34,7 +34,7 @@
 
 
 
-LOCALINCLUDES= -I$(INCLUDE_TOP)\stx\goodies\refactoryBrowser\helpers -I$(INCLUDE_TOP)\stx\goodies\refactoryBrowser\lint -I$(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser -I$(INCLUDE_TOP)\stx\goodies\regex -I$(INCLUDE_TOP)\stx\goodies\sunit -I$(INCLUDE_TOP)\stx\libbasic -I$(INCLUDE_TOP)\stx\libbasic2 -I$(INCLUDE_TOP)\stx\libbasic3 -I$(INCLUDE_TOP)\stx\libcomp -I$(INCLUDE_TOP)\stx\libhtml -I$(INCLUDE_TOP)\stx\libjava -I$(INCLUDE_TOP)\stx\libjava\tools -I$(INCLUDE_TOP)\stx\libtool -I$(INCLUDE_TOP)\stx\libview -I$(INCLUDE_TOP)\stx\libview2 -I$(INCLUDE_TOP)\stx\libwidg -I$(INCLUDE_TOP)\stx\libwidg2
+LOCALINCLUDES= -I$(INCLUDE_TOP)\stx\goodies\refactoryBrowser\helpers -I$(INCLUDE_TOP)\stx\goodies\refactoryBrowser\lint -I$(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser -I$(INCLUDE_TOP)\stx\goodies\regex -I$(INCLUDE_TOP)\stx\libbasic -I$(INCLUDE_TOP)\stx\libbasic2 -I$(INCLUDE_TOP)\stx\libbasic3 -I$(INCLUDE_TOP)\stx\libcomp -I$(INCLUDE_TOP)\stx\libhtml -I$(INCLUDE_TOP)\stx\libjava -I$(INCLUDE_TOP)\stx\libjava\tools -I$(INCLUDE_TOP)\stx\libtool -I$(INCLUDE_TOP)\stx\libview -I$(INCLUDE_TOP)\stx\libview2 -I$(INCLUDE_TOP)\stx\libwidg -I$(INCLUDE_TOP)\stx\libwidg2
 LOCALDEFINES=
 
 STCLOCALOPT=-package=$(PACKAGE) -I. $(LOCALINCLUDES) -headerDir=. $(STCLOCALOPTIMIZATIONS) $(STCWARNINGS) $(LOCALDEFINES)  -varPrefix=$(LIBNAME)
@@ -61,7 +61,6 @@
 	pushd ..\..\libview & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\..\libview2 & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\refactoryBrowser\browser & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
-	pushd ..\sunit & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\..\libwidg & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\refactoryBrowser\lint & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\..\libhtml & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
--- a/extensions.st	Sat May 10 11:31:11 2014 +0100
+++ b/extensions.st	Tue Oct 07 15:22:01 2014 +0100
@@ -56,49 +56,49 @@
 
 !DoWhatIMeanSupport methodsFor:'code completion - smallsense'!
 
-smallSenseCodeCompletionForClass: classOrNilArg context: contextOrNil codeView: codeViewArg 
+stx_goodies_smallsense_codeCompletionForClass:classOrNilArg context:contextOrNil codeView:codeViewArg
     <swizzle: #codeCompletionForClass:context:codeView:>
     "SmallSense version of #codeCompletionForClass:context:codeView:.
 
      When SmallSense is loaded, this method is swizzled as #codeCompletionForClass:context:codeView:.
      into DoWhatIMeanSupport."
-    
+
     | p  node  text  items  mode |
 
     codeView := codeViewArg.
-    
+
     "/ The respondsTo: hack is because CVS CodeView2 has no #mode method.
-    
-    mode := (codeView respondsTo: #mode) ifTrue: [
+
+    mode := (codeView respondsTo:#mode) ifTrue:[
             codeView mode
-        ] ifFalse: [ #method ].
-    contextOrNil notNil ifTrue: [
+        ] ifFalse:[ #method ].
+    contextOrNil notNil ifTrue:[
         mode := #method.
     ].
-    items := SmallSense::SmalltalkCompletion 
-            resultSetFor: mode
-            source: codeView contents
-            class: classOrNilArg
-            line: codeView cursorLine
-            column: codeView cursorCol.
-    items notEmptyOrNil ifTrue: [
-        (p := items position) notNil ifTrue: [
+    items := SmallSense::SmalltalkCompletion
+            resultSetFor:mode
+            source:codeView contents
+            class:classOrNilArg
+            line:codeView cursorLine
+            column:codeView cursorCol.
+    items notEmptyOrNil ifTrue:[
+        (p := items position) notNil ifTrue:[
             node := p node.
-            node notNil ifTrue: [
-                (node isVariable and: [ p isInNode ]) ifTrue: [
+            node notNil ifTrue:[
+                (node isVariable and:[ p isInNode ]) ifTrue:[
                     text := node name
-                ] ifFalse: [
-                    node isMessage ifTrue: [
+                ] ifFalse:[
+                    node isMessage ifTrue:[
                         text := node selector
                     ]
                 ].
             ].
         ].
     ].
-    SmallSense::CompletionWindow 
-        openForView: codeView
-        text: text
-        items: items.
+    SmallSense::CompletionWindow
+        openForView:codeView
+        text:text
+        items:items.
 
     "Created: / 19-08-2013 / 15:01:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 02-09-2013 / 12:52:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -323,9 +323,9 @@
     [ stmt notNil ] whileTrue:[
         | expr |
 
-        stmt isReturnNode ifTrue:[ 
+        stmt isReturnNode ifTrue:[
             expr := stmt.
-        ] ifFalse:[ 
+        ] ifFalse:[
             expr := stmt expression.
         ].
         aBlock value: ('statement[%1]' bindWith: index) value: expr.
@@ -356,21 +356,17 @@
 
 !Tools::CodeCompletionService class methodsFor:'testing'!
 
-smallSenseIsUsefulFor:aCodeView
-    "No old completion once there's SmallSense :-)"
+stx_goodies_smallsense_isUsefulFor: arg1
+    <swizzle: #isUsefulFor:>
 
-    <swizzle: #isUsefulFor:>     
-
-    ^ false.
-
-    "Created: / 02-09-2013 / 12:58:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    ^ false
 ! !
 
 !Tools::CodeHighlightingService class methodsFor:'instance creation'!
 
 new
     "return an initialized instance"
-    
+
     ^ (SmallSense::CodeHighlightingService ? self) basicNew initialize.
 
     "Created: / 27-07-2013 / 22:47:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -381,7 +377,7 @@
 
 new
     "return an initialized instance"
-    
+
     ^ (SmallSense::CodeNavigationService ? self) basicNew initialize.
 
     "Created: / 27-07-2013 / 22:47:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -390,18 +386,17 @@
 
 !Tools::NavigationState methodsFor:'aspects - SmallSense'!
 
-smallSenseSelectedClasses
-
-    <swizzle: #selectedClasses>     
-
+stx_goodies_smallsense_selectedClasses
+    <swizzle: #selectedClasses>
     selectedClasses isNil ifTrue:[
-        selectedClasses := "SpecialValueHolder with:nil." nil asValue.
+        selectedClasses := nil asValue.
         (ConfigurableFeatures includesFeature:'SmallSenseEnabled') ifTrue:[
-            selectedClasses onChangeEvaluate:[
-                selectedClasses value ? #() do:[:cls|
-                    (Smalltalk at:#SmallSense::Manager) instance updateInfoForClass: cls.
-                ].
-            ]
+            selectedClasses
+                onChangeEvaluate:[
+                    selectedClasses value ? #() do:[:cls |
+                        (Smalltalk at:#'SmallSense::Manager') instance updateInfoForClass:cls.
+                    ].
+                ]
         ]
     ].
     ^ selectedClasses
@@ -414,7 +409,7 @@
 searchCompletionBlock_SmallSense
     "This returns a class/selector name completion block that uses
      standard DoWhatIMeanSupport"
-    
+
     ^ [:patternString | self smallSenseSearchCompletion:patternString ]
 
     "Created: / 25-11-2013 / 12:27:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -422,9 +417,9 @@
 
 !Tools::NewSystemBrowser methodsFor:'private-searching-smallsense'!
 
-smallSenseSearchCompletion:patternString 
+smallSenseSearchCompletion:patternString
     "/sorry, no method search yet"
-    
+
     ^ self smallSenseSearchCompletionNewForClass:patternString
 
     "Modified: / 04-08-2011 / 19:05:28 / cg"
@@ -436,7 +431,7 @@
 smallSenseSearchCompletionBlock
     "This returns a class/selector name completion block that uses
      standard DoWhatIMeanSupport"
-    
+
     ^ [:patternString | self smallSenseSearchCompletion:patternString ]
 
     "Modified: / 04-08-2011 / 19:05:28 / cg"
@@ -445,7 +440,7 @@
 
 !Tools::NewSystemBrowser methodsFor:'private-searching-smallsense'!
 
-smallSenseSearchCompletionEntryForClass:aClass showPrefix:showPrefix 
+smallSenseSearchCompletionEntryForClass:aClass showPrefix:showPrefix
     ^ (SmallSense::ClassPO new)
         klass:aClass;
         showPrefix:showPrefix.
@@ -456,7 +451,7 @@
 
 !Tools::NewSystemBrowser methodsFor:'private-searching-smallsense'!
 
-smallSenseSearchCompletionNewForClass:patternString 
+smallSenseSearchCompletionNewForClass:patternString
     | env  pattern  matcher  matches  relax  withPrefix |
 
     patternString isEmptyOrNil ifTrue:[
@@ -479,15 +474,15 @@
         matches isEmptyOrNil and:[ relax <= 3 ]
     ] whileTrue:[
         matches := OrderedCollection new.
-        env 
-            keysDo:[:nm | 
+        env
+            keysDo:[:nm |
                 | cls |
 
                 cls := env at:nm.
-                (cls notNil and:[ cls isBehavior and:[ (matches includesIdentical:cls) not ] ]) 
+                (cls notNil and:[ cls isBehavior and:[ (matches includesIdentical:cls) not ] ])
                         ifTrue:[
-                            "cls isJavaClass"false ifTrue:[ 
-                                cls isAnonymous ifFalse:[ 
+                            "cls isJavaClass"false ifTrue:[
+                                cls isAnonymous ifFalse:[
                                     (matcher value:cls) ifTrue:[
                                         matches add:cls
                                     ].
@@ -504,8 +499,8 @@
     matches isEmpty ifTrue:[
         ^ #( nil #() )
     ] ifFalse:[
-        matches := matches 
-                collect:[:cls | 
+        matches := matches
+                collect:[:cls |
                     self smallSenseSearchCompletionEntryForClass:cls showPrefix:withPrefix
                 ].
         ^ {
@@ -683,9 +678,8 @@
 
 !Workspace class methodsFor:'defaults - smallsense'!
 
-smallSenseCodeCompletionServiceClass
+stx_goodies_smallsense_codeCompletionServiceClass
     <swizzle: #codeCompletionServiceClass>
-
     ^ SmallSense::CodeCompletionService
 
     "Created: / 24-09-2013 / 00:29:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
--- a/smallsense.rc	Sat May 10 11:31:11 2014 +0100
+++ b/smallsense.rc	Tue Oct 07 15:22:01 2014 +0100
@@ -25,7 +25,7 @@
       VALUE "LegalCopyright", "Copyright Jan Vrany 2013-2014\0"
       VALUE "ProductName", "SmallSense\0"
       VALUE "ProductVersion", "6.2.4.0\0"
-      VALUE "ProductDate", "Thu, 14 Aug 2014 08:12:42 GMT\0"
+      VALUE "ProductDate", "Tue, 07 Oct 2014 14:13:45 GMT\0"
     END
 
   END
--- a/stx_goodies_smallsense.st	Sat May 10 11:31:11 2014 +0100
+++ b/stx_goodies_smallsense.st	Tue Oct 07 15:22:01 2014 +0100
@@ -46,6 +46,11 @@
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 "
+!
+
+extensionsVersion_HG
+
+    ^ '$Changeset: <not expanded> $'
 ! !
 
 !stx_goodies_smallsense class methodsFor:'initialization'!
@@ -104,8 +109,7 @@
         #'stx:goodies/refactoryBrowser/helpers'    "BrowserEnvironment - superclass of SmallSense::SmalltalkUnacceptedMethodEnvironment"
         #'stx:goodies/refactoryBrowser/lint'    "RBLintRule - extended"
         #'stx:goodies/regex'    "Regex::RxCharSetParser - superclass of SmallSense::TokenPatternParser::TokenSpecParser"
-        #'stx:goodies/sunit'    "TestAsserter - superclass of SmallSense::AbstractJavaCompletionEngineTests"
-        #'stx:libbasic'    "Collection - extended"
+        #'stx:libbasic'    "Autoload - superclass of SmallSense::AbstractJavaCompletionEngineTests"
         #'stx:libcomp'    "AbstractSyntaxHighlighter - superclass of SmallSense::SmalltalkParser"
         #'stx:libhtml'    "HTMLDocumentFrame - extended"
         #'stx:libtool'    "AbstractSettingsApplication - superclass of SmallSense::SettingsAppl"
@@ -167,8 +171,6 @@
 
     ^ #(
         "<className> or (<className> attributes...) in load order"
-        (#'SmallSense::AbstractTestCase' autoload)
-        (#'SmallSense::BaseTestClass' autoload)
         #'SmallSense::CodeHighlightingService'
         #'SmallSense::CodeNavigationService'
         #'SmallSense::CompletionContext'
@@ -180,7 +182,6 @@
         #'SmallSense::EditService'
         #'SmallSense::EditSupport'
         #'SmallSense::Info'
-        (#'SmallSense::JavaCompletionEngineEnvironmentResource' autoload)
         #'SmallSense::Manager'
         #'SmallSense::PO'
         #'SmallSense::ParseTreeIndex'
@@ -198,9 +199,7 @@
         #'SmallSense::SmalltalkQuickFixer'
         #'SmallSense::SmalltalkSyntaxHighlighter'
         #'SmallSense::SmalltalkUnacceptedMethodEnvironment'
-        (#'SmallSense::TestCase' autoload)
         #'SmallSense::TokenPatternMatcher'
-        (#'SmallSense::TokenPatternMatcherTests' autoload)
         #'SmallSense::TokenPatternParser'
         #'SmallSense::TokenPatternToken'
         #'SmallSense::TokenPatternTokenSet'
@@ -212,40 +211,45 @@
         #'SmallSense::ClassInfo'
         #'SmallSense::ClassPO'
         #'SmallSense::ClassType'
-        (#'SmallSense::CompletionEngineTests' autoload)
         #'SmallSense::ConstantPO'
-        (#'SmallSense::EditSupportTests' autoload)
-        (#'SmallSense::FinderTests' autoload)
         #'SmallSense::GenericEditSupport'
         #'SmallSense::JavaEditSupport'
         #'SmallSense::JavaImportPO'
         #'SmallSense::MethodBindingPO'
         #'SmallSense::MethodInfo'
         #'SmallSense::MethodPO'
-        (#'SmallSense::RecognizerTests' autoload)
         #'SmallSense::SmalltalkCompletionEngine'
         #'SmallSense::SmalltalkEditSupport'
         #'SmallSense::SmalltalkInferencer'
         #'SmallSense::SmalltalkParseNodeFinder'
-        (#'SmallSense::SmalltalkParserTests' autoload)
         #'SmallSense::SnippetPO'
         #'SmallSense::UnionType'
         #'SmallSense::UnknownType'
         #'SmallSense::VariableBindingPO'
         #'SmallSense::VariablePO'
         #'SmallSense::AbstractJavaCompletionEngineSimple'
-        (#'SmallSense::AbstractJavaCompletionEngineTests' autoload)
         #'SmallSense::GroovyEditSupport'
         #'SmallSense::JavaCompletionEngine'
         #'SmallSense::JavaConstructorPO'
+        #'SmallSense::MethodKeywordRestPO'
+        #'SmallSense::JavaCompletionEngineSimple'
+        #'SmallSense::GroovyCompletionEngineSimple'
+        (#'SmallSense::AbstractJavaCompletionEngineTests' autoload)
+        (#'SmallSense::AbstractTestCase' autoload)
+        (#'SmallSense::BaseTestClass' autoload)
+        (#'SmallSense::CompletionEngineTests' autoload)
+        (#'SmallSense::EditSupportTests' autoload)
+        (#'SmallSense::FinderTests' autoload)
+        (#'SmallSense::GroovyCompletionEngineSimpleTests' autoload)
+        (#'SmallSense::JavaCompletionEngineEnvironmentResource' autoload)
+        (#'SmallSense::JavaCompletionEngineTests' autoload)
         (#'SmallSense::JavaEditSupportTests' autoload)
-        #'SmallSense::MethodKeywordRestPO'
+        (#'SmallSense::RecognizerTests' autoload)
         (#'SmallSense::SmalltalkCompletionEngineTests' autoload)
         (#'SmallSense::SmalltalkEditSupportTests' autoload)
-        (#'SmallSense::GroovyCompletionEngineSimpleTests' autoload)
-        #'SmallSense::JavaCompletionEngineSimple'
-        (#'SmallSense::JavaCompletionEngineTests' autoload)
-        #'SmallSense::GroovyCompletionEngineSimple'
+        (#'SmallSense::SmalltalkParserTests' autoload)
+        (#'SmallSense::TestCase' autoload)
+        (#'SmallSense::TokenPatternMatcherTests' autoload)
     )
 !
 
@@ -279,12 +283,8 @@
         UserPreferences smallSenseBackgroundTypingEnabled:
         HTMLDocumentView doQuickFix:
         'Tools::CodeHighlightingService class' new
-        DoWhatIMeanSupport smallSenseCodeCompletionForClass:context:codeView:
-        #'Tools::NavigationState' smallSenseSelectedClasses
-        'Tools::CodeCompletionService class' smallSenseIsUsefulFor:
         BlockNode childNamesAndValuesDo:
         'Tools::CodeNavigationService class' new
-        'Workspace class' smallSenseCodeCompletionServiceClass
         ParseNode navigateToUsing:
         MessageNode navigateToUsing:
         VariableNode navigateToUsing:
@@ -305,6 +305,11 @@
         UserPreferences smallSenseSmalltalkIndentOnPasteEnabled
         UserPreferences smallSenseSmalltalkIndentOnPasteEnabled:
         EditTextViewCompletionSupport isCompletionViewShown
+        DoWhatIMeanSupport #'stx_goodies_smallsense_codeCompletionForClass:context:codeView:'
+        #'Tools::NavigationState' #'stx_goodies_smallsense_selectedClasses'
+        'Tools::CodeCompletionService class' #'stx_goodies_smallsense_isUsefulFor:'
+        'Workspace class' #'stx_goodies_smallsense_codeCompletionServiceClass'
+
     )
 ! !
 
@@ -371,21 +376,27 @@
 swizzle
     "Swizzle all methods annotated as <swizzle:>"
 
+
     Swizzled ifTrue:[ ^ self ].
-    [
-        self extensionMethods do:[:m|self swizzle: m].
-        Swizzled := true.
-    ] on: Error do:[:ex |
-        Logger log: ('Cannot swizzle: %1' bindWith: ex description) severity: #error
+    ParserFlags initialize.
+    self extensionMethods do:[:m |
+        [
+            self swizzle: m.
+        ] on: Error do:[:ex |
+            Logger error: 'Cannot swizzle %1: %2' with: m selector with: ex description.
+            "/ Debugger enter.
+        ].
     ].
+    Swizzled := true.
 
 
     "
     stx_goodies_smallsense swizzle
+    Swizzled := false.
     "
 
     "Created: / 19-08-2013 / 14:54:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 02-09-2013 / 12:30:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 07-10-2014 / 15:02:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 swizzle: method
@@ -427,47 +438,89 @@
      means somebody changed that method meanwhile and we should
      validate/update swizzlling method"
 
-    | cls overwrittenMethod overwrittenMethodSHA overwrittenMethodProjectDefinition swizzledMethod  |
+    | cls shadowedMethod shadowedMethodSHA shadowedMethodProjectDefinition shadowedMethodCopy swizzledForwarderMethodSource swizzledForwarderMethod |
 
     cls := swizzlingMethod mclass.
-    overwrittenMethod := cls compiledMethodAt: selector.
-    overwrittenMethod isNil ifTrue:[
+    shadowedMethod := cls compiledMethodAt: selector.
+    shadowedMethod isNil ifTrue:[
         "/ Oops, method gone?
         self breakPoint: #jv.
         ^ self.
     ].
 
-    self assert: swizzlingMethod numArgs == overwrittenMethod numArgs.
+    self assert: swizzlingMethod numArgs == shadowedMethod numArgs.
+    self assert: (swizzlingMethod selector startsWith: self name , '_').
 
     expectedSHA notNil ifTrue:[
         | src |
 
-        src := overwrittenMethod source.
+        src := shadowedMethod source.
         src notNil ifTrue:[
-            overwrittenMethodSHA := SHA1Stream new nextPutAll: src; hashValue.
-            overwrittenMethodSHA = expectedSHA ifFalse:[
-                self breakPoint: #jv.
-                Logger log: 'Overwritten method checksum does not match' severity: #error.
+            shadowedMethodSHA := SHA1Stream new nextPutAll: src; hashValue.
+            shadowedMethodSHA = expectedSHA ifFalse:[
+                Logger error: 'Overwritten method checksum for: %1 does not match %2' with: shadowedMethod selector with: expectedSHA
             ].
         ].
     ].
 
-    swizzledMethod := swizzlingMethod copy.
-    "/ Now, fake the package and source of swizzled method
-    "/ so on fileout, original code gets filed out.
-    swizzledMethod setPackage: overwrittenMethod package.
-    swizzledMethod setCategory: overwrittenMethod category.
-    swizzledMethod source: overwrittenMethod source.
+    "/ Save shadowedMethod to project...
+    shadowedMethodProjectDefinition := ProjectDefinition definitionClassForPackage: shadowedMethod package.
+    shadowedMethodProjectDefinition rememberOverwrittenMethod:shadowedMethod inClass: shadowedMethod mclass.
+
+
+    swizzledForwarderMethodSource := String streamContents:[ :s |
+    	| selector keywords |
+
+    	selector := shadowedMethod selector.
+    	selector numArgs > 0 ifTrue:[
+    	    keywords := selector keywords.
+            keywords withIndexDo:[ :keyword :index |
+                s nextPutAll: keyword; space; nextPutAll: 'arg'; nextPutAll: index printString; space.
+            ].
+    	] ifFalse:[
+    	    s nextPutAll: selector; cr.
+    	].
 
-    "/ Save swizzledMethod to project...
-    overwrittenMethodProjectDefinition := ProjectDefinition definitionClassForPackage: overwrittenMethod package.
-    overwrittenMethodProjectDefinition rememberOverwrittenMethod:overwrittenMethod inClass: overwrittenMethod mclass.
+        s cr.
+        s nextPutLine: '    "This method has been swizled by SmallSense, forwarding to SmallSense implementation"'.
+        s nextPutAll:  '    ^ self '; nextPutAll: self name; nextPut: $_.
+        selector numArgs > 0 ifTrue:[
+            keywords withIndexDo:[ :keyword :index |
+                s nextPutAll: keyword; space; nextPutAll: 'arg'; nextPutAll: index printString; space
+            ].
+    	] ifFalse:[
+    	    s nextPutAll: selector.
+    	].
+    	s cr.
+
+    ].
+
+    "/ Stdout nextPutAll: '>>>'; nextPutLine: selector.
+    "/ Stdout nextPutLine: '----'.
+    "/ Stdout nextPutLine: swizzledForwarderMethodSource.
+    "/ Stdout nextPutLine: '----'.
+
+
+    shadowedMethodCopy := shadowedMethod copy.
+    shadowedMethodCopy setPackage: #__swizzled__.
+    shadowedMethodCopy setCategory: shadowedMethod category.
+    shadowedMethodCopy source: ((shadowedMethod package copyReplaceAll: $: with: $_) replaceAll: $/ with: $_) , '_' , shadowedMethod source.
+    shadowedMethod mclass
+        basicAddSelector: (((shadowedMethod package copyReplaceAll: $: with: $_) replaceAll: $/ with: $_) , '_' , shadowedMethod selector) asSymbol
+        withMethod: shadowedMethodCopy.
+
 
     "/ Install the swizzled method
-    cls methodDictionary at: selector put: swizzledMethod
+    "/ Stdout nextPutLine: '^^^ Compiling'.
+    swizzledForwarderMethod := ByteCodeCompiler compile: swizzledForwarderMethodSource forClass: cls install: false.
+    swizzledForwarderMethod category: shadowedMethod category.
+    swizzledForwarderMethod package: self package.
+    cls basicAddSelector:selector withMethod:swizzledForwarderMethod.
+
+    "/ Stdout nextPutLine: '^^^ Compiled'.
 
     "Created: / 10-05-2014 / 00:23:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 10-05-2014 / 11:00:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 07-10-2014 / 15:09:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !stx_goodies_smallsense class methodsFor:'documentation'!