org.eclipse.xtext.formatting.IWhitespaceInformationProvider Java Examples

The following examples show how to use org.eclipse.xtext.formatting.IWhitespaceInformationProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LineSeparatorHarmonizerTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testHarmonizeLineBreaks() {
	IWhitespaceInformationProvider whitespaceInformationProvider = get(IWhitespaceInformationProvider.class);
	URI uri = URI.createURI("example.txt");
	String ls = whitespaceInformationProvider.getLineSeparatorInformation(uri).getLineSeparator();
	assertFalse(isEmpty(ls));
	LineSeparatorHarmonizer lineSeparatorHarmonizer = get(LineSeparatorHarmonizer.class);

	assertEquals(ls, lineSeparatorHarmonizer.postProcess(uri, "\n"));
	assertEquals(ls, lineSeparatorHarmonizer.postProcess(uri, "\r"));
	assertEquals(ls, lineSeparatorHarmonizer.postProcess(uri, "\n\r"));
	assertEquals(ls, lineSeparatorHarmonizer.postProcess(uri, "\r\n"));
	
	assertEquals("0" + ls + "1" + ls + "2", lineSeparatorHarmonizer.postProcess(uri, "0\n1\r2"));
	assertEquals("0" + ls + "1" + ls + "2", lineSeparatorHarmonizer.postProcess(uri, "0\n\r1\r\n2"));
	assertEquals("0" + ls + ls + "1", lineSeparatorHarmonizer.postProcess(uri, "0\n\r\n\r1"));
	assertEquals("0" + ls + ls + "1", lineSeparatorHarmonizer.postProcess(uri, "0\r\n\r\n1"));
	assertEquals("0" + ls + ls + ls + "1", lineSeparatorHarmonizer.postProcess(uri, "0\n\r\n\r\n1"));
	assertEquals("0" + ls + ls + ls + "1", lineSeparatorHarmonizer.postProcess(uri, "0\r\n\r\n\r1"));
}
 
Example #2
Source File: DefaultUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @since 2.3
 */
public Class<? extends IWhitespaceInformationProvider> bindIWhitespaceInformationProvider() {
	return PreferenceStoreWhitespaceInformationProvider.class;
}
 
Example #3
Source File: LineSeparatorHarmonizer.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
protected IWhitespaceInformationProvider getWhitespaceInformationProvider() {
	return whitespaceInformationProvider;
}