Search in sources :

Example 1 with TextChange

use of org.eclipse.che.ide.api.editor.changeintercept.TextChange in project che by eclipse.

the class CloseCStyleCommentChangeInterceptorTest method testStartNotEmptyLine.

@Test
public void testStartNotEmptyLine() {
    doReturn("whatever").when(document).getLineContent(0);
    doReturn("s/*").when(document).getLineContent(1);
    doReturn(" *").when(document).getLineContent(2);
    final TextChange input = new TextChange.Builder().from(new TextPosition(1, 3)).to(new TextPosition(2, 2)).insert("\n *").build();
    final TextChange output = interceptor.processChange(input, document);
    assertNull(output);
}
Also used : TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) TextChange(org.eclipse.che.ide.api.editor.changeintercept.TextChange) Test(org.junit.Test)

Example 2 with TextChange

use of org.eclipse.che.ide.api.editor.changeintercept.TextChange in project che by eclipse.

the class CloseCStyleCommentChangeInterceptorTest method testPasteWholeCommentStart.

@Test
public void testPasteWholeCommentStart() {
    doReturn("/**").when(document).getLineContent(0);
    doReturn(" *").when(document).getLineContent(1);
    final TextChange input = new TextChange.Builder().from(new TextPosition(0, 0)).to(new TextPosition(1, 2)).insert("/**\n *").build();
    final TextChange output = interceptor.processChange(input, document);
    assertNull(output);
}
Also used : TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) TextChange(org.eclipse.che.ide.api.editor.changeintercept.TextChange) Test(org.junit.Test)

Example 3 with TextChange

use of org.eclipse.che.ide.api.editor.changeintercept.TextChange in project che by eclipse.

the class CloseCStyleCommentChangeInterceptorTest method testWithLeading.

private void testWithLeading(final String lead) {
    doReturn(lead + "/*").when(document).getLineContent(1);
    doReturn(lead + " *").when(document).getLineContent(2);
    final TextChange input = new TextChange.Builder().from(new TextPosition(1, 2 + lead.length())).to(new TextPosition(2, 2 + lead.length())).insert("\n" + lead + " *").build();
    final TextChange output = interceptor.processChange(input, document);
    assertNotNull(output);
    final TextChange expected = new TextChange.Builder().from(new TextPosition(1, 2 + lead.length())).to(new TextPosition(3, 3 + lead.length())).insert("\n" + lead + " * " + "\n" + lead + " */").build();
    Assert.assertEquals(expected, output);
}
Also used : TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) TextChange(org.eclipse.che.ide.api.editor.changeintercept.TextChange)

Example 4 with TextChange

use of org.eclipse.che.ide.api.editor.changeintercept.TextChange in project che by eclipse.

the class CloseCStyleCommentChangeInterceptorTest method testCloseComment.

@Test
public void testCloseComment() {
    doReturn("/**").when(document).getLineContent(0);
    doReturn(" *").when(document).getLineContent(1);
    final TextChange input = new TextChange.Builder().from(new TextPosition(0, 0)).to(new TextPosition(1, 2)).insert("/**\n *").build();
    final TextChange output = interceptor.processChange(input, document);
    assertNull(output);
}
Also used : TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) TextChange(org.eclipse.che.ide.api.editor.changeintercept.TextChange) Test(org.junit.Test)

Example 5 with TextChange

use of org.eclipse.che.ide.api.editor.changeintercept.TextChange in project che by eclipse.

the class CloseCStyleCommentChangeInterceptorTest method testJavadocStyleComment.

@Ignore
@Test
public void testJavadocStyleComment() {
    doReturn("/**").when(document).getLineContent(0);
    doReturn(" *").when(document).getLineContent(1);
    final TextChange input = new TextChange.Builder().from(new TextPosition(0, 3)).to(new TextPosition(1, 2)).insert("\n *").build();
    final TextChange output = interceptor.processChange(input, document);
    assertNotNull(output);
    final TextChange expected = new TextChange.Builder().from(new TextPosition(0, 3)).to(new TextPosition(2, 3)).insert("\n * \n */").build();
    Assert.assertEquals(expected, output);
}
Also used : TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) TextChange(org.eclipse.che.ide.api.editor.changeintercept.TextChange) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

TextChange (org.eclipse.che.ide.api.editor.changeintercept.TextChange)8 TextPosition (org.eclipse.che.ide.api.editor.text.TextPosition)8 Test (org.junit.Test)7 Ignore (org.junit.Ignore)4