Search in sources :

Example 86 with MapBasedPreferenceValues

use of org.eclipse.xtext.preferences.MapBasedPreferenceValues in project xtext-xtend by eclipse.

the class XtendFormatterBugTests method bug403823.

@Test
public void bug403823() {
    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.newLine();
        _builder.append("\t\t\t");
        _builder.append("\'", "\t\t\t");
        _builder.append("\'", "\t\t\t");
        _builder.append("\'", "\t\t\t");
        _builder.append("(");
        _builder.append("�", "\t\t\t");
        _builder.append("c");
        _builder.append("�", "\t\t\t");
        _builder.append(")");
        _builder.append("\'", "\t\t\t");
        _builder.append("\'", "\t\t\t");
        _builder.append("\'", "\t\t\t");
        _builder.newLineIfNotEmpty();
        _builder.append("\t\t");
        _builder.append("else");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("\'\'");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        it.setToBeFormatted(_builder);
    };
    this.tester.assertFormatted(_function);
}
Also used : Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) FormatterTestRequest(org.eclipse.xtext.testing.formatter.FormatterTestRequest) MapBasedPreferenceValues(org.eclipse.xtext.preferences.MapBasedPreferenceValues) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) AbstractXtendFormatterTest(org.eclipse.xtend.core.tests.formatting.AbstractXtendFormatterTest) Test(org.junit.Test)

Example 87 with MapBasedPreferenceValues

use of org.eclipse.xtext.preferences.MapBasedPreferenceValues in project xtext-xtend by eclipse.

the class XtendFormatterBugTests method bug403340.

@Test
public void bug403340() {
    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.newLine();
        _builder.append("\t\t\t");
        _builder.append("\'", "\t\t\t");
        _builder.append("\'", "\t\t\t");
        _builder.append("\'", "\t\t\t");
        _builder.append("Same");
        _builder.append("\'", "\t\t\t");
        _builder.append("\'", "\t\t\t");
        _builder.append("\'", "\t\t\t");
        _builder.newLineIfNotEmpty();
        _builder.append("\t\t");
        _builder.append("else");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("\'", "\t\t\t");
        _builder.append("\'", "\t\t\t");
        _builder.append("\'", "\t\t\t");
        _builder.append("Not the Same");
        _builder.append("\'", "\t\t\t");
        _builder.append("\'", "\t\t\t");
        _builder.append("\'", "\t\t\t");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        it.setToBeFormatted(_builder);
    };
    this.tester.assertFormatted(_function);
}
Also used : Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) FormatterTestRequest(org.eclipse.xtext.testing.formatter.FormatterTestRequest) MapBasedPreferenceValues(org.eclipse.xtext.preferences.MapBasedPreferenceValues) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) AbstractXtendFormatterTest(org.eclipse.xtend.core.tests.formatting.AbstractXtendFormatterTest) Test(org.junit.Test)

Example 88 with MapBasedPreferenceValues

use of org.eclipse.xtext.preferences.MapBasedPreferenceValues in project xtext-xtend by eclipse.

the class XtendInterfaceFormatterTest method formatFieldInit01.

@Test
public void formatFieldInit01() {
    final Procedure1<MapBasedPreferenceValues> _function = (MapBasedPreferenceValues it) -> {
    };
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("interface bar {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("int foo = 1 + 1");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    this.assertFormatted(_function, _builder);
}
Also used : MapBasedPreferenceValues(org.eclipse.xtext.preferences.MapBasedPreferenceValues) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) AbstractXtendFormatterTest(org.eclipse.xtend.core.tests.formatting.AbstractXtendFormatterTest) Test(org.junit.Test)

Example 89 with MapBasedPreferenceValues

use of org.eclipse.xtext.preferences.MapBasedPreferenceValues in project xtext-xtend by eclipse.

the class XtendInterfaceFormatterTest method formatFieldStatic02.

@Test
public void formatFieldStatic02() {
    final Procedure1<MapBasedPreferenceValues> _function = (MapBasedPreferenceValues it) -> {
    };
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("interface bar {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static int bar");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    this.assertFormatted(_function, _builder);
}
Also used : MapBasedPreferenceValues(org.eclipse.xtext.preferences.MapBasedPreferenceValues) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) AbstractXtendFormatterTest(org.eclipse.xtend.core.tests.formatting.AbstractXtendFormatterTest) Test(org.junit.Test)

Example 90 with MapBasedPreferenceValues

use of org.eclipse.xtext.preferences.MapBasedPreferenceValues in project xtext-xtend by eclipse.

the class XtendInterfaceFormatterTest method formatFieldInit02.

@Test
public void formatFieldInit02() {
    final Procedure1<MapBasedPreferenceValues> _function = (MapBasedPreferenceValues it) -> {
    };
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("interface bar {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("int foo = 1 + 1");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("int baz = 1 + 1");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    this.assertFormatted(_function, _builder);
}
Also used : MapBasedPreferenceValues(org.eclipse.xtext.preferences.MapBasedPreferenceValues) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) AbstractXtendFormatterTest(org.eclipse.xtend.core.tests.formatting.AbstractXtendFormatterTest) Test(org.junit.Test)

Aggregations

MapBasedPreferenceValues (org.eclipse.xtext.preferences.MapBasedPreferenceValues)106 Test (org.junit.Test)100 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)99 AbstractXtendFormatterTest (org.eclipse.xtend.core.tests.formatting.AbstractXtendFormatterTest)91 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)14 IFormattableDocument (org.eclipse.xtext.formatting2.IFormattableDocument)8 IHiddenRegionFormatter (org.eclipse.xtext.formatting2.IHiddenRegionFormatter)8 GenericFormatter (org.eclipse.xtext.formatting2.internal.GenericFormatter)8 GenericFormatterTestRequest (org.eclipse.xtext.formatting2.internal.GenericFormatterTestRequest)8 ITextRegionExtensions (org.eclipse.xtext.formatting2.regionaccess.ITextRegionExtensions)8 KWList (org.eclipse.xtext.formatting2.internal.formattertestlanguage.KWList)7 FormatterTestRequest (org.eclipse.xtext.testing.formatter.FormatterTestRequest)6 Ignore (org.junit.Ignore)5 IAutowrapFormatter (org.eclipse.xtext.formatting2.IAutowrapFormatter)2 IFormattableSubDocument (org.eclipse.xtext.formatting2.IFormattableSubDocument)2 IHiddenRegionFormatting (org.eclipse.xtext.formatting2.IHiddenRegionFormatting)2 ISubFormatter (org.eclipse.xtext.formatting2.ISubFormatter)2 ITextReplacement (org.eclipse.xtext.formatting2.regionaccess.ITextReplacement)2 ITextSegment (org.eclipse.xtext.formatting2.regionaccess.ITextSegment)2 ITextRegion (org.eclipse.xtext.util.ITextRegion)2