@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); }
@Override public TextChange processChange(final TextChange change, ReadOnlyDocument document) { final RegExp regex = RegExp.compile("^\n(\\s*)\\*\\s*$"); final MatchResult matchResult = regex.exec(change.getNewText()); if (matchResult != null) { final String line = document.getLineContent(change.getFrom().getLine()); return new TextChange.Builder().from(change.getFrom()).to(change.getFrom()).insert(modifiedInsert).build(); } else { return null; } }
CloseCStyleCommentChangeInterceptor implements TextChangeInterceptor { @Override public TextChange processChange(final TextChange change, ReadOnlyDocument document) { final RegExp regex = RegExp.compile("^\n(\\s*)\\*\\s*$"); final MatchResult matchResult = regex.exec(change.getNewText()); if (matchResult != null) { final String line = document.getLineContent(change.getFrom().getLine()); return new TextChange.Builder().from(change.getFrom()).to(change.getFrom()).insert(modifiedInsert).build(); } else { return null; } } }
CloseCStyleCommentChangeInterceptor implements TextChangeInterceptor { @Override public TextChange processChange(final TextChange change, ReadOnlyDocument document) { final RegExp regex = RegExp.compile("^\n(\\s*)\\*\\s*$"); final MatchResult matchResult = regex.exec(change.getNewText()); if (matchResult != null) { final String line = document.getLineContent(change.getFrom().getLine()); return new TextChange.Builder().from(change.getFrom()).to(change.getFrom()).insert(modifiedInsert).build(); } else { return null; } }  }
CloseCStyleCommentChangeInterceptor implements TextChangeInterceptor { @Override public TextChange processChange(final TextChange change, ReadOnlyDocument document) { final RegExp regex = RegExp.compile("^\n(\\s*)\\*\\s*$"); final MatchResult matchResult = regex.exec(change.getNewText()); if (matchResult != null) { final String line = document.getLineContent(change.getFrom().getLine()); return new TextChange.Builder().from(change.getFrom()).to(change.getFrom()).insert(modifiedInsert).build(); } else { return null; } }  @Override TextChange processChange(final TextChange change, ReadOnlyDocument document); }
CloseCStyleCommentChangeInterceptor implements TextChangeInterceptor { @Override public TextChange processChange(final TextChange change, ReadOnlyDocument document) { final RegExp regex = RegExp.compile("^\n(\\s*)\\*\\s*$"); final MatchResult matchResult = regex.exec(change.getNewText()); if (matchResult != null) { final String line = document.getLineContent(change.getFrom().getLine()); return new TextChange.Builder().from(change.getFrom()).to(change.getFrom()).insert(modifiedInsert).build(); } else { return null; } }  @Override TextChange processChange(final TextChange change, ReadOnlyDocument document);  }