开发者

Eclipse Indigo "Save Actions" are not being applied

开发者 https://www.devze.com 2023-03-25 20:40 出处:网络
I\'m new to Eclipse and downloaded the following version: Eclipse Java EE IDE for Web Developers. Version: Indigo Release

I'm new to Eclipse and downloaded the following version: Eclipse Java EE IDE for Web Developers. Version: Indigo Release Build id: 20110615-0604

[edit] Eclipse开发者_Python百科 Platform Version 3.7

I have edited Java > Editor > Save Actions to do the following: Remove trailing white spaces on all lines, Correct indentation

When I save the .java file, those actions are not applied... is this a bug? Found this that might be related: https://bugs.eclipse.org/bugs/show_bug.cgi?id=350475


Assuming that this relates to JavaScript files, then the related Eclipse bug could be helpful.

The problem (as I've just experienced) is that you can edit the JavaScript -> Save Actions preferences via the context menu when editing a JavaScript file, but the actions will not be run.

The solution is to right click on the project containing the .js file, and select Configure -> Convert to JavaScript project.

The bad news is that this will then will also enable Eclipse's not-so-great JavaScript validation, therefore telling you that libraries such as moment.min.js are broken.


Well for those of you who have found this topic... I did find 2 solutions, no thanks to Eclipse, other than the fact that it is open source and people can write plugins.

Eclipse Platform Version 3.7

  1. AnyEdit - plugin that does it for you when you Save file (I believe this is what eclipse SHOULD be doing)
  2. Go to: Window > Preferences. Then under General > Keys. Make sure drop down for Scheme: is Default and enter 'remove trailing' in the filter. You should then see "Remove Trailing Whitespace" under the command column. Bind it to your own key command.

The only drawback to #2 is that you have to actually press the key binding while editing the file, kindof like a cleanup action.

Too bad Eclipse hasn't taken the approach that ALL file types should be configurable in this way... sometimes I miss TextPad.


Old question, but at least for newer Eclipse versions there's a better solution: Go to the project properties, then to Project Facets. If it tells you that your project isn't in faceted form yet, then convert it. Afterwards (or if it already was faceted), just enable the JavaScript checkbox.

I had the same issue with Eclipse 4.4 (Luna) and this fixed it for me, the save actions are now executed on save.


Adding to jlh's answer, I also had to configure the JavaScript include path of the project to enable save actions. Before that even a manual "Clean Up ..." from the source menu wouldn't work.

0

精彩评论

暂无评论...
验证码 换一张
取 消