ResourcePack.st
changeset 6174 982b8576dfbe
parent 6113 798f118104a7
child 6219 7e760ee68af9
--- a/ResourcePack.st	Fri Dec 06 15:41:32 2013 +0100
+++ b/ResourcePack.st	Fri Dec 13 10:38:16 2013 +0100
@@ -1094,6 +1094,54 @@
 
     template := self at:s ifAbsent:s.
     ^ template withCRs expandPlaceholdersWith:argArray.
+!
+
+whichPackIncludesKey:aKey
+    "for debugging: return the pack (alogn the super-pack chain), which
+     has a translation for a string"
+
+    |val pack projectPack alreadySearched|
+
+    aKey isNil ifTrue:[ ^ nil ].
+
+    val := self localAt:aKey.
+    val notNil ifTrue:[^ self].
+
+    (projectPack := self projectPack) notNil ifTrue:[
+        val := projectPack localAt:aKey.
+        val notNil ifTrue:[^ projectPack].
+    ].
+    alreadySearched := Set new.
+    projectPack notNil ifTrue:[ alreadySearched add:projectPack ].
+
+    pack := self superPack.
+    [ pack notNil ] whileTrue:[
+        val := pack localAt:aKey.
+        val notNil ifTrue:[^ pack].
+
+        (projectPack := pack projectPack) notNil ifTrue:[
+            (alreadySearched includes:projectPack) ifFalse:[
+                val := projectPack localAt:aKey.
+                val notNil ifTrue:[^ projectPack].
+                alreadySearched add:projectPack.
+            ].
+        ].
+        pack := pack superPack
+    ].
+
+    alreadySearched copy do:[:projectPack |
+        |p|
+
+        p := projectPack superPack.
+        [p notNil and:[(alreadySearched includes:p) not]] whileTrue:[
+            val := p localAt:aKey.
+            val notNil ifTrue:[^ p].
+            alreadySearched add:p.
+            p := p superPack.
+        ].
+    ].
+
+    ^ nil
 ! !
 
 !ResourcePack methodsFor:'accessing-internals'!
@@ -1421,11 +1469,11 @@
 !ResourcePack class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.153 2013-08-10 11:24:20 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.154 2013-12-13 09:38:16 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.153 2013-08-10 11:24:20 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.154 2013-12-13 09:38:16 cg Exp $'
 ! !