Bug 328531 - Support for non Eclipse-specific paths for server side JavaScript files
Summary: Support for non Eclipse-specific paths for server side JavaScript files
Status: NEW
Alias: None
Product: JSDT
Classification: WebTools
Component: Debug (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: Future   Edit
Assignee: Michael Rennie CLA
QA Contact: Simon Kaegi CLA
URL:
Whiteboard:
Keywords:
: 331034 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-10-23 14:23 EDT by Sandro Boehme CLA
Modified: 2011-04-25 13:55 EDT (History)
5 users (show)

See Also:


Attachments
Patch for ToggleBreakpointAdapter.java (2.05 KB, text/plain)
2010-10-23 14:24 EDT, Sandro Boehme CLA
no flags Details
Patch for JavaScriptBreakpoint.java (976 bytes, text/plain)
2010-10-23 14:25 EDT, Sandro Boehme CLA
no flags Details
update (35.52 KB, patch)
2011-02-17 16:28 EST, 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 Sandro Boehme CLA 2010-10-23 14:23:45 EDT
Build Identifier: I20100608-0911

This is the problem scenario:
++ the server side ++
o At the serverside is a Rhino ContextFactory that has a started org.eclipse.wst.jsdt.debug.rhino.debugger.RhinoDebugger instance
o This instance is also added as a listener of the ContextFactory resulting in getting the contextCreated event, being set as a debugger for the context and getting the compilationDone event
o If the compilationDone event is triggered it saves the source uri as absolute paths

++ the client side ++
o When setting the breakpoint the IJavaScriptBreakpoint.SCRIPT_PATH is relative to the root of the Eclipse workspace. 
o After connecting the debugger to the remote VM org.eclipse.wst.jsdt.debug.internal.core.breakpoints.JavaScriptBreakpoint.scriptPathMatches() is called to check if the breakpoint can be installed.
o In this case that can only fail as the client path is relative and contains at least the Eclipse project name and the name of the source folder and the server path is absolute and can not contain that leading path elements. E.g. this compares "testProject/src/libs/sling/servlet/default/explorer/item.esp" with "/libs/sling/servlet/default/explorer/item.esp".

The attached patch does work in my environment but it might not be the complete solution. Especially adding a leading '/' to the script path is probalby not preferable.

Reproducible: Always
Comment 1 Sandro Boehme CLA 2010-10-23 14:24:55 EDT
Created attachment 181583 [details]
Patch for ToggleBreakpointAdapter.java
Comment 2 Sandro Boehme CLA 2010-10-23 14:25:26 EDT
Created attachment 181584 [details]
Patch for JavaScriptBreakpoint.java
Comment 3 Sandro Boehme CLA 2010-10-23 14:28:49 EDT
Right now I can not evaluate JavaScript expressions using the "Display" view and the non-primary variables in the "Variables" view show only Object as a type. Is it possible that this is a sideeffect in my environment?
Comment 4 Sandro Boehme CLA 2010-10-24 07:12:08 EDT
One note: The patch only works if the breakpoint is set on JavaScript files within a JavaScript Eclipse project.
Comment 5 Michael Rennie CLA 2010-10-25 10:43:04 EDT
(In reply to comment #3)

Thanks for the patches and bug report Sandro!

> Right now I can not evaluate JavaScript expressions using the "Display" view

The display view is Java specific. There is an enhancement request(s) for a JS one: bug 303843 and bug 313014

> and the non-primary variables in the "Variables" view show only Object as a
> type. Is it possible that this is a sideeffect in my environment?

No, there is a lot of polish work to be done on the variables in the Rhino implementation, for example see bug 322861 and bug 312287

I will look at your patches as soon as I can.
Comment 6 Sandro Boehme CLA 2010-10-25 15:41:50 EDT
(In reply to comment #5)
> (In reply to comment #3)
> 
> Thanks for the patches and bug report Sandro!
> 
> > Right now I can not evaluate JavaScript expressions using the "Display" view
> 
> The display view is Java specific. There is an enhancement request(s) for a JS
> one: bug 303843 and bug 313014
> 
> > and the non-primary variables in the "Variables" view show only Object as a
> > type. Is it possible that this is a sideeffect in my environment?
> 
> No, there is a lot of polish work to be done on the variables in the Rhino
> implementation, for example see bug 322861 and bug 312287
Thanks for the links.

> 
> I will look at your patches as soon as I can.
Don't worry I'm really not in a hurry. :-)

I would like to contribute it (https://issues.apache.org/jira/browse/SLING-1851) to Apache Sling after the expressions view works and the variables view shows types because this would make a nicely integrated debugger. Right now Sling uses the Swing based Rhino debugger (Dim) that has an expression editor and a good variables view. But it doesn't look very appealing and it's not integrated at all.
Comment 7 Michael Rennie CLA 2010-11-24 11:16:18 EST
*** Bug 331034 has been marked as a duplicate of this bug. ***
Comment 8 Ravi CLA 2010-11-24 22:47:51 EST
How to get updated JSDT JAR's that has this patch?
Comment 9 Michael Rennie CLA 2010-11-25 10:14:20 EST
(In reply to comment #8)
> How to get updated JSDT JAR's that has this patch?

The patches have not been applied to HEAD yet, so you would have to:

1. get the source for JSDT debug, which can be done using the team project set file here: http://www.eclipse.org/webtools/jsdt/psf/jsdt-debug.psf
2. apply the patches from this bug to the source
3. use File > Export > Deployable plug-ins and fragments and export the patched jar(s)
Comment 10 Michael Rennie CLA 2011-02-17 16:28:15 EST
Created attachment 189231 [details]
update

Heres an updated patch that changes our source lookup a bit and adds the External JavaScript Source project to the source lookup path properly.
Comment 11 Michael Rennie CLA 2011-02-25 15:04:56 EST
Applied the patch plus a few updates to HEAD as a first round of fixes. This commit also contained the fix to bug 337183 due to over-lapping changes.

I think this work is a big step in the right direction, it brings the source look up of our remote debug sessions closer to how JDT debug works, with the exception that if you do not configure your source look up path, our session will fall back to bringing in the source from the server and use the 'External JavaScript Source' project.

Some major challenges left to resolve:

1. if source is recompiled on the server so that it differs from the version in the client how should we handle this case? In its current state breakpoints will try to re-add themselves on the script load, but the actual source displayed will differ. We could prompt the user to say something like: "Script foo.js has been recompiled, would you like to replace your local source with the remote source?"?

2. if you have more than one script with the same name in the same source lookup path, how do we know that the one you choose (from the resulting choose source dialog) is *actually* the one the server wants to show you?

3. if you have the case in 2. above, and say you have breakpoints in one of the scripts, then if the breakpoint is hit the source lookup could pick the one that that the breakpoints are not actually set in