Community
Participate
Working Groups
Build Identifier: Build id: 20100218-1602 It should be possible to set white-space formatting rules differently for anonymous functions and named functions. Use-case: It should be possible to stipulate that white-space must precede the opening parenthesis in an anonymous function declaration while named function declaration should not. Example: var foo = function () { // some code }; function foo() { // some code } Reproducible: Always Steps to Reproduce: Not really a bug, more of a feature request. Go to Window > Preferences > Web > JavaScript > Code Style > Formatter. Under the White Space tab open Declarations and see that there is only a setting for Functions (not Named Functions and Anonymous Functions)
I don't expect we'll be working on this. High-quality contributed patches would be entertained.
duplicate: https://bugs.eclipse.org/bugs/show_bug.cgi?id=293243
I think it's a show stopper. This is what stopping me from using eclipse javascript formatter.
Any chance to port Aptana's solution? http://jira.appcelerator.org/browse/APSTUD-3792
According to http://wiki.eclipse.org/JSDTDevelopment formatter implementation is located somewhere here: https://github.com/eclipse/webtools.jsdt.core/tree/master/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter
Created attachment 222271 [details] Fixes an appropriate test This is a patch that changes the formatter test.
Created attachment 222272 [details] Actual fix patch This is a patch that changes behaviour of formatter to add a space after function keyword. I.e. this: function() { } function namedFunction() { } would be formatted as this: function () { } function namedFunction() { } Still, it doesn't make this behaviour optional, just provides better defaults.
Created attachment 222273 [details] Actual fix patch Oops accedently submitted wrong patch. Update.
Created attachment 222274 [details] Actual fix patch Oh, no, again. Sorry.
You can also find my patches here https://github.com/Vanuan/webtools.jsdt.core/commit/c3b3cfc10ed4109ed05eb0c5810249610751f5a7 and here: https://github.com/Vanuan/webtools.jsdt.tests/commit/47dd3b27caf2e40653ae4ffd2fb0f1269983e98f
You can review my patches here: https://github.com/eclipse/webtools.jsdt.core/pull/1 As you requested: Provide a configuration setting, add JSLint built-in profile.
Tests can be found here: https://github.com/eclipse/webtools.jsdt.tests/pull/1
Reopening for potential contribution.
(In reply to comment #10) > You can also find my patches here > https://github.com/Vanuan/webtools.jsdt.core/commit/ > c3b3cfc10ed4109ed05eb0c5810249610751f5a7 > and here: > https://github.com/Vanuan/webtools.jsdt.tests/commit/ > 47dd3b27caf2e40653ae4ffd2fb0f1269983e98f Commented on the change in the tests repo (https://github.com/Vanuan/webtools.jsdt.tests/commit/4d53cfe7a5c1c0f3da5747eefef55aac0d617e0b#commitcomment-2074117 ). Unrelated to that, why remove the ';' from the white space example? Were the formatted results not coming out right for the preview?
(In reply to comment #14) > Commented on the change in the tests repo > (https://github.com/Vanuan/webtools.jsdt.tests/commit/ > 4d53cfe7a5c1c0f3da5747eefef55aac0d617e0b#commitcomment-2074117 ). Thanks, pushed a new version. > Unrelated > to that, why remove the ';' from the white space example? Were the > formatted results not coming out right for the preview? Do you mean this: https://github.com/Vanuan/webtools.jsdt.core/commit/0adccb0e6e8897fd01e1e6b476db2bb341070315#L5R193 That semicolon is not needed there. If semicolon was there that snippet would be formatted like this: function foo() { } ; function bar(x, y) { } var baz = function () { }; I.e. semicolon in this context is an empty statement. Because function declarations are not statements: http://stackoverflow.com/questions/1834642/best-practice-for-semicolon-after-every-function-in-javascript While function expressions are. So the semicolon after baz variable assignment is strongly recommended. I think that examples in formatter should be of proper javascript, not only of formatter options. That's why I edited it. If you disagree, I can revert that, no problem.
Seems like this project is doomed. Sorry, but 3 months of awaiting for a simple change like this to be accepted is too much for me. VJET looks much more dynamic.
I have reviewed this patch and the patches on GitHub for the new JSLint profile and recommend that they all be included in 3.5.1. Chris, can you officially review it.
This patch simply takes one arbitrary formatting decision and changes it to another. I support adding a preference to accomplish this.
(In reply to comment #18) > This patch simply takes one arbitrary formatting decision and changes it to > another. I support adding a preference to accomplish this. Isn't that basically what it's doing? Just in a manner that gives it slightly higher visibility by establishing its own profile?
(In reply to comment #18) > This patch simply takes one arbitrary formatting decision and changes it to > another. I support adding a preference to accomplish this. Obviously, you reviewed the wrong patch. If you look closer into this discussion, you'll see that I provided a link to an appropriate pull request on github. I thought it would've been easier for committer to fetch my branch and cherry pick corresponding commits. Anyway, to avoid confusion, and since there is no established process to accept patches from github, I'll resubmit these patches here.
Created attachment 232865 [details] Core patch
Created attachment 232866 [details] Tests patch
By the way, they are also available under the following links: https://github.com/eclipse/webtools.jsdt.core/pull/1.patch https://github.com/eclipse/webtools.jsdt.tests/pull/1.patch
They are presented as three commits. You can squash them if you like.
Somebody had assured me that this would be included in the Kepler release. I'm a bit disappointed that nobody had looked into this patch for 7 months. Anyway, it seems that this project is not maintained anymore. It's been 2 commits since the last release.
@John: that seems to be a good improvement (functionally speaking, I didn't look at the code). Could you please make it in a Gerrit patch to ease the review? https://wiki.eclipse.org/JSDTDevelopment#Pushing_Gerrit_Reviews
2015 is almost over. Even in Mars it is still not possible to format JavaScript code to fulfill JSHint's rules. I changed from Eclipse to ******** **** some years ago. Tickets like this (a patch exists, but is not merged due to politics or so) remind me why I felt so uncomfortable with Eclipse. Too sad this still seems to be true :-(
@Marcus: Did you have the opportunity to try those patches? It would be nice if John would submit the patches as Gerrit contributions, making the review and merge easier.
New Gerrit change created: https://git.eclipse.org/r/59941
New Gerrit change created: https://git.eclipse.org/r/59943
Added gerrit. Not sure why it's failing though.
Thanks. I'm taking care of avoiding the failures. @Victor and others: do you think you could have a look at this patch soon?
Gerrit change https://git.eclipse.org/r/59943 was merged to [master]. Commit: http://git.eclipse.org/c/jsdt/webtools.jsdt.git/commit/?id=9ccbc6f7fadabf5665397b7f7517e4f49436b89b