Community
Participate
Working Groups
We need to be able to determine the line delimiter to use when adding code to an existing Java class. We currently use class.org.eclipse.jdt.internal.corext.codemanipulation.StubUtility.getLineDelimiterUsed(IJavaElement), which is internal. We need public API for this.
There is org.eclipse.jface.text.TextUtilities in plugin org.eclipse.text. /** * Returns the default line delimiter for the given document. This is either the delimiter of the first line, or the platform line delimiter if it is * a legal line delimiter or the first one of the legal line delimiters. The default line delimiter should be used when performing document * manipulations that span multiple lines. * * @param document the document * @return the document's default line delimiter * @since 3.0 */ public static String getDefaultLineDelimiter(IDocument document) Would this do the trick ? Or do you need it to be on an IJavaElement per se ?
Hmm. I dunno. We have an IJavaElement in hand, not an IDocument. Is there a (quick, efficient) way to get an IDocument given an IJavaElement?
Added API IOpenable#findRecommendedLineSeparator() and tests JavaModelTests#testFindLineSeparator01/04.
Verified for 3.2 M4 using build I20051212-0010
*** Bug 111464 has been marked as a duplicate of this bug. ***
Thanks!