Java Code Examples for org.eclipse.xtend2.lib.StringConcatenation#newLine()

The following examples show how to use org.eclipse.xtend2.lib.StringConcatenation#newLine() . 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: XbaseFormatterTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void formatDoWhile3() {
  final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
    final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> {
      it_1.<Boolean>put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true));
    };
    it.preferences(_function_1);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("do");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("println(\"x\")");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("while (true)");
    _builder.newLine();
    it.setToBeFormatted(_builder);
  };
  this._xbaseFormatterTester.assertFormattedExpression(_function);
}
 
Example 2
Source File: InheritedStaticMethodTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected String inMethodBody(final String invocation) {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("import overloading.CopiedAssert");
  _builder.newLine();
  _builder.append("class C extends CopiedAssert {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def void m() {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append(invocation, "\t\t");
  _builder.newLineIfNotEmpty();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  return _builder.toString();
}
 
Example 3
Source File: GrammarPDAProviderTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testUnassignedFragmentRuleCall() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("Rule: Called;");
  _builder.newLine();
  _builder.append("fragment Called returns Abstract: name=ID;");
  _builder.newLine();
  final String actual = this.toPda(_builder);
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("Rule:");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("start -> >>Called");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("<<Called -> stop");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append(">>Called -> name=ID");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("name=ID -> <<Called");
  _builder_1.newLine();
  final String expected = _builder_1.toString();
  Assert.assertEquals(expected, actual);
}
 
Example 4
Source File: OperatorDeclarationTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testAndOperatorDeclaration_static_error_01() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class A {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def static String &&(String s) {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendFile file = this._parseHelper.parse(_builder);
    this._validationTestHelper.assertError(file, 
      XtendPackage.Literals.XTEND_FUNCTION, 
      IssueCodes.INVALID_OPERATOR_SIGNATURE, 
      "The static binary operator \'&&\' requires exactly two arguments.");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 5
Source File: OverriddenValueInspectorTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testFragment_02() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("grammar org.foo with org.eclipse.xtext.common.Terminals");
  _builder.newLine();
  _builder.append("generate metamodel \'foo.sample\'");
  _builder.newLine();
  _builder.append("First : Named;");
  _builder.newLine();
  _builder.append("fragment Named: name=ID+;");
  _builder.newLine();
  String grammarAsString = _builder.toString();
  final Grammar grammar = this.getGrammar(grammarAsString);
  AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "First");
  final ParserRule rule = ((ParserRule) _findRuleForName);
  this.validateRule(rule);
  Assert.assertEquals(this.warnings.toString(), 0, this.warnings.size());
  AbstractRule _findRuleForName_1 = GrammarUtil.findRuleForName(grammar, "Named");
  final ParserRule fragment = ((ParserRule) _findRuleForName_1);
  this.validateRule(fragment);
  Assert.assertEquals(this.warnings.toString(), 1, this.warnings.size());
}
 
Example 6
Source File: Case_8.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Inject
public void explicitName() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("com.acme.SimpleElement as FooBar {}");
  _builder.newLine();
  final EObject element = this.parseAcme(_builder);
  Assert.assertEquals("FooBar", this.qualifiedNameProvider.getFullyQualifiedName(element).toString());
}
 
Example 7
Source File: DelegateCompilerTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testMethodAlreadyDefined() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import org.eclipse.xtend.lib.annotations.Delegate");
    _builder.newLine();
    _builder.append("interface I<T> {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def T foo(T foo)");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class B implements I<String> {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("override String foo(String foo) {\"\"}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class C implements I<String> {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("@Delegate B delegate");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("override String foo(String foo) {\"\"}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    this._validationTestHelper.assertWarning(this.file(_builder.toString()), XtendPackage.Literals.XTEND_FIELD, IssueCodes.UNUSED_PRIVATE_MEMBER, "delegate");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 8
Source File: ClassBuilderTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testXtendClass() {
  AbstractClassBuilder _createClassBuilder = this._codeBuilderFactory.createClassBuilder(this.getXtendClass());
  final Procedure1<AbstractClassBuilder> _function = (AbstractClassBuilder it) -> {
    it.setContext(this.getXtendClass());
    it.setClassName("Bar");
    it.setVisibility(JvmVisibility.PUBLIC);
  };
  AbstractClassBuilder _doubleArrow = ObjectExtensions.<AbstractClassBuilder>operator_doubleArrow(_createClassBuilder, _function);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("class Bar {");
  _builder.newLine();
  _builder.append("}");
  this.assertBuilds(_doubleArrow, _builder.toString());
}
 
Example 9
Source File: XtendRichStringFormatterTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testForLoopInline() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("val x = ```");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("<<FOR String y : newArrayList(\"a\")>>foo<<ENDFOR>>");
  _builder.newLine();
  _builder.append("```");
  _builder.newLine();
  this.assertFormattedRichStringExpression(_builder);
}
 
Example 10
Source File: ImportOrganizerTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testFeatureCallToStaticLocalField() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("class Foo {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("static int foo");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def bar() {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("foo");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("class Foo {");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("static int foo");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("def bar() {");
  _builder_1.newLine();
  _builder_1.append("\t\t");
  _builder_1.append("foo");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("}");
  _builder_1.newLine();
  _builder_1.append("}");
  _builder_1.newLine();
  this.assertIsOrganizedTo(_builder, _builder_1);
}
 
Example 11
Source File: XbaseFormatterTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void formatIfElse1SL() {
  final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("if(true) println(\"foo\") else println(\"bar\")");
    _builder.newLine();
    it.setExpectation(_builder);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("if(true)println(\"foo\")else  println(\"bar\")");
    _builder_1.newLine();
    it.setToBeFormatted(_builder_1);
  };
  this._xbaseFormatterTester.assertFormattedExpression(_function);
}
 
Example 12
Source File: DocumentHighlightTest2.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testHighlightDeclarationWithNestedReference() {
  final Procedure1<DocumentHighlightConfiguration> _function = (DocumentHighlightConfiguration it) -> {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("decl myDecl end myDecl;");
    _builder.newLine();
    it.setModel(_builder.toString());
    it.setLine(0);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("decl myDec");
    it.setColumn(_builder_1.length());
    it.setExpectedDocumentHighlight("W [[0, 5] .. [0, 11]] | R [[0, 16] .. [0, 22]]");
  };
  this.testDocumentHighlight(_function);
}
 
Example 13
Source File: Bug458611Test.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test_02() throws Exception {
  ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("import static extension C.Foo.*");
  _builder.newLine();
  _builder.append("class C {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("static class Bar {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("static class Foo {");
  _builder.newLine();
  _builder.append("\t    ");
  _builder.append("static def sum(Bar[] bars) {");
  _builder.newLine();
  _builder.append("\t    ");
  _builder.append("}");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("    ");
  _builder.append("def doit(Iterable<Bar> myBars) {");
  _builder.newLine();
  _builder.append("        ");
  _builder.append("myBars.sum<|>");
  _builder.newLine();
  _builder.append("    ");
  _builder.append("}");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  _newBuilder.append(_builder.toString()).assertProposalAtCursor("sum");
}
 
Example 14
Source File: ValidationBug433213Test.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void test_02() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def <T> m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Object {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("def T m2() {}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendFile file = this.parser.parse(_builder);
    final XtendTypeDeclaration c = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
    XtendMember _head = IterableExtensions.<XtendMember>head(c.getMembers());
    final XtendFunction m = ((XtendFunction) _head);
    XExpression _expression = m.getExpression();
    final XBlockExpression body = ((XBlockExpression) _expression);
    XExpression _head_1 = IterableExtensions.<XExpression>head(body.getExpressions());
    final AnonymousClass anon = ((AnonymousClass) _head_1);
    XtendMember _head_2 = IterableExtensions.<XtendMember>head(anon.getMembers());
    final XtendFunction m2 = ((XtendFunction) _head_2);
    final JvmTypeReference returnType = m2.getReturnType();
    final JvmType t = returnType.getType();
    Assert.assertNotNull("notNull", t);
    Assert.assertFalse("t.eIsProxy", t.eIsProxy());
    this.helper.assertNoErrors(file);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 15
Source File: AmbiguousGenericFeatureCallTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testUnambiguousMethods_08() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("class C {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def void n(L<String> list) {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("list.addListener [");
  _builder.newLine();
  _builder.append("\t\t\t");
  _builder.append("O o |");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("]");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  _builder.append("interface O {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def void addListener(IL listener)");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  _builder.append("interface L<E> extends O {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def void addListener(LL<? super E> listener)");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  _builder.append("interface LL<E> {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def void onChanged(LC<? extends E> c)");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  _builder.append("interface LC<E> {}");
  _builder.newLine();
  _builder.append("interface IL {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def void invalidated(O o)");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  this.assertUnambiguous(_builder);
}
 
Example 16
Source File: ErrorTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testErrorModel_099() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("package x ");
  _builder.newLine();
  _builder.append("class Y {  ");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("static int j   ");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("int i   ");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("new() { ");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("this(j   ");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("new(int i) {");
  _builder.newLine();
  _builder.append("\t\t\t");
  _builder.append("this.i = i");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("}   ");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("def static invokeMe() {");
  _builder.newLine();
  _builder.append("\t\t\t");
  _builder.append("j = 47 new Y().i");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  this._oven.fireproof(_builder);
}
 
Example 17
Source File: XtendFileGenerator.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public Pair<String, String> getNetNode() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("package xtend.tutorial.util;");
  _builder.newLine();
  _builder.newLine();
  _builder.append("import static java.util.Collections.*;");
  _builder.newLine();
  _builder.newLine();
  _builder.append("class NetNode {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("String name;");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("Iterable<NetNode> references = emptySet();");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def String getName() {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("return name;");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def void setName(String name) {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("this.name = name;");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def Iterable<NetNode> getReferences() {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("return references;");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def void setReferences(Iterable<NetNode> references) {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("this.references = references;");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  return Pair.<String, String>of("xtend/tutorial/util/NetNode.xtend", _builder.toString());
}
 
Example 18
Source File: XtextCallHierarchyBuilderTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testBuildHierarchy_04() {
  final Procedure1<AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration> _function = (AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> {
    Collection<Pair<String, String>> _models = it.getModels();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("grammar org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals hidden(ID)");
    _builder.newLine();
    _builder.newLine();
    _builder.append("generate baseCallHierarchyBuilderTestLanguage \"http://www.eclipse.org/2010/tmf/xtext/BaseCallHierarchyBuilderTestLanguage\"");
    _builder.newLine();
    _builder.newLine();
    _builder.append("Model: name=ID;");
    _builder.newLine();
    String _unix = LineDelimiters.toUnix(_builder.toString());
    Pair<String, String> _mappedTo = Pair.<String, String>of("baseCallHierarchyBuilderTestLanguage.xtext", _unix);
    _models.add(_mappedTo);
    Collection<Pair<String, String>> _models_1 = it.getModels();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("generate callHierarchyBuilderTestLanguage \"http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage\"");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@Override");
    _builder_1.newLine();
    _builder_1.append("Model: name=ID;");
    _builder_1.newLine();
    String _unix_1 = LineDelimiters.toUnix(_builder_1.toString());
    Pair<String, String> _mappedTo_1 = Pair.<String, String>of("callHierarchyBuilderTestLanguage.xtext", _unix_1);
    _models_1.add(_mappedTo_1);
    it.setResourceURI(IterableExtensions.<Pair<String, String>>head(it.getModels()).getKey());
    it.setIndex(IterableExtensions.<Pair<String, String>>head(it.getModels()).getValue().indexOf("ID"));
    StringConcatenation _builder_2 = new StringConcatenation();
    _builder_2.append("ID {");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("grammar: org.eclipse.xtext.common.Terminals");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage {");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("\'ID\' [136, 2]");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("}");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("Model {");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("\'name=ID\' [272, 7]");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("}");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("Model {");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("\'name=ID\' [305, 7]");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("}");
    _builder_2.newLine();
    _builder_2.append("}");
    _builder_2.newLine();
    it.setExpectedHierarchy(_builder_2.toString());
  };
  this.testBuildHierarchy(_function);
}
 
Example 19
Source File: XbaseValidationTest.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testIncompleteCasesOnEnum_2() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("switch org.eclipse.xtext.xbase.tests.validation.Color.RED {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("case RED: {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("1");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("case GREEN: {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("1");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("case BLUE: {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("1");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    this._validationTestHelper.assertNoIssues(this.expression(_builder));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 20
Source File: CompilerBug404051Test.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void test_03() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("class C {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def m(Iterable<String> iterable) {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("iterable.flatMap[].sortBy [ intValue ]");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def <A,B extends Number> Iterable<? extends B> flatMap(Iterable<? extends A> iterable, (A)=>B map) {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("return null");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("import java.util.List;");
  _builder_1.newLine();
  _builder_1.append("import org.eclipse.xtext.xbase.lib.Functions.Function1;");
  _builder_1.newLine();
  _builder_1.append("import org.eclipse.xtext.xbase.lib.IterableExtensions;");
  _builder_1.newLine();
  _builder_1.newLine();
  _builder_1.append("@SuppressWarnings(\"all\")");
  _builder_1.newLine();
  _builder_1.append("public class C {");
  _builder_1.newLine();
  _builder_1.append("  ");
  _builder_1.append("public List<? extends Number> m(final Iterable<String> iterable) {");
  _builder_1.newLine();
  _builder_1.append("    ");
  _builder_1.append("final Function1<String, Number> _function = new Function1<String, Number>() {");
  _builder_1.newLine();
  _builder_1.append("      ");
  _builder_1.append("public Number apply(final String it) {");
  _builder_1.newLine();
  _builder_1.append("        ");
  _builder_1.append("return null;");
  _builder_1.newLine();
  _builder_1.append("      ");
  _builder_1.append("}");
  _builder_1.newLine();
  _builder_1.append("    ");
  _builder_1.append("};");
  _builder_1.newLine();
  _builder_1.append("    ");
  _builder_1.append("final Function1<Number, Integer> _function_1 = new Function1<Number, Integer>() {");
  _builder_1.newLine();
  _builder_1.append("      ");
  _builder_1.append("public Integer apply(final Number it) {");
  _builder_1.newLine();
  _builder_1.append("        ");
  _builder_1.append("return Integer.valueOf(it.intValue());");
  _builder_1.newLine();
  _builder_1.append("      ");
  _builder_1.append("}");
  _builder_1.newLine();
  _builder_1.append("    ");
  _builder_1.append("};");
  _builder_1.newLine();
  _builder_1.append("    ");
  _builder_1.append("return IterableExtensions.sortBy(this.<String, Number>flatMap(iterable, _function), _function_1);");
  _builder_1.newLine();
  _builder_1.append("  ");
  _builder_1.append("}");
  _builder_1.newLine();
  _builder_1.append("  ");
  _builder_1.newLine();
  _builder_1.append("  ");
  _builder_1.append("public <A extends Object, B extends Number> Iterable<? extends B> flatMap(final Iterable<? extends A> iterable, final Function1<? super A, ? extends B> map) {");
  _builder_1.newLine();
  _builder_1.append("    ");
  _builder_1.append("return null;");
  _builder_1.newLine();
  _builder_1.append("  ");
  _builder_1.append("}");
  _builder_1.newLine();
  _builder_1.append("}");
  _builder_1.newLine();
  this.assertCompilesTo(_builder, _builder_1);
}