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

The following examples show how to use org.eclipse.xtend2.lib.StringConcatenation#newLineIfNotEmpty() . 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: AbstractAntlrGrammarGenerator.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
protected CharSequence compileTerminalRules(final Grammar it, final AntlrOptions options) {
  StringConcatenation _builder = new StringConcatenation();
  {
    boolean _isBacktrackLexer = options.isBacktrackLexer();
    if (_isBacktrackLexer) {
      _builder.newLine();
      _builder.append("// Rules duplicated to allow inter-rule references");
      _builder.newLine();
    }
  }
  {
    List<TerminalRule> _allTerminalRules = GrammarUtil.allTerminalRules(it);
    for(final TerminalRule rule : _allTerminalRules) {
      _builder.newLine();
      CharSequence _compileRule = this.compileRule(rule, it, options);
      _builder.append(_compileRule);
      _builder.newLineIfNotEmpty();
    }
  }
  return _builder;
}
 
Example 2
Source File: JavaDocHyperlinkingTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void import_statement() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("import ");
  _builder.append(this.c);
  _builder.append("java.util.Date");
  _builder.append(this.c);
  _builder.newLineIfNotEmpty();
  _builder.newLine();
  _builder.append("class Foo {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("Date date");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  this.hasHyperlinkToJavaDate(_builder);
}
 
Example 3
Source File: Ecore2XtextGrammarCreator.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
public CharSequence subClassDispatcherRule(final EClass it) {
  StringConcatenation _builder = new StringConcatenation();
  {
    boolean _needsDispatcherRule = Ecore2XtextExtensions.needsDispatcherRule(it);
    if (_needsDispatcherRule) {
      String _uniqueName = UniqueNameUtil.uniqueName(it);
      _builder.append(_uniqueName);
      _builder.append(" returns ");
      String _fqn = Ecore2XtextExtensions.fqn(it);
      _builder.append(_fqn);
      _builder.append(":");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      String _subClassAlternatives = this.subClassAlternatives(it);
      _builder.append(_subClassAlternatives, "\t");
      _builder.append(";");
      _builder.newLineIfNotEmpty();
    }
  }
  return _builder;
}
 
Example 4
Source File: MethodBuilderTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testXtendExceptions() {
  AbstractMethodBuilder _createMethodBuilder = this._codeBuilderFactory.createMethodBuilder(this.getXtendClass());
  final Procedure1<AbstractMethodBuilder> _function = (AbstractMethodBuilder it) -> {
    it.setContext(this.getXtendClass());
    it.setMethodName("foo");
    LightweightTypeReference _createTypeRef = this.createTypeRef(Exception.class, this.getXtendClass());
    LightweightTypeReference _createTypeRef_1 = this.createTypeRef(RuntimeException.class, this.getXtendClass());
    it.setExceptions(Collections.<LightweightTypeReference>unmodifiableList(CollectionLiterals.<LightweightTypeReference>newArrayList(_createTypeRef, _createTypeRef_1)));
  };
  AbstractMethodBuilder _doubleArrow = ObjectExtensions.<AbstractMethodBuilder>operator_doubleArrow(_createMethodBuilder, _function);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("def foo() throws Exception, RuntimeException {");
  _builder.newLine();
  _builder.append("  ");
  _builder.append(AbstractBuilderTest.DEFAULT_BODY, "  ");
  _builder.newLineIfNotEmpty();
  _builder.append("}");
  this.assertBuilds(_doubleArrow, _builder.toString());
}
 
Example 5
Source File: RuleEngineHyperlinkingTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void hyperlink_on_rule_when_part() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("Device Window can be open, closed");
  _builder.newLine();
  _builder.append("Device Heater can be on, off, error");
  _builder.newLine();
  _builder.newLine();
  _builder.append("Rule \'rule1\' when ");
  _builder.append(this.c);
  _builder.append("Window.open");
  _builder.append(this.c);
  _builder.append(" then");
  _builder.newLineIfNotEmpty();
  _builder.append("\t");
  _builder.append("fire(Heater.off)");
  _builder.newLine();
  this.hasHyperlinkTo(_builder, "Window.open");
}
 
Example 6
Source File: JavaDocHyperlinkingTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void javadoc_see02() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("/**");
  _builder.newLine();
  _builder.append(" ");
  _builder.append("* @see ");
  _builder.append(this.c, " ");
  _builder.append("java.util.Date");
  _builder.append(this.c, " ");
  _builder.newLineIfNotEmpty();
  _builder.append(" ");
  _builder.append("* @see java.lang.StringBuffer");
  _builder.newLine();
  _builder.append(" ");
  _builder.append("*/");
  _builder.newLine();
  _builder.append("class Foo {");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  this.hasHyperlinkToJavaDate(_builder);
}
 
Example 7
Source File: ConstructorBuilderTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testXtendConstructor() {
  AbstractConstructorBuilder _createConstructorBuilder = this._codeBuilderFactory.createConstructorBuilder(this.getXtendClass());
  final Procedure1<AbstractConstructorBuilder> _function = (AbstractConstructorBuilder it) -> {
    it.setContext(this.getXtendClass());
    it.setVisibility(JvmVisibility.PROTECTED);
    AbstractParameterBuilder _newParameterBuilder = it.newParameterBuilder();
    _newParameterBuilder.setType(this.createTypeRef(this.getXtendClass()));
    AbstractParameterBuilder _newParameterBuilder_1 = it.newParameterBuilder();
    _newParameterBuilder_1.setType(this.createTypeRef(this.getXtendClass()));
  };
  AbstractConstructorBuilder _doubleArrow = ObjectExtensions.<AbstractConstructorBuilder>operator_doubleArrow(_createConstructorBuilder, _function);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("protected new(Foo foo, Foo foo2) {");
  _builder.newLine();
  _builder.append("  ");
  _builder.append(AbstractBuilderTest.DEFAULT_BODY, "  ");
  _builder.newLineIfNotEmpty();
  _builder.append("}");
  this.assertBuilds(_doubleArrow, _builder.toString());
}
 
Example 8
Source File: IndentationAwareLanguageTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
private StringConcatenation asText(final OtherTreeNode treeNode) {
  StringConcatenation _builder = new StringConcatenation();
  String _name = treeNode.getName();
  _builder.append(_name);
  _builder.newLineIfNotEmpty();
  {
    ChildList _childList = treeNode.getChildList();
    boolean _tripleNotEquals = (_childList != null);
    if (_tripleNotEquals) {
      _builder.append("\t");
      _builder.append(">");
      _builder.newLine();
      {
        EList<OtherTreeNode> _children = treeNode.getChildList().getChildren();
        for(final OtherTreeNode node : _children) {
          _builder.append("\t");
          _builder.append("\t");
          StringConcatenation _asText = this.asText(node);
          _builder.append(_asText, "\t\t");
          _builder.newLineIfNotEmpty();
        }
      }
    }
  }
  return _builder;
}
 
Example 9
Source File: RuleEngineContentAssistTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void empty() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append(this.c);
  _builder.newLineIfNotEmpty();
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("Device");
  _builder_1.newLine();
  this.testContentAssistant(_builder, 
    Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("Device", "Rule")), "Device", _builder_1.toString());
}
 
Example 10
Source File: AntlrGrammarGenerator.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected String compileInit(final AbstractRule it, final AntlrOptions options) {
  StringConcatenation _builder = new StringConcatenation();
  {
    if ((it instanceof ParserRule)) {
      boolean _isPassCurrentIntoFragment = this.isPassCurrentIntoFragment();
      boolean _not = (!_isPassCurrentIntoFragment);
      String _parameterList = AntlrGrammarGenUtil.getParameterList(((ParserRule)it), Boolean.valueOf(_not), this.getCurrentType());
      _builder.append(_parameterList);
    }
  }
  _builder.append(" returns ");
  CharSequence _compileReturns = this.compileReturns(it, options);
  _builder.append(_compileReturns);
  _builder.newLineIfNotEmpty();
  _builder.append("@init {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("enterRule();");
  _builder.newLine();
  _builder.append("\t");
  CharSequence _compileInitHiddenTokens = this.compileInitHiddenTokens(it, options);
  _builder.append(_compileInitHiddenTokens, "\t");
  _builder.newLineIfNotEmpty();
  _builder.append("\t");
  CharSequence _compileInitUnorderedGroups = this.compileInitUnorderedGroups(it, options);
  _builder.append(_compileInitUnorderedGroups, "\t");
  _builder.newLineIfNotEmpty();
  _builder.append("}");
  _builder.newLine();
  _builder.append("@after {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("leaveRule();");
  _builder.newLine();
  _builder.append("}");
  return _builder.toString();
}
 
Example 11
Source File: StatemachineHyperlinkingTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void hyperlink_on_event() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("events");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("doorClosed D1CL");
  _builder.newLine();
  _builder.append("end");
  _builder.newLine();
  _builder.newLine();
  _builder.append("state idle");
  _builder.newLine();
  _builder.append("\t");
  _builder.append(this.c, "\t");
  _builder.append("doorClosed");
  _builder.append(this.c, "\t");
  _builder.append(" => active");
  _builder.newLineIfNotEmpty();
  _builder.append("end");
  _builder.newLine();
  _builder.newLine();
  _builder.append("state active");
  _builder.newLine();
  _builder.append("end");
  _builder.newLine();
  this.hasHyperlinkTo(_builder, "doorClosed");
}
 
Example 12
Source File: RewritableImportSectionTest0.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected CharSequence getModel(final boolean isStatic, final Class<?>[] types) {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("package foo");
  _builder.newLine();
  _builder.newLine();
  {
    for(final Class<?> type : types) {
      {
        if (isStatic) {
          _builder.append("import static ");
          String _canonicalName = type.getCanonicalName();
          _builder.append(_canonicalName);
          _builder.append(".*");
          _builder.newLineIfNotEmpty();
        } else {
          _builder.append("import ");
          String _canonicalName_1 = type.getCanonicalName();
          _builder.append(_canonicalName_1);
          _builder.newLineIfNotEmpty();
        }
      }
    }
  }
  _builder.newLine();
  _builder.append("class Foo{}");
  _builder.newLine();
  return _builder;
}
 
Example 13
Source File: OnTheFlyJavaCompiler2.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public <RT extends Object> Function0<RT> createFunction(final String expression, final Class<RT> returnType) {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("public class __Generated implements org.eclipse.xtext.xbase.lib.Functions.Function0<");
    String _name = returnType.getName();
    _builder.append(_name);
    _builder.append("> {");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("public ");
    String _name_1 = returnType.getName();
    _builder.append(_name_1, "\t");
    _builder.append(" apply() {");
    _builder.newLineIfNotEmpty();
    _builder.append("\t\t");
    _builder.append(expression, "\t\t");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final Class<?> clazz = this.compileToClass("__Generated", _builder.toString());
    Object _newInstance = clazz.getDeclaredConstructor().newInstance();
    return ((Function0<RT>) _newInstance);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 14
Source File: MutableElementsConditionsTestCase.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void checkMutableFieldDeclaration() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("class Foo {");
  _builder.newLine();
  _builder.newLine();
  _builder.append("\t");
  _builder.append("@");
  String _name = CheckMutableFieldDeclaration.class.getName();
  _builder.append(_name, "\t");
  _builder.append(" Object foo");
  _builder.newLineIfNotEmpty();
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("import ");
  String _name_1 = CheckMutableFieldDeclaration.class.getName();
  _builder_1.append(_name_1);
  _builder_1.append(";");
  _builder_1.newLineIfNotEmpty();
  _builder_1.newLine();
  _builder_1.append("@SuppressWarnings(\"all\")");
  _builder_1.newLine();
  _builder_1.append("public class Foo {");
  _builder_1.newLine();
  _builder_1.append("  ");
  _builder_1.append("@");
  String _simpleName = CheckMutableFieldDeclaration.class.getSimpleName();
  _builder_1.append(_simpleName, "  ");
  _builder_1.newLineIfNotEmpty();
  _builder_1.append("  ");
  _builder_1.append("private Object foo;");
  _builder_1.newLine();
  _builder_1.append("}");
  _builder_1.newLine();
  this._xtendCompilerTester.assertCompilesTo(_builder, _builder_1);
}
 
Example 15
Source File: AbstractAntlrGrammarWithActionsGenerator.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected String _ebnf2(final Assignment it, final AntlrOptions options, final boolean supportActions) {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("(");
  _builder.newLine();
  _builder.append("\t");
  String __ebnf2 = super._ebnf2(it, options, supportActions);
  _builder.append(__ebnf2, "\t");
  _builder.newLineIfNotEmpty();
  _builder.append(")");
  _builder.newLine();
  return _builder.toString();
}
 
Example 16
Source File: AbstractLanguageServerTest.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
protected String _toExpectation(final CompletionItem it) {
  StringConcatenation _builder = new StringConcatenation();
  String _label = it.getLabel();
  _builder.append(_label);
  {
    boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(it.getDetail());
    boolean _not = (!_isNullOrEmpty);
    if (_not) {
      _builder.append(" (");
      String _detail = it.getDetail();
      _builder.append(_detail);
      _builder.append(")");
    }
  }
  {
    TextEdit _textEdit = it.getTextEdit();
    boolean _tripleNotEquals = (_textEdit != null);
    if (_tripleNotEquals) {
      _builder.append(" -> ");
      String _expectation = this.toExpectation(it.getTextEdit());
      _builder.append(_expectation);
      {
        boolean _isNullOrEmpty_1 = IterableExtensions.isNullOrEmpty(it.getAdditionalTextEdits());
        boolean _not_1 = (!_isNullOrEmpty_1);
        if (_not_1) {
          _builder.append("   + ");
          final Function1<TextEdit, String> _function = (TextEdit it_1) -> {
            return this.toExpectation(it_1);
          };
          String _join = IterableExtensions.join(ListExtensions.<TextEdit, String>map(it.getAdditionalTextEdits(), _function), "   + ");
          _builder.append(_join);
        }
      }
    } else {
      if (((it.getInsertText() != null) && (!Objects.equal(it.getInsertText(), it.getLabel())))) {
        _builder.append(" -> ");
        String _insertText = it.getInsertText();
        _builder.append(_insertText);
      }
    }
  }
  _builder.newLineIfNotEmpty();
  return _builder.toString();
}
 
Example 17
Source File: AntlrGrammarGenerator.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected String _assignmentEbnf(final CrossReference it, final Assignment assignment, final AntlrOptions options, final boolean supportActions) {
  String _xifexpression = null;
  if (supportActions) {
    StringConcatenation _builder = new StringConcatenation();
    {
      boolean _isBacktrack = options.isBacktrack();
      if (_isBacktrack) {
        _builder.append("{");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("/* */");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
      }
    }
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("if ($current==null) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("$current = ");
    CharSequence _createModelElement = this.createModelElement(assignment);
    _builder.append(_createModelElement, "\t\t");
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    String __assignmentEbnf = super._assignmentEbnf(it, assignment, options, supportActions);
    _builder.append(__assignmentEbnf);
    _xifexpression = _builder.toString();
  } else {
    _xifexpression = super._assignmentEbnf(it, assignment, options, supportActions);
  }
  return _xifexpression;
}
 
Example 18
Source File: ConstantOperators.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public static void main(final String[] args) {
  Pair<String, String> _mappedTo = Pair.<String, String>of("Integer", "intValue()");
  Pair<String, String> _mappedTo_1 = Pair.<String, String>of("Short", "shortValue()");
  Pair<String, String> _mappedTo_2 = Pair.<String, String>of("Long", "longValue()");
  Pair<String, String> _mappedTo_3 = Pair.<String, String>of("Float", "floatValue()");
  Pair<String, String> _mappedTo_4 = Pair.<String, String>of("Double", "doubleValue()");
  Pair<String, String> _mappedTo_5 = Pair.<String, String>of("Byte", "byteValue()");
  final Map<String, String> types = Collections.<String, String>unmodifiableMap(CollectionLiterals.<String, String>newHashMap(_mappedTo, _mappedTo_1, _mappedTo_2, _mappedTo_3, _mappedTo_4, _mappedTo_5));
  Pair<String, String> _mappedTo_6 = Pair.<String, String>of("plus", "+");
  Pair<String, String> _mappedTo_7 = Pair.<String, String>of("minus", "-");
  Pair<String, String> _mappedTo_8 = Pair.<String, String>of("divide", "/");
  Pair<String, String> _mappedTo_9 = Pair.<String, String>of("multiply", "*");
  Pair<String, String> _mappedTo_10 = Pair.<String, String>of("modulo", "%");
  Pair<String, String> _mappedTo_11 = Pair.<String, String>of("lessThan", "<");
  Pair<String, String> _mappedTo_12 = Pair.<String, String>of("greaterThan", ">");
  Pair<String, String> _mappedTo_13 = Pair.<String, String>of("lessEquals", "<=");
  Pair<String, String> _mappedTo_14 = Pair.<String, String>of("greaterEquals", ">=");
  Pair<String, String> _mappedTo_15 = Pair.<String, String>of("same", "===");
  Pair<String, String> _mappedTo_16 = Pair.<String, String>of("notSame", "!==");
  final Map<String, String> operators = Collections.<String, String>unmodifiableMap(CollectionLiterals.<String, String>newHashMap(_mappedTo_6, _mappedTo_7, _mappedTo_8, _mappedTo_9, _mappedTo_10, _mappedTo_11, _mappedTo_12, _mappedTo_13, _mappedTo_14, _mappedTo_15, _mappedTo_16));
  final Set<String> booleanOps = Collections.<String>unmodifiableSet(CollectionLiterals.<String>newHashSet("<", "<=", ">", ">=", "===", "!=="));
  Set<Map.Entry<String, String>> _entrySet = operators.entrySet();
  for (final Map.Entry<String, String> op : _entrySet) {
    {
      String _xifexpression = null;
      boolean _contains = booleanOps.contains(op.getValue());
      if (_contains) {
        _xifexpression = "boolean ";
      } else {
        _xifexpression = "Object ";
      }
      final String returnType = _xifexpression;
      StringConcatenation _builder = new StringConcatenation();
      _builder.newLine();
      _builder.append("def dispatch ");
      _builder.append(returnType);
      String _key = op.getKey();
      _builder.append(_key);
      _builder.append("(Object left, Object right) {");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("throw new ConstantExpressionEvaluationException(\"Unsupported operator \'");
      String _value = op.getValue();
      _builder.append(_value, "\t");
      _builder.append("\' for operands \"+left+\" and \"+right);");
      _builder.newLineIfNotEmpty();
      _builder.append("}");
      _builder.newLine();
      InputOutput.<String>println(_builder.toString());
      Set<String> _keySet = types.keySet();
      for (final String left : _keySet) {
        {
          InputOutput.<String>println("");
          Set<String> _keySet_1 = types.keySet();
          for (final String right : _keySet_1) {
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("def dispatch ");
            _builder_1.append(returnType);
            String _key_1 = op.getKey();
            _builder_1.append(_key_1);
            _builder_1.append("(");
            _builder_1.append(left);
            _builder_1.append(" left, ");
            _builder_1.append(right);
            _builder_1.append(" right) { left.");
            String _get = types.get(left);
            _builder_1.append(_get);
            _builder_1.append(" ");
            String _value_1 = op.getValue();
            _builder_1.append(_value_1);
            _builder_1.append(" right.");
            String _get_1 = types.get(right);
            _builder_1.append(_get_1);
            _builder_1.append(" }");
            InputOutput.<String>println(_builder_1.toString());
          }
        }
      }
    }
  }
}
 
Example 19
Source File: MutableElementsConditionsTestCase.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void checkMutableMethodDeclaration() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("class Foo {");
  _builder.newLine();
  _builder.newLine();
  _builder.append("\t");
  _builder.append("@");
  String _name = CheckMutableMethodDeclaration.class.getName();
  _builder.append(_name, "\t");
  _builder.append(" def void foo () {}");
  _builder.newLineIfNotEmpty();
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("import ");
  String _name_1 = CheckMutableMethodDeclaration.class.getName();
  _builder_1.append(_name_1);
  _builder_1.append(";");
  _builder_1.newLineIfNotEmpty();
  _builder_1.newLine();
  _builder_1.append("@SuppressWarnings(\"all\")");
  _builder_1.newLine();
  _builder_1.append("public class Foo {");
  _builder_1.newLine();
  _builder_1.append("  ");
  _builder_1.append("@");
  String _simpleName = CheckMutableMethodDeclaration.class.getSimpleName();
  _builder_1.append(_simpleName, "  ");
  _builder_1.newLineIfNotEmpty();
  _builder_1.append("  ");
  _builder_1.append("public void foo() {");
  _builder_1.newLine();
  _builder_1.append("  ");
  _builder_1.append("}");
  _builder_1.newLine();
  _builder_1.append("}");
  _builder_1.newLine();
  this._xtendCompilerTester.assertCompilesTo(_builder, _builder_1);
}
 
Example 20
Source File: StatemachineContentAssistTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void transition_template() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("events");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("doorClosed   D1CL");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("drawerOpened D2OP");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("lightOn      L1ON");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("doorOpened   D1OP");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("panelClosed  PNCL");
  _builder.newLine();
  _builder.append("end");
  _builder.newLine();
  _builder.newLine();
  _builder.append("state idle");
  _builder.newLine();
  _builder.append("\t");
  _builder.append(this.c, "\t");
  _builder.newLineIfNotEmpty();
  _builder.append("end");
  _builder.newLine();
  _builder.newLine();
  _builder.append("state active");
  _builder.newLine();
  _builder.append("end");
  _builder.newLine();
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("events");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("doorClosed   D1CL");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("drawerOpened D2OP");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("lightOn      L1ON");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("doorOpened   D1OP");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("panelClosed  PNCL");
  _builder_1.newLine();
  _builder_1.append("end");
  _builder_1.newLine();
  _builder_1.newLine();
  _builder_1.append("state idle");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("doorClosed => idle");
  _builder_1.newLine();
  _builder_1.append("end");
  _builder_1.newLine();
  _builder_1.newLine();
  _builder_1.append("state active");
  _builder_1.newLine();
  _builder_1.append("end");
  _builder_1.newLine();
  this.testContentAssistant(_builder, 
    Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("doorClosed", "drawerOpened", "lightOn", "doorOpened", "panelClosed", "actions", "end", "Transition - Template for a Transition")), "Transition - Template for a Transition", _builder_1.toString());
}