org.eclipse.xtext.formatting2.internal.WhitespaceReplacer Java Examples

The following examples show how to use org.eclipse.xtext.formatting2.internal.WhitespaceReplacer. 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: OffMultilineCommentReplacer.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void configureWhitespace(WhitespaceReplacer leading, WhitespaceReplacer trailing) {
	if (noIndent) {
		leading.getFormatting().setNoIndentation(true);
		trailing.getFormatting().setNoIndentation(true);
	}
}
 
Example #2
Source File: FixedMultilineCommentReplacer.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void configureWhitespace(WhitespaceReplacer leading, WhitespaceReplacer trailing) {
	if (multiline) {
		enforceNewLine(leading);
		enforceNewLine(trailing);
	} else {
		enforceSingleSpace(leading);
		enforceSingleSpace(trailing);
	}
}
 
Example #3
Source File: FixedMultilineCommentReplacer.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/** */
protected void enforceNewLine(WhitespaceReplacer replacer) {
	if (replacer.getRegion().getOffset() <= 0)
		return;
	Integer min = replacer.getFormatting().getNewLineMin();
	if (min == null || min < 1)
		replacer.getFormatting().setNewLinesMin(1);
}
 
Example #4
Source File: FixedMultilineCommentReplacer.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/** */
protected void enforceSingleSpace(WhitespaceReplacer replacer) {
	if (replacer.getRegion().getOffset() <= 0)
		return;
	String space = replacer.getFormatting().getSpace();
	if (space == null || space.length() < 1)
		replacer.getFormatting().setSpace(" ");
}
 
Example #5
Source File: SARLSinglelineCommentReplacer.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public void configureWhitespace(WhitespaceReplacer leading, WhitespaceReplacer trailing) {
	// Do not configure the whitespaces before and after the single line comment in order
	// to let the developer to write them as s/he want.

	// The whitespace replacers are lready configured for the current context.
	// It means that line lines may be added around the single line comment.
}
 
Example #6
Source File: AbstractFormatter2.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public ITextReplacer createWhitespaceReplacer(ITextSegment hiddens, IHiddenRegionFormatting formatting) {
	return new WhitespaceReplacer(hiddens, formatting);
}