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

Bug 323834

Summary: Global variables declared inside functions are not discovered
Product: [WebTools] JSDT Reporter: Jim Zhang <jzhang>
Component: GeneralAssignee: Project Inbox <jsdt.javascript-inbox>
Status: CLOSED DUPLICATE QA Contact: Nitin Dahyabhai <thatnitind>
Severity: normal    
Priority: P3 CC: cmjaun
Version: unspecified   
Target Milestone: 3.2.3   
Hardware: All   
OS: All   
Whiteboard:

Description Jim Zhang CLA 2010-08-27 10:30:34 EDT
Build Identifier: Eclipse 3.6

This is manifested the most with jazz web UI code, where usage of anonymous functions is prevalent.  As an example, /net.jazz.web.app/resources/internal/AuthenticationInterceptor.js wraps the entire code inside an anonymous function.  Using this file as an example, I would expect the global variables declared inside it, such as jazz.app.internal.AuthenticationInterceptor, to be discovered by JSDT.  But that doesn't seem to be the case.

Reproducible: Always

Steps to Reproduce:
1. you can get jazz web UI code by registering at jazz.net and download the most recent SDK driver, such as https://jazz.net/downloads/rational-team-concert/releases/2.0.0.2iFix3/RTC-SDK-2.0.0.2iFix3.zip
2.
3.
Comment 1 Jim Zhang CLA 2010-08-27 10:58:05 EDT
I did a little more research.  I suspect this is how JSDT supports global variable discovery:
1. when something is declared "in the clear" with a "var" qualifier, it's picked up as a global variable.  for instance in a js file I just declare 
   var globalVar = "";

it shows up in the project explorer as a global variable.

2. if instead the same variable was declared without a "var" qualifier, although semantically it's equivalent to #1, JSDT does not discover it.

3. if I'm declaring a global variable "in the clear", I will have the option of always putting "var" in front and life is good.  however if I'm doing this inside a function, the only way to declare a global variable is to not put the "var" in front, otherwise it becomes a local variable in the function's scope.

In essence, the problem is not so much with anonymous functions, but that global variables declared inside functions are not being discovered.
Comment 2 Chris Jaun CLA 2010-09-16 10:26:31 EDT
Pretty sure this is a duplicate of BUG311643.

It was a similar problem where global variables were not being discovered.

*** This bug has been marked as a duplicate of bug 311643 ***