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

The following examples show how to use org.eclipse.xtend2.lib.StringConcatenation#append() . 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: OverriddenValueInspectorTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testBug306281_03() 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("Model : name=ID (({Binary.left=current} operator = \'-\' | {Binary.left=current} operator = \'+\') right=ID)+ name=ID;");
  _builder.newLine();
  String grammarAsString = _builder.toString();
  final Grammar grammar = this.getGrammar(grammarAsString);
  AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "Model");
  final ParserRule rule = ((ParserRule) _findRuleForName);
  this.validateRule(rule);
  Assert.assertTrue(this.warnings.toString(), this.warnings.isEmpty());
}
 
Example 2
Source File: OldDataCompilerTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testClassAndSuperClassWithTypeParameters() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("@Data class Foo<T> {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("T foo");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("@Data class Bar<X> extends Foo<X> {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final IAcceptor<CompilationTestHelper.Result> _function = (CompilationTestHelper.Result it) -> {
      Assert.assertTrue(it.getGeneratedCode("Bar").contains("public Bar(final X foo) {"));
    };
    this.compilationTestHelper.compile(_builder, _function);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 3
Source File: InsertionOffsetTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testConstructor_2() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("class Foo {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("int x");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("double y$");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def foo() {|");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  this.checkConstructorInsertionOffset(_builder);
}
 
Example 4
Source File: XbaseValidationTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testDuplicateCases_typeLiteral_6() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("switch x : String {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("case Integer: 1");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("case String: 1");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    this._validationTestHelper.assertNoErrors(this.expression(_builder));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 5
Source File: AbstractSingleEditorQueuedBuildTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void removePrimaryTopLevelType() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package mypackage;");
    _builder.newLine();
    _builder.newLine();
    _builder.append("public class Bar {}");
    _builder.newLine();
    this.testHelper.createFile("/mypackage/Bar.java", _builder.toString());
    final Procedure0 _function = () -> {
      this.save("/mypackage/Bar.java", "public class Bar {}", "");
    };
    this.assertThereAreDeltas(_function, "mypackage.Bar");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 6
Source File: DomainmodelParsingTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testParsingAndLinkingWithImports() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.List");
    _builder.newLine();
    _builder.append("package example {");
    _builder.newLine();
    _builder.append("  ");
    _builder.append("entity MyEntity {");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("p : List<String>");
    _builder.newLine();
    _builder.append("  ");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    this._validationTestHelper.assertNoErrors(this._parseHelper.parse(_builder));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 7
Source File: RuleEngineHoverTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void hover_over_device_state() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("Device Window can be open, closed");
  _builder.newLine();
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("State open");
  this.hasHoverOver(_builder, "open", _builder_1.toString());
}
 
Example 8
Source File: Java8ValidationTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testAbstractMethodCall() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("interface A {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void foo()");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class E implements A {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("override void foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("A.super.foo");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    this._validationTestHelper.assertError(this.file(_builder.toString()), XbasePackage.Literals.XMEMBER_FEATURE_CALL, org.eclipse.xtext.xbase.validation.IssueCodes.ABSTRACT_METHOD_INVOCATION, 
      "Cannot directly invoke the abstract method foo() of the type A");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 9
Source File: PartialSerializerTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testOptionalChildRemove() {
  final IChangeSerializer.IModification<OptionalChild> _function = (OptionalChild it) -> {
    it.setChild(null);
  };
  ITextRegionAccess _recordDiff = this.<OptionalChild>recordDiff(OptionalChild.class, "#5 foo", _function);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("0 0   H");
  _builder.newLine();
  _builder.append("      ");
  _builder.append("B OptionalChild        Model");
  _builder.newLine();
  _builder.append("0 2    S \"#5\"                 Model:\'#5\'");
  _builder.newLine();
  _builder.append("      ");
  _builder.append("E OptionalChild        Model");
  _builder.newLine();
  _builder.append("2 1 1 H \" \"                  Whitespace:TerminalRule\'WS\'");
  _builder.newLine();
  _builder.append("------------ diff 1 ------------");
  _builder.newLine();
  _builder.append("2 1  H \" \"                  Whitespace:TerminalRule\'WS\'");
  _builder.newLine();
  _builder.append("3 3  S \"foo\"                MandatoryValue:name=ID");
  _builder.newLine();
  _builder.append("6 0  H");
  _builder.newLine();
  this._changeSerializerTestHelper.operator_tripleEquals(_recordDiff, _builder);
}
 
Example 10
Source File: Bug435043Test.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test_27() throws Exception {
  ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("class C {");
  _builder.newLine();
  _builder.append("  ");
  _builder.append("static class D {");
  _builder.newLine();
  _builder.append("\t  ");
  _builder.append("val foo = \"\"");
  _builder.newLine();
  _builder.append("\t  ");
  _builder.append("<|>");
  _builder.newLine();
  _builder.append("\t  ");
  _builder.append("override toString() {");
  _builder.newLine();
  _builder.append("\t    ");
  _builder.append("\"\"");
  _builder.newLine();
  _builder.append("\t  ");
  _builder.append("}");
  _builder.newLine();
  _builder.append("\t  ");
  _builder.newLine();
  _builder.append("\t  ");
  _builder.append("val bar = \"\"");
  _builder.newLine();
  _builder.append("\t  ");
  _builder.newLine();
  _builder.append("  ");
  _builder.append("}");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  _newBuilder.append(_builder.toString()).assertProposalDisplayedAtCursor("equals(Object) - Override method from Object");
}
 
Example 11
Source File: XbaseFormatterTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void formatFeatureCallMultiline() {
  final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("val ML2 = newArrayList(");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("newArrayList(1, 2, 3, 4),");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("newArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109,");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120),");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("newArrayList(9),");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("newArrayList(10)");
    _builder.newLine();
    _builder.append(")");
    _builder.newLine();
    it.setExpectation(_builder);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("val ML2 = newArrayList(newArrayList(1, 2, 3, 4), newArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120), newArrayList(9), newArrayList(10)");
    _builder_1.newLine();
    _builder_1.append(")");
    _builder_1.newLine();
    it.setToBeFormatted(_builder_1);
  };
  this._xbaseFormatterTester.assertFormattedExpression(_function);
}
 
Example 12
Source File: XbaseFormatterTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void formatMemberFeatureCallBuilder2() {
  final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("newArrayList(\"x\").map()[lenght]");
    _builder.newLine();
    it.setExpectation(_builder);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("newArrayList(\"x\")  .  map  (  )  [  lenght  ]");
    _builder_1.newLine();
    it.setToBeFormatted(_builder_1);
  };
  this._xbaseFormatterTester.assertFormattedExpression(_function);
}
 
Example 13
Source File: AnonymousClassTypeTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testOverriddenMethodTypeArgumentInference_2() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("def <T> foo() {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("new Iterable<T>() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("override iterator() {}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendFunction function = this.function(_builder.toString());
    final JvmOperation operation = this._iXtendJvmAssociations.getDirectlyInferredOperation(function);
    final IResolvedTypes resolvedTypes = this._iBatchTypeResolver.resolveTypes(operation.eResource());
    Assert.assertEquals("Iterable<T>", resolvedTypes.getActualType(operation).toString());
    XExpression _expression = function.getExpression();
    XExpression _head = IterableExtensions.<XExpression>head(((XBlockExpression) _expression).getExpressions());
    final AnonymousClass anonymousClass = ((AnonymousClass) _head);
    XtendMember _last = IterableExtensions.<XtendMember>last(anonymousClass.getMembers());
    final JvmOperation overriding = this._iXtendJvmAssociations.getDirectlyInferredOperation(((XtendFunction) _last));
    Assert.assertEquals("Iterator<T>", resolvedTypes.getActualType(overriding).toString());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 14
Source File: ExtractVariableIntegrationTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testValInBlock() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("class Foo {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def bar() {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("22 + $33$");
  _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("def bar() {");
  _builder_1.newLine();
  _builder_1.append("\t\t");
  _builder_1.append("val i = 33");
  _builder_1.newLine();
  _builder_1.append("\t\t");
  _builder_1.append("22 + i");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("}");
  _builder_1.newLine();
  _builder_1.append("}");
  _builder_1.newLine();
  this.assertAfterExtract(_builder, _builder_1, true);
}
 
Example 15
Source File: ValidationBug452602Test.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void test_01() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Test {");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("val String attrName");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("new(String s) {");
    _builder.newLine();
    _builder.append("    \t");
    _builder.append("attrName = s");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("}");
    _builder.newLine();
    _builder.append("    ");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("def boolean test(Object o) {");
    _builder.newLine();
    _builder.append("        ");
    _builder.append("val x = o as Test");
    _builder.newLine();
    _builder.append("        ");
    _builder.append("if (attrName != x.attrName) ");
    _builder.newLine();
    _builder.append("        \t");
    _builder.append("return false ");
    _builder.newLine();
    _builder.append("        ");
    _builder.append("return true");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendFile c = this.parser.parse(_builder);
    this.helper.assertNoIssues(c);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 16
Source File: OrganizeImportsTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testMemberImport_02() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("import static java.lang.Integer.*");
  _builder.newLine();
  _builder.append("import static java.lang.Integer.valueOf");
  _builder.newLine();
  _builder.newLine();
  _builder.append("class Foo {");
  _builder.newLine();
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def foo() {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("valueOf(1)");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("import static java.lang.Integer.valueOf");
  _builder_1.newLine();
  _builder_1.newLine();
  _builder_1.append("class Foo {");
  _builder_1.newLine();
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("def foo() {");
  _builder_1.newLine();
  _builder_1.append("\t\t");
  _builder_1.append("valueOf(1)");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("}");
  _builder_1.newLine();
  _builder_1.newLine();
  _builder_1.append("}");
  _builder_1.newLine();
  this.assertIsOrganizedTo(_builder, "repro/Foo", _builder_1);
}
 
Example 17
Source File: ExtractMethodIntegrationTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testTemplateExpression_19() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("class Foo {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def foo(boolean a) \'");
  _builder.append("\'\'");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("$");
  _builder.append("�", "\t\t");
  _builder.append("IF a");
  _builder.append("�", "\t\t");
  _builder.newLineIfNotEmpty();
  _builder.append("\t\t\t");
  _builder.append("�", "\t\t\t");
  _builder.append("1");
  _builder.append("�", "\t\t\t");
  _builder.newLineIfNotEmpty();
  _builder.append("\t\t");
  _builder.append("�", "\t\t");
  _builder.append("ELSE");
  _builder.append("�", "\t\t");
  _builder.newLineIfNotEmpty();
  _builder.append("\t\t\t");
  _builder.append("�", "\t\t\t");
  _builder.append("2");
  _builder.append("�", "\t\t\t");
  _builder.newLineIfNotEmpty();
  _builder.append("\t\t");
  _builder.append("�", "\t\t");
  _builder.append("ENDIF");
  _builder.append("�", "\t\t");
  _builder.append("$");
  _builder.newLineIfNotEmpty();
  _builder.append("\t");
  _builder.append("\'");
  _builder.append("\'\'");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  final Procedure1<ExtractMethodRefactoring> _function = (ExtractMethodRefactoring it) -> {
  };
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("class Foo {");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("def foo(boolean a) \'");
  _builder_1.append("\'\'");
  _builder_1.newLine();
  _builder_1.append("\t\t");
  _builder_1.append("�", "\t\t");
  _builder_1.append("bar(a)");
  _builder_1.append("�", "\t\t");
  _builder_1.newLineIfNotEmpty();
  _builder_1.append("\t");
  _builder_1.append("\'");
  _builder_1.append("\'\'");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("def bar(boolean a)");
  _builder_1.newLine();
  _builder_1.append("\t\t");
  _builder_1.append("\'");
  _builder_1.append("\'\'");
  _builder_1.append("�", "\t\t");
  _builder_1.append("IF a");
  _builder_1.append("�", "\t\t");
  _builder_1.newLineIfNotEmpty();
  _builder_1.append("\t\t\t");
  _builder_1.append("�", "\t\t\t");
  _builder_1.append("1");
  _builder_1.append("�", "\t\t\t");
  _builder_1.newLineIfNotEmpty();
  _builder_1.append("\t\t");
  _builder_1.append("�", "\t\t");
  _builder_1.append("ELSE");
  _builder_1.append("�", "\t\t");
  _builder_1.newLineIfNotEmpty();
  _builder_1.append("\t\t\t");
  _builder_1.append("�", "\t\t\t");
  _builder_1.append("2");
  _builder_1.append("�", "\t\t\t");
  _builder_1.newLineIfNotEmpty();
  _builder_1.append("\t\t");
  _builder_1.append("�", "\t\t");
  _builder_1.append("ENDIF");
  _builder_1.append("�", "\t\t");
  _builder_1.append("\'");
  _builder_1.append("\'\'");
  _builder_1.newLineIfNotEmpty();
  _builder_1.append("\t");
  _builder_1.newLine();
  _builder_1.append("}");
  _builder_1.newLine();
  this.assertAfterExtract(_builder, _function, _builder_1);
}
 
Example 18
Source File: CompilerTests2.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testBug434224_02() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("switch bar : new Object {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("Byte: bar as char");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("char _switchResult = (char) 0;");
    _builder_1.newLine();
    _builder_1.append("Object _object = new Object();");
    _builder_1.newLine();
    _builder_1.append("final Object bar = _object;");
    _builder_1.newLine();
    _builder_1.append("boolean _matched = false;");
    _builder_1.newLine();
    _builder_1.append("if (bar instanceof Byte) {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("_matched=true;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("_switchResult = ((char) ((Byte) bar).byteValue());");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("return _switchResult;");
    _builder_1.newLine();
    this.compilesTo(_builder, _builder_1);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 19
Source File: JavaASTFlattener.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public boolean visit(final ArrayCreation node) {
  ArrayType at = node.getType();
  int dims = at.getDimensions();
  if ((dims > 1)) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("/* FIXME Only one dimensional arrays are supported. ");
    _builder.append(node);
    _builder.append("*/");
    this.appendToBuffer(_builder.toString());
    this.addProblem(node, "Only one dimension arrays are supported.");
    return false;
  }
  ArrayInitializer _initializer = node.getInitializer();
  boolean _tripleNotEquals = (_initializer != null);
  if (_tripleNotEquals) {
    if (this.fallBackStrategy) {
      this.appendToBuffer("(");
    }
    node.getInitializer().accept(this);
    if (this.fallBackStrategy) {
      this.appendToBuffer(" as ");
      at.accept(this);
      this.appendToBuffer(")");
    }
  } else {
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("new");
    String _xifexpression = null;
    boolean _isPrimitiveType = node.getType().getElementType().isPrimitiveType();
    if (_isPrimitiveType) {
      Type _elementType = node.getType().getElementType();
      _xifexpression = StringExtensions.toFirstUpper(((PrimitiveType) _elementType).getPrimitiveTypeCode().toString());
    }
    _builder_1.append(_xifexpression);
    _builder_1.append("ArrayOfSize(");
    this.appendToBuffer(_builder_1.toString());
    List _dimensions = node.dimensions();
    (((Expression[])Conversions.unwrapArray(((Iterable<Expression>) _dimensions), Expression.class))[0]).accept(this);
    this.appendToBuffer(")");
  }
  return false;
}
 
Example 20
Source File: CompilerTests2.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testBug466974_03() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("var i = 0");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("Math.max({ i = i + 1 }, if (i == 1) { 1 } else { 2 })");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("int _xblockexpression = (int) 0;");
    _builder_1.newLine();
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("int i = 0;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("int _i = i = (i + 1);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("int _xifexpression = (int) 0;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("if ((i == 1)) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("_xifexpression = 1;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("} else {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("_xifexpression = 2;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("_xblockexpression = Math.max(_i, _xifexpression);");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("return _xblockexpression;");
    _builder_1.newLine();
    this.compilesTo(_builder, _builder_1);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}