Hi Toby,
Some formatting questions:
- Can IntelliJ be configured not to break on the 'dot' operator? In JavaToJavaScriptCompiler(305) for example, this would always be formatted such that the entirety of "GenerateJavaAST.exec(allTypeDeclarations," would never be broken; the first break would happen after the first parameter.
- Whitespace at end of lines: is this an IntelliJ issue, or were the new sections of EnumsTest (for example) not reformatted? An Eclipse autoformat would leave lines 200 and 255 blank, and truncate line 217 for example. This is a lot more apparently when using a diff tool/editor set to show whitespace characters. (I saw this in other files as well.)
--ScottOn Jan 28, 2008 6:07 PM, Toby Reyelts <to...@google.com> wrote:Hi Scott (and all),
Would you please be kind enough to review this patch that updates our JRE emul classes such that they can be compiled by Sun's JDK (tested with 1.5.0._07). From issue 2039:
Problems:
1) Call sites where javac is not inferencing type parameters of generic
functions where the type parameter is only used for the return type.
2) javac explicitly uses Class.desiredAssertionStatus when it compiles
assert statements.
3) javac explicitly uses Enum.valueOf(Class,String) when it encounters enums.
The attached patch explicitly specifies type parameters where needed and
implements both Class.desiredAssertionStatus and Enum.valueOf.
Thanks,
-Toby
On Jan 29, 2008 12:44 PM, Scott Blum <sco...@google.com> wrote:Hi Toby,
Some formatting questions:
- Can IntelliJ be configured not to break on the 'dot' operator? In JavaToJavaScriptCompiler(305) for example, this would always be formatted such that the entirety of "GenerateJavaAST.exec(allTypeDeclarations," would never be broken; the first break would happen after the first parameter.
I'm not sure why that was that way. I fixed the line break and did an auto-format, and it didn't introduce a new break. /shrug- Whitespace at end of lines: is this an IntelliJ issue, or were the new sections of EnumsTest (for example) not reformatted? An Eclipse autoformat would leave lines 200 and 255 blank, and truncate line 217 for example. This is a lot more apparently when using a diff tool/editor set to show whitespace characters. (I saw this in other files as well.)
There are three options:
1) Strip all trailing whitespace
2) Only strip trailing whitespace for lines that you modify
3) Never strip trailing whitespace
The first obviously won't work, since eclipse doesn't have that functionality. The second is really a pain, because Intellij "remembers" which lines you've modified. The third ends up saving trailing whitespace that you don't seem to like.
I've really tried to give an effort to meet our eclipse's settings as much as possible, but there are 260 settings in the eclipse code formatting styles - and that doesn't include the large set of CodeStyle rules or the 24 rules I had to set up for ordering. In some cases obvious things are easily met, and in other cases (such as whitespace), I'm not sure that there is any solution where Intellij can act as a perfect eclipse emulator. Can we not come to an agreement that is amenable to more editors/IDEs than eclipse alone?
Thanks,
-Toby--ScottOn Jan 28, 2008 6:07 PM, Toby Reyelts <to...@google.com> wrote:Hi Scott (and all),
Would you please be kind enough to review this patch that updates our JRE emul classes such that they can be compiled by Sun's JDK (tested with 1.5.0._07). From issue 2039:
Problems:
1) Call sites where javac is not inferencing type parameters of generic
functions where the type parameter is only used for the return type.
2) javac explicitly uses Class.desiredAssertionStatus when it compiles
assert statements.
3) javac explicitly uses Enum.valueOf(Class,String) when it encounters enums.
The attached patch explicitly specifies type parameters where needed and
implements both Class.desiredAssertionStatus and Enum.valueOf.
Thanks,
-Toby
On Jan 29, 2008 1:55 PM, Toby Reyelts <to...@google.com> wrote:On Jan 29, 2008 12:44 PM, Scott Blum <sco...@google.com> wrote:Hi Toby,
Some formatting questions:
- Can IntelliJ be configured not to break on the 'dot' operator? In JavaToJavaScriptCompiler(305) for example, this would always be formatted such that the entirety of "GenerateJavaAST.exec(allTypeDeclarations," would never be broken; the first break would happen after the first parameter.
I'm not sure why that was that way. I fixed the line break and did an auto-format, and it didn't introduce a new break. /shrug- Whitespace at end of lines: is this an IntelliJ issue, or were the new sections of EnumsTest (for example) not reformatted? An Eclipse autoformat would leave lines 200 and 255 blank, and truncate line 217 for example. This is a lot more apparently when using a diff tool/editor set to show whitespace characters. (I saw this in other files as well.)
There are three options:
1) Strip all trailing whitespace
2) Only strip trailing whitespace for lines that you modify
3) Never strip trailing whitespace
The first obviously won't work, since eclipse doesn't have that functionality. The second is really a pain, because Intellij "remembers" which lines you've modified. The third ends up saving trailing whitespace that you don't seem to like.
Eclipse has this under Clean Up, which can be initiated manually, or automatically when you save.
Preferences -> Java -> Code Style -> Clean Up -> Code Organizing -> Formatter -> Remove Trailing whitespace -> All Lines
Everyone,
I'd really like to get some feedback from a number of people on some of these issues. To put more perspective on it, we've been going around on these issues for a while, but it seems like we've hit the limit on the extent to which we can make Eclipse and IntelliJ agree to autoformat the same way.
Maybe it's time to have a larger discussion and rethink the original purposes. How important is auto-format? Is it important to not thrash whitespace in svn? Should we make everyone use Eclipse (at least for formatting) or perhaps dive into the Eclipse code and hack together a command line tool to perform Eclipse auto-formatting?
Thoughts?
ScottOn Jan 29, 2008 3:55 PM, Toby Reyelts <to...@google.com> wrote:On Jan 29, 2008 12:44 PM, Scott Blum <sco...@google.com> wrote:Hi Toby,
Some formatting questions:
- Can IntelliJ be configured not to break on the 'dot' operator? In JavaToJavaScriptCompiler(305) for example, this would always be formatted such that the entirety of "GenerateJavaAST.exec(allTypeDeclarations," would never be broken; the first break would happen after the first parameter.
I'm not sure why that was that way. I fixed the line break and did an auto-format, and it didn't introduce a new break. /shrug- Whitespace at end of lines: is this an IntelliJ issue, or were the new sections of EnumsTest (for example) not reformatted? An Eclipse autoformat would leave lines 200 and 255 blank, and truncate line 217 for example. This is a lot more apparently when using a diff tool/editor set to show whitespace characters. (I saw this in other files as well.)
There are three options:
1) Strip all trailing whitespace
2) Only strip trailing whitespace for lines that you modify
3) Never strip trailing whitespace
The first obviously won't work, since eclipse doesn't have that functionality. The second is really a pain, because Intellij "remembers" which lines you've modified. The third ends up saving trailing whitespace that you don't seem to like.
I've really tried to give an effort to meet our eclipse's settings as much as possible, but there are 260 settings in the eclipse code formatting styles - and that doesn't include the large set of CodeStyle rules or the 24 rules I had to set up for ordering. In some cases obvious things are easily met, and in other cases (such as whitespace), I'm not sure that there is any solution where Intellij can act as a perfect eclipse emulator. Can we not come to an agreement that is amenable to more editors/IDEs than eclipse alone?
Thanks,
-Toby
FWIW, I believe that you can already launch the Eclipse formatter application from the command line. See: http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.jdt.doc.user/tasks/tasks-232.htm
Second, the formatter does go into JSNI methods. I am posting it as is, in the hopes that some Eclipse guru could figure out how to make the formatting rules do the right thing for JSNI methods. Alternatively, we might decide that the auto-formatted JSNI is reasonable.
On Feb 4, 2008 4:32 PM, Lex Spoon <sp...@google.com> wrote:I don't think what Eclipse currently does with JSNI is acceptable.Second, the formatter does go into JSNI methods. I am posting it as is, in the hopes that some Eclipse guru could figure out how to make the formatting rules do the right thing for JSNI methods. Alternatively, we might decide that the auto-formatted JSNI is reasonable.
I think we can figure out the internals, override necessary parts with our own classes in the classpath ahead of the Eclipse jars, and correct the behavior there, but that will be a lot of work and fragile to Eclipse version differences. Maybe once we have a plugin that properly formats JSNI, that plugin could be hooked into this command-line formatter tool.
I know this thread has been primarily focused on configurations for ides (with the exception of Jalopy). But, we used an ant plugin/task to enforce coding style conventions in the xdoclet project.
The tool we used was Refactory and it ran as part of the build.xml. This was appealing since it didn't restrict the set of tools people used (not that this is a big deal). But must importantly it happened automatically and did not require folks to integrate settings into their ide.
rovrevikOn Feb 4, 2008 6:30 PM, John Tamplin <j...@google.com> wrote:On Feb 4, 2008 4:32 PM, Lex Spoon <sp...@google.com> wrote:I don't think what Eclipse currently does with JSNI is acceptable.Second, the formatter does go into JSNI methods. I am posting it as is, in the hopes that some Eclipse guru could figure out how to make the formatting rules do the right thing for JSNI methods. Alternatively, we might decide that the auto-formatted JSNI is reasonable.
Okay.
I think we can figure out the internals, override necessary parts with our own classes in the classpath ahead of the Eclipse jars, and correct the behavior there, but that will be a lot of work and fragile to Eclipse version differences. Maybe once we have a plugin that properly formats JSNI, that plugin could be hooked into this command-line formatter tool.
If we are going to write some code, there are two other paths to consider.
One is to revive Jalopy. Jalopy is a much smaller dependency than Eclipse, small enough that we could check the jars into the repository. There is also an old Eclipse plugin for Jalopy, and that could also be revived if anyone was motivated enough.
Two would be to write enough code that we only need the JDT and not all of Eclipse in order to run a code format. We already check a lot of the JDT into the repository anyway, so it would not be a big deal to check in a slightly modified version. The modification might use classpath overriding if that works best.
I am going back and forth about which way sounds better. It depends on whether Jalopy is close enough where it is (maybe it sucks, I have no idea), and on whether JDT's formatter has low enough dependencies to be usable by itself (again, I have no idea).
-Lex