Bug 110650

Summary: Need API for determining Java line delimiter
Product: [Eclipse Project] JDT Reporter: Gary Johnston <GaryJohnston>
Component: CoreAssignee: Jerome Lanneluc <jerome_lanneluc>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: martinae, vtrivedi
Version: 3.1   
Target Milestone: 3.2 M4   
Hardware: All   
OS: All   
Whiteboard:

Description Gary Johnston CLA 2005-09-26 13:51:53 EDT
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.
Comment 1 Philipe Mulet CLA 2005-11-09 12:41:26 EST
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 ?
Comment 2 Gary Johnston CLA 2005-11-09 14:09:04 EST
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?
Comment 3 Jerome Lanneluc CLA 2005-11-15 08:53:49 EST
Added API IOpenable#findRecommendedLineSeparator() and tests
JavaModelTests#testFindLineSeparator01/04.
Comment 4 David Audel CLA 2005-12-12 11:35:10 EST
Verified for 3.2 M4 using build I20051212-0010
Comment 5 Jerome Lanneluc CLA 2006-01-30 07:08:20 EST
*** Bug 111464 has been marked as a duplicate of this bug. ***
Comment 6 Gary Johnston CLA 2006-06-16 11:13:14 EDT
Thanks!