use of org.eclipse.xtext.testing.formatter.FormatterTestRequest in project xtext-xtend by eclipse.
the class XtendFormatterBugTests method testtestCoreIssue527_02.
@Test
public void testtestCoreIssue527_02() {
final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> {
it_1.<Integer>put(FormatterPreferenceKeys.maxLineWidth, Integer.valueOf(80));
};
it.preferences(_function_1);
StringConcatenation _builder = new StringConcatenation();
_builder.append("class ModuleDeclaration {");
_builder.newLine();
_builder.append("\t");
_builder.append("public List<Object> moduleComponents");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("class AbstractTypeDeclaration {");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("class AliasDeclaration extends AbstractTypeDeclaration {");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("class JavaGenerator {");
_builder.newLine();
_builder.append("\t");
_builder.append("def void generateCommon(String projectSourceRootPath,");
_builder.newLine();
_builder.append("\t\t");
_builder.append("ModuleDeclaration module) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("for (element : module.moduleComponents.filter(AbstractTypeDeclaration).");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("filter [ e |");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("!(e instanceof AliasDeclaration)");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("]) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
it.setToBeFormatted(_builder);
};
this.tester.assertFormatted(_function);
}
use of org.eclipse.xtext.testing.formatter.FormatterTestRequest in project xtext-xtend by eclipse.
the class XtendFormatterBugTests method bug403823_1.
@Test
public void bug403823_1() {
final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> {
it_1.<Integer>put(FormatterPreferenceKeys.maxLineWidth, Integer.valueOf(120));
};
it.preferences(_function_1);
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("def void format(String a, String b, String c) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if (a != b) ");
_builder.append("\'", "\t\t");
_builder.append("\'", "\t\t");
_builder.append("\'", "\t\t");
_builder.append("(");
_builder.append("�", "\t\t");
_builder.append("c");
_builder.append("�", "\t\t");
_builder.append(")");
_builder.append("\'", "\t\t");
_builder.append("\'", "\t\t");
_builder.append("\'", "\t\t");
_builder.append(" else \'\'");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
it.setToBeFormatted(_builder);
};
this.tester.assertFormatted(_function);
}
use of org.eclipse.xtext.testing.formatter.FormatterTestRequest in project xtext-xtend by eclipse.
the class XtendFormatterBugTests method bug462628.
@Test
public void bug462628() {
final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> {
it_1.<Integer>put(FormatterPreferenceKeys.maxLineWidth, Integer.valueOf(120));
};
it.preferences(_function_1);
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("def void format() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("mmmmmmmmmmmmmmmcontainsBlockExprmmmmmmmexprcasesemptymmmmexprmmdefaultmmmmmmmm &&");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("mexprmcasesmexists[multiline] && mexprmmdefaultmmultilineOrInNewLine");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
it.setToBeFormatted(_builder);
};
this.tester.assertFormatted(_function);
}
use of org.eclipse.xtext.testing.formatter.FormatterTestRequest in project xtext-xtend by eclipse.
the class XtendFormatterBugTests method bug403340_1.
@Test
public void bug403340_1() {
final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> {
it_1.<Integer>put(FormatterPreferenceKeys.maxLineWidth, Integer.valueOf(120));
};
it.preferences(_function_1);
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("def void format(String v1, String v2) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if (v1 === v2) ");
_builder.append("\'", "\t\t");
_builder.append("\'", "\t\t");
_builder.append("\'", "\t\t");
_builder.append("Same");
_builder.append("\'", "\t\t");
_builder.append("\'", "\t\t");
_builder.append("\'", "\t\t");
_builder.append(" else ");
_builder.append("\'", "\t\t");
_builder.append("\'", "\t\t");
_builder.append("\'", "\t\t");
_builder.append("Not the Same");
_builder.append("\'", "\t\t");
_builder.append("\'", "\t\t");
_builder.append("\'", "\t\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
it.setToBeFormatted(_builder);
};
this.tester.assertFormatted(_function);
}
use of org.eclipse.xtext.testing.formatter.FormatterTestRequest in project xtext-xtend by eclipse.
the class AbstractXtendFormatterTest method assertFormatted.
public void assertFormatted(final Procedure1<? super MapBasedPreferenceValues> cfg, final CharSequence expectation, final CharSequence toBeFormatted, final String prefix, final String postfix, final boolean allowErrors) {
final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> {
it_1.<Integer>put(FormatterPreferenceKeys.maxLineWidth, Integer.valueOf(80));
it_1.<Boolean>put(XtendFormatterPreferenceKeys.keepOneLineMethods, Boolean.valueOf(false));
if (cfg != null) {
cfg.apply(it_1);
}
};
it.preferences(_function_1);
it.setExpectation(((prefix + expectation) + postfix));
it.setToBeFormatted(((prefix + toBeFormatted) + postfix));
Collection<ITextRegion> _regions = it.getRequest().getRegions();
int _length = prefix.length();
int _length_1 = toBeFormatted.length();
TextRegion _textRegion = new TextRegion(_length, _length_1);
_regions.add(_textRegion);
it.setAllowSyntaxErrors(allowErrors);
};
this.tester.assertFormatted(_function);
}
Aggregations