use of org.eclipse.xtext.formatting2.IHiddenRegionFormatter in project xtext-core by eclipse.
the class TestLanguageFormatter method _format.
protected void _format(final TypeDeclaration type, @Extension final IFormattableDocument document) {
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.newLine();
};
document.append(this.textRegionExtensions.regionFor(type).keyword(this._testLanguageGrammarAccess.getTypeDeclarationAccess().getLeftCurlyBracketKeyword_3()), _function);
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.newLine();
};
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.newLine();
};
document.append(document.prepend(this.textRegionExtensions.regionFor(type).keyword(this._testLanguageGrammarAccess.getTypeDeclarationAccess().getRightCurlyBracketKeyword_5()), _function_1), _function_2);
final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
it.indent();
};
document.<ISemanticRegion, ISemanticRegion>interior(this.textRegionExtensions.regionFor(type).keyword(this._testLanguageGrammarAccess.getTypeDeclarationAccess().getLeftCurlyBracketKeyword_3()), this.textRegionExtensions.regionFor(type).keyword(this._testLanguageGrammarAccess.getTypeDeclarationAccess().getRightCurlyBracketKeyword_5()), _function_3);
Iterable<Property> _filter = Iterables.<Property>filter(type.getMembers(), Property.class);
for (final Property property : _filter) {
document.<Property>format(property);
}
}
use of org.eclipse.xtext.formatting2.IHiddenRegionFormatter in project xtext-core by eclipse.
the class FormattableDocument method prepend.
@Override
public ISemanticRegion prepend(ISemanticRegion token, Procedure1<? super IHiddenRegionFormatter> before) {
if (token != null) {
IHiddenRegion gap = token.getPreviousHiddenRegion();
set(gap, before);
}
return token;
}
use of org.eclipse.xtext.formatting2.IHiddenRegionFormatter in project xtext-core by eclipse.
the class FormattableDocument method append.
@Override
public ISemanticRegion append(ISemanticRegion token, Procedure1<? super IHiddenRegionFormatter> after) {
if (token != null) {
IHiddenRegion gap = token.getNextHiddenRegion();
set(gap, after);
}
return token;
}
use of org.eclipse.xtext.formatting2.IHiddenRegionFormatter in project xtext-core by eclipse.
the class FormattableDocument method surround.
@Override
public ISemanticRegion surround(ISemanticRegion token, Procedure1<? super IHiddenRegionFormatter> beforeAndAfter) {
if (token != null) {
IHiddenRegion previous = token.getPreviousHiddenRegion();
IHiddenRegion next = token.getNextHiddenRegion();
set(previous, next, beforeAndAfter);
}
return token;
}
use of org.eclipse.xtext.formatting2.IHiddenRegionFormatter in project xtext-core by eclipse.
the class CommentFormatterTest method MLML_paragraph.
@Test
public void MLML_paragraph() {
final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("idlist");
_builder.newLine();
_builder.newLine();
_builder.newLine();
_builder.append("/*");
_builder.newLine();
_builder.append("x");
_builder.newLine();
_builder.append("*/");
_builder.newLine();
_builder.newLine();
_builder.newLine();
_builder.append("a");
_builder.newLine();
it.setToBeFormatted(_builder);
final GenericFormatter<IDList> _function_1 = new GenericFormatter<IDList>() {
@Override
protected void format(final IDList model, @Extension final ITextRegionExtensions regions, @Extension final IFormattableDocument document) {
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it_1) -> {
it_1.oneSpace();
};
document.append(regions.regionFor(model).keyword("idlist"), _function);
}
};
it.setFormatter(_function_1);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("idlist");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("/*");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("* x");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("*/");
_builder_1.newLine();
_builder_1.append("a");
_builder_1.newLine();
it.setExpectation(_builder_1);
};
this._genericFormatterTester.assertFormatted(_function);
}
Aggregations