Search in sources :

Example 6 with ExclusiveRange

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

the class AbstractExecutableBuilder method appendParameters.

protected ISourceAppender appendParameters(final ISourceAppender appendable) {
    ISourceAppender _xblockexpression = null;
    {
        appendable.append("(");
        final HashSet<String> notAllowed = CollectionLiterals.<String>newHashSet();
        boolean _isEmpty = this.parameterBuilders.isEmpty();
        boolean _not = (!_isEmpty);
        if (_not) {
            AbstractParameterBuilder _last = IterableExtensions.<AbstractParameterBuilder>last(this.parameterBuilders);
            _last.setVarArgsFlag(this.varArgsFlag);
        }
        int _size = this.parameterBuilders.size();
        ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true);
        for (final Integer i : _doubleDotLessThan) {
            {
                final AbstractParameterBuilder parameterBuilder = this.parameterBuilders.get((i).intValue());
                final VariableNameAcceptor acceptor = new VariableNameAcceptor(notAllowed);
                String _name = parameterBuilder.getName();
                boolean _tripleEquals = (_name == null);
                if (_tripleEquals) {
                    this._jdtVariableCompletions.getVariableProposals(parameterBuilder.getType().getIdentifier(), this.getContext(), JdtVariableCompletions.VariableType.PARAMETER, notAllowed, acceptor);
                    parameterBuilder.setName(acceptor.getVariableName());
                }
                parameterBuilder.build(appendable);
                int _size_1 = this.parameterBuilders.size();
                int _minus = (_size_1 - 1);
                boolean _notEquals = ((i).intValue() != _minus);
                if (_notEquals) {
                    appendable.append(", ");
                }
            }
        }
        _xblockexpression = appendable.append(")");
    }
    return _xblockexpression;
}
Also used : AbstractParameterBuilder(org.eclipse.xtend.ide.codebuilder.AbstractParameterBuilder) ISourceAppender(org.eclipse.xtext.xbase.compiler.ISourceAppender) ExclusiveRange(org.eclipse.xtext.xbase.lib.ExclusiveRange) VariableNameAcceptor(org.eclipse.xtend.ide.codebuilder.VariableNameAcceptor) HashSet(java.util.HashSet)

Example 7 with ExclusiveRange

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

the class XtendTaskFinderTest method assertContainsTasks.

private void assertContainsTasks(final Resource resource, final List<Task> expectedTasks) {
    final List<Task> actualTasks = this.finder.findTasks(resource);
    Assert.assertEquals(expectedTasks.size(), actualTasks.size());
    int _size = expectedTasks.size();
    ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true);
    for (final Integer i : _doubleDotLessThan) {
        XtendTaskFinderTest.assertExactMatch(expectedTasks.get((i).intValue()), actualTasks.get((i).intValue()));
    }
}
Also used : Task(org.eclipse.xtext.tasks.Task) ExclusiveRange(org.eclipse.xtext.xbase.lib.ExclusiveRange)

Example 8 with ExclusiveRange

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

the class CompilationUnitImpl method translate.

protected Object translate(final Object object) {
    if ((object instanceof XAnnotation[])) {
        final AnnotationReference[] result = new AnnotationReference[((Object[]) object).length];
        int _length = ((Object[]) object).length;
        ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _length, true);
        for (final Integer i : _doubleDotLessThan) {
            result[(i).intValue()] = this.translateAnnotation(((XAnnotation[]) object)[(i).intValue()]);
        }
        return result;
    }
    if ((object instanceof XAnnotation)) {
        return this.translateAnnotation(((XAnnotation) object));
    }
    if ((object instanceof JvmTypeReference[])) {
        final TypeReference[] result_1 = new TypeReference[((Object[]) object).length];
        int _length_1 = ((Object[]) object).length;
        ExclusiveRange _doubleDotLessThan_1 = new ExclusiveRange(0, _length_1, true);
        for (final Integer i_1 : _doubleDotLessThan_1) {
            Object _translate = this.translate(((Object[]) object)[(i_1).intValue()]);
            result_1[(i_1).intValue()] = ((TypeReference) _translate);
        }
        return result_1;
    }
    if ((object instanceof JvmTypeReference)) {
        return this.toTypeReference(((JvmTypeReference) object));
    }
    if ((object instanceof JvmEnumerationLiteral[])) {
        final EnumerationValueDeclaration[] result_2 = new EnumerationValueDeclaration[((Object[]) object).length];
        int _length_2 = ((Object[]) object).length;
        ExclusiveRange _doubleDotLessThan_2 = new ExclusiveRange(0, _length_2, true);
        for (final Integer i_2 : _doubleDotLessThan_2) {
            Object _translate_1 = this.translate(((Object[]) object)[(i_2).intValue()]);
            result_2[(i_2).intValue()] = ((EnumerationValueDeclaration) _translate_1);
        }
        return result_2;
    }
    if ((object instanceof JvmEnumerationLiteral)) {
        return this.toMemberDeclaration(((JvmMember) object));
    }
    return object;
}
Also used : ExclusiveRange(org.eclipse.xtext.xbase.lib.ExclusiveRange) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) XAnnotation(org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotation) JvmEnumerationLiteral(org.eclipse.xtext.common.types.JvmEnumerationLiteral) JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference) AnnotationReference(org.eclipse.xtend.lib.macro.declaration.AnnotationReference) EObject(org.eclipse.emf.ecore.EObject) JvmMember(org.eclipse.xtext.common.types.JvmMember) LightweightTypeReference(org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference) TypeReference(org.eclipse.xtend.lib.macro.declaration.TypeReference) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) EnumerationValueDeclaration(org.eclipse.xtend.lib.macro.declaration.EnumerationValueDeclaration)

Example 9 with ExclusiveRange

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

the class ResolvedExecutableImpl method getResolvedParameters.

@Override
public Iterable<? extends ResolvedParameter> getResolvedParameters() {
    Iterable<? extends ResolvedParameter> _xblockexpression = null;
    {
        if ((this.resolvedParameters == null)) {
            int _size = this.getDelegate().getDeclaration().getParameters().size();
            final Function1<Integer, ResolvedParameterImpl> _function = (Integer i) -> {
                ParameterDeclaration _parameterDeclaration = this.getCompilationUnit().toParameterDeclaration(this.getDelegate().getDeclaration().getParameters().get((i).intValue()));
                TypeReference _typeReference = this.getCompilationUnit().toTypeReference(this.getDelegate().getResolvedParameterTypes().get((i).intValue()));
                return new ResolvedParameterImpl(_parameterDeclaration, _typeReference);
            };
            this.resolvedParameters = IterableExtensions.<Integer, ResolvedParameterImpl>map(new ExclusiveRange(0, _size, true), _function);
        }
        _xblockexpression = this.resolvedParameters;
    }
    return _xblockexpression;
}
Also used : Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) ResolvedParameterImpl(org.eclipse.xtend.core.macro.declaration.ResolvedParameterImpl) LightweightTypeReference(org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference) TypeReference(org.eclipse.xtend.lib.macro.declaration.TypeReference) ExclusiveRange(org.eclipse.xtext.xbase.lib.ExclusiveRange) ParameterDeclaration(org.eclipse.xtend.lib.macro.declaration.ParameterDeclaration)

Example 10 with ExclusiveRange

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

the class SwtBotProjectHelper method getLineAndColumn.

protected static Pair<Integer, Integer> getLineAndColumn(final String content, final int offset) {
    Pair<Integer, Integer> _xblockexpression = null;
    {
        int line = 0;
        int column = 0;
        String ignoreNext = null;
        ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, offset, true);
        for (final Integer i : _doubleDotLessThan) {
            String _substring = content.substring((i).intValue(), ((i).intValue() + 1));
            boolean _matched = false;
            if (Objects.equal(_substring, ignoreNext)) {
                _matched = true;
                ignoreNext = null;
            }
            if (!_matched) {
                if (Objects.equal(_substring, "\n")) {
                    _matched = true;
                    column = 0;
                    line = (line + 1);
                    ignoreNext = "\r";
                }
            }
            if (!_matched) {
                if (Objects.equal(_substring, "\r")) {
                    _matched = true;
                    column = 0;
                    line = (line + 1);
                    ignoreNext = "\n";
                }
            }
            if (!_matched) {
                {
                    ignoreNext = null;
                    column = (column + 1);
                }
            }
        }
        _xblockexpression = Pair.<Integer, Integer>of(Integer.valueOf(line), Integer.valueOf(column));
    }
    return _xblockexpression;
}
Also used : ExclusiveRange(org.eclipse.xtext.xbase.lib.ExclusiveRange)

Aggregations

ExclusiveRange (org.eclipse.xtext.xbase.lib.ExclusiveRange)17 Task (org.eclipse.xtext.tasks.Task)4 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 TypeReference (org.eclipse.xtend.lib.macro.declaration.TypeReference)2 SerializableEObjectDescription (org.eclipse.xtext.resource.persistence.SerializableEObjectDescription)2 SerializableReferenceDescription (org.eclipse.xtext.resource.persistence.SerializableReferenceDescription)2 TaskTag (org.eclipse.xtext.tasks.TaskTag)2 LightweightTypeReference (org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference)2 Splitter (com.google.common.base.Splitter)1 HashSet (java.util.HashSet)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 URI (org.eclipse.emf.common.util.URI)1 EObject (org.eclipse.emf.ecore.EObject)1 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)1 ResolvedParameterImpl (org.eclipse.xtend.core.macro.declaration.ResolvedParameterImpl)1 AbstractParameterBuilder (org.eclipse.xtend.ide.codebuilder.AbstractParameterBuilder)1 VariableNameAcceptor (org.eclipse.xtend.ide.codebuilder.VariableNameAcceptor)1 AnnotationReference (org.eclipse.xtend.lib.macro.declaration.AnnotationReference)1