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

The following examples show how to use org.eclipse.xtext.xbase.lib.IterableExtensions#exists() . 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
@Override
public Set<String> getDevelopmentBundles() {
  final LinkedHashSet<String> result = CollectionLiterals.<String>newLinkedHashSet(
    "org.eclipse.xtext.xbase", 
    "org.eclipse.xtext.common.types", 
    "org.eclipse.xtext.xtext.generator", 
    "org.eclipse.emf.codegen.ecore", 
    "org.eclipse.emf.mwe.utils", 
    "org.eclipse.emf.mwe2.launch", 
    "org.eclipse.emf.mwe2.lib", 
    "org.objectweb.asm", 
    "org.apache.commons.logging", 
    "org.apache.log4j");
  boolean _isFromExistingEcoreModels = this.isFromExistingEcoreModels();
  if (_isFromExistingEcoreModels) {
    final Function1<EPackageInfo, Boolean> _function = (EPackageInfo it) -> {
      String _fileExtension = it.getGenmodelURI().fileExtension();
      return Boolean.valueOf(Objects.equal(_fileExtension, "xcore"));
    };
    boolean _exists = IterableExtensions.<EPackageInfo>exists(this.getConfig().getEcore2Xtext().getEPackageInfos(), _function);
    if (_exists) {
      result.add("org.eclipse.emf.ecore.xcore");
    }
  }
  return result;
}
 
Example 2
private <T> T visitConstructors(EObject grammarContainer, EObject container,
		Function4<? super CodeElementExtractor, ? super EObject, ? super EObject, ? super EClassifier, ? extends T> callback) {
	final Set<String> treatedConstructors = new HashSet<>();
	for (final Assignment expressionAssignment : IterableExtensions.filter(
			GrammarUtil.containedAssignments(container), passignment -> getCodeBuilderConfig()
			.getMemberBlockExpressionExtensionGrammarName().equals(passignment.getFeature()))) {
		// Get the container of the name assignment
		final EObject consContainer = getContainerInRule(grammarContainer, expressionAssignment);
		if (consContainer != null
			&& !IterableExtensions.exists(GrammarUtil.containedAssignments(consContainer),
				it -> getCodeBuilderConfig()
				.getMemberNameExtensionGrammarName().equals(it.getFeature()))) {
			final EClassifier classifier = getGeneratedTypeFor(consContainer);
			if (!treatedConstructors.contains(classifier.getName())) {
				treatedConstructors.add(classifier.getName());
				final T retVal = callback.apply(this, grammarContainer, consContainer, classifier);
				if (retVal != null) {
					return retVal;
				}
			}
		}
	}
	return null;
}
 
Example 3
protected Result<Boolean> applyRuleExistsSubtypeWithLambda(final RuleEnvironment G, final RuleApplicationTrace _trace_, final ClassType left, final ClassType right) throws RuleFailedException {
  final Function1<org.eclipse.xsemantics.example.fj.fj.Class, Boolean> _function = new Function1<org.eclipse.xsemantics.example.fj.fj.Class, Boolean>() {
    public Boolean apply(final org.eclipse.xsemantics.example.fj.fj.Class it) {
      /* G |- it <| right.classref */
      org.eclipse.xsemantics.example.fj.fj.Class _classref = right.getClassref();
      boolean _ruleinvocation = subclassSucceeded(G, _trace_, it, _classref);
      return Boolean.valueOf(_ruleinvocation);
    }
  };
  /* left.classref.superclasses.reverseView.exists[ G |- it <| right.classref ] */
  if (!IterableExtensions.<org.eclipse.xsemantics.example.fj.fj.Class>exists(ListExtensions.<org.eclipse.xsemantics.example.fj.fj.Class>reverseView(this.superclassesInternal(_trace_, left.getClassref())), _function)) {
    sneakyThrowRuleFailedException("left.classref.superclasses.reverseView.exists[ G |- it <| right.classref ]");
  }
  return new Result<Boolean>(true);
}
 
Example 4
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public boolean isDeclaredFinal() {
	final Function1<Annotation, Boolean> _function = new Function1<Annotation, Boolean>() {
		public Boolean apply(final Annotation it) {
			String _name = it.getName();
			return Boolean.valueOf(Objects.equal(_name, "Final"));
		}
	};
	return IterableExtensions.<Annotation>exists(this.getAnnotations(), _function);
}
 
Example 5
@Override
public boolean isVarArgs() {
  final Function1<XtendParameter, Boolean> _function = (XtendParameter it) -> {
    return Boolean.valueOf(this.isVarArgs());
  };
  return IterableExtensions.<XtendParameter>exists(this.getDelegate().getParameters(), _function);
}
 
Example 6
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public boolean isAbstract() {
	return ((((this.eContainer() instanceof N4InterfaceDeclaration) && (this.getBody() == null)) && 
		(!IterableExtensions.<Annotation>exists(this.getAnnotations(), new Function1<Annotation, Boolean>() {
			public Boolean apply(final Annotation it) {
				String _name = it.getName();
				return Boolean.valueOf(Objects.equal(_name, "ProvidesDefaultImplementation"));
			}
		}))) || this.isDeclaredAbstract());
}
 
Example 7
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public boolean isAbstract() {
	return ((((this.eContainer() instanceof N4InterfaceDeclaration) && (this.getBody() == null)) && 
		(!IterableExtensions.<Annotation>exists(this.getAnnotations(), new Function1<Annotation, Boolean>() {
			public Boolean apply(final Annotation it) {
				String _name = it.getName();
				return Boolean.valueOf(Objects.equal(_name, "ProvidesDefaultImplementation"));
			}
		}))) || this.isDeclaredAbstract());
}
 
Example 8
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public boolean isDeclaredFinal() {
	final Function1<Annotation, Boolean> _function = new Function1<Annotation, Boolean>() {
		public Boolean apply(final Annotation it) {
			String _name = it.getName();
			return Boolean.valueOf(Objects.equal(_name, "Final"));
		}
	};
	return IterableExtensions.<Annotation>exists(this.getAnnotations(), _function);
}
 
Example 9
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public boolean hasPostponedSubstitutionFor(final TypeVariable typeVar) {
	final Function1<TypeVariableMapping, Boolean> _function = new Function1<TypeVariableMapping, Boolean>() {
		public Boolean apply(final TypeVariableMapping m) {
			TypeVariable _typeVar = null;
			if (m!=null) {
				_typeVar=m.getTypeVar();
			}
			return Boolean.valueOf((_typeVar == typeVar));
		}
	};
	return IterableExtensions.<TypeVariableMapping>exists(this.getPostponedSubstitutions(), _function);
}
 
Example 10
/**
 * @since 2.14
 */
protected boolean isDeprecated(final AbstractRule rule) {
  final Function1<Annotation, Boolean> _function = (Annotation it) -> {
    return Boolean.valueOf(AnnotationNames.DEPRECATED.equals(it.getName()));
  };
  return IterableExtensions.<Annotation>exists(rule.getAnnotations(), _function);
}
 
Example 11
@Override
public boolean isDeprecated() {
  final Function1<XAnnotation, Boolean> _function = (XAnnotation it) -> {
    String _name = Deprecated.class.getName();
    JvmType _annotationType = it.getAnnotationType();
    String _identifier = null;
    if (_annotationType!=null) {
      _identifier=_annotationType.getIdentifier();
    }
    return Boolean.valueOf(Objects.equal(_name, _identifier));
  };
  return IterableExtensions.<XAnnotation>exists(this.getDelegate().getAnnotations(), _function);
}
 
Example 12
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public boolean hasPostponedSubstitutionFor(final TypeVariable typeVar) {
	final Function1<TypeVariableMapping, Boolean> _function = new Function1<TypeVariableMapping, Boolean>() {
		public Boolean apply(final TypeVariableMapping m) {
			TypeVariable _typeVar = null;
			if (m!=null) {
				_typeVar=m.getTypeVar();
			}
			return Boolean.valueOf((_typeVar == typeVar));
		}
	};
	return IterableExtensions.<TypeVariableMapping>exists(this.getPostponedSubstitutions(), _function);
}
 
Example 13
protected Result<Boolean> applyRuleExistsSubtypeWithLambda(final RuleEnvironment G, final RuleApplicationTrace _trace_, final ClassType left, final ClassType right) throws RuleFailedException {
  final Function1<org.eclipse.xsemantics.example.fj.fj.Class, Boolean> _function = new Function1<org.eclipse.xsemantics.example.fj.fj.Class, Boolean>() {
    public Boolean apply(final org.eclipse.xsemantics.example.fj.fj.Class it) {
      /* G |- it <| right.classref */
      org.eclipse.xsemantics.example.fj.fj.Class _classref = right.getClassref();
      boolean _ruleinvocation = subclassSucceeded(G, _trace_, it, _classref);
      return Boolean.valueOf(_ruleinvocation);
    }
  };
  /* left.classref.superclasses.reverseView.exists[ G |- it <| right.classref ] */
  if (!IterableExtensions.<org.eclipse.xsemantics.example.fj.fj.Class>exists(ListExtensions.<org.eclipse.xsemantics.example.fj.fj.Class>reverseView(this.superclassesInternal(_trace_, left.getClassref())), _function)) {
    sneakyThrowRuleFailedException("left.classref.superclasses.reverseView.exists[ G |- it <| right.classref ]");
  }
  return new Result<Boolean>(true);
}
 
Example 14
public boolean isCalled(final AbstractRule rule, final Grammar grammar) {
  boolean _xblockexpression = false;
  {
    final List<AbstractRule> allRules = GrammarUtil.allRules(grammar);
    _xblockexpression = ((allRules.indexOf(rule) == 0) || IterableExtensions.<RuleCall>exists(Iterables.<RuleCall>concat(ListExtensions.<AbstractRule, List<RuleCall>>map(allRules, ((Function1<AbstractRule, List<RuleCall>>) (AbstractRule it) -> {
      return GrammarUtil.containedRuleCalls(it);
    }))), ((Function1<RuleCall, Boolean>) (RuleCall ruleCall) -> {
      AbstractRule _rule = ruleCall.getRule();
      return Boolean.valueOf(Objects.equal(_rule, rule));
    })));
  }
  return _xblockexpression;
}
 
Example 15
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public boolean hasPostponedSubstitutionFor(final TypeVariable typeVar) {
	final Function1<TypeVariableMapping, Boolean> _function = new Function1<TypeVariableMapping, Boolean>() {
		public Boolean apply(final TypeVariableMapping m) {
			TypeVariable _typeVar = null;
			if (m!=null) {
				_typeVar=m.getTypeVar();
			}
			return Boolean.valueOf((_typeVar == typeVar));
		}
	};
	return IterableExtensions.<TypeVariableMapping>exists(this.getPostponedSubstitutions(), _function);
}
 
Example 16
public boolean hasGetter(final FieldDeclaration it) {
  final Function1<String, Boolean> _function = (String name) -> {
    MethodDeclaration _findDeclaredMethod = it.getDeclaringType().findDeclaredMethod(name);
    return Boolean.valueOf((_findDeclaredMethod != null));
  };
  return IterableExtensions.<String>exists(this.getPossibleGetterNames(it), _function);
}
 
Example 17
public boolean isStatic(final Iterable<IExtendedModifier> modifiers) {
  final Function1<Modifier, Boolean> _function = (Modifier it) -> {
    return Boolean.valueOf(it.isStatic());
  };
  return IterableExtensions.<Modifier>exists(Iterables.<Modifier>filter(modifiers, Modifier.class), _function);
}
 
Example 18
protected CharSequence _compileRule(final UnorderedGroup it, final Grammar grammar, final AntlrOptions options) {
  CharSequence _xblockexpression = null;
  {
    final Function1<AbstractElement, Boolean> _function = (AbstractElement it_1) -> {
      boolean _isOptionalCardinality = GrammarUtil.isOptionalCardinality(it_1);
      return Boolean.valueOf((!_isOptionalCardinality));
    };
    final boolean hasMandatoryContent = IterableExtensions.<AbstractElement>exists(it.getElements(), _function);
    StringConcatenation _builder = new StringConcatenation();
    String _contentAssistRuleName = AntlrGrammarGenUtil.getContentAssistRuleName(GrammarUtil.containingRule(it));
    _builder.append(_contentAssistRuleName);
    _builder.append("__");
    String _gaElementIdentifier = this._grammarAccessExtensions.gaElementIdentifier(AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it));
    _builder.append(_gaElementIdentifier);
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("@init {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("int stackSize = keepStackSize();");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("getUnorderedGroupHelper().enter(grammarAccess.");
    String _gaRuleElementAccessor = this._grammarAccessExtensions.gaRuleElementAccessor(AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it));
    _builder.append(_gaRuleElementAccessor, "\t\t");
    _builder.append(");");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append(":");
    _builder.newLine();
    _builder.append("\t");
    String _contentAssistRuleName_1 = AntlrGrammarGenUtil.getContentAssistRuleName(GrammarUtil.containingRule(it));
    _builder.append(_contentAssistRuleName_1, "\t");
    _builder.append("__");
    String _gaElementIdentifier_1 = this._grammarAccessExtensions.gaElementIdentifier(AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it));
    _builder.append(_gaElementIdentifier_1, "\t");
    _builder.append("__0");
    _builder.newLineIfNotEmpty();
    {
      if (hasMandatoryContent) {
        _builder.append("\t");
        _builder.append("{getUnorderedGroupHelper().canLeave(grammarAccess.");
        String _gaRuleElementAccessor_1 = this._grammarAccessExtensions.gaRuleElementAccessor(AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it));
        _builder.append(_gaRuleElementAccessor_1, "\t");
        _builder.append(")}?");
        _builder.newLineIfNotEmpty();
      } else {
        _builder.append("\t");
        _builder.append("?");
        _builder.newLine();
      }
    }
    _builder.append(";");
    _builder.newLine();
    _builder.append("finally {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("getUnorderedGroupHelper().leave(grammarAccess.");
    String _gaRuleElementAccessor_2 = this._grammarAccessExtensions.gaRuleElementAccessor(AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it));
    _builder.append(_gaRuleElementAccessor_2, "\t");
    _builder.append(");");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("restoreStackSize(stackSize);");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    CharSequence _ruleImpl = this.ruleImpl(it, grammar, options);
    _builder.append(_ruleImpl);
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    CharSequence _ruleImpl_1 = this.ruleImpl(it, grammar, options, 0);
    _builder.append(_ruleImpl_1);
    _builder.newLineIfNotEmpty();
    _xblockexpression = _builder;
  }
  return _xblockexpression;
}
 
Example 19
protected boolean hasSyntheticTerminalRule() {
  final Function1<TerminalRule, Boolean> _function = (TerminalRule it) -> {
    return Boolean.valueOf(this._syntheticTerminalDetector.isSyntheticTerminalRule(it));
  };
  return IterableExtensions.<TerminalRule>exists(GrammarUtil.allTerminalRules(this.getGrammar()), _function);
}
 
Example 20
public boolean isNotSupportedInnerType(final TypeDeclaration it) {
  return (((!it.isInterface()) && ((it.getParent() instanceof TypeDeclaration) || (it.getParent() instanceof Block))) && 
    (!IterableExtensions.<Modifier>exists(Iterables.<Modifier>filter(it.modifiers(), Modifier.class), ((Function1<Modifier, Boolean>) (Modifier it_1) -> {
      return Boolean.valueOf(it_1.isStatic());
    }))));
}