Search in sources :

Example 1 with IntegerRange

use of org.eclipse.xtext.xbase.lib.IntegerRange in project xtext-xtend by eclipse.

the class Case_0 method foo.

public String foo(final String a, final String b) {
    String _xblockexpression = null;
    {
        ArrayList<String> list = CollectionLiterals.<String>newArrayList();
        int _size = list.size();
        int _minus = (_size - 1);
        IntegerRange _upTo = new IntegerRange(0, _minus);
        for (final Integer i : _upTo) {
            String _string = i.toString();
            String _plus = (_string + " ");
            String _get = list.get((i).intValue());
            String _plus_1 = (_plus + _get);
            InputOutput.<String>println(_plus_1);
        }
        String _xifexpression = null;
        boolean _isUpper = this.isUpper(a);
        if (_isUpper) {
            _xifexpression = this.another(a, (b + "holla"));
        } else {
            String _xblockexpression_1 = null;
            {
                String x = a;
                char[] _charArray = b.toCharArray();
                for (final char y : _charArray) {
                    x = (x + Character.valueOf(y));
                }
                _xblockexpression_1 = x;
            }
            _xifexpression = _xblockexpression_1;
        }
        _xblockexpression = _xifexpression;
    }
    return _xblockexpression;
}
Also used : IntegerRange(org.eclipse.xtext.xbase.lib.IntegerRange) ArrayList(java.util.ArrayList)

Example 2 with IntegerRange

use of org.eclipse.xtext.xbase.lib.IntegerRange in project xtext-xtend by eclipse.

the class Case_3 method testReturnExpression_07.

public void testReturnExpression_07(final Class<?> c) {
    boolean _notEquals = (!Objects.equal(Case_3.class, c));
    if (_notEquals) {
        final Function1<Integer, Integer> _function = (Integer i) -> {
            return (i).intValue();
        };
        final Function1<? super Integer, ? extends Integer> closure = _function;
        IntegerRange _upTo = new IntegerRange(1, 100);
        for (final Integer x : _upTo) {
            closure.apply(x);
        }
    }
}
Also used : IntegerRange(org.eclipse.xtext.xbase.lib.IntegerRange)

Example 3 with IntegerRange

use of org.eclipse.xtext.xbase.lib.IntegerRange in project xtext-xtend by eclipse.

the class RichStringToLineModel method acceptSemanticText.

@Override
public void acceptSemanticText(final CharSequence text, final RichStringLiteral origin) {
    super.acceptSemanticText(text, origin);
    if ((!this.content)) {
        if (((text.length() > 0) && (IterableExtensions.<Integer, Boolean>fold(new IntegerRange(0, (text.length() - 1)), Boolean.valueOf(false), ((Function2<Boolean, Integer, Boolean>) (Boolean v, Integer i) -> {
            return Boolean.valueOf(((v).booleanValue() || (!Character.isWhitespace(text.charAt((i).intValue())))));
        }))).booleanValue())) {
            this.startContent();
        }
    }
    int _length = text.length();
    int _plus = (this.offset + _length);
    this.offset = _plus;
}
Also used : IntegerRange(org.eclipse.xtext.xbase.lib.IntegerRange) Function2(org.eclipse.xtext.xbase.lib.Functions.Function2)

Example 4 with IntegerRange

use of org.eclipse.xtext.xbase.lib.IntegerRange in project xtext-xtend by eclipse.

the class XtendFormatter method _format.

protected void _format(final XtendEnum enumeration, @Extension final IFormattableDocument format) {
    this.formatAnnotations(enumeration, format, XbaseFormatterPreferenceKeys.newLineAfterClassAnnotations);
    this.formatModifiers(enumeration, format);
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
    };
    format.append(this.textRegionExtensions.regionFor(enumeration).keyword("enum"), _function);
    final ISemanticRegion open = this.textRegionExtensions.regionFor(enumeration).keyword("{");
    final ISemanticRegion close = this.textRegionExtensions.regionFor(enumeration).keyword("}");
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.indent();
    };
    format.<ISemanticRegion, ISemanticRegion>interior(open, close, _function_1);
    format.prepend(open, XbaseFormatterPreferenceKeys.bracesInNewLine);
    boolean _isEmpty = enumeration.getMembers().isEmpty();
    boolean _not = (!_isEmpty);
    if (_not) {
        format.append(open, XtendFormatterPreferenceKeys.blankLinesBeforeFirstMember);
        int _size = enumeration.getMembers().size();
        int _minus = (_size - 1);
        IntegerRange _upTo = new IntegerRange(0, _minus);
        for (final Integer i : _upTo) {
            {
                final XtendMember current = enumeration.getMembers().get((i).intValue());
                format.<XtendMember>format(current);
                int _size_1 = enumeration.getMembers().size();
                int _minus_1 = (_size_1 - 1);
                boolean _lessThan = ((i).intValue() < _minus_1);
                if (_lessThan) {
                    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
                        it.noSpace();
                    };
                    format.append(format.prepend(this.textRegionExtensions.immediatelyFollowing(current).keyword(","), _function_2), XtendFormatterPreferenceKeys.blankLinesBetweenEnumLiterals);
                } else {
                    format.<XtendMember>append(current, XtendFormatterPreferenceKeys.blankLinesAfterLastMember);
                }
            }
        }
    } else {
        final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
            it.newLine();
        };
        format.append(open, _function_2);
    }
}
Also used : IntegerRange(org.eclipse.xtext.xbase.lib.IntegerRange) IHiddenRegionFormatter(org.eclipse.xtext.formatting2.IHiddenRegionFormatter) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) ISemanticRegion(org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion) JvmTypeConstraint(org.eclipse.xtext.common.types.JvmTypeConstraint)

Example 5 with IntegerRange

use of org.eclipse.xtext.xbase.lib.IntegerRange in project xtext-xtend by eclipse.

the class XtendFormatter method formatBody.

protected ISemanticRegion formatBody(final XtendTypeDeclaration type, @Extension final IFormattableDocument format) {
    ISemanticRegion _xblockexpression = null;
    {
        final ISemanticRegion open = this.textRegionExtensions.regionFor(type).keyword("{");
        final ISemanticRegion close = this.textRegionExtensions.regionFor(type).keyword("}");
        final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
            it.indent();
        };
        format.<ISemanticRegion, ISemanticRegion>interior(open, close, _function);
        format.prepend(open, XbaseFormatterPreferenceKeys.bracesInNewLine);
        ISemanticRegion _xifexpression = null;
        boolean _isEmpty = type.getMembers().isEmpty();
        boolean _not = (!_isEmpty);
        if (_not) {
            format.append(open, XtendFormatterPreferenceKeys.blankLinesBeforeFirstMember);
            int _size = type.getMembers().size();
            int _minus = (_size - 1);
            IntegerRange _upTo = new IntegerRange(0, _minus);
            for (final Integer i : _upTo) {
                {
                    final XtendMember current = type.getMembers().get((i).intValue());
                    format.<XtendMember>format(current);
                    int _size_1 = type.getMembers().size();
                    int _minus_1 = (_size_1 - 1);
                    boolean _lessThan = ((i).intValue() < _minus_1);
                    if (_lessThan) {
                        final XtendMember next = type.getMembers().get(((i).intValue() + 1));
                        if (((current instanceof XtendField) && (next instanceof XtendField))) {
                            format.<XtendMember>append(current, XtendFormatterPreferenceKeys.blankLinesBetweenFields);
                        } else {
                            if (((current instanceof XtendFunction) && (next instanceof XtendFunction))) {
                                format.<XtendMember>append(current, XtendFormatterPreferenceKeys.blankLinesBetweenMethods);
                            } else {
                                format.<XtendMember>append(current, XtendFormatterPreferenceKeys.blankLinesBetweenFieldsAndMethods);
                            }
                        }
                    } else {
                        final XtendMember member = type.getMembers().get((i).intValue());
                        format.<XtendMember>append(member, XtendFormatterPreferenceKeys.blankLinesAfterLastMember);
                    }
                }
            }
        } else {
            final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
                it.newLine();
            };
            _xifexpression = format.append(open, _function_1);
        }
        _xblockexpression = _xifexpression;
    }
    return _xblockexpression;
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) IntegerRange(org.eclipse.xtext.xbase.lib.IntegerRange) IHiddenRegionFormatter(org.eclipse.xtext.formatting2.IHiddenRegionFormatter) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) ISemanticRegion(org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion) JvmTypeConstraint(org.eclipse.xtext.common.types.JvmTypeConstraint) XtendField(org.eclipse.xtend.core.xtend.XtendField)

Aggregations

IntegerRange (org.eclipse.xtext.xbase.lib.IntegerRange)19 Test (org.junit.Test)9 List (java.util.List)4 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)4 ArrayList (java.util.ArrayList)2 EList (org.eclipse.emf.common.util.EList)2 URI (org.eclipse.emf.common.util.URI)2 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)2 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)2 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)2 JvmTypeConstraint (org.eclipse.xtext.common.types.JvmTypeConstraint)2 JvmTypeParameter (org.eclipse.xtext.common.types.JvmTypeParameter)2 IHiddenRegionFormatter (org.eclipse.xtext.formatting2.IHiddenRegionFormatter)2 ISemanticRegion (org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion)2 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)2 ITypeReferenceOwner (org.eclipse.xtext.xbase.typesystem.references.ITypeReferenceOwner)2 ActualTypeArgumentCollector (org.eclipse.xtext.xbase.typesystem.util.ActualTypeArgumentCollector)2 SecureRandom (java.security.SecureRandom)1 NoSuchElementException (java.util.NoSuchElementException)1 ExecutionException (java.util.concurrent.ExecutionException)1