Bug 110650 - Need API for determining Java line delimiter
Summary: Need API for determining Java line delimiter
Status: CLOSED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.2 M4   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 111464 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-09-26 13:51 EDT by Gary Johnston CLA
Modified: 2006-06-16 11:13 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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!