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
Source File: RuntimeProjectDescriptor.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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
Source File: NoBacktrackGrammarCodeElementExtractor.java    From sarl with Apache License 2.0 6 votes vote down vote up
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
Source File: AccessorsProcessor.java    From xtext-lib with Eclipse Public License 2.0 5 votes vote down vote up
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 4
Source File: FjTestsForLambdas.java    From xsemantics with Eclipse Public License 1.0 5 votes vote down vote up
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 5
Source File: VersionedParameterizedTypeRefStructural_IMImpl.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- 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 6
Source File: GrammarAccessExtensions.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
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 7
Source File: FjTestsForLambdas.java    From xsemantics with Eclipse Public License 1.0 5 votes vote down vote up
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 8
Source File: StructuralTypeRefImpl.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- 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 9
Source File: XtendMemberDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@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 10
Source File: ValidatorFragment2.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @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
Source File: ThisTypeRefStructuralImpl.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- 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 12
Source File: N4SetterDeclarationImpl.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- 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 13
Source File: N4SetterDeclarationImpl.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- 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 14
Source File: N4FieldAccessorImpl.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- 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 15
Source File: XtendConstructorDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@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 16
Source File: N4MemberAnnotationListImpl.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- 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 17
Source File: ASTFlattenerUtils.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
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());
    }))));
}
 
Example 18
Source File: XtextAntlrGeneratorFragment2.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
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 19
Source File: AntlrContentAssistGrammarGenerator.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
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 20
Source File: ASTFlattenerUtils.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
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);
}