--- a/SystemBrowser.st Wed Sep 04 11:33:19 2013 +0100
+++ b/SystemBrowser.st Thu Sep 05 16:40:58 2013 +0100
@@ -3730,84 +3730,149 @@
result := false.
- src := m source.
- src notNil ifTrue:[
- needMatch ifFalse:[
- "
- before doing a slow parse, quickly scan the
- method's source for the variable's name ...
- "
- result := (src findString:baseVarName) ~~ 0.
- ] ifTrue:[
- result := true.
- ].
- result ifTrue:[
- result := false.
- parser := Parser
- parseMethod:src
- in:c
- ignoreErrors:true
- ignoreWarnings:true.
-
- (parser notNil and:[parser ~~ #Error]) ifTrue:[
- vars := Set new.
- doInstVars ifTrue:[
- accessType == #read ifTrue:[
- instVars := parser readInstVars
- ] ifFalse:[
- accessType == #write ifTrue:[
- instVars := parser modifiedInstVars
+ "/ JV Following code is bad. It assumes that method is a Smalltalk method.
+ "/ But it may not, it could be JavaScript method, Java method or whatever fancy language
+ "/ method. Should be actually delegated to the method itself.
+
+ m programmingLanguage isSmalltalk ifTrue:[
+ "/ For Smalltalk, use parser...
+ src := m source.
+ src notNil ifTrue:[
+ needMatch ifFalse:[
+ "
+ before doing a slow parse, quickly scan the
+ method's source for the variable's name ...
+ "
+ result := (src findString:baseVarName) ~~ 0.
+ ] ifTrue:[
+ result := true.
+ ].
+ result ifTrue:[
+ result := false.
+ parser := Parser
+ parseMethod:src
+ in:c
+ ignoreErrors:true
+ ignoreWarnings:true.
+
+ (parser notNil and:[parser ~~ #Error]) ifTrue:[
+ vars := Set new.
+ doInstVars ifTrue:[
+ accessType == #read ifTrue:[
+ instVars := parser readInstVars
] ifFalse:[
- instVars := parser usedInstVars
+ accessType == #write ifTrue:[
+ instVars := parser modifiedInstVars
+ ] ifFalse:[
+ instVars := parser usedInstVars
+ ]
+ ].
+ vars addAll:instVars.
+ ].
+ doClassVars ifTrue:[
+ accessType == #read ifTrue:[
+ classVars := parser readClassVars
+ ] ifFalse:[
+ accessType == #write ifTrue:[
+ classVars := parser modifiedClassVars
+ ] ifFalse:[
+ classVars := parser usedClassVars
+ ]
+ ].
+ vars addAll:classVars.
+ ].
+ doPoolVars ifTrue:[
+ accessType == #read ifTrue:[
+ poolVars := parser readPoolVars
+ ] ifFalse:[
+ accessType == #write ifTrue:[
+ poolVars := parser modifiedPoolVars
+ ] ifFalse:[
+ poolVars := parser usedPoolVars
+ ]
+ ].
+ vars addAll:poolVars.
+ ].
+ doGlobals ifTrue:[
+ accessType == #read ifTrue:[
+ globals := parser readGlobals
+ ] ifFalse:[
+ accessType == #write ifTrue:[
+ globals := parser modifiedGlobals
+ ] ifFalse:[
+ globals := parser usedGlobals
+ ]
+ ].
+ vars addAll:globals.
+ ].
+ vars size > 0 ifTrue:[
+ needMatch ifTrue:[
+ result := vars contains:[:cv | (varName match:cv)]
+ ] ifFalse:[
+ result := vars includes:varName
]
- ].
- vars addAll:instVars.
+ ]
].
- doClassVars ifTrue:[
- accessType == #read ifTrue:[
- classVars := parser readClassVars
- ] ifFalse:[
- accessType == #write ifTrue:[
- classVars := parser modifiedClassVars
- ] ifFalse:[
- classVars := parser usedClassVars
- ]
- ].
- vars addAll:classVars.
- ].
- doPoolVars ifTrue:[
- accessType == #read ifTrue:[
- poolVars := parser readPoolVars
- ] ifFalse:[
- accessType == #write ifTrue:[
- poolVars := parser modifiedPoolVars
- ] ifFalse:[
- poolVars := parser usedPoolVars
- ]
- ].
- vars addAll:poolVars.
- ].
- doGlobals ifTrue:[
- accessType == #read ifTrue:[
- globals := parser readGlobals
- ] ifFalse:[
- accessType == #write ifTrue:[
- globals := parser modifiedGlobals
- ] ifFalse:[
- globals := parser usedGlobals
- ]
- ].
- vars addAll:globals.
- ].
- vars size > 0 ifTrue:[
- needMatch ifTrue:[
- result := vars contains:[:cv | (varName match:cv)]
- ] ifFalse:[
- result := vars includes:varName
- ]
+ ].
+ ].
+ ] ifFalse:[
+ "/ For all other languages, ask method.
+ vars := Set new.
+ doInstVars ifTrue:[
+ accessType == #read ifTrue:[
+ instVars := m readInstVars
+ ] ifFalse:[
+ accessType == #write ifTrue:[
+ instVars := m modifiedInstVars
+ ] ifFalse:[
+ instVars := m usedInstVars
]
].
+ vars addAll:instVars.
].
+ doClassVars ifTrue:[
+ accessType == #read ifTrue:[
+ classVars := m readClassVars
+ ] ifFalse:[
+ accessType == #write ifTrue:[
+ classVars := m modifiedClassVars
+ ] ifFalse:[
+ classVars := m usedClassVars
+ ]
+ ].
+ vars addAll:classVars.
+ ].
+ doPoolVars ifTrue:[
+ accessType == #read ifTrue:[
+ poolVars := m readPoolVars
+ ] ifFalse:[
+ accessType == #write ifTrue:[
+ poolVars := m modifiedPoolVars
+ ] ifFalse:[
+ poolVars := m usedPoolVars
+ ]
+ ].
+ vars addAll:poolVars.
+ ].
+ doGlobals ifTrue:[
+ accessType == #read ifTrue:[
+ globals := m readGlobals
+ ] ifFalse:[
+ accessType == #write ifTrue:[
+ globals := m modifiedGlobals
+ ] ifFalse:[
+ globals := m usedGlobals
+ ]
+ ].
+ vars addAll:globals.
+ ].
+ vars size > 0 ifTrue:[
+ needMatch ifTrue:[
+ result := vars contains:[:cv | (varName match:cv)]
+ ] ifFalse:[
+ result := vars includes:varName
+ ]
+ ]
].
Processor yield.
result
@@ -3816,6 +3881,7 @@
"Modified: / 19-06-1997 / 18:27:57 / cg"
"Modified (format): / 25-11-2011 / 14:00:44 / cg"
+ "Modified: / 05-09-2013 / 15:23:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
findAnyResourceIn:aCollectionOfClasses
--- a/Tools__Toolbox.st Wed Sep 04 11:33:19 2013 +0100
+++ b/Tools__Toolbox.st Thu Sep 05 16:40:58 2013 +0100
@@ -14,7 +14,7 @@
"{ NameSpace: Tools }"
Object subclass:#Toolbox
- instanceVariableNames:'browser'
+ instanceVariableNames:'browser environment'
classVariableNames:''
poolDictionaries:''
category:'Interface-Tools'
@@ -36,6 +36,14 @@
"
! !
+!Toolbox class methodsFor:'instance creation'!
+
+new
+ "return an initialized instance"
+
+ ^ self basicNew initialize.
+! !
+
!Toolbox methodsFor:'accessing'!
browser
@@ -44,6 +52,28 @@
browser:aNewSystemBrowser
browser := aNewSystemBrowser.
+!
+
+environment
+ ^ environment
+!
+
+environment:env
+ environment := env.
+! !
+
+!Toolbox methodsFor:'initialization'!
+
+initialize
+ "Invoked when a new instance is created."
+
+ "/ please change as required (and remove this comment)
+ "/ browser := nil.
+ environment := Smalltalk
+
+ "/ super initialize. -- commented since inherited method does nothing
+
+ "Modified: / 05-09-2013 / 12:46:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!Toolbox methodsFor:'menus'!