Community
Participate
Working Groups
WorkbenchPlugin.log( WorkbenchMessages.format("WorkspaceAction.logTitle", new Object[] {getClass ().getName(), e.getTargetException()}), StatusUtil.newStatus(IStatus.ERROR, null, "foo", e.getTargetException())); //$NON-NLS-1$ displayError(e.getTargetException().getMessage());
Sorry Could not finish writing: Tab+Space in this bug system == Commit. I selected the first two lines of a code that looks like: System.out.println("Foo"); System.out.println("Foo"); //$NON-NLS-1$ System.out.println("Foo"); The comment "//$NON-NLS-1$" was added to a 3rd line. Ending up like that: System.out.println("Foo"); System.out.println("Foo"); //$NON-NLS-1$ System.out.println("Foo"); PS: Change the number of columns in the format preferences so that System.out.println("Foo"); //$NON-NLS-1$ does not fit in a single line.
Which build are you using?
Build 20020319
A workaround is to format the three lines together. The issue seems to be that the formatter is removing line ends at the end of the formatted string.
Could a bonus one be added at the end ? I have seen similar additions in UI code.
*** Bug 12187 has been marked as a duplicate of this bug. ***
*** Bug 16517 has been marked as a duplicate of this bug. ***
I can patch this by adding a line delimiter at the end of the output string. This doesn't fix the case where several line delimiters are at the end of the source that is formatted, but it solves problems like this one and the one in <A HREF="http://dev.eclipse.org/bugs/show_bug.cgi?id=16517>16517</A>. Is this good enough for now? We want to revisit the whole code formatter after 2.0 anyway.
Patch released. Please reopen if the new formatted source is still boggus.
*** Bug 17626 has been marked as a duplicate of this bug. ***
Verified.
I checked in the F2 build, and there is still a small problem with this with respect to the end of file (see the duplicate bug 12187). Now, the formatter removes all but one line termination character from the end of file, which is the correct behavior. However, if there is *no* line termination character to start with, it will not add one. It should, since all java lines must end with a line termination character, according to the language spec. Not that the compilers seem to care, mind you, but, still...
Rick - the Java grammar does not mention any need for a trailing line delimitor at the end of a source file. What do you have in mind ?
Sorry. A cursory reading of the language spec gave me the impression that all lines needed to end with a line terminator. We also have a developer here who was relying on that assumption and choked on code that did not have the terminal line terminator. That particular issue has apparently gone away. Reading grammars gives me a headache. In the immortal words of Emily Litella, may she rest in peace: "Never mind."