Search in sources :

Example 1 with ExclusiveRange

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

the class SerializerPerformanceTest method setup.

@Before
public void setup() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("entities");
        _builder.newLine();
        {
            ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, SerializerPerformanceTest.numberOfElements, true);
            for (final Integer i : _doubleDotLessThan) {
                _builder.append("\t");
                _builder.append("//comment before element");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("Foo /* comment between elements*/ \"Bar\" //comment after element ");
                _builder.newLine();
            }
        }
        _builder.append("end");
        _builder.newLine();
        this.model = this._parseHelper.parse(_builder);
        final EList<Entity> entities = this.model.getDomainModel().getEntities();
        final Function1<Integer, Boolean> _function = (Integer it) -> {
            return Boolean.valueOf((((it).intValue() % SerializerPerformanceTest.editEvery) == 0));
        };
        final Function1<Integer, Entity> _function_1 = (Integer it) -> {
            return entities.get((it).intValue());
        };
        final Iterable<Entity> removeUs = IterableExtensions.<Integer, Entity>map(IterableExtensions.<Integer>filter(new ExclusiveRange(0, SerializerPerformanceTest.numberOfElements, true), _function), _function_1);
        CollectionExtensions.<Entity>removeAll(entities, removeUs);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : Entity(org.eclipse.xtext.serializer.hiddentokensequencertest.Entity) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) ExclusiveRange(org.eclipse.xtext.xbase.lib.ExclusiveRange) Before(org.junit.Before)

Example 2 with ExclusiveRange

use of org.eclipse.xtext.xbase.lib.ExclusiveRange in project metalib by softlang.

the class FsmlGenerator method getPackageName.

/**
 * Gets an appropriate package name for the resource
 */
public String getPackageName(final Resource resource) {
    final StringBuilder result = new StringBuilder();
    final URI uri = resource.getURI();
    int _segmentCount = uri.segmentCount();
    int _minus = (_segmentCount - 1);
    ExclusiveRange _doubleDotLessThan = new ExclusiveRange(3, _minus, true);
    for (final Integer i : _doubleDotLessThan) {
        {
            String _segment = uri.segment((i).intValue());
            String _firstLower = StringExtensions.toFirstLower(_segment);
            result.append(_firstLower);
            result.append(".");
        }
    }
    String _lastSegment = uri.lastSegment();
    String _firstLower = StringExtensions.toFirstLower(_lastSegment);
    String _fileName = this.getFileName(_firstLower);
    result.append(_fileName);
    return result.toString();
}
Also used : ExclusiveRange(org.eclipse.xtext.xbase.lib.ExclusiveRange) URI(org.eclipse.emf.common.util.URI)

Example 3 with ExclusiveRange

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

the class SwtBotProjectHelper method fileNew.

protected static void fileNew(final SWTWorkbenchBot it, final String newWhat) {
    int retries = 3;
    ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, retries, true);
    for (final Integer i : _doubleDotLessThan) {
        try {
            it.menu("File").menu("New").menu(newWhat).click();
            return;
        } catch (final Throwable _t) {
            if (_t instanceof WidgetNotFoundException) {
                final WidgetNotFoundException e = (WidgetNotFoundException) _t;
                if (((i).intValue() == (retries - 1))) {
                    throw e;
                }
                String _message = e.getMessage();
                String _plus = ("failed: " + _message);
                InputOutput.<String>println(_plus);
                InputOutput.<String>println("retrying...");
                it.sleep(1000);
            } else {
                throw Exceptions.sneakyThrow(_t);
            }
        }
    }
}
Also used : WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) ExclusiveRange(org.eclipse.xtext.xbase.lib.ExclusiveRange)

Example 4 with ExclusiveRange

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

the class ChunkedResourceDescriptions method readExternal.

@Override
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
    final int numChunks = in.readInt();
    ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, numChunks, true);
    for (final Integer i : _doubleDotLessThan) {
        {
            final String chunkName = in.readUTF();
            final int numDescriptions = in.readInt();
            final ArrayList<IResourceDescription> descriptions = new ArrayList<IResourceDescription>(numDescriptions);
            ExclusiveRange _doubleDotLessThan_1 = new ExclusiveRange(0, numDescriptions, true);
            for (final Integer j : _doubleDotLessThan_1) {
                Object _readObject = in.readObject();
                descriptions.add(((IResourceDescription) _readObject));
            }
            ResourceDescriptionsData _resourceDescriptionsData = new ResourceDescriptionsData(descriptions);
            this.chunk2resourceDescriptions.put(chunkName, _resourceDescriptionsData);
        }
    }
}
Also used : ResourceDescriptionsData(org.eclipse.xtext.resource.impl.ResourceDescriptionsData) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) ArrayList(java.util.ArrayList) ExclusiveRange(org.eclipse.xtext.xbase.lib.ExclusiveRange)

Example 5 with ExclusiveRange

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

the class SerializableResourceDescription method readExternal.

@Override
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
    this.setURI(SerializationExtensions.readURI(in));
    final int descriptionsSize = in.readInt();
    ArrayList<SerializableEObjectDescription> _arrayList = new ArrayList<SerializableEObjectDescription>(descriptionsSize);
    this.descriptions = _arrayList;
    ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, descriptionsSize, true);
    for (final Integer i : _doubleDotLessThan) {
        this.descriptions.add(SerializationExtensions.<SerializableEObjectDescription>readCastedObject(in));
    }
    final int referencesSize = in.readInt();
    ArrayList<SerializableReferenceDescription> _arrayList_1 = new ArrayList<SerializableReferenceDescription>(referencesSize);
    this.references = _arrayList_1;
    ExclusiveRange _doubleDotLessThan_1 = new ExclusiveRange(0, referencesSize, true);
    for (final Integer i_1 : _doubleDotLessThan_1) {
        this.references.add(SerializationExtensions.<SerializableReferenceDescription>readCastedObject(in));
    }
    final int importedNamesSize = in.readInt();
    ArrayList<QualifiedName> _arrayList_2 = new ArrayList<QualifiedName>(importedNamesSize);
    this.importedNames = _arrayList_2;
    ExclusiveRange _doubleDotLessThan_2 = new ExclusiveRange(0, importedNamesSize, true);
    for (final Integer i_2 : _doubleDotLessThan_2) {
        this.importedNames.add(SerializationExtensions.readQualifiedName(in));
    }
}
Also used : SerializableEObjectDescription(org.eclipse.xtext.resource.persistence.SerializableEObjectDescription) SerializableReferenceDescription(org.eclipse.xtext.resource.persistence.SerializableReferenceDescription) QualifiedName(org.eclipse.xtext.naming.QualifiedName) ArrayList(java.util.ArrayList) ExclusiveRange(org.eclipse.xtext.xbase.lib.ExclusiveRange)

Aggregations

ExclusiveRange (org.eclipse.xtext.xbase.lib.ExclusiveRange)16 Task (org.eclipse.xtext.tasks.Task)4 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)3 ArrayList (java.util.ArrayList)2 URI (org.eclipse.emf.common.util.URI)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 LightweightTypeReference (org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference)2 Test (org.junit.Test)2 HashSet (java.util.HashSet)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 EObject (org.eclipse.emf.ecore.EObject)1 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)1 AnnotationReference (org.eclipse.xtend.lib.macro.declaration.AnnotationReference)1 EnumerationValueDeclaration (org.eclipse.xtend.lib.macro.declaration.EnumerationValueDeclaration)1 ParameterDeclaration (org.eclipse.xtend.lib.macro.declaration.ParameterDeclaration)1 JvmAnnotationReference (org.eclipse.xtext.common.types.JvmAnnotationReference)1 JvmEnumerationLiteral (org.eclipse.xtext.common.types.JvmEnumerationLiteral)1 JvmMember (org.eclipse.xtext.common.types.JvmMember)1