Java Code Examples for org.eclipse.xtext.xbase.lib.Exceptions#sneakyThrow()

The following examples show how to use org.eclipse.xtext.xbase.lib.Exceptions#sneakyThrow() . 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: WorkingCopyOwnerProviderTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testWorkingCopyOwner_02() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package foo");
    _builder.newLine();
    _builder.append("class MyClass {");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    this.workbenchTestHelper.createFile("foo/MyClass.xtend", _builder.toString());
    IResourcesSetupUtil.waitForBuild();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package foo;");
    _builder_1.newLine();
    _builder_1.append("public class MyClass{");
    _builder_1.newLine();
    _builder_1.append("}");
    Assert.assertEquals(Strings.toUnixLineSeparator(_builder_1).toString(), this.newWorkingCopyOwner().findSource("MyClass", "foo"));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 2
Source File: Java8ValidationTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testConflictingDefaultMethods02() {
  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("interface B {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void foo() { }");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("interface C extends A, B { }");
    _builder.newLine();
    this._validationTestHelper.assertError(this.file(_builder.toString()), XtendPackage.Literals.XTEND_INTERFACE, IssueCodes.CONFLICTING_DEFAULT_METHODS, 
      "The type C inherits multiple implementations of the method foo() from A and B.");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 3
Source File: ResolvedOperationTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testListToArrayHasTwoOrThreeCandidates() {
  final IResolvedOperation operation = this.toOperation("(null as java.util.List<String>).toArray(null)");
  final List<JvmOperation> candidates = operation.getOverriddenAndImplementedMethodCandidates();
  final Function1<JvmOperation, String> _function = (JvmOperation it) -> {
    return it.getIdentifier();
  };
  final String message = IterableExtensions.join(ListExtensions.<JvmOperation, String>map(candidates, _function), ", ");
  try {
    Assert.assertEquals(message, 2, candidates.size());
  } catch (final Throwable _t) {
    if (_t instanceof AssertionError) {
      Assert.assertEquals(message, 3, candidates.size());
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  }
}
 
Example 4
Source File: XtendUIValidationTests.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testDiscouragedConstructorCallInnernClass() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import org.eclipse.xtend.core.tests.internal.InternalClass$InnerInternalClass");
    _builder.newLine();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("InnerInternalClass x = new InnerInternalClass");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendFile xtendFile = this.testHelper.xtendFile("Clazz.xtend", _builder.toString());
    this.helper.assertWarning(xtendFile.getImportSection().getImportDeclarations().get(0), XtypePackage.Literals.XIMPORT_DECLARATION, org.eclipse.xtext.xbase.validation.IssueCodes.DISCOURAGED_REFERENCE);
    XtendMember _head = IterableExtensions.<XtendMember>head(IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class)).getMembers());
    final XtendField field = ((XtendField) _head);
    this.helper.assertWarning(field.getType(), TypesPackage.Literals.JVM_TYPE_REFERENCE, org.eclipse.xtext.xbase.validation.IssueCodes.DISCOURAGED_REFERENCE);
    this.helper.assertWarning(field.getInitialValue(), XbasePackage.Literals.XCONSTRUCTOR_CALL, org.eclipse.xtext.xbase.validation.IssueCodes.DISCOURAGED_REFERENCE);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 5
Source File: ValidationBug437678Test.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void test_12() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def static void m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("m2");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def static void m2(Object o) {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendFile file = this.parser.parse(_builder);
    this.helper.assertError(file, XbasePackage.Literals.XFEATURE_CALL, IssueCodes.STATIC_ACCESS_TO_INSTANCE_MEMBER, "Cannot make an implicit reference to this from a static context");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 6
Source File: AbstractLanguageServerTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
protected void testFormatting(final Procedure1<? super DocumentFormattingParams> paramsConfigurator, final Procedure1<? super FormattingConfiguration> configurator) {
  try {
    @Extension
    final FormattingConfiguration configuration = new FormattingConfiguration();
    configuration.setFilePath(("MyModel." + this.fileExtension));
    configurator.apply(configuration);
    final FileInfo fileInfo = this.initializeContext(configuration);
    DocumentFormattingParams _documentFormattingParams = new DocumentFormattingParams();
    final Procedure1<DocumentFormattingParams> _function = (DocumentFormattingParams it) -> {
      String _uri = fileInfo.getUri();
      TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(_uri);
      it.setTextDocument(_textDocumentIdentifier);
      if ((paramsConfigurator != null)) {
        paramsConfigurator.apply(it);
      }
    };
    DocumentFormattingParams _doubleArrow = ObjectExtensions.<DocumentFormattingParams>operator_doubleArrow(_documentFormattingParams, _function);
    final CompletableFuture<List<? extends TextEdit>> changes = this.languageServer.formatting(_doubleArrow);
    String _contents = fileInfo.getContents();
    final Document result = new Document(Integer.valueOf(1), _contents).applyChanges(ListExtensions.<TextEdit>reverse(CollectionLiterals.<TextEdit>newArrayList(((TextEdit[])Conversions.unwrapArray(changes.get(), TextEdit.class)))));
    this.assertEqualsStricter(configuration.getExpectedText(), result.getContents());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 7
Source File: UIResourceChangeRegistryTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testFolderChildren() {
  try {
    final IProject project = WorkbenchTestHelper.createPluginProject("foo");
    final String folderPath = "/foo/bar";
    this.resourceChangeRegistry.registerGetChildren(folderPath, this.uri);
    Assert.assertTrue(this.resourceChangeRegistry.getChildrenListeners().containsKey(folderPath));
    final IFolder folder = project.getFolder("bar");
    final WorkspaceModifyOperation _function = new WorkspaceModifyOperation() {
      @Override
      protected void execute(final IProgressMonitor it) throws CoreException, InvocationTargetException, InterruptedException {
        folder.create(true, true, null);
      }
    };
    this.modifyWorkspace(_function);
    Assert.assertFalse(this.resourceChangeRegistry.getChildrenListeners().containsKey(folderPath));
    Assert.assertEquals(1, this.resourceChangeRegistry.queuedURIs.size());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 8
Source File: FinalFieldsConstructorCompilerTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testIntegrationWithAccessors() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor");
    _builder.newLine();
    _builder.append("import org.eclipse.xtend.lib.annotations.Accessors");
    _builder.newLine();
    _builder.append("@FinalFieldsConstructor @Accessors class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val int a");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val String b");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String source = _builder.toString();
    this._validationTestHelper.assertNoErrors(this.clazz(source));
    final IAcceptor<CompilationTestHelper.Result> _function = (CompilationTestHelper.Result it) -> {
      final Function1<Constructor<?>, Boolean> _function_1 = (Constructor<?> it_1) -> {
        List<Class<?>> _list = IterableExtensions.<Class<?>>toList(((Iterable<Class<?>>)Conversions.doWrapArray(it_1.getParameterTypes())));
        return Boolean.valueOf(Objects.equal(_list, Collections.<Class<? extends Object>>unmodifiableList(CollectionLiterals.<Class<? extends Object>>newArrayList(int.class, String.class))));
      };
      Assert.assertTrue(
        IterableExtensions.<Constructor<?>>exists(((Iterable<Constructor<?>>)Conversions.doWrapArray(it.getCompiledClass().getDeclaredConstructors())), _function_1));
    };
    this.compilationTestHelper.compile(source, _function);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 9
Source File: XImportSectionValidationTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void checkDuplicateImportWithStaticAccess_10() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import static java.lang.String.*");
    _builder.newLine();
    _builder.append("import static extension java.lang.String.*");
    _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();
    final XtendFile file = this.file(_builder.toString());
    this._validationTestHelper.assertWarning(file, XtypePackage.Literals.XIMPORT_DECLARATION, IssueCodes.IMPORT_UNUSED, "java.lang.String");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 10
Source File: JavaIoFileSystemTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testSetWorkspaceContentsAsStream() {
  try {
    byte[] _bytes = "Hello World!".getBytes();
    ByteArrayInputStream _byteArrayInputStream = new ByteArrayInputStream(_bytes);
    this.fs.setContentsAsStream(Path.ROOT, _byteArrayInputStream);
    Assert.fail();
  } catch (final Throwable _t) {
    if (_t instanceof IllegalArgumentException) {
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  }
}
 
Example 11
Source File: DispatchRenameSupportTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testSuperClass() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Super {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def dispatch foo(Double x) {}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def dispatch foo(Object x) {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final IFile superFile = this.testHelper.createFile("Super", _builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("class Sub extends Super {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("def dispatch foo(String x) {}");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("def dispatch foo(Integer x) {}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.testHelper.createFile("Sub", _builder_1.toString());
    this.checkDispatchOperations(superFile, 
      "Super.foo(Object)", "Super._foo(Double)", "Super._foo(Object)", 
      "Sub._foo(String)", "Sub._foo(Integer)", "Sub.foo(Object)");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 12
Source File: ValidationBug464563Test.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testJvmConstructor_09() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package mypackage");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("new(void arg0) {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void bar() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Foo(notify)");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendFile file = this._parseHelper.parse(_builder);
    this._validationTestHelper.assertError(file, 
      XbasePackage.Literals.XCONSTRUCTOR_CALL, 
      IssueCodes.REFER_INVALID_TYPES, 
      "The constructor Foo(void) has an illegal argument type");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 13
Source File: UniqueClassNameValidatorUITest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testXtendAndJavaDifferentProject() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package acme;");
    _builder.newLine();
    _builder.append("public class A {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    IResourcesSetupUtil.createFile("first.p384008/src/acme/A.java", _builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package acme");
    _builder_1.newLine();
    _builder_1.append("class A {");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    final IFile secondFile = IResourcesSetupUtil.createFile("second.p384008/src/acme/B.xtend", _builder_1.toString());
    final IWorkspaceRunnable _function = (IProgressMonitor it) -> {
      this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, XtextBuilder.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
      this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, JavaCore.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
    };
    this.runInWorkspace(_function);
    final IMarker[] secondFileMarkers = secondFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
    Assert.assertEquals(IResourcesSetupUtil.printMarker(secondFileMarkers), 0, secondFileMarkers.length);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 14
Source File: CompoundAssignmentOperatorValidationTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test_6() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import static extension compound.IntCompoundExtensions.*");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("var i = 1");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("new() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("i *= 2");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    this._validationTestHelper.assertNoErrors(this._parseHelper.parse(_builder));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 15
Source File: PostfixOperatorValidationTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test_2() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val i = 2");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("i++");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    this._validationTestHelper.assertError(this._parseHelper.parse(_builder), XbasePackage.Literals.XABSTRACT_FEATURE_CALL, IssueCodes.ASSIGNMENT_TO_FINAL);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 16
Source File: ValidationBug427432Test.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void finalInstanceField() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val x = 1");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("switch y : 1 {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("case x: 1");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("case x: 1");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    this._validationTestHelper.assertError(this._parseHelper.parse(_builder), XbasePackage.Literals.XFEATURE_CALL, IssueCodes.DUPLICATE_CASE);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 17
Source File: AbstractSingleEditorQueuedBuildTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void removePrimaryTopLevelTypeWithinDefaultPackage() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("public class Bar {}");
    _builder.newLine();
    this.testHelper.createFile("Bar.java", _builder.toString());
    final Procedure0 _function = () -> {
      this.save("Bar.java", "public class Bar {}", "");
    };
    this.assertThereAreDeltas(_function, "Bar");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 18
Source File: XbaseValidationTest.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testUnreachableInstanceOf_8() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val x = new Object");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val y = new Object");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("if (x instanceof java.io.IOException) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("1");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("} else if (y instanceof java.io.IOException) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("2");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("} else if (x instanceof java.io.FileNotFoundException) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("3");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("} else if (y instanceof java.io.FileNotFoundException) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("4");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    this._validationTestHelper.assertError(this.expression(_builder), TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE, IssueCodes.UNREACHABLE_IF_BLOCK);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 19
Source File: CompilerTests2.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testBug466974_01() {
  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);
  }
}
 
Example 20
Source File: CompilerTests2.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testLibIssue60() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val a = <String>newArrayOfSize(1)");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("a.set(0, \"\").length");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("a.set(0,\"hello\")");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("1");
    _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("final String[] a = new String[1];");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("(a[0] = \"\").length();");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("a[0] = \"hello\";");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("_xblockexpression = 1;");
    _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);
  }
}