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

Bug 359451

Summary: ISourceLookupDirector does not make honor to new ISourceLocator added programatically
Product: [WebTools] JSDT Reporter: Leopoldo (Polo) Miranda <polomm>
Component: DebugAssignee: Michael Rennie <Michael_Rennie>
Status: RESOLVED FIXED QA Contact: Michael Rennie <Michael_Rennie>
Severity: normal    
Priority: P2 CC: thatnitind
Version: 3.2Keywords: readme
Target Milestone: 3.4 M3   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on:    
Bug Blocks: 367806    
Attachments:
Description Flags
After doing "Open Source" by programatically set a local project as source, it wants to retrieve it from a URL.
none
patch none

Description Leopoldo (Polo) Miranda CLA 2011-09-29 12:08:19 EDT
Created attachment 204309 [details]
After doing "Open Source" by programatically set a local project as source, it wants to retrieve it from a URL.

Problem summary :

Trying to add a project name programmatically to Remote JavaScript launch it looks like work by looking at the Edit Source Lookup... options, however files cannot be retried from the local project.

1. Add ISourceLocator into the Remote JavaScript launch configuration e.g.


myJsLunch.setSourceLocator(launchManager.newSourceLocator("org.eclipse.wst.jsdt.debug.core.sourceLocator"));

2. Then adding the setting the container

theSourceDirector.setSourceContainers(theNewContainers);


3. After launching the Remote JavaScript, I can see that I have certainly set the desired project in the "Edit Source Lookup..." 

Current Result:

Trying "Open Source" of a JS file that belongs to the previously project, looks like it wants to be retrieved from the a hots e.g. http://server:port/projectname/folderX/myJSfile.js


Expected Result:

By setting a project name as part of the Source Lookup, match JS files should be retrieved from local project (for this example) instead of looking in a remote host.
Comment 1 Michael Rennie CLA 2011-10-07 14:05:44 EDT
Created attachment 204771 [details]
patch

Testing the default source lookup from the IDE the scenario works as expected. I did find a case where a script node that had no JS-like extension would fail to be found (which is what this patch fixes).

Leopoldo, can you post more of your code on how you are composing your launch, etc ? I am thinking there is a missing initialization step that is not happening.
Comment 2 Michael Rennie CLA 2011-10-07 14:57:11 EDT
I applied the patch to HEAD with a minor update.
Comment 3 Leopoldo (Polo) Miranda CLA 2011-10-11 14:02:46 EDT
For this particular scenario, I've changed the following line 

myLaunch.setSourceLocator((ISourceLocator) launchManager.newSourceLocator("org.eclipse.wst.jsdt.debug.core.sourceLocator"));

by this

JavaScriptSourceDirector myJSdirector = (JavaScriptSourceDirector) launchManager.newSourceLocator("org.eclipse.wst.jsdt.debug.core.sourceLocator");
myJSdirector.initializeParticipants();
myLaunch.setSourceLocator(myJSdirector);


Having this update I'm now able to open/locate resources from a pro grammatically JS launch.
Comment 4 Michael Rennie CLA 2011-10-11 14:05:42 EDT
(In reply to comment #3) 
> Having this update I'm now able to open/locate resources from a pro
> grammatically JS launch.

Thanks for reporting back Leopoldo, I will mark this bug as a readme in case anyone else encounters a similar issue.