ActiveState Community

anonymous function syntax (YUI2/3)

Posted by pnp on 2009-07-01 04:53
OS: All / Any

I'm trying to use Komodo IDE for javascript development because it provides a good code browser. I had 4.4 and I am now evaluating 5.1 However I'm currently not being able to use neither of them because I'm developing with YUI2 and 3 and here the preferred syntax is like shown below:

YUI({modules:  {ea_forms4: {
                         path: "../js/ea_forms4.js",
                         type: "js"                        
                      }
               },
               filter: 'raw',
               base:"/yui3/"}
               
	).use("base","node","io-form","dump","json-parse","plugin",

	function(Y) {
		
		
		Y.use('ea_forms4',function(Y){

//here is the main part of the code

                    //initialize the page
		var init = function(){
			
			//do things
			
		}

                var myMethod = function(){

                         //do things
                 }

	});
});

With this coding style Komodo is not providing any insight into the code.

To see anything I need to remove the last 2 lines and the first 11. But of course I cannot run this code on a server and would have to add/remove comments all the time.

Do you have a solution to this problem? Or do you expect to be able to support this syntax in a future release?

/Paolo

ericp | Wed, 2009-07-01 11:09

Right now the JavaScript auto-indentation is based
on C/C++/Java indenting, but the limitations of doing
it that way are obvious once you add closures.

It's a good feature for a future release.
I've written it up at
http://bugs.activestate.com/show_bug.cgi?id=83550

- Eric

toddw | Wed, 2009-07-01 15:15

Komodo is not showing anonymous functions that are created an argument of a method call, though I can see by this example it would be helpful to still show these functions.

I've created (and subsequently fixed) a bug for this here:
http://bugs.activestate.com/show_bug.cgi?id=83553

You can manually apply the one-line patch to your installed Komodo build, which should fix this problem (patch is to the file "lang_javascript.py" in your Komodo installation):
http://svn.openkomodo.com/openkomodo/revision/?rev=3837

Cheers,
Todd

pnp | Thu, 2009-07-02 01:18

Wooww! This is it!

Thank you so much, I wish I had told this before!

/paolo

P.S. For other that want to patch, the path in my Windows Vista is C:/programs/ActiveState Komodo IDE 5/lib/mozilla/python/komodo/codeintel2/lang_javascript.py