Java 类org.eclipse.xtext.formatting.IWhitespaceInformationProvider 实例源码

项目:xtext-core    文件:LineSeparatorHarminizerTest.java   
@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"));
}
项目:xtext-core    文件:LineSeparatorHarmonizer.java   
protected IWhitespaceInformationProvider getWhitespaceInformationProvider() {
    return whitespaceInformationProvider;
}
项目:bts    文件:DefaultUiModule.java   
/**
 * @since 2.3
 */
public Class<? extends IWhitespaceInformationProvider> bindIWhitespaceInformationProvider() {
    return PreferenceStoreWhitespaceInformationProvider.class;
}