1

I'm using Win 10 (64bit) and I've tried this with Eclipse Photon and version 2018-09 (64 bit version both times) but I'm getting the same result with both:

I created a new project (File > New > Project...: JavaScript > JavaScript Project) and a JavaScript script (File > New > JavaScript Source File). If I type

function test() {
    var inputField = doc
}

then press Ctrl+Space, it should give me a list of suggestions but instead the list only says "No Default Proposals". If I press Ctrl+Space again after writing document. the list only says "MISSING".

Writing code inside the <script></script> part of an HTML file results in the same empty window. Suggestions for HTML and CSS often work but sometimes the window doesn't even open in the first place and if I write e.g. <sty, there's no suggestion for <style>.

I can train Eclipse in a way if I write e.g.:

var inputField = document.getElementById("inputField");
inputField.style = "red";

Pressing Ctrl+Space after writing inputField again suggests "style". This only works within the same file, if I get the same input field in a different script, there's no suggestion for "style".

I haven't changed anything about the settings (Window > Prerferences):

  • JavaScript > Editor > Content Assist: "Enable auto activation" isn't checked (I don't want it to do that) and enabling it doesn't change anything
  • JavaScript - Editor - Content Assist - Advanced: click (I tried checking everything except "Word Proposals" but no change)
  • Web > HTML Files > Editor > Content Assist: Everything is checked
  • Web > CSS Files > Editor > Content Assist: Everything is checked

I'm using Mars.2 for a Java project and everything works fine there, so not sure if it's the version (I don't want to use a version that old for the new JS project) or if Eclipse simply can't handle JS properly.

Any ideas/suggestions what I could try to fix this (without installing extra plugins)?

Edit: I just tried 2 more versions: It works with Mars.2 (PHP) but not with Neon. I'd still prefer fixing Photon or 2018-09 though instead of using a version that was released almost 3 years ago.

Neph
  • 1,823
  • 2
  • 31
  • 69
  • Does your project's JavaScript Include Path include the browser library? Browser objects aren't built into the JavaScript language, they're only present in web browsers. – nitind Dec 05 '18 at 19:26
  • No, there are no entries under "User Libraries" in Eclipse Photon or Mars.2, yet the content assist works out of the box with Mars.2: If I type "doc" inside a ".js" file, it suggests `document`, `Document`, `DocumentFragment` and `DocumentType`. In every version after that (I tested Neon, Photon and 2018-09 - always the same "Eclipse IDE for JavaScript and Web Developers" version, only with Mars.2 it's "Eclipse for PHP Developers") it doesn't and sometimes even says "MISSING". The description of every version I've tested says "JavaScript, HTML", so you'd think that that's included too. – Neph Dec 06 '18 at 10:01
  • I also just tested version 2018-09 of "Eclipse IDE for PHP Developers" but it's got the same problem as the other "Eclipse IDE for JavaScript and Web Developers" versions I mentioned in my question. It's weird, this is a problem in 4 big versions and there's even a bug report for it (linked in another 2 year old Stackoverflow question [here](https://stackoverflow.com/q/40345457/2016165)), yet Eclipse's developers haven't fixed it so far. – Neph Dec 06 '18 at 11:06
  • Possible duplicate of [Eclipse Neon Content Assist has no proposals for JavaScript](https://stackoverflow.com/questions/40345457/eclipse-neon-content-assist-has-no-proposals-for-javascript) – howlger Dec 10 '18 at 12:50
  • That's the thread I linked one post above yours. It's almost the same problem except: 1. Not only Neon is affected but also Photon and 2018-09, which I'd prefer to use but which were released after the other question was posted. 2. It works just fine in Mars.2 for me, while it didn't for the other poster. 3. I'm also getting that "MISSING" message, which the other poster didn't even mention. – Neph Dec 10 '18 at 14:18
  • @Neph The functionality was lost during the renewal of the JSDT core (new parser, etc.). The removal of this feature in Neon is a known issue for which no one has voted or commented for months. There is a plug-in that fills the gap and there is also a new Eclipse project (Wild Web Developer) that offers JavaScript support based on LSP and which will probably replace JSDT sometime. Your constructive feedback is especially welcome at Eclipse Wild Web Developer. You say 99% of bugs will never be fixed. I have reported 74 issues to Eclipse of which more than 60% have already been fixed. – howlger Dec 10 '18 at 20:04

1 Answers1

-1

Only in the context of a web browser there is a document on which you can call getElementById. Current Eclipse offers out-of-the-box only general JavaScript support.

For example, the Tern Eclipse IDE offers what you want:

  1. Right-click the project and choose Configure > Convert to Tern Project...
  2. Select the Browser module

The Tern Eclipse IDE supports a couple of JavaScript frameworks, e. g. if you select the jQuery module, you can type $. and hit Ctrl+Space to get jQuery specific functions proposed.

howlger
  • 31,050
  • 11
  • 59
  • 99
  • `Eclipse offers out-of-the-box only general JavaScript support.` - That's not true, it works just fine with Vanilla "Eclipse for PHP Developers" (Mars.2, doesn't work with 2018-09), no need to download an extra plugin. It's just that I'd prefer using one of the newer versions if I'm already starting a new project - easier to upgrade now than when I'm a couple of weeks in. – Neph Dec 06 '18 at 10:35
  • I referred to the current versions of Eclipse. Nowadays JavaScript is no longer used within HTML pages only. In Eclipse Neon, JavaScript support has been fundamentally changed to support Node.js ([see my video](https://youtu.be/lCsd681yo1c?t=247). Maybe that was when it was changed. – howlger Dec 06 '18 at 12:06
  • You didn't use the content assist when you were using JS starting at about 4:58, so sorry, I'm not sure why the video his relevant. I didn't change the default settings when I was testing the newer versions and while getting no suggestions at all (even though I should, according to the settings) is suspicious, getting a "MISSING" text makes it looks more like a bug than a wanted change (check my comment above, there's even a bug report for it). This bug is exactly what I want to fix - without any type of inofficial plugin that might make everything even worse. – Neph Dec 06 '18 at 14:07
  • In Neon, the implementation has been fundamentally changed (new JavaScript parser, etc.) to support Node.js as well, e.g. for server-side JavaScript (where there's no DOM). Unfortunately, some existing features have been broken. You're welcome to vote for or to fix [Eclipse bug 504057](https://bugs.eclipse.org/bugs/show_bug.cgi?id=504057). Alternatively, you can try [Eclipse Wild Web Developer](http://eclipse.org/wildwebdeveloper) which requires to have NPM installed and which might replace the current Eclipse JavaScript tooling (it is based on LSP and more active). – howlger Dec 06 '18 at 14:29
  • I'm aware that it's a bug, I found the bug report and if I knew how to fix it, I would. I haven't got high hopes that they're going to fix it now though, since they haven't shown any interest in it for the last 2 years. Unfortunately the "Wild Web Developer" (thanks for the link) is another plugin but I want to avoid installing extras because in the end they won't fix the problem either, they'll just cover it up until they don't get any more updates/break and then I'm back to square one. Maybe there's a way to fix it through special settings (or work around) and that's what I'm looking for. – Neph Dec 06 '18 at 15:23
  • Why do you think that? There is no _they_ in open source. Neither for commercial nor for open source software there is a guarantee that the development will be continued for ever. If you don't want to spend money, provide feedback (report issues and give feedback, especially positive feedback if you want people to motivate to do something for you for free). Don't be so pessimistic and give one of them a try! – howlger Dec 06 '18 at 15:54
  • `there is a guarantee that the development will be continued for ever` - That's exactly the problem. I'm going to make an account on the bug reporting website but I'm not getting my hopes up because they've ignored the problem for 2 years, it's highly unlikely that they'll fix it now. Similar problem with plugins: It might work or not but might add more bugs that'll never get fixed and are even worse. Adding plugins brings risks to any project (risks I'm not willing to take for this) and unless there's a way to fix the initial problem through some trick/settings, I'll have to use Mars.2. – Neph Dec 07 '18 at 09:48
  • It is in your interest to support the open source software you use so that it will be improved. Why are you [doing the opposite](https://twitter.com/_godin_/status/1070753093674000384)? – howlger Dec 07 '18 at 11:46
  • I can only repeat what I already wrote: They don't seem to care enough to fix a bug that's in multiple versions, people asked about it, I said that I plan on posting on the bug report site but is it going to change anything? Probably not. You call it pessimistic, I call it realistic. That's the way it is 99% of the time, some bugs simply never get fixed. What do you expect, that I praise them for not caring? Back to topic now please, I'm looking for a way to fix the problem without using extra plugins. – Neph Dec 07 '18 at 12:18
  • So far I have had exactly the opposite experience. I guess it makes a difference to ask and how to ask. I have given my answer in knowing the settings and the code. I also tested the solution. – howlger Dec 07 '18 at 12:36
  • Count yourself lucky then. You're welcome to ask them directly and if you should get an answer, feel free to post it here. ;) Thanks but unfortunately it's not what I'm looking for. – Neph Dec 07 '18 at 12:56
  • Come on, you can do that on your own. I can't believe you still don't have a Bugzilla account. Your question was _"Any ideas/suggestions what I could try to fix this?"_ which has been answered. I've already wasted far too much time on your problem for which there is a solution. – howlger Dec 07 '18 at 13:30
  • You have edited the question after it was answered. The removed functionality cannot be re-added by changes some settings (see [my comment](https://stackoverflow.com/questions/53635280/eclipse-content-assist-not-showing-suggestions/53647181?noredirect=1#comment94280103_53635280)). Since Eclipse consists of plug-ins, you have already added extra plug-ins by upgrading it. – howlger Dec 11 '18 at 11:50