use of org.eclipse.xtext.formatting2.internal.GenericFormatterTestRequest in project xtext-core by eclipse.
the class FormattingConflictTest method enableDebugTracingTrue.
@Test
public void enableDebugTracingTrue() {
final Wrapper<Throwable> wrapper = new Wrapper<Throwable>();
final Wrapper<Integer> execution = new Wrapper<Integer>(Integer.valueOf(0));
final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("idlist 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) {
Integer _get = execution.get();
int _plus = ((_get).intValue() + 1);
execution.set(Integer.valueOf(_plus));
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it_1) -> {
it_1.setSpace(" ");
};
document.append(regions.regionFor(model).keyword("idlist"), _function);
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it_1) -> {
it_1.setSpace("\t");
};
document.append(regions.regionFor(model).keyword("idlist"), _function_1);
}
};
it.setFormatter(_function_1);
FormatterRequest _request = it.getRequest();
_request.setEnableDebugTracing(true);
FormatterRequest _request_1 = it.getRequest();
final IAcceptor<Exception> _function_2 = (Exception e) -> {
wrapper.set(e);
};
_request_1.setExceptionHandler(_function_2);
};
this._genericFormatterTester.assertFormatted(_function);
Throwable _get = wrapper.get();
final ConflictingRegionsException exception = ((ConflictingRegionsException) _get);
Assert.assertEquals(1, (execution.get()).intValue());
Assert.assertEquals(2, exception.getTraces().size());
}
use of org.eclipse.xtext.formatting2.internal.GenericFormatterTestRequest 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);
}
use of org.eclipse.xtext.formatting2.internal.GenericFormatterTestRequest in project xtext-core by eclipse.
the class CommentFormatterTest method SL_multiline.
@Test
public void SL_multiline() {
final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("idlist ");
_builder.newLine();
_builder.newLine();
_builder.append("//x");
_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 //x");
_builder_1.newLine();
_builder_1.append("a");
_builder_1.newLine();
it.setExpectation(_builder_1);
};
this._genericFormatterTester.assertFormatted(_function);
}
use of org.eclipse.xtext.formatting2.internal.GenericFormatterTestRequest in project xtext-core by eclipse.
the class CommentFormatterTest method SL_inline.
@Test
public void SL_inline() {
final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("idlist //x");
_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 //x");
_builder_1.newLine();
_builder_1.append("a");
_builder_1.newLine();
it.setExpectation(_builder_1);
};
this._genericFormatterTester.assertFormatted(_function);
}
use of org.eclipse.xtext.formatting2.internal.GenericFormatterTestRequest in project xtext-core by eclipse.
the class FormattableDocumentTest method autoWrapWithSpan.
@Test
public void autoWrapWithSpan() {
final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> {
it_1.<Integer>put(FormatterPreferenceKeys.maxLineWidth, Integer.valueOf(10));
};
it.preferences(_function_1);
StringConcatenation _builder = new StringConcatenation();
_builder.append("kwlist kw1 kw2 kw3 kw4");
_builder.newLine();
it.setToBeFormatted(_builder);
final GenericFormatter<KWList> _function_2 = new GenericFormatter<KWList>() {
@Override
protected void format(final KWList model, @Extension final ITextRegionExtensions regions, @Extension final IFormattableDocument document) {
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it_1) -> {
it_1.autowrap(6);
it_1.oneSpace();
};
document.append(regions.regionFor(model).keyword("kwlist"), _function);
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it_1) -> {
it_1.autowrap();
it_1.oneSpace();
};
document.append(regions.regionFor(model).keyword("kw1"), _function_1);
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it_1) -> {
it_1.autowrap();
it_1.oneSpace();
};
document.append(regions.regionFor(model).keyword("kw2"), _function_2);
final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it_1) -> {
it_1.autowrap();
it_1.oneSpace();
};
document.append(regions.regionFor(model).keyword("kw3"), _function_3);
final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it_1) -> {
it_1.autowrap();
it_1.newLine();
};
document.append(regions.regionFor(model).keyword("kw4"), _function_4);
}
};
it.setFormatter(_function_2);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("kwlist");
_builder_1.newLine();
_builder_1.append("kw1 kw2");
_builder_1.newLine();
_builder_1.append("kw3 kw4");
_builder_1.newLine();
it.setExpectation(_builder_1);
};
this._genericFormatterTester.assertFormatted(_function);
}
Aggregations