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

The following examples show how to use org.eclipse.xtext.xbase.lib.IterableExtensions#filter() . 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: ActiveAnnotationContextProvider.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
protected void registerMacroAnnotations(final XtendAnnotationTarget candidate, final IAcceptor<Pair<JvmAnnotationType, XAnnotation>> acceptor) {
  final Function1<XAnnotation, Boolean> _function = (XAnnotation it) -> {
    return Boolean.valueOf(this._xAnnotationExtensions.isProcessed(it));
  };
  Iterable<XAnnotation> _filter = IterableExtensions.<XAnnotation>filter(candidate.getAnnotations(), _function);
  for (final XAnnotation annotation : _filter) {
    {
      final JvmAnnotationType activeAnnotationDeclaration = this._xAnnotationExtensions.tryFindAnnotationType(annotation);
      if ((activeAnnotationDeclaration != null)) {
        boolean _isValid = this.isValid(annotation, activeAnnotationDeclaration);
        if (_isValid) {
          Pair<JvmAnnotationType, XAnnotation> _mappedTo = Pair.<JvmAnnotationType, XAnnotation>of(activeAnnotationDeclaration, annotation);
          acceptor.accept(_mappedTo);
        }
      }
    }
  }
}
 
Example 2
Source File: WebIntegrationFragment.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void checkConfiguration(final Issues issues) {
  super.checkConfiguration(issues);
  boolean _isSet = this.framework.isSet();
  boolean _not = (!_isSet);
  if (_not) {
    issues.addError("The property \'framework\' is required.");
  }
  final Function1<String, Boolean> _function = (String it) -> {
    return Boolean.valueOf(this.suppressedPatterns.contains(it));
  };
  Iterable<String> _filter = IterableExtensions.<String>filter(this.enabledPatterns, _function);
  for (final String pattern : _filter) {
    issues.addError((("The pattern \'" + pattern) + "\' cannot be enabled and suppressed."));
  }
}
 
Example 3
Source File: JvmModelGenerator.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected Iterable<JvmMember> _getMembersToBeCompiled(final JvmEnumerationType type) {
  Iterable<JvmMember> _xblockexpression = null;
  {
    String _identifier = type.getIdentifier();
    String _plus = (_identifier + ".");
    String _plus_1 = (_plus + "valueOf(java.lang.String)");
    String _identifier_1 = type.getIdentifier();
    String _plus_2 = (_identifier_1 + ".");
    String _plus_3 = (_plus_2 + "values()");
    final Set<String> syntheticEnumMethods = Collections.<String>unmodifiableSet(CollectionLiterals.<String>newHashSet(_plus_1, _plus_3));
    final Function1<JvmMember, Boolean> _function = (JvmMember it) -> {
      return Boolean.valueOf((!((it instanceof JvmOperation) && syntheticEnumMethods.contains(it.getIdentifier()))));
    };
    _xblockexpression = IterableExtensions.<JvmMember>filter(type.getMembers(), _function);
  }
  return _xblockexpression;
}
 
Example 4
Source File: XbaseReferenceUpdater.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected Iterable<IReferenceDescription> getImportTypeReferences(Iterable<IReferenceDescription> referenceDescriptions) {
	return IterableExtensions.filter(referenceDescriptions, new Functions.Function1<IReferenceDescription, Boolean>() {

		@Override
		public Boolean apply(IReferenceDescription p) {
			return isImportTypeReference(p);
		}
		
	});
}
 
Example 5
Source File: N4ClassifierDeclarationImpl.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public EList<N4MemberDeclaration> getOwnedMembers() {
	final Function1<N4MemberDeclaration, Boolean> _function = new Function1<N4MemberDeclaration, Boolean>() {
		public Boolean apply(final N4MemberDeclaration it) {
			boolean _isCallableConstructor = it.isCallableConstructor();
			return Boolean.valueOf((!_isCallableConstructor));
		}
	};
	final Iterable<N4MemberDeclaration> methods = IterableExtensions.<N4MemberDeclaration>filter(Iterables.<N4MemberDeclaration>filter(this.getOwnedMembersRaw(), N4MemberDeclaration.class), _function);
	List<N4MemberDeclaration> _list = IterableExtensions.<N4MemberDeclaration>toList(methods);
	return new BasicEList<N4MemberDeclaration>(_list);
}
 
Example 6
Source File: Ecore2XtextExtensions.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public static Iterable<EClass> subClasses(final EClass it) {
  Iterable<EClass> _xifexpression = null;
  EPackage _ePackage = it.getEPackage();
  boolean _tripleEquals = (_ePackage == null);
  if (_tripleEquals) {
    _xifexpression = CollectionLiterals.<EClass>emptyList();
  } else {
    final Function1<EClass, Boolean> _function = (EClass c) -> {
      return Boolean.valueOf(c.getEAllSuperTypes().contains(it));
    };
    _xifexpression = IterableExtensions.<EClass>filter(Iterables.<EClass>filter(it.getEPackage().getEClassifiers(), EClass.class), _function);
  }
  return _xifexpression;
}
 
Example 7
Source File: DelegateProcessor.java    From xtext-lib with Eclipse Public License 2.0 5 votes vote down vote up
public Iterable<? extends MemberDeclaration> getDelegates(final TypeDeclaration it) {
  final Function1<MemberDeclaration, Boolean> _function = (MemberDeclaration it_1) -> {
    AnnotationReference _findAnnotation = it_1.findAnnotation(this.context.findTypeGlobally(Delegate.class));
    return Boolean.valueOf((_findAnnotation != null));
  };
  return IterableExtensions.filter(it.getDeclaredMembers(), _function);
}
 
Example 8
Source File: PackageImportHyperlinkHelper.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected EObject getOriginTarget(EObject target) {
	Iterable<EObject> originTraces = IterableExtensions.filter(tracing.getOriginTraces(target), EObject.class);
	Iterator<EObject> iter = originTraces.iterator();
	if (iter.hasNext()) {
		target = iter.next();
	} else if (target instanceof Property) {
		Type type = ((Property) target).getType();
		if (statechartUtil.isOriginScope(type)) {
			target = statechartUtil.getOriginScope(type);
		}
	}
	return target;
}
 
Example 9
Source File: AntlrContentAssistGrammarGenerator.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected CharSequence compileRules(final Grammar g, final AntlrOptions options) {
  StringConcatenation _builder = new StringConcatenation();
  {
    List<ParserRule> _allParserRules = GrammarUtil.allParserRules(g);
    List<EnumRule> _allEnumRules = GrammarUtil.allEnumRules(g);
    Iterable<AbstractRule> _plus = Iterables.<AbstractRule>concat(_allParserRules, _allEnumRules);
    Collection<? extends AbstractElement> _allAlternatives = GrammarUtil.getAllAlternatives(g);
    Iterable<EObject> _plus_1 = Iterables.<EObject>concat(_plus, _allAlternatives);
    Collection<? extends AbstractElement> _allGroups = GrammarUtil.getAllGroups(g);
    Iterable<EObject> _plus_2 = Iterables.<EObject>concat(_plus_1, _allGroups);
    Collection<? extends AbstractElement> _allUnorderedGroups = GrammarUtil.getAllUnorderedGroups(g);
    Iterable<EObject> _plus_3 = Iterables.<EObject>concat(_plus_2, _allUnorderedGroups);
    Collection<? extends AbstractElement> _allAssignments = GrammarUtil.getAllAssignments(g);
    final Function1<EObject, Boolean> _function = (EObject it) -> {
      return Boolean.valueOf(this._grammarAccessExtensions.isCalled(GrammarUtil.containingRule(it), g));
    };
    Iterable<EObject> _filter = IterableExtensions.<EObject>filter(Iterables.<EObject>concat(_plus_3, _allAssignments), _function);
    for(final EObject rule : _filter) {
      _builder.newLine();
      CharSequence _compileRule = this.compileRule(rule, g, options);
      _builder.append(_compileRule);
      _builder.newLineIfNotEmpty();
    }
  }
  {
    boolean _isCombinedGrammar = this.isCombinedGrammar();
    if (_isCombinedGrammar) {
      CharSequence _compileTerminalRules = this.compileTerminalRules(g, options);
      _builder.append(_compileTerminalRules);
      _builder.newLineIfNotEmpty();
    }
  }
  return _builder;
}
 
Example 10
Source File: GrammarKeywordAccessFragment2.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** 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 11
Source File: XtendGenerator.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Iterable<JvmMember> _getMembersToBeCompiled(final JvmGenericType it) {
  Iterable<JvmMember> _xifexpression = null;
  boolean _isLocal = it.isLocal();
  if (_isLocal) {
    final Function1<JvmMember, Boolean> _function = (JvmMember it_1) -> {
      return Boolean.valueOf((it_1 instanceof JvmOperation));
    };
    _xifexpression = IterableExtensions.<JvmMember>filter(it.getMembers(), _function);
  } else {
    _xifexpression = this._getMembersToBeCompiled(((JvmDeclaredType) it));
  }
  return _xifexpression;
}
 
Example 12
Source File: JvmModelGenerator.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected Iterable<JvmMember> _getMembersToBeCompiled(final JvmGenericType it) {
  Iterable<JvmMember> _xifexpression = null;
  boolean _isAnonymous = it.isAnonymous();
  if (_isAnonymous) {
    final Function1<JvmMember, Boolean> _function = (JvmMember it_1) -> {
      return Boolean.valueOf((!(it_1 instanceof JvmConstructor)));
    };
    _xifexpression = IterableExtensions.<JvmMember>filter(it.getMembers(), _function);
  } else {
    _xifexpression = this._getMembersToBeCompiled(((JvmDeclaredType) it));
  }
  return _xifexpression;
}
 
Example 13
Source File: XbaseReferenceUpdater.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected Iterable<IReferenceDescription> getNotImportTypeReferences(Iterable<IReferenceDescription> referenceDescriptions) {
	return IterableExtensions.filter(referenceDescriptions, new Functions.Function1<IReferenceDescription, Boolean>() {

		@Override
		public Boolean apply(IReferenceDescription p) {
			return !isImportTypeReference(p);
		}
		
	});
}
 
Example 14
Source File: N4ClassifierDefinitionImpl.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- 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 15
Source File: N4ClassifierDefinitionImpl.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public EList<N4MemberDeclaration> getOwnedMembers() {
	final Function1<N4MemberDeclaration, Boolean> _function = new Function1<N4MemberDeclaration, Boolean>() {
		public Boolean apply(final N4MemberDeclaration it) {
			boolean _isCallableConstructor = it.isCallableConstructor();
			return Boolean.valueOf((!_isCallableConstructor));
		}
	};
	final Iterable<N4MemberDeclaration> methods = IterableExtensions.<N4MemberDeclaration>filter(Iterables.<N4MemberDeclaration>filter(this.getOwnedMembersRaw(), N4MemberDeclaration.class), _function);
	List<N4MemberDeclaration> _list = IterableExtensions.<N4MemberDeclaration>toList(methods);
	return new BasicEList<N4MemberDeclaration>(_list);
}
 
Example 16
Source File: JavaASTFlattener.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
private Iterable<Comment> unAssignedComments(final CompilationUnit cu) {
  final Function1<Comment, Boolean> _function = (Comment c) -> {
    return Boolean.valueOf(((!(c.isDocComment() && (c.getParent() != null))) && this.notAssigned(c)));
  };
  return IterableExtensions.<Comment>filter(cu.getCommentList(), _function);
}
 
Example 17
Source File: DataProcessor.java    From xtext-lib with Eclipse Public License 2.0 4 votes vote down vote up
public Iterable<? extends FieldDeclaration> getDataFields(final ClassDeclaration it) {
  final Function1<FieldDeclaration, Boolean> _function = (FieldDeclaration it_1) -> {
    return Boolean.valueOf(((!it_1.isStatic()) && this.context.isThePrimaryGeneratedJavaElement(it_1)));
  };
  return IterableExtensions.filter(it.getDeclaredFields(), _function);
}
 
Example 18
Source File: Ecore2XtextExtensions.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public static Iterable<EReference> allContainmentReferences(final EClass it) {
  final Function1<EReference, Boolean> _function = (EReference f) -> {
    return Boolean.valueOf(f.isContainment());
  };
  return IterableExtensions.<EReference>filter(Iterables.<EReference>filter(Ecore2XtextExtensions.inlinedFeatures(it), EReference.class), _function);
}
 
Example 19
Source File: Ecore2XtextExtensions.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public static Iterable<EStructuralFeature> prefixFeatures(final EClass it) {
  final Function1<EStructuralFeature, Boolean> _function = (EStructuralFeature f) -> {
    return Boolean.valueOf((Ecore2XtextExtensions.needsAssignment(f) && Ecore2XtextExtensions.isPrefixBooleanFeature(f)));
  };
  return IterableExtensions.<EStructuralFeature>filter(it.getEAllStructuralFeatures(), _function);
}
 
Example 20
Source File: AbstractCodeBuilder.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
protected ISourceAppender appendTypeParameters(final ISourceAppender appendable, final List<JvmTypeParameter> typeParameters) {
  ISourceAppender _xblockexpression = null;
  {
    final Iterator<JvmTypeParameter> iterator = typeParameters.iterator();
    boolean _hasNext = iterator.hasNext();
    if (_hasNext) {
      appendable.append("<");
      do {
        {
          final JvmTypeParameter typeParameter = iterator.next();
          appendable.append(typeParameter.getName());
          final Function1<JvmUpperBound, Boolean> _function = (JvmUpperBound it) -> {
            String _identifier = it.getTypeReference().getIdentifier();
            return Boolean.valueOf((!Objects.equal(_identifier, "java.lang.Object")));
          };
          final Iterable<JvmUpperBound> upperBounds = IterableExtensions.<JvmUpperBound>filter(Iterables.<JvmUpperBound>filter(typeParameter.getConstraints(), JvmUpperBound.class), _function);
          boolean _isEmpty = IterableExtensions.isEmpty(upperBounds);
          boolean _not = (!_isEmpty);
          if (_not) {
            appendable.append(" extends ");
            boolean isFirst = true;
            final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, this.context);
            for (final JvmUpperBound upperBound : upperBounds) {
              {
                if ((!isFirst)) {
                  appendable.append(" & ");
                }
                isFirst = false;
                this.appendType(appendable, owner.toLightweightTypeReference(upperBound.getTypeReference()), "Object");
              }
            }
          }
          boolean _hasNext_1 = iterator.hasNext();
          if (_hasNext_1) {
            appendable.append(",");
          }
        }
      } while(iterator.hasNext());
      appendable.append("> ");
    }
    _xblockexpression = appendable;
  }
  return _xblockexpression;
}