This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 486577 - Support cross file linting - was "[tern] .tern-project not working in test project]"
Summary: Support cross file linting - was "[tern] .tern-project not working in test pr...
Status: RESOLVED FIXED
Alias: None
Product: Orion (Archived)
Classification: ECD
Component: JS Tools (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P2 normal (vote)
Target Milestone: 12.0   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 485693
  Show dependency tree
 
Reported: 2016-01-26 09:55 EST by Steve Northover CLA
Modified: 2016-02-26 13:18 EST (History)
2 users (show)

See Also:


Attachments
Current draft (10.94 KB, patch)
2016-02-04 13:47 EST, Olivier Thomann CLA
no flags Details | Diff
New patch (15.46 KB, patch)
2016-02-05 13:49 EST, Olivier Thomann CLA
no flags Details | Diff
New patch (15.46 KB, patch)
2016-02-05 13:51 EST, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Northover CLA 2016-01-26 09:55:45 EST
1) Get the code from https://hub.jazz.net/git/snorthov/test
2) Click on javascript/test.js
3) BUG: main() is marked as unreferenced but it is referenced from main.html

Likely a path is wrong in .tern-project.  If I get rid of the "javascript" directory and put index.html and test.js in the same directory, it works.
Comment 1 Steve Northover CLA 2016-01-26 09:56:24 EST
Mike, can you take a look a this one?  Thanks
Comment 2 Steve Northover CLA 2016-01-26 10:00:33 EST
> ... same directory, it works.

Of course I need to edit all the paths in the various places, then refresh the page.
Comment 3 Steve Northover CLA 2016-01-26 11:15:10 EST
From a chat with Mike, he was seeing errors:

Error: Cycle: undefined
   at Object.p.isExtensionOf (https://hub.jazz.net/code/edit/edit.js:5:22463)
   at https://hub.jazz.net/code/edit/edit.js:20:3865
   at Array.some (native)
   at https://hub.jazz.net/code/edit/edit.js:20:3818
   at Array.filter (native)
   at m.e.mixin.setContentType (https://hub.jazz.net/code/edit/edit.js:20:3726)
   at https://hub.jazz.net/code/edit/edit.js:19:31382
   at https://hub.jazz.net/code/edit/edit.js:1:4505
   at Array.forEach (native)
   at e.dispatchEvent (https://hub.jazz.net/code/edit/edit.js:1:4460)

and after clear() and refresh, things worked for him.

For me, I don't see the errors.  I have not tried a clear() or anything.
Comment 4 Olivier Thomann CLA 2016-01-26 11:32:32 EST
Steve, it works for me out of the box. Went to the link you sent, did "Edit code" and then find references in the project and it worked. I got the reference inside index.html.
No sure there is anothing I can do here if I cannot reproduce it.
Comment 5 Steve Northover CLA 2016-01-26 11:56:55 EST
It is possible that this never was supported although I could have sworn that it worked when I gave a tooling demo before Christmas.  It was part of Curtis getting references etc. to work for the plain HTML case.
Comment 6 Olivier Thomann CLA 2016-01-27 11:30:41 EST
As far as I can say, the check for unused function (rule named "no-unused-vars") only considers what is defined within the current scope. See load-rules-async.js line 1305.
In order to get what you want I think we would need to check if the function not found within the current scope is called from another project file.

Michael, do you think this is something we can easily add to that rule? Since that rule is checked by default (warning level), this might be a costly check.
Comment 7 Michael Rennie CLA 2016-01-27 11:46:51 EST
(In reply to Olivier Thomann from comment #6)
> As far as I can say, the check for unused function (rule named
> "no-unused-vars") only considers what is defined within the current scope.
> See load-rules-async.js line 1305.
> In order to get what you want I think we would need to check if the function
> not found within the current scope is called from another project file.
> 
> Michael, do you think this is something we can easily add to that rule?
> Since that rule is checked by default (warning level), this might be a
> costly check.

We currently do not support cross-file linting (Its on the 11.0 plan). I recall Curtis investigating putting in a hack to silence the rule for HTML-context. The preferred way to denote something is global (defined elsewhere) is to use the globals directive like so:

/* globals main */

If you are talking about main in the JS file knowing it is being used from the HTML file for linting, this does not work (and has never worked).
Comment 8 Steve Northover CLA 2016-01-27 12:31:19 EST
Ok, perhaps what I was seeing was a delay in the Tern loading and the warning going away temporarily?  Let's mark this as a dup of the bug for cross file linting.
Comment 9 Steve Northover CLA 2016-01-27 12:31:50 EST
Ok, perhaps what I was seeing was a delay in the Tern loading and the warning going away temporarily?  Let's mark this as a dup of the bug for cross file linting.
Comment 10 Steve Northover CLA 2016-01-27 12:32:18 EST
I seem to get comments doubled quite a bit in bugzilla.  Anyway ...
Comment 11 Olivier Thomann CLA 2016-02-04 13:47:26 EST
Created attachment 259577 [details]
Current draft
Comment 12 Olivier Thomann CLA 2016-02-05 13:49:36 EST
Created attachment 259605 [details]
New patch

Also handle the test case from bug 485693.
Comment 13 Olivier Thomann CLA 2016-02-05 13:51:31 EST
Created attachment 259606 [details]
New patch

Also handles test case from bug 485693.
Comment 14 Curtis Windatt CLA 2016-02-18 16:26:42 EST
Work for this is going on in a branch
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/?h=oliviert%2FBug486577_crossFileLint

Olivier pushed the implementation there along with 2 rules.
I've pushed an additional change with support for the no-undef rule and some tests.
Comment 15 Eclipse Genie CLA 2016-02-22 11:33:57 EST
New Gerrit change created: https://git.eclipse.org/r/67079
Comment 17 Olivier Thomann CLA 2016-02-26 13:18:28 EST
Fixed. More performance work will be done in separate bug reports if necessary.