Java Code Examples for org.eclipse.xtend2.lib.StringConcatenation

The following examples show how to use org.eclipse.xtend2.lib.StringConcatenation. These examples are extracted from open source projects. 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 Project: xtext-xtend   Source File: ErrorTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testErrorModel_061() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("class C<T> implements C1<T> {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def void m(C1<?> p) {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("m(this)");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  _builder.append("interface C1<A1> extends C2<A1> {}");
  _builder.newLine();
  _builder.append("interface C2<A2> extends C3<A2, C2<A2>> {}");
  _builder.newLine();
  _builder.append("interface C3<A3, B3> extends C4<A3, C1<A3>> {}");
  _builder.newLine();
  _builder.append("interface C4<A4, B4> {}");
  _builder.newLine();
  this.processWithoutException(_builder);
}
 
Example 2
@Test
public void testUnambiguousMethods_15() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("class C {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def void n() {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("m(#[ null ])");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def void m(String... s) {}");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def void m(boolean... s) {}");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  this.assertUnambiguous(_builder);
}
 
Example 3
@Test
public void formatMethod02() {
  final Procedure1<MapBasedPreferenceValues> _function = (MapBasedPreferenceValues it) -> {
    it.<Boolean>put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true));
  };
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("package foo");
  _builder.newLine();
  _builder.newLine();
  _builder.append("class bar");
  _builder.newLine();
  _builder.append("{");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def baz()");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("{");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  this.assertFormatted(_function, _builder);
}
 
Example 4
@Test
public void testEnumLiteral_WithStaticImport() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import static test.Enum1.* ");
    _builder.newLine();
    _builder.append("class C { ");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("Enum1 testFoo = RED");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendFile file = this.file(_builder.toString());
    final XtendField field = IterableExtensions.<XtendField>head(Iterables.<XtendField>filter(IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes()).getMembers(), XtendField.class));
    Object _evaluate = this.interpreter.evaluate(field.getInitialValue(), field.getType());
    final JvmEnumerationLiteral blue = ((JvmEnumerationLiteral) _evaluate);
    Assert.assertEquals("RED", blue.getSimpleName());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 5
@Test
public void formatIfElseCondExpML() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("c = (a < b)");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("? 3");
  _builder.newLine();
  _builder.append("\t");
  _builder.append(": 4");
  _builder.newLine();
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("c=(a<b)?");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("3:");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("4");
  _builder_1.newLine();
  this.assertFormattedExpression(_builder.toString(), _builder_1);
}
 
Example 6
Source Project: xtext-core   Source File: XtextLinkerTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testQualifiedRuleCall_02() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("grammar test with org.eclipse.xtext.common.Terminals");
  _builder.newLine();
  _builder.append("generate test \'http://test\'");
  _builder.newLine();
  _builder.append("Rule: name=ID;");
  _builder.newLine();
  _builder.append("terminal STRING: super;");
  _builder.newLine();
  final String grammarAsString = _builder.toString();
  final XtextResource resource = this.getResourceFromString(grammarAsString);
  EObject _get = resource.getContents().get(0);
  Grammar grammar = ((Grammar) _get);
  AbstractRule _get_1 = grammar.getRules().get(1);
  final TerminalRule string = ((TerminalRule) _get_1);
  AbstractElement _alternatives = string.getAlternatives();
  final RuleCall callToSuper = ((RuleCall) _alternatives);
  Assert.assertEquals(GrammarUtil.findRuleForName(IterableExtensions.<Grammar>head(grammar.getUsedGrammars()), "STRING"), callToSuper.getRule());
}
 
Example 7
@Test
public void test_14() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def static void m(Object it) {");
    _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.assertNoIssues(file);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 8
Source Project: xtext-extras   Source File: XbaseValidationTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testSynchronizedExpression_5() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val ()=>int x = [|1]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("synchronized (x.apply) {");
    _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 9
Source Project: xtext-xtend   Source File: Bug436564Test.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void test_12() throws Exception {
  ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("class C {");
  _builder.newLine();
  _builder.append("  ");
  _builder.append("val o = new Object() {");
  _builder.newLine();
  _builder.append("  \t");
  _builder.append("override toString() {}");
  _builder.newLine();
  _builder.append("  ");
  _builder.append("}");
  _builder.newLine();
  _builder.append("  ");
  _builder.append("toS<|>");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  _newBuilder.append(_builder.toString()).assertProposalDisplayedAtCursor("toString() - Override method from Object");
}
 
Example 10
@Test
public void testBug306281_06() 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 = [Model] | {Binary.left=current} operator = [Model]) right=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 11
@Test
public void testForbiddenImport() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import org.eclipse.xtend.core.tests.restricted.RestrictedClass");
    _builder.newLine();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendFile xtendFile = this.testHelper.xtendFile("Clazz.xtend", _builder.toString());
    this.helper.assertError(xtendFile.getImportSection().getImportDeclarations().get(0), XtypePackage.Literals.XIMPORT_DECLARATION, org.eclipse.xtext.xbase.validation.IssueCodes.FORBIDDEN_REFERENCE);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 12
private StringConcatenation asText(final TreeNode treeNode) {
  StringConcatenation _builder = new StringConcatenation();
  String _name = treeNode.getName();
  _builder.append(_name);
  _builder.newLineIfNotEmpty();
  {
    EList<TreeNode> _children = treeNode.getChildren();
    for(final TreeNode node : _children) {
      _builder.append("\t");
      StringConcatenation _asText = this.asText(node);
      _builder.append(_asText, "\t");
      _builder.newLineIfNotEmpty();
    }
  }
  return _builder;
}
 
Example 13
@Test
public void testBug470235() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("class C {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("Object o = new () { // missing type is intentional");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("List list = null");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("} ");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  this.hasUnresolvedTypesWithErrors(_builder, "List");
}
 
Example 14
Source Project: xtext-xtend   Source File: JvmModelTests.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testJvmTypeParameter_04() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("new <T>() {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(this.file(_builder.toString(), false, false).getXtendTypes());
    final JvmGenericType clazz = this._iXtendJvmAssociations.getInferredType(((XtendClass) _head));
    final JvmConstructor member = IterableExtensions.<JvmConstructor>head(Iterables.<JvmConstructor>filter(clazz.getMembers(), JvmConstructor.class));
    EList<JvmTypeParameter> _typeParameters = member.getTypeParameters();
    String _plus = ("" + _typeParameters);
    Assert.assertEquals(_plus, 1, member.getTypeParameters().size());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 15
Source Project: xtext-extras   Source File: CompilerTests2.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testObjectEqualNull() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("\"Foo\" == null");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("boolean _equals = com.google.common.base.Objects.equal(\"Foo\", null);");
    _builder_1.newLine();
    _builder_1.append("return _equals;");
    _builder_1.newLine();
    this.compilesTo(_builder, _builder_1);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 16
protected void assertRequireBundles(final String[] expectedBundleIds) {
  try {
    IProject _project = this.workbenchHelper.getProject();
    Path _path = new Path("META-INF/MANIFEST.MF");
    InputStream _contents = _project.getFile(_path).getContents();
    final MergeableManifest2 manifest = new MergeableManifest2(_contents);
    final String requireBunbles = manifest.getMainAttributes().get(MergeableManifest2.REQUIRE_BUNDLE);
    for (final String bundleId : expectedBundleIds) {
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("require bundle entry ");
      _builder.append(bundleId);
      _builder.append(" is present");
      Assert.assertTrue(_builder.toString(), requireBunbles.contains(bundleId));
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 17
Source Project: xtext-core   Source File: ValidatorTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testDiagnosticAtEndOfLineIncludingNewline() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("type");
  _builder.newLine();
  this.writeFile("MyType1.testlang", Strings.toUnixLineSeparator(_builder));
  this.initialize();
  final List<Diagnostic> problems = IterableExtensions.<Map.Entry<String, List<Diagnostic>>>head(this.getDiagnostics().entrySet()).getValue();
  String _join = IterableExtensions.join(problems, "\n");
  String _plus = ("problems found:\n" + _join);
  Assert.assertEquals(_plus, 1, problems.size());
  final Diagnostic problem = IterableExtensions.<Diagnostic>head(problems);
  this.assertEquals("mismatched input \'<EOF>\' expecting RULE_ID", problem.getMessage());
  Assert.assertEquals(org.eclipse.xtext.diagnostics.Diagnostic.SYNTAX_DIAGNOSTIC, problem.getCode().get());
  final Range range = problem.getRange();
  Assert.assertEquals(0, range.getStart().getLine());
  Assert.assertEquals(4, range.getStart().getCharacter());
  Assert.assertEquals(1, range.getEnd().getLine());
  Assert.assertEquals(0, range.getEnd().getCharacter());
}
 
Example 18
Source Project: xtext-xtend   Source File: MethodBuilderTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testXtendSynchronized() {
  AbstractMethodBuilder _createMethodBuilder = this._codeBuilderFactory.createMethodBuilder(this.getXtendClass());
  final Procedure1<AbstractMethodBuilder> _function = (AbstractMethodBuilder it) -> {
    it.setContext(this.getXtendClass());
    it.setMethodName("foo");
    it.setReturnType(this.createTypeRef(this.getXtendClass()));
    it.setVisibility(JvmVisibility.PUBLIC);
    it.setSynchronizedFlag(true);
  };
  AbstractMethodBuilder _doubleArrow = ObjectExtensions.<AbstractMethodBuilder>operator_doubleArrow(_createMethodBuilder, _function);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("def synchronized foo() {");
  _builder.newLine();
  _builder.append("  ");
  _builder.append(AbstractBuilderTest.DEFAULT_BODY, "  ");
  _builder.newLineIfNotEmpty();
  _builder.append("}");
  this.assertBuilds(_doubleArrow, _builder.toString());
}
 
Example 19
Source Project: xtext-xtend   Source File: ImportOrganizerTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testSimple() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("package foo");
  _builder.newLine();
  _builder.newLine();
  _builder.append("class Foo implements java.io.Serializable {}");
  _builder.newLine();
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("package foo");
  _builder_1.newLine();
  _builder_1.newLine();
  _builder_1.append("import java.io.Serializable");
  _builder_1.newLine();
  _builder_1.newLine();
  _builder_1.append("class Foo implements Serializable {}");
  _builder_1.newLine();
  this.assertIsOrganizedTo(_builder, _builder_1);
}
 
Example 20
Source Project: xtext-xtend   Source File: DelegateCompilerTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testStaticMethodsInInterfaces() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import org.eclipse.xtend.lib.annotations.Delegate");
    _builder.newLine();
    _builder.append("import testdata.InterfaceWithStaticMethod");
    _builder.newLine();
    _builder.append("class Bar implements InterfaceWithStaticMethod {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("@Delegate InterfaceWithStaticMethod delegate");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String text = _builder.toString();
    this._validationTestHelper.assertNoIssues(this.file(text));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 21
Source Project: xtext-core   Source File: PrepareRenameTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testPrepareRenameFqn_missing_file_null() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("missing.");
    _builder.append(this.fileExtension);
    final String uri = this._uriExtensions.toUriString(new File(_builder.toString()).toURI().normalize());
    this.initializeWithPrepareSupport();
    TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
    Position _position = new Position(2, 5);
    final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
    Assert.assertNull(this.languageServer.prepareRename(params).get());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 22
Source Project: xtext-xtend   Source File: ImportOrganizerTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testDontOverrideTypeParameter() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("class Foo<String> {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("java.lang.String s");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("class Foo<String> {");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("java.lang.String s");
  _builder_1.newLine();
  _builder_1.append("}");
  _builder_1.newLine();
  this.assertIsOrganizedTo(_builder, _builder_1);
}
 
Example 23
@Test
public void formatEmptyMethod3() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("class C {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def m() {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("class C {");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("def m() {}");
  _builder_1.newLine();
  _builder_1.append("}");
  _builder_1.newLine();
  this.assertFormatted(_builder, _builder_1);
}
 
Example 24
@Ignore
@Test
public void formatFieldInit03() {
  final Procedure1<MapBasedPreferenceValues> _function = (MapBasedPreferenceValues it) -> {
  };
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("annotation Bar {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("val foo = 1 + 1");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  this.assertFormatted(_function, _builder);
}
 
Example 25
@Test
public void testNestedType_07() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("class C {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("val entry = new Map$Entry");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  this.hasUnresolvedType(_builder, "Map");
}
 
Example 26
Source Project: xtext-xtend   Source File: CompilerTraceTest.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testClassKeyword() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("package pack");
  _builder.newLine();
  _builder.append("/**");
  _builder.newLine();
  _builder.append(" ");
  _builder.append("* my comment");
  _builder.newLine();
  _builder.append(" ");
  _builder.append("*/");
  _builder.newLine();
  _builder.append("cl#a#ss Zonk {}");
  _builder.newLine();
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("package pack;");
  _builder_1.newLine();
  _builder_1.newLine();
  _builder_1.append("/**");
  _builder_1.newLine();
  _builder_1.append(" ");
  _builder_1.append("* my comment");
  _builder_1.newLine();
  _builder_1.append(" ");
  _builder_1.append("*/");
  _builder_1.newLine();
  _builder_1.append("#@SuppressWarnings(\"all\")");
  _builder_1.newLine();
  _builder_1.append("public class Zonk {");
  _builder_1.newLine();
  _builder_1.append("}#");
  _builder_1.newLine();
  this.tracesTo(_builder, _builder_1);
}
 
Example 27
@Test
public void test_5() {
  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("val 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.assertError(this._parseHelper.parse(_builder), XbasePackage.Literals.XABSTRACT_FEATURE_CALL, IssueCodes.ASSIGNMENT_TO_FINAL);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 28
@Override
protected void _createProposals(RuleCall ruleCall, ContentAssistContext context,
		IIdeContentProposalAcceptor acceptor) {
	if (testLanguageGrammarAccess.getTypeDeclarationRule().equals(ruleCall.getRule())) {
		StringConcatenation builder = new StringConcatenation();
		builder.append("type ${1|A,B,C|} {");
		builder.newLine();
		builder.append("\t");
		builder.newLine();
		builder.append("}");
		acceptor.accept(getProposalCreator().createSnippet(builder.toString(), "Sample Snippet", context), 0);
	}
	super._createProposals(ruleCall, context, acceptor);
}
 
Example 29
Source Project: xtext-extras   Source File: CompilerTests2.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test406762_ReturnInThrow() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("throw return");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("try {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("return;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("throw /* error - couldn\'t compile nested return */;");
    _builder_1.newLine();
    _builder_1.append("} catch (Throwable _e) {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("throw org.eclipse.xtext.xbase.lib.Exceptions.sneakyThrow(_e);");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.compilesTo(_builder, _builder_1, false);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 30
@Test
public void checkDuplicateImportWithExtensionAccess_5() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import static java.lang.String.*");
    _builder.newLine();
    _builder.append("import static extension java.lang.String.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("1.valueOf");
    _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\'");
    this._validationTestHelper.assertNoWarnings(file, XtypePackage.Literals.XIMPORT_DECLARATION, IssueCodes.IMPORT_UNUSED, "\'java.lang.String.valueOf\'");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}