Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 392666

Summary: Local method declaration causes problems with Shrinksafe
Product: [ECD] Orion Reporter: Adam Peller <apeller>
Component: EditorAssignee: Mark Macdonald <mamacdon>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: mamacdon, Silenio_Quarti, simon_kaegi
Version: 1.0   
Target Milestone: 2.0 M1   
Hardware: PC   
OS: Mac OS X   
See Also: http://bugs.dojotoolkit.org/ticket/11673
Whiteboard:

Description Adam Peller CLA 2012-10-23 11:30:56 EDT
The definition of the clone method in the editor's textStyler module seems to cause problems with Dojo Shrinksafe, namely the construct:

  clone: function clone(){...}

and use of the local reference 'clone' in the code.  I'm not sure what the ECMAScript spec has to say about this.  Isn't this form only supposed to be used at the global scope?  Even if it's a Shrinksafe bug, it's easier to fix the code.  clone does not have any reference to the object instance and is very easily defined as a separate function within the closure.  Please consider making this change. Thanks

https://github.com/maqetta/maqetta/commit/bf88b9d9e5f6a2c2179745868402560efd81f94f
Comment 1 Simon Kaegi CLA 2012-10-23 11:37:58 EDT
Sure that's fine will do in master as soon as things open up again as we're about to declare 1.0. 

The code as it stands would create "clone" in the lexical scope so there is no difference if we extract it and put it at the top.
Comment 2 Silenio Quarti CLA 2012-11-08 10:43:40 EST
Mark, this is a problem in the textMateStyler.js.  I thought this was a problem in textStyler.js which also defines a clone method, but the name there is _clone(), which seems to be ok.
Comment 3 Mark Macdonald CLA 2012-11-08 11:35:46 EST
Fixed

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=35073938aa4103ab95a4b90f81227285ae1477e2

FWIW, the construct is a bit unusual but is valid js -- it just provides a way to name a function used in an object literal expression so that it can recursively call itself.