Bug 359451 - ISourceLookupDirector does not make honor to new ISourceLocator added programatically
Summary: ISourceLookupDirector does not make honor to new ISourceLocator added program...
Status: RESOLVED FIXED
Alias: None
Product: JSDT
Classification: WebTools
Component: Debug (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows 7
: P2 normal (vote)
Target Milestone: 3.4 M3   Edit
Assignee: Michael Rennie CLA
QA Contact: Michael Rennie CLA
URL:
Whiteboard:
Keywords: readme
Depends on:
Blocks: 367806
  Show dependency tree
 
Reported: 2011-09-29 12:08 EDT by Leopoldo (Polo) Miranda CLA
Modified: 2012-01-03 19:45 EST (History)
1 user (show)

See Also:


Attachments
After doing "Open Source" by programatically set a local project as source, it wants to retrieve it from a URL. (23.45 KB, image/gif)
2011-09-29 12:08 EDT, Leopoldo (Polo) Miranda CLA
no flags Details
patch (1.24 KB, patch)
2011-10-07 14:05 EDT, Michael Rennie CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.