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

Bug 476907

Summary: Unable to navigate to function using RequireJS
Product: [ECD] Orion Reporter: Steve Northover <steve_northover>
Component: JS ToolsAssignee: Michael Rennie <Michael_Rennie>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2 CC: curtis.windatt.public, Michael_Rennie, Silenio_Quarti, simon_kaegi
Version: unspecified   
Target Milestone: 10.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Steve Northover CLA 2015-09-08 13:48:59 EDT
1) Get minesweeper-require (beta3)
2) In main.js, put the cursor on "setValue" (line 31)
3) Tools->Open Declaration

It fails with 'Could not fine declaration', however, in the lines above, require() statements indicate that "/counter" and "/board" contain code that might be referenced.

NOTE: minesweeper-require is a minimal RequireJS wrapper and not necessarily the way a real RequireJS program might be written, however, modules do define "classes" that are used to stamp out instances of objects from the module.
Comment 1 Curtis Windatt CLA 2015-09-08 14:26:34 EDT
Reproduced, it is failing sometime before resolving counter.js.  Since it doesn't resolve counter.js it can't find any types defined in it.
Comment 2 Curtis Windatt CLA 2015-09-08 15:41:23 EDT
Can't reproduce after importing the code into an Orion target site for debugging.  Both navigation and open declaration work.
Comment 3 Steve Northover CLA 2015-09-08 15:53:56 EDT
Is this the old "I need to have opened the file somewhere before it works" thing?  Shouldn't the RequireJS statement find the file for me?
Comment 4 Michael Rennie CLA 2015-09-08 16:40:39 EDT
(In reply to Steve Northover from comment #3)
> Is this the old "I need to have opened the file somewhere before it works"
> thing?  Shouldn't the RequireJS statement find the file for me?

The problem is the project name combined with the encoding of the URL. Notice in beta3 the file is encoded like so:

https://beta3.hub.jazz.net/code/edit/edit.html#/code/file/mrennie-OrionContent/snorthov%2520%257C%2520minesweeper-require/public/javascript/main.js

and that the part of the name ' | ' is doubly encoded. So that when we try to find the file the URLs do not match and Tern records the file as 'not found' (no types).

Silenio, do you recall why there would be double encoding happening? If I rename Steves' project in Orion to include ' | ' and encode that I get %20|%20 (which is also wrong)
Comment 5 Michael Rennie CLA 2015-09-08 16:51:33 EDT
Perhaps there would be value in adding a util function in URL-shim like URL#urlsEqual(string, string), so clients can easily compare URLs regardless of encoding foibles.

Simon, thoughts on this?
Comment 6 Steve Northover CLA 2015-09-08 17:19:40 EDT
Is there anything I can do to temporarily work around the problem locally to see things working?  I thought all the stupid project names had "|" in them.

SSQ, we need to release / finish the code that makes project.json optional.  I forget where we were on that ...
Comment 7 Michael Rennie CLA 2015-09-09 12:25:44 EDT
(In reply to Steve Northover from comment #6)
> Is there anything I can do to temporarily work around the problem locally to
> see things working?  I thought all the stupid project names had "|" in them.
> 
> SSQ, we need to release / finish the code that makes project.json optional. 
> I forget where we were on that ...

Rename the project to remove the offending spaces + '|' and you should be good to go
Comment 8 Steve Northover CLA 2015-09-09 17:43:06 EDT
I don't remember putting them in there.  The project was created by doing a 'Fork' menu operation (not sure that matters).  What I'm getting at is, shouldn't everyone be seeing this?  I believe that I am just using the default name that was created for me.
Comment 9 Michael Rennie CLA 2015-09-10 17:35:02 EDT
I distilled it down to a relativey simple fix in the JS bundle (+ tests):

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=4a0705be04e261fa6204709ca4cf4a65e9b05ed1