Java Code Examples for org.eclipse.xtext.xbase.lib.IterableExtensions#toList()

The following examples show how to use org.eclipse.xtext.xbase.lib.IterableExtensions#toList() . 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
protected List<SemanticHighlightingInformation> appendEmptyLineTokens(final List<SemanticHighlightingInformation> infos, final Document document) {
  final int lineCount = document.getLineCount();
  final Function<SemanticHighlightingInformation, Integer> _function = (SemanticHighlightingInformation it) -> {
    return Integer.valueOf(it.getLine());
  };
  final HashMap<Integer, SemanticHighlightingInformation> tokens = Maps.<Integer, SemanticHighlightingInformation>newHashMap(Maps.<Integer, SemanticHighlightingInformation>uniqueIndex(infos, _function));
  ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, lineCount, true);
  for (final Integer i : _doubleDotLessThan) {
    boolean _containsKey = tokens.containsKey(i);
    boolean _not = (!_containsKey);
    if (_not) {
      SemanticHighlightingInformation _semanticHighlightingInformation = new SemanticHighlightingInformation((i).intValue(), null);
      tokens.put(i, _semanticHighlightingInformation);
    }
  }
  return IterableExtensions.<SemanticHighlightingInformation>toList(tokens.values());
}
 
Example 2
@Override
public Iterable<? extends ResolvedTypeParameter> getResolvedTypeParameters() {
  ArrayList<ResolvedTypeParameterImpl> _xblockexpression = null;
  {
    final ArrayList<ResolvedTypeParameterImpl> resolvedTypeParameters = CollectionLiterals.<ResolvedTypeParameterImpl>newArrayList();
    for (int i = 0; (i < this.getDelegate().getResolvedTypeParameters().size()); i++) {
      TypeParameterDeclaration _typeParameterDeclaration = this.getCompilationUnit().toTypeParameterDeclaration(this.getDelegate().getResolvedTypeParameters().get(i));
      final Function1<LightweightTypeReference, TypeReference> _function = (LightweightTypeReference it) -> {
        return this.getCompilationUnit().toTypeReference(it);
      };
      List<TypeReference> _list = IterableExtensions.<TypeReference>toList(ListExtensions.<LightweightTypeReference, TypeReference>map(this.getDelegate().getResolvedTypeParameterConstraints(i), _function));
      ResolvedTypeParameterImpl _resolvedTypeParameterImpl = new ResolvedTypeParameterImpl(_typeParameterDeclaration, _list);
      resolvedTypeParameters.add(_resolvedTypeParameterImpl);
    }
    _xblockexpression = resolvedTypeParameters;
  }
  return _xblockexpression;
}
 
Example 3
private static void allAssignedClassifiers(final EClass eClazz, final Collection<EClassifier> acceptor) {
  final Function1<EStructuralFeature, Boolean> _function = (EStructuralFeature f) -> {
    return Boolean.valueOf(Ecore2XtextExtensions.needsAssignment(f));
  };
  final Function1<EStructuralFeature, EClassifier> _function_1 = (EStructuralFeature it) -> {
    return it.getEType();
  };
  final List<EClassifier> classifiers = IterableExtensions.<EClassifier>toList(IterableExtensions.<EStructuralFeature, EClassifier>map(IterableExtensions.<EStructuralFeature>filter(eClazz.getEAllStructuralFeatures(), _function), _function_1));
  Iterable<EClass> _subClasses = Ecore2XtextExtensions.subClasses(eClazz);
  Iterables.<EClassifier>addAll(classifiers, _subClasses);
  classifiers.removeAll(acceptor);
  boolean _isEmpty = classifiers.isEmpty();
  if (_isEmpty) {
    return;
  } else {
    Iterables.<EClassifier>addAll(acceptor, classifiers);
    final Consumer<EClass> _function_2 = (EClass c) -> {
      Ecore2XtextExtensions.allAssignedClassifiers(c, acceptor);
    };
    Iterables.<EClass>filter(classifiers, EClass.class).forEach(_function_2);
  }
}
 
Example 4
private static String getPackageName(final String qualifiedName, final boolean strict) {
  final List<String> segments = IterableExtensions.<String>toList(Splitter.on(".").split(qualifiedName));
  int _size = segments.size();
  boolean _equals = (_size == 1);
  if (_equals) {
    return "";
  }
  if (strict) {
    int _length = ((Object[])Conversions.unwrapArray(segments, Object.class)).length;
    int _minus = (_length - 1);
    final List<String> packageSegments = segments.subList(0, _minus);
    final Function1<String, Boolean> _function = (String it) -> {
      return Boolean.valueOf(Character.isUpperCase(it.charAt(0)));
    };
    boolean _isEmpty = IterableExtensions.isEmpty(IterableExtensions.<String>filter(packageSegments, _function));
    boolean _not = (!_isEmpty);
    if (_not) {
      throw new IllegalArgumentException((("Cannot determine the package name of \'" + qualifiedName) + "\'. Please use the TypeReference(packageName, className) constructor"));
    }
    return IterableExtensions.join(packageSegments, ".");
  } else {
    int _length_1 = ((Object[])Conversions.unwrapArray(segments, Object.class)).length;
    int _minus_1 = (_length_1 - 1);
    List<String> packageSegments_1 = segments.subList(0, _minus_1);
    while ((!packageSegments_1.isEmpty())) {
      boolean _isUpperCase = Character.isUpperCase(IterableExtensions.<String>last(packageSegments_1).charAt(0));
      if (_isUpperCase) {
        final List<String> _converted_packageSegments_1 = (List<String>)packageSegments_1;
        int _length_2 = ((Object[])Conversions.unwrapArray(_converted_packageSegments_1, Object.class)).length;
        int _minus_2 = (_length_2 - 1);
        packageSegments_1 = packageSegments_1.subList(0, _minus_2);
      } else {
        return IterableExtensions.join(packageSegments_1, ".");
      }
    }
    return "";
  }
}
 
Example 5
protected List<AbstractRule> getExportedRulesFromGrammar() {
  List<AbstractRule> _xblockexpression = null;
  {
    final HashSet<EClassifier> alreadyCollected = CollectionLiterals.<EClassifier>newHashSet();
    final Function1<AbstractRule, Boolean> _function = (AbstractRule it) -> {
      return Boolean.valueOf((this.isExported(it) && alreadyCollected.add(it.getType().getClassifier())));
    };
    _xblockexpression = IterableExtensions.<AbstractRule>toList(IterableExtensions.<AbstractRule>filter(this.getGrammar().getRules(), _function));
  }
  return _xblockexpression;
}
 
Example 6
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public EList<N4SetterDeclaration> getOwnedSetters() {
	final Iterable<N4SetterDeclaration> setters = Iterables.<N4SetterDeclaration>filter(this.getOwnedMembersRaw(), N4SetterDeclaration.class);
	List<N4SetterDeclaration> _list = IterableExtensions.<N4SetterDeclaration>toList(setters);
	return new BasicEList<N4SetterDeclaration>(_list);
}
 
Example 7
/** Returns all grammars from the hierarchy that are used from rules of this grammar.
 *
 * @param grammar the grammar.
 * @return the used grammars.
 */
protected static List<Grammar> getEffectivelyUsedGrammars(final Grammar grammar) {
	final List<AbstractRule> allRules = GrammarUtil.allRules(grammar);
	final List<Grammar> map = ListExtensions.<AbstractRule, Grammar>map(allRules, it -> GrammarUtil.getGrammar(it));
	final Iterable<Grammar> filter = IterableExtensions.<Grammar>filter(map, it -> Boolean.valueOf(it != grammar));
	final Set<Grammar> set = IterableExtensions.<Grammar>toSet(filter);
	return IterableExtensions.<Grammar>toList(set);
}
 
Example 8
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public EList<N4MethodDeclaration> getOwnedMethods() {
	final Function1<N4MethodDeclaration, Boolean> _function = new Function1<N4MethodDeclaration, Boolean>() {
		public Boolean apply(final N4MethodDeclaration it) {
			return Boolean.valueOf(((!it.isConstructor()) && (!it.isCallableConstructor())));
		}
	};
	final Iterable<N4MethodDeclaration> methods = IterableExtensions.<N4MethodDeclaration>filter(Iterables.<N4MethodDeclaration>filter(this.getOwnedMembersRaw(), N4MethodDeclaration.class), _function);
	List<N4MethodDeclaration> _list = IterableExtensions.<N4MethodDeclaration>toList(methods);
	return new BasicEList<N4MethodDeclaration>(_list);
}
 
Example 9
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public EList<N4FieldDeclaration> getOwnedFields() {
	final Iterable<N4FieldDeclaration> fields = Iterables.<N4FieldDeclaration>filter(this.getOwnedMembersRaw(), N4FieldDeclaration.class);
	List<N4FieldDeclaration> _list = IterableExtensions.<N4FieldDeclaration>toList(fields);
	return new BasicEList<N4FieldDeclaration>(_list);
}
 
Example 10
@Override
public Iterable<? extends TypeReference> getUpperBounds() {
  final Function1<JvmUpperBound, TypeReference> _function = (JvmUpperBound it) -> {
    return this.getCompilationUnit().toTypeReference(it.getTypeReference());
  };
  return IterableExtensions.<TypeReference>toList(IterableExtensions.<JvmUpperBound, TypeReference>map(Iterables.<JvmUpperBound>filter(this.getDelegate().getConstraints(), JvmUpperBound.class), _function));
}
 
Example 11
private void writeImportedNames(SerializableResourceDescription resourceDescription, DataOutput output)
		throws IOException {

	List<QualifiedName> importedNames = IterableExtensions.toList(resourceDescription.getImportedNames());
	output.writeInt(importedNames.size());
	for (QualifiedName importedName : importedNames) {
		writeQualifiedName(importedName, output);
	}
}
 
Example 12
Source Project: xtext-core   File: Indexer.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Process the changed resources.
 */
protected List<IResourceDescription.Delta> getDeltasForChangedResources(Iterable<URI> affectedUris,
		ResourceDescriptionsData oldIndex, BuildContext context) {
	try {
		compilerPhases.setIndexing(context.getResourceSet(), true);
		// Since context.executeClustered, we can avoid a copy due of the list due to the impl detail of
		// IterableExtensions.toList
		return IterableExtensions
				.toList(context.executeClustered(affectedUris, it -> addToIndex(it, true, oldIndex, context)));
	} finally {
		compilerPhases.setIndexing(context.getResourceSet(), false);
	}
}
 
Example 13
public boolean hasFinalFieldsConstructor(final MutableTypeDeclaration cls) {
  boolean _xblockexpression = false;
  {
    final ArrayList<TypeReference> expectedTypes = this.getFinalFieldsConstructorArgumentTypes(cls);
    final Function1<MutableConstructorDeclaration, Boolean> _function = (MutableConstructorDeclaration it) -> {
      final Function1<MutableParameterDeclaration, TypeReference> _function_1 = (MutableParameterDeclaration it_1) -> {
        return it_1.getType();
      };
      List<TypeReference> _list = IterableExtensions.<TypeReference>toList(IterableExtensions.map(it.getParameters(), _function_1));
      return Boolean.valueOf(Objects.equal(_list, expectedTypes));
    };
    _xblockexpression = IterableExtensions.exists(cls.getDeclaredConstructors(), _function);
  }
  return _xblockexpression;
}
 
Example 14
@Test
public void testIntegrationWithData() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor");
    _builder.newLine();
    _builder.append("import org.eclipse.xtend.lib.annotations.Data");
    _builder.newLine();
    _builder.append("@FinalFieldsConstructor @Data class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val int a");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val String b");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String source = _builder.toString();
    this._validationTestHelper.assertNoErrors(this.clazz(source));
    final IAcceptor<CompilationTestHelper.Result> _function = (CompilationTestHelper.Result it) -> {
      final Function1<Constructor<?>, Boolean> _function_1 = (Constructor<?> it_1) -> {
        List<Class<?>> _list = IterableExtensions.<Class<?>>toList(((Iterable<Class<?>>)Conversions.doWrapArray(it_1.getParameterTypes())));
        return Boolean.valueOf(Objects.equal(_list, Collections.<Class<? extends Object>>unmodifiableList(CollectionLiterals.<Class<? extends Object>>newArrayList(int.class, String.class))));
      };
      Assert.assertTrue(
        IterableExtensions.<Constructor<?>>exists(((Iterable<Constructor<?>>)Conversions.doWrapArray(it.getCompiledClass().getDeclaredConstructors())), _function_1));
    };
    this.compilationTestHelper.compile(source, _function);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 15
@Override
public ConstructorDeclaration findDeclaredConstructor(final TypeReference... parameterTypes) {
  final Function1<ConstructorDeclaration, Boolean> _function = (ConstructorDeclaration constructor) -> {
    final Function1<ParameterDeclaration, TypeReference> _function_1 = (ParameterDeclaration it) -> {
      return it.getType();
    };
    List<TypeReference> _list = IterableExtensions.<TypeReference>toList(IterableExtensions.map(constructor.getParameters(), _function_1));
    List<TypeReference> _list_1 = IterableExtensions.<TypeReference>toList(((Iterable<TypeReference>)Conversions.doWrapArray(parameterTypes)));
    return Boolean.valueOf(Objects.equal(_list, _list_1));
  };
  return IterableExtensions.findFirst(this.getDeclaredConstructors(), _function);
}
 
Example 16
@Override
protected Iterable<IReferenceDescription> getNotImportTypeReferences(final Iterable<IReferenceDescription> referenceDescriptions) {
  List<IReferenceDescription> _xblockexpression = null;
  {
    final List<IReferenceDescription> result = IterableExtensions.<IReferenceDescription>toList(super.getNotImportTypeReferences(referenceDescriptions));
    final String localClassesFragmentPart = "@localClasses.";
    final Comparator<IReferenceDescription> _function = (IReferenceDescription o1, IReferenceDescription o2) -> {
      final String f1 = o1.getSourceEObjectUri().fragment();
      final String f2 = o2.getSourceEObjectUri().fragment();
      if ((f1.contains(localClassesFragmentPart) && f2.contains(localClassesFragmentPart))) {
        return f1.compareTo(f2);
      }
      boolean _contains = f1.contains(localClassesFragmentPart);
      if (_contains) {
        return 1;
      }
      boolean _contains_1 = f2.contains(localClassesFragmentPart);
      if (_contains_1) {
        return (-1);
      }
      return f1.compareTo(f2);
    };
    result.sort(_function);
    _xblockexpression = result;
  }
  return _xblockexpression;
}
 
Example 17
Source Project: xtext-xtend   File: Case_3.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public List<Character> testFeatureCall_03() {
  List<Character> _xblockexpression = null;
  {
    char[] _charArray = "abc".toCharArray();
    List<Character> x = IterableExtensions.<Character>toList(((Iterable<Character>) Conversions.doWrapArray(_charArray)));
    _xblockexpression = x;
  }
  return _xblockexpression;
}
 
Example 18
public <T extends EClassifier> List<T> but(final Iterable<T> classes, final EClassifier it) {
  final List<T> retVal = IterableExtensions.<T>toList(classes);
  retVal.remove(it);
  return retVal;
}
 
Example 19
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public List<ExecutionVariable> getAllVariables() {
	return IterableExtensions.<ExecutionVariable>toList(Iterables.<ExecutionVariable>filter(this.getAllSlots(), ExecutionVariable.class));
}
 
Example 20
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public List<ExecutionEvent> getAllEvents() {
	return IterableExtensions.<ExecutionEvent>toList(Iterables.<ExecutionEvent>filter(this.getAllSlots(), ExecutionEvent.class));
}