Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » JavaScript Editor contributions(Adding to the JavaScript syntax interpretation in the JS Editor)
JavaScript Editor contributions [message #660145] Thu, 17 March 2011 03:46 Go to next message
Matt  is currently offline Matt
Messages: 2
Registered: March 2011
Junior Member
Hi guys,

I'd really like to get the JS Editor in WTP to pickup a few more JS patterns than it curently does, e.g. the module pattern.

If I have:

var someVar = 1;
function someFn = function() {
  // empty
}


They both appear in the outline. However if I wrap those two in a module with its own scope like so:

namespace.module = (function() {
var someVar = 1;
function someFn = function() {
  // empty
}
}());


The outline is now empty.

I've had a quick look at the src but a bit lost already, can anyone point me in the right direction?
Re: JavaScript Editor contributions [message #660146 is a reply to message #660145] Thu, 17 March 2011 03:54 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2277
Registered: July 2009
Senior Member
org.eclipse.wst.jsdt.core.infer.InferEngine is the default visitor run against the AST to divine what should be treated as a org.eclipse.wst.jsdt.core.infer.InferredType, InferredMethod, or InferredAttribute. The org.eclipse.wst.jsdt.core.inferrenceSupport extension point allows other engines to be run, but something as generic as this pattern would belong in the default. This has been discussed in bugs 298062 and 338540, but unless we also have offsets in the source for all of the inferred members, we can't support the expected refactoring and hyper-linking later on.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=298062
https://bugs.eclipse.org/bugs/show_bug.cgi?id=338540


---
Nitin Dahyabhai
Eclipse WTP, IBM

[Updated on: Thu, 17 March 2011 04:00]

Report message to a moderator

Re: JavaScript Editor contributions [message #660670 is a reply to message #660145] Mon, 21 March 2011 00:25 Go to previous messageGo to next message
Matt  is currently offline Matt
Messages: 2
Registered: March 2011
Junior Member
Is there any way we can use annotations to have JSDT pickup what is inferred, so that we can benefit from the Outline Explorer?
Re: JavaScript Editor contributions [message #660721 is a reply to message #660670] Mon, 21 March 2011 12:13 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2277
Registered: July 2009
Senior Member
What do you mean by "annotations"?

---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: JavaScript Editor contributions [message #665086 is a reply to message #660670] Wed, 13 April 2011 08:45 Go to previous messageGo to next message
Sergey  is currently offline Sergey
Messages: 1
Registered: July 2009
Junior Member
Matt, I've recently found a workaround for module pattern to work in JSDT using just JSDoc. Check out this code snippet:

/**
 * @type module
 * @memberOf __module
 */
var module = (/** @constructor */ function () {
	function innerFunc() {
		
	}
	
	return {
		/**
		 * @memberOf module
		 * @returns String
		 */
		method: function() {
			return "hello";
		}
	};
})();


1. @memberOf __module and /** @constructor */ at closure function used to display inner functions and variables inside module closure (i.e. innerFunc()). Two underscores in type name are just my naming conventions for types that doesn't exists, they are used just for outline.

2. @type module is mandatory and should be the same as your real module name.

3. @memberOf module binds return object's method to your module/type. You don't need to put @memberOf module near every return function, the first one is OK.

And here's a template I use to create modules:

/**
 * @type ${name}
 * @memberOf __${name}
 */
var ${name} = (/** @constructor */ function () {
	${cursor}
})();


Re: JavaScript Editor contributions [message #665160 is a reply to message #660145] Wed, 13 April 2011 13:45 Go to previous messageGo to next message
Philippe Marschall is currently offline Philippe Marschall
Messages: 120
Registered: July 2009
Senior Member
On 03/17/2011 04:46 AM, Matt wrote:
> Hi guys,
>
> I'd really like to get the JS Editor in WTP to pickup a few more JS
> patterns than it curently does, e.g. the module pattern.

Yeah, it's kinda annoying that you get punished for following what
Douglas Crockford recommends.

Anyway here's the bug where you can vote or contribute a patch:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=338336


Cheers
Philippe
Re: JavaScript Editor contributions [message #665434 is a reply to message #665160] Thu, 14 April 2011 15:25 Go to previous message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2277
Registered: July 2009
Senior Member
I'm not sure that "punish" is the right word. I'm even less sure that the bug you've linked to is actually the same issue Matt's running into.

---
Nitin Dahyabhai
Eclipse WTP, IBM
Previous Topic:running eclipse rhino debugger
Next Topic:Exception in web project export
Goto Forum:
  


Current Time: Tue Sep 23 14:33:43 GMT 2014

Powered by FUDForum. Page generated in 0.04975 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software