org.eclipse.xtend2.lib.StringConcatenation Java Examples

The following examples show how to use org.eclipse.xtend2.lib.StringConcatenation. 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: MethodBuilderTest.java    From xtext-xtend with 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 #2
Source File: XtendClassFormatterTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@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 #3
Source File: ErrorTest.java    From xtext-xtend with 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 #4
Source File: ConstantExpressionsInterpreterTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@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
Source File: AmbiguousPlainFeatureCallTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@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 #6
Source File: XtendConditionalExpressionFormatterTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@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 #7
Source File: PrepareRenameTest.java    From xtext-core with 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 #8
Source File: DelegateCompilerTest.java    From xtext-xtend with 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 #9
Source File: ImportOrganizerTest.java    From xtext-xtend with 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 #10
Source File: XtendOnelinersFormatterTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@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 #11
Source File: ImportOrganizerTest.java    From xtext-xtend with 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 #12
Source File: XtextLinkerTest.java    From xtext-core with 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 #13
Source File: ValidatorTest.java    From xtext-core with 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 #14
Source File: AbstractJunitLibClasspathAdderTestCase.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
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 #15
Source File: ValidationBug437678Test.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@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 #16
Source File: XbaseValidationTest.java    From xtext-extras with 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 #17
Source File: CompilerTests2.java    From xtext-extras with 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 #18
Source File: JvmModelTests.java    From xtext-xtend with 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 #19
Source File: Bug436564Test.java    From xtext-xtend with 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 #20
Source File: OverriddenValueInspectorTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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 #21
Source File: XtendUIValidationTests.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@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 #22
Source File: IndentationAwareLanguageTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
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 #23
Source File: TypeUsageCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@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 #24
Source File: ErrorTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testErrorModel_26() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("{ val list = newArrayList(if (false) new Double(\'-20\') else newInteger(\'20\')).map(v|v.intValue)");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("val Object o = list.head ");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("list");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  this._oven.fireproof(_builder);
}
 
Example #25
Source File: ParameterizedTypeCompilerTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testSimpleArgument_09() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("class MyRef<U> extends java.lang.ref.WeakReference<Iterable<U>> {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("new(U u) { super(newArrayList(u)) }");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("import java.lang.ref.WeakReference;");
  _builder_1.newLine();
  _builder_1.append("import org.eclipse.xtext.xbase.lib.CollectionLiterals;");
  _builder_1.newLine();
  _builder_1.newLine();
  _builder_1.append("@SuppressWarnings(\"all\")");
  _builder_1.newLine();
  _builder_1.append("public class MyRef<U extends Object> extends WeakReference<Iterable<U>> {");
  _builder_1.newLine();
  _builder_1.append("  ");
  _builder_1.append("public MyRef(final U u) {");
  _builder_1.newLine();
  _builder_1.append("    ");
  _builder_1.append("super(CollectionLiterals.<U>newArrayList(u));");
  _builder_1.newLine();
  _builder_1.append("  ");
  _builder_1.append("}");
  _builder_1.newLine();
  _builder_1.append("}");
  _builder_1.newLine();
  this.assertCompilesTo(_builder, _builder_1);
}
 
Example #26
Source File: AbstractRewritableImportSectionTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testDoubleAddAsString_5() {
  final RewritableImportSection section = this.getSection(Collections.class);
  section.addStaticImport("java.util.Collections", "sort");
  section.addStaticImport("java.util.Collections", "*");
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("import java.util.Collections");
  _builder.newLine();
  _builder.append("import static java.util.Collections.sort");
  _builder.newLine();
  _builder.append("import static java.util.Collections.*");
  _builder.newLine();
  this.assertEquals(section, _builder);
}
 
Example #27
Source File: GrammarPDAProviderTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testGroup() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("Rule: {Rule} \'a\' \'b\' \'c\';");
  _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 -> {Rule}");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("\'a\' -> \'b\'");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("\'b\' -> \'c\'");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("\'c\' -> stop");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("{Rule} -> \'a\'");
  _builder_1.newLine();
  final String expected = _builder_1.toString();
  Assert.assertEquals(expected, actual);
}
 
Example #28
Source File: RegionSetTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testNoMergeConflic2() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("issues=");
  _builder.newLine();
  _builder.append("set=[[20,0], [20,1]]");
  _builder.newLine();
  final Procedure1<TestableTextSegmentSet> _function = (TestableTextSegmentSet it) -> {
    TextSegment _textSegment = new TextSegment(null, 20, 1);
    it.add(_textSegment);
    TextSegment _textSegment_1 = new TextSegment(null, 20, 0);
    it.add(_textSegment_1);
  };
  this.test(_builder, _function);
}
 
Example #29
Source File: AnnotationTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected void assertContains(final CharSequence code, final String text) {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("Substring \'");
  _builder.append(text);
  _builder.append("\' not found in \'");
  _builder.append(code);
  _builder.append("\' ");
  Assert.assertTrue(_builder.toString(), code.toString().contains(text));
}
 
Example #30
Source File: Xtext2EcoreTransformerTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testOverrideEnumRule_03() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("grammar test with org.eclipse.xtext.enumrules.EnumRulesTestLanguage");
  _builder.newLine();
  _builder.append("import \'classpath:/org/eclipse/xtext/enumrules/enums.ecore\'");
  _builder.newLine();
  _builder.append("ExistingEnum returns ExistingEnum: \'a\' | \'z\';");
  _builder.newLine();
  final String grammarAsString = _builder.toString();
  this.getResourceFromString(grammarAsString);
}