Java 类org.eclipse.xtext.xbase.lib.Functions.Function1 实例源码

项目:n4js    文件:TypeImpl.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public String getTypeAsString() {
    String _xifexpression = null;
    boolean _isGeneric = this.isGeneric();
    if (_isGeneric) {
        String _name = this.getName();
        String _plus = (_name + "<");
        final Function1<TypeVariable, String> _function = new Function1<TypeVariable, String>() {
            public String apply(final TypeVariable it) {
                return it.getTypeAsString();
            }
        };
        String _join = IterableExtensions.join(XcoreEListExtensions.<TypeVariable, String>map(this.getTypeVars(), _function), ",");
        String _plus_1 = (_plus + _join);
        _xifexpression = (_plus_1 + ">");
    }
    else {
        _xifexpression = this.getName();
    }
    return _xifexpression;
}
项目:n4js    文件:InternalTypeSystem.java   
protected Result<TypeRef> applyRuleUpperBoundUnionTypeExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final UnionTypeExpression U) throws RuleFailedException {
  TypeRef T = null; // output parameter
  final Function1<TypeRef, TypeRef> _function = (TypeRef it) -> {
    TypeRef _xblockexpression = null;
    {
      TypeRef E = null;
      /* G|~ it /\ E */
      Result<TypeRef> result = upperBoundInternal(G, _trace_, it);
      checkAssignableTo(result.getFirst(), TypeRef.class);
      E = (TypeRef) result.getFirst();

      _xblockexpression = E;
    }
    return _xblockexpression;
  };
  T = TypeUtils.createNonSimplifiedUnionType(
    ListExtensions.<TypeRef, TypeRef>map(U.getTypeRefs(), _function));
  TypeUtils.copyTypeModifiers(T, U);
  return new Result<TypeRef>(T);
}
项目:n4js    文件:InternalTypeSystem.java   
protected Result<TypeRef> applyRuleUpperBoundIntersectionTypeExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final IntersectionTypeExpression I) throws RuleFailedException {
  TypeRef T = null; // output parameter
  final Function1<TypeRef, TypeRef> _function = (TypeRef it) -> {
    TypeRef _xblockexpression = null;
    {
      TypeRef E = null;
      /* G|~ it /\ E */
      Result<TypeRef> result = upperBoundInternal(G, _trace_, it);
      checkAssignableTo(result.getFirst(), TypeRef.class);
      E = (TypeRef) result.getFirst();

      _xblockexpression = E;
    }
    return _xblockexpression;
  };
  T = TypeUtils.createNonSimplifiedIntersectionType(
    ListExtensions.<TypeRef, TypeRef>map(I.getTypeRefs(), _function));
  TypeUtils.copyTypeModifiers(T, I);
  return new Result<TypeRef>(T);
}
项目:n4js    文件:InternalTypeSystem.java   
protected Result<TypeRef> applyRuleLowerBoundUnionTypeExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final UnionTypeExpression U) throws RuleFailedException {
  TypeRef T = null; // output parameter
  final Function1<TypeRef, TypeRef> _function = (TypeRef it) -> {
    TypeRef _xblockexpression = null;
    {
      TypeRef E = null;
      /* G|~ it \/ E */
      Result<TypeRef> result = lowerBoundInternal(G, _trace_, it);
      checkAssignableTo(result.getFirst(), TypeRef.class);
      E = (TypeRef) result.getFirst();

      _xblockexpression = E;
    }
    return _xblockexpression;
  };
  T = TypeUtils.createNonSimplifiedUnionType(
    ListExtensions.<TypeRef, TypeRef>map(U.getTypeRefs(), _function));
  TypeUtils.copyTypeModifiers(T, U);
  return new Result<TypeRef>(T);
}
项目:n4js    文件:InternalTypeSystem.java   
protected Result<TypeRef> applyRuleLowerBoundIntersectionTypeExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final IntersectionTypeExpression I) throws RuleFailedException {
  TypeRef T = null; // output parameter
  final Function1<TypeRef, TypeRef> _function = (TypeRef it) -> {
    TypeRef _xblockexpression = null;
    {
      TypeRef E = null;
      /* G|~ it \/ E */
      Result<TypeRef> result = lowerBoundInternal(G, _trace_, it);
      checkAssignableTo(result.getFirst(), TypeRef.class);
      E = (TypeRef) result.getFirst();

      _xblockexpression = E;
    }
    return _xblockexpression;
  };
  T = TypeUtils.createNonSimplifiedIntersectionType(
    ListExtensions.<TypeRef, TypeRef>map(I.getTypeRefs(), _function));
  TypeUtils.copyTypeModifiers(T, I);
  return new Result<TypeRef>(T);
}
项目:n4js    文件:JSDocNodeImpl.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setMarker(final String theKey, final String value) {
    final Function1<Marker, Boolean> _function = new Function1<Marker, Boolean>() {
        public Boolean apply(final Marker it) {
            String _key = it.getKey();
            String _key_1 = it.getKey();
            return Boolean.valueOf(Objects.equal(_key, _key_1));
        }
    };
    Marker marker = IterableExtensions.<Marker>findFirst(this.getMarkers(), _function);
    if ((marker == null)) {
        marker = DomFactory.eINSTANCE.createMarker();
        marker.setKey(theKey);
        this.getMarkers().add(marker);
    }
    marker.setValue(value);
}
项目:gemoc-studio    文件:StateAspect.java   
protected static void _privk3_step(final StateAspectStateAspectProperties _self_, final State _self, final String inputString) {
  try {
    final Function1<Transition, Boolean> _function = (Transition t) -> {
      return Boolean.valueOf(inputString.startsWith(t.getInput()));
    };
    final Iterable<Transition> validTransitions = IterableExtensions.<Transition>filter(_self.getOutgoingTransitions(), _function);
    boolean _isEmpty = IterableExtensions.isEmpty(validTransitions);
    if (_isEmpty) {
      throw new Exception("No Transition");
    }
    int _size = IterableExtensions.size(validTransitions);
    boolean _greaterThan = (_size > 1);
    if (_greaterThan) {
      throw new Exception("Non Determinism");
    }
    TransitionAspect.fire(((Transition[])Conversions.unwrapArray(validTransitions, Transition.class))[0]);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:mochalog-sarl-beliefs    文件:BasicBeliefSocialisation.java   
@Override
public AgentContest organiseContest(EventSpace space, Scope<Address> scope, 
    BeliefQuery eligibilityQuery, List<Object> prize, long timeout, 
    ExperimentEvaluator<AgentContestBallot> evaluator,
    Function1<? super Set<UUID>, ? extends List<UUID>> winnerSelector)
{
    return new AgentContestImpl.Executor()
        .setSpace(space)
        .setAccessPrincipal(principal)
        .addSurveys(eligibilityQuery)
        .setSurveyScope(scope)
        .setPrize(prize)
        .setEvaluator(evaluator)
        .setWinnerSelector(winnerSelector)
        .endExperimentAfter(timeout)
        .execute();
}
项目:xtext-core    文件:AbstractCompletePrefixProviderTest.java   
private <T extends Object> Iterable<T> upTo(final Iterable<T> iter, final Object element) {
  abstract class __AbstractCompletePrefixProviderTest_1 implements Function1<T, Boolean> {
    boolean found;
  }

  __AbstractCompletePrefixProviderTest_1 ___AbstractCompletePrefixProviderTest_1 = new __AbstractCompletePrefixProviderTest_1() {
    {
      found = false;
    }
    @Override
    public Boolean apply(final T t) {
      if (this.found) {
        return Boolean.valueOf(false);
      }
      try {
        return Boolean.valueOf(true);
      } finally {
        boolean _equals = Objects.equal(t, element);
        this.found = _equals;
      }
    }
  };
  return IterableExtensions.<T>filter(iter, ___AbstractCompletePrefixProviderTest_1);
}
项目:xtext-core    文件:GrammarPDAProviderTest.java   
private void assertNoLeakedGrammarElements(final Grammar grammar, final Pda<ISerState, RuleCall> pda) {
  final Function1<ISerState, AbstractElement> _function = (ISerState it) -> {
    return it.getGrammarElement();
  };
  Iterable<AbstractElement> _filterNull = IterableExtensions.<AbstractElement>filterNull(IterableExtensions.<ISerState, AbstractElement>map(new NfaUtil().<ISerState>collect(pda), _function));
  for (final AbstractElement ele : _filterNull) {
    {
      final Grammar actual = GrammarUtil.getGrammar(ele);
      if ((actual != grammar)) {
        String _objPath = EmfFormatter.objPath(ele);
        String _plus = ("Element " + _objPath);
        String _plus_1 = (_plus + " leaked!");
        Assert.fail(_plus_1);
      }
    }
  }
}
项目:xtext-core    文件:AbstractLanguageServerTest.java   
protected Map<String, List<Diagnostic>> getDiagnostics() {
  try {
    final Function1<CancelIndicator, HashMap<String, List<Diagnostic>>> _function = (CancelIndicator it) -> {
      final HashMap<String, List<Diagnostic>> result = CollectionLiterals.<String, List<Diagnostic>>newHashMap();
      final Function1<Pair<String, Object>, Object> _function_1 = (Pair<String, Object> it_1) -> {
        return it_1.getValue();
      };
      Iterable<PublishDiagnosticsParams> _filter = Iterables.<PublishDiagnosticsParams>filter(ListExtensions.<Pair<String, Object>, Object>map(this.notifications, _function_1), PublishDiagnosticsParams.class);
      for (final PublishDiagnosticsParams diagnostic : _filter) {
        result.put(diagnostic.getUri(), diagnostic.getDiagnostics());
      }
      return result;
    };
    return this.languageServer.getRequestManager().<HashMap<String, List<Diagnostic>>>runRead(_function).get();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:xtext-core    文件:RequestManagerTest.java   
@Test(timeout = 1000)
public void testRunWriteAfterRead() {
  final Function1<CancelIndicator, Integer> _function = (CancelIndicator it) -> {
    return Integer.valueOf(this.sharedState.incrementAndGet());
  };
  final CompletableFuture<Integer> previsousRead = this.requestManager.<Integer>runRead(_function);
  final Function0<Object> _function_1 = () -> {
    return null;
  };
  final Function2<CancelIndicator, Object, Integer> _function_2 = (CancelIndicator $0, Object $1) -> {
    int _xblockexpression = (int) 0;
    {
      while (((this.sharedState.get() == 0) && (!previsousRead.isCancelled()))) {
      }
      _xblockexpression = this.sharedState.incrementAndGet();
    }
    return Integer.valueOf(_xblockexpression);
  };
  this.requestManager.<Object, Integer>runWrite(_function_1, _function_2).join();
  Assert.assertEquals(2, this.sharedState.get());
}
项目:xtext-lib    文件:DelegateProcessor.java   
public Set<TypeReference> getDelegatedInterfaces(final MemberDeclaration delegate) {
  Set<TypeReference> _xblockexpression = null;
  {
    final Set<TypeReference> interfacesOfDeclaringType = this.getImplementedInterfaces(this.context.newSelfTypeReference(delegate.getDeclaringType()));
    final Set<TypeReference> listedInterfaces = this.listedInterfaces(delegate);
    final Set<TypeReference> availableInterfaces = this.getImplementedInterfaces(this.getType(delegate));
    final Function1<TypeReference, Boolean> _function = new Function1<TypeReference, Boolean>() {
      @Override
      public Boolean apply(final TypeReference iface) {
        return Boolean.valueOf((interfacesOfDeclaringType.contains(iface) && (listedInterfaces.isEmpty() || IterableExtensions.<TypeReference>exists(listedInterfaces, new Function1<TypeReference, Boolean>() {
          @Override
          public Boolean apply(final TypeReference it) {
            return Boolean.valueOf(iface.isAssignableFrom(it));
          }
        }))));
      }
    };
    _xblockexpression = IterableExtensions.<TypeReference>toSet(IterableExtensions.<TypeReference>filter(availableInterfaces, _function));
  }
  return _xblockexpression;
}
项目:xtext-lib    文件:IteratorExtensionsTest.java   
@Test
public void testGroupBy__WhenCalculatedKeyNull() {
    List<String> names = new ArrayList<String>();
    names.add("Mueller");
    names.add("Schneider");
    names.add("Schmidt");
    names.add("Koch");
    Function1<String, String> computeKeys = new Function1<String, String>() {

        @Override
        public String apply(String p) {
            return p.contains("y") ? "y" : null;
        }
    };
    Map<String, List<String>> map = IteratorExtensions.groupBy(names.iterator(), computeKeys);
    Assert.assertEquals("Expected grouped map size", 1, map.size());
    Assert.assertTrue("Contains null as key", map.keySet().contains(null));
    Assert.assertEquals("Contains 4 entries for key null", 4, map.get(null).size());
}
项目:xtext-lib    文件:BaseIterablesIteratorsTest.java   
@Test public void testFindLast_exceptionInFilter() {
    final RuntimeException expectedException = new RuntimeException();
    Function1<Integer, Boolean> filter = new Functions.Function1<Integer, Boolean>() {
        @Override
        public Boolean apply(Integer p) {
            throw expectedException;
        }
    };
    for(IterableOrIterator testMe: testData(first, second, third)) {
        try {
            findLast(testMe, filter);
            fail("expected exception");
        } catch(RuntimeException e) {
            assertSame(expectedException, e);
        }
    }
}
项目:xtext-extras    文件:XbaseResourceDescriptionStrategyTest.java   
@Test
public void testNoReferenceDescriptionsForPackageFragments() {
  try {
    final XExpression expression = this.expression("java::lang::String::valueOf(\"\")");
    final Resource resource = expression.eResource();
    final IResourceDescription description = this.resourceDescriptionManager.getResourceDescription(resource);
    final Function1<IReferenceDescription, String> _function = (IReferenceDescription it) -> {
      return it.getTargetEObjectUri().toString();
    };
    final Set<String> referenceDescriptions = IterableExtensions.<String>toSet(IterableExtensions.<IReferenceDescription, String>map(description.getReferenceDescriptions(), _function));
    Assert.assertEquals(2, referenceDescriptions.size());
    final Set<String> expectation = Collections.<String>unmodifiableSet(CollectionLiterals.<String>newHashSet("java:/Objects/java.lang.String#java.lang.String", "java:/Objects/java.lang.String#java.lang.String.valueOf(java.lang.Object)"));
    Assert.assertEquals(expectation, referenceDescriptions);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:xtext-extras    文件:JvmModelGenerator.java   
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;
}
项目:xtext-extras    文件:HiddenLeafAccess.java   
protected ILeafNode findPreviousLeaf(final INode node, final Function1<? super ILeafNode, ? extends Boolean> matches) {
  INode current = node;
  while ((current instanceof ICompositeNode)) {
    current = ((ICompositeNode)current).getLastChild();
  }
  if (((current instanceof ILeafNode) && (matches.apply(((ILeafNode) current))).booleanValue())) {
    return ((ILeafNode) current);
  }
  if ((current != null)) {
    final NodeIterator ni = new NodeIterator(current);
    while (ni.hasPrevious()) {
      {
        final INode previous = ni.previous();
        if (((previous instanceof ILeafNode) && (matches.apply(((ILeafNode) previous))).booleanValue())) {
          return ((ILeafNode) previous);
        }
      }
    }
  }
  return null;
}
项目:xtext-core    文件:Ecore2XtextExtensions.java   
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);
  }
}
项目:xtext-extras    文件:NodeModelAccess.java   
public ILeafNode findNextLeaf(final INode node, final Function1<? super ILeafNode, ? extends Boolean> matches) {
  Object _xifexpression = null;
  if ((node != null)) {
    if (((node instanceof ILeafNode) && (matches.apply(((ILeafNode) node))).booleanValue())) {
      return ((ILeafNode) node);
    }
    final NodeIterator ni = new NodeIterator(node);
    while (ni.hasNext()) {
      {
        final INode next = ni.next();
        if (((next instanceof ILeafNode) && (matches.apply(((ILeafNode) next))).booleanValue())) {
          return ((ILeafNode) next);
        }
      }
    }
  }
  return ((ILeafNode)_xifexpression);
}
项目:xtext-core    文件:LanguageServerImpl.java   
@Override
public CompletableFuture<CodeLens> resolveCodeLens(final CodeLens unresolved) {
  final URI uri = this.uninstallURI(unresolved);
  if ((uri == null)) {
    return CompletableFuture.<CodeLens>completedFuture(unresolved);
  }
  final Function1<CancelIndicator, CodeLens> _function = (CancelIndicator cancelIndicator) -> {
    final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
    ICodeLensResolver _get = null;
    if (resourceServiceProvider!=null) {
      _get=resourceServiceProvider.<ICodeLensResolver>get(ICodeLensResolver.class);
    }
    final ICodeLensResolver resolver = _get;
    if ((resolver == null)) {
      return unresolved;
    }
    final Function2<Document, XtextResource, CodeLens> _function_1 = (Document document, XtextResource resource) -> {
      final CodeLens result = resolver.resolveCodeLens(document, resource, unresolved, cancelIndicator);
      return result;
    };
    return this.workspaceManager.<CodeLens>doRead(uri, _function_1);
  };
  return this.requestManager.<CodeLens>runRead(_function);
}
项目:xtext-extras    文件:FormattableDocument.java   
public String getWrap(final int levels) {
  String _xifexpression = null;
  if ((levels > 0)) {
    String _xblockexpression = null;
    {
      final String sep = this.cfg.get(BasicFormatterPreferenceKeys.lineSeparator);
      final Function1<Integer, String> _function = (Integer it) -> {
        return sep;
      };
      _xblockexpression = IterableExtensions.join(IterableExtensions.<Integer, String>map(new IntegerRange(0, (levels - 1)), _function));
    }
    _xifexpression = _xblockexpression;
  } else {
    _xifexpression = "";
  }
  return _xifexpression;
}
项目:xtext-extras    文件:XbaseFormatter2.java   
protected void _format(final XCollectionLiteral literal, final FormattableDocument document) {
  final Procedure1<FormattingDataInit> _function = (FormattingDataInit it) -> {
    it.noSpace();
  };
  Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _append = this._formattingDataFactory.append(this._nodeModelAccess.nodeForKeyword(literal, "#"), _function);
  document.operator_add(_append);
  ILeafNode _elvis = null;
  ILeafNode _nodeForKeyword = this._nodeModelAccess.nodeForKeyword(literal, "[");
  if (_nodeForKeyword != null) {
    _elvis = _nodeForKeyword;
  } else {
    ILeafNode _nodeForKeyword_1 = this._nodeModelAccess.nodeForKeyword(literal, "{");
    _elvis = _nodeForKeyword_1;
  }
  final ILeafNode open = _elvis;
  ILeafNode _elvis_1 = null;
  ILeafNode _nodeForKeyword_2 = this._nodeModelAccess.nodeForKeyword(literal, "]");
  if (_nodeForKeyword_2 != null) {
    _elvis_1 = _nodeForKeyword_2;
  } else {
    ILeafNode _nodeForKeyword_3 = this._nodeModelAccess.nodeForKeyword(literal, "}");
    _elvis_1 = _nodeForKeyword_3;
  }
  final ILeafNode close = _elvis_1;
  this.formatCommaSeparatedList(literal.getElements(), open, close, document);
}
项目:xtext-core    文件:ContentAssistFragment2.java   
public Set<String> getFQFeatureNamesToExclude(final Grammar g) {
  Set<String> _xifexpression = null;
  Grammar _nonTerminalsSuperGrammar = GrammarUtil2.getNonTerminalsSuperGrammar(g);
  boolean _tripleNotEquals = (_nonTerminalsSuperGrammar != null);
  if (_tripleNotEquals) {
    Sets.SetView<String> _xblockexpression = null;
    {
      final Set<String> thisGrammarFqFeatureNames = IterableExtensions.<String>toSet(this.computeFQFeatureNames(g));
      final Function1<Grammar, Iterable<String>> _function = (Grammar it) -> {
        return this.computeFQFeatureNames(it);
      };
      final Set<String> superGrammarsFqFeatureNames = IterableExtensions.<String>toSet(Iterables.<String>concat(ListExtensions.<Grammar, Iterable<String>>map(GrammarUtil.allUsedGrammars(g), _function)));
      _xblockexpression = Sets.<String>intersection(thisGrammarFqFeatureNames, superGrammarsFqFeatureNames);
    }
    _xifexpression = _xblockexpression;
  } else {
    _xifexpression = CollectionLiterals.<String>emptySet();
  }
  return _xifexpression;
}
项目:xtext-extras    文件:FormattingDataFactory.java   
protected Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _newFormattingData(final HiddenLeafs leafs, final NewLineOrPreserveKey key, final FormattingDataInit it) {
  final Function1<FormattableDocument, Iterable<FormattingData>> _function = (FormattableDocument doc) -> {
    Iterable<FormattingData> _xblockexpression = null;
    {
      final boolean newLine = doc.getCfg().get(key);
      final boolean preserve = doc.getCfg().get(XbaseFormatterPreferenceKeys.preserveNewLines);
      int _xifexpression = (int) 0;
      if (newLine) {
        _xifexpression = 1;
      } else {
        _xifexpression = 0;
      }
      int _xifexpression_1 = (int) 0;
      if ((preserve || newLine)) {
        _xifexpression_1 = 1;
      } else {
        _xifexpression_1 = 0;
      }
      _xblockexpression = this.newNewLineData(leafs, _xifexpression, _xifexpression_1, it.increaseIndentationChange, it.decreaseIndentationChange, 
        doc.isDebugConflicts());
    }
    return _xblockexpression;
  };
  return _function;
}
项目:xtext-extras    文件:FormattingDataFactory.java   
protected Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _newFormattingData(final HiddenLeafs leafs, final NewLineKey key, final FormattingDataInit it) {
  final Function1<FormattableDocument, Iterable<FormattingData>> _function = (FormattableDocument doc) -> {
    Iterable<FormattingData> _xblockexpression = null;
    {
      final boolean newLine = doc.getCfg().get(key);
      int _xifexpression = (int) 0;
      if (newLine) {
        _xifexpression = 1;
      } else {
        _xifexpression = 0;
      }
      final int minmax = _xifexpression;
      _xblockexpression = this.newNewLineData(leafs, minmax, minmax, it.increaseIndentationChange, it.decreaseIndentationChange, doc.isDebugConflicts());
    }
    return _xblockexpression;
  };
  return _function;
}
项目:xtext-extras    文件:FormattingDataFactory.java   
protected Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _newFormattingData(final HiddenLeafs leafs, final WhitespaceKey key, final FormattingDataInit it) {
  final Function1<FormattableDocument, Iterable<FormattingData>> _function = (FormattableDocument doc) -> {
    Iterable<FormattingData> _xblockexpression = null;
    {
      final boolean space = doc.getCfg().get(key);
      String _xifexpression = null;
      if (space) {
        _xifexpression = " ";
      } else {
        _xifexpression = "";
      }
      _xblockexpression = this.newWhitespaceData(leafs, _xifexpression, it.increaseIndentationChange, it.decreaseIndentationChange, doc.isDebugConflicts());
    }
    return _xblockexpression;
  };
  return _function;
}
项目:xtext-extras    文件:FormattingDataFactory.java   
protected Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> newFormattingData(final HiddenLeafs leafs, final PreferenceKey key, final FormattingDataInit it) {
  if (key instanceof BlankLineKey) {
    return _newFormattingData(leafs, (BlankLineKey)key, it);
  } else if (key instanceof NewLineKey) {
    return _newFormattingData(leafs, (NewLineKey)key, it);
  } else if (key instanceof NewLineOrPreserveKey) {
    return _newFormattingData(leafs, (NewLineOrPreserveKey)key, it);
  } else if (key instanceof WhitespaceKey) {
    return _newFormattingData(leafs, (WhitespaceKey)key, it);
  } else if (key == null) {
    return _newFormattingData(leafs, (Void)null, it);
  } else if (key != null) {
    return _newFormattingData(leafs, key, it);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(leafs, key, it).toString());
  }
}
项目:xtext-core    文件:ParentProjectDescriptor.java   
public CharSequence settingsGradle() {
  StringConcatenation _builder = new StringConcatenation();
  {
    final Function1<ProjectDescriptor, Boolean> _function = (ProjectDescriptor it) -> {
      return Boolean.valueOf(((!Objects.equal(it, this)) && it.isPartOfGradleBuild()));
    };
    Iterable<ProjectDescriptor> _filter = IterableExtensions.<ProjectDescriptor>filter(this.getConfig().getEnabledProjects(), _function);
    for(final ProjectDescriptor p : _filter) {
      {
        ProjectLayout _projectLayout = this.getConfig().getProjectLayout();
        boolean _equals = Objects.equal(_projectLayout, ProjectLayout.FLAT);
        if (_equals) {
          _builder.append("includeFlat");
        } else {
          _builder.append("include");
        }
      }
      _builder.append(" \'");
      String _name = p.getName();
      _builder.append(_name);
      _builder.append("\'");
      _builder.newLineIfNotEmpty();
    }
  }
  return _builder;
}
项目:xtext-extras    文件:FragmentAdapter.java   
private void generateGuiceModuleRt(final LanguageConfig config1, final XpandExecutionContext ctx) {
  final IXtextGeneratorLanguage config2 = this.getLanguage();
  final Set<Binding> bindings = this.fragment.getGuiceBindingsRt(config1.getGrammar());
  if ((bindings != null)) {
    final Function1<Binding, GuiceModuleAccess.Binding> _function = (Binding it) -> {
      return this.translateBinding(it);
    };
    config2.getRuntimeGenModule().addAll(IterableExtensions.<Binding, GuiceModuleAccess.Binding>map(bindings, _function));
  }
  if ((this.fragment instanceof IGeneratorFragmentExtension4)) {
    final String superClass = ((IGeneratorFragmentExtension4)this.fragment).getDefaultRuntimeModuleClassName(config1.getGrammar());
    if ((superClass != null)) {
      GuiceModuleAccess _runtimeGenModule = config2.getRuntimeGenModule();
      TypeReference _typeReference = new TypeReference(superClass);
      _runtimeGenModule.setSuperClass(_typeReference);
    }
  }
}
项目:xtext-extras    文件:FragmentAdapter.java   
private void generateGuiceModuleUi(final LanguageConfig config1, final XpandExecutionContext ctx) {
  final IXtextGeneratorLanguage config2 = this.getLanguage();
  final Set<Binding> bindings = this.fragment.getGuiceBindingsUi(config1.getGrammar());
  if ((bindings != null)) {
    final Function1<Binding, GuiceModuleAccess.Binding> _function = (Binding it) -> {
      return this.translateBinding(it);
    };
    config2.getEclipsePluginGenModule().addAll(IterableExtensions.<Binding, GuiceModuleAccess.Binding>map(bindings, _function));
  }
  if ((this.fragment instanceof IGeneratorFragmentExtension4)) {
    final String superClass = ((IGeneratorFragmentExtension4)this.fragment).getDefaultUiModuleClassName(config1.getGrammar());
    if ((superClass != null)) {
      GuiceModuleAccess _eclipsePluginGenModule = config2.getEclipsePluginGenModule();
      TypeReference _typeReference = new TypeReference(superClass);
      _eclipsePluginGenModule.setSuperClass(_typeReference);
    }
  }
}
项目:xtext-core    文件:TracingSugarTest.java   
public StringConcatenationClient __generatePropertyWithDebugging(final Property it) {
  StringConcatenationClient _client = new StringConcatenationClient() {
    @Override
    protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
      _builder.append("Property ");
      IGeneratorNode __name = TracingSugarTest.this._myExtensions._name(it, true);
      _builder.append(__name);
      _builder.append(" : ");
      final Function1<Type, String> _function = (Type it_1) -> {
        return it_1.getName();
      };
      IGeneratorNode __type = TracingSugarTest.this._myExtensions._type(it, _function);
      _builder.append(__type);
      _builder.newLineIfNotEmpty();
    }
  };
  return _client;
}
项目:xtext-extras    文件:BatchTypeArgumentTest.java   
@Override
protected void hasTypeArguments(final XExpression expression, final String... typeArguments) {
  final List<LightweightTypeReference> actualTypeArguments = this.resolvedTypes.getActualTypeArguments(expression);
  Assert.assertEquals(((List<String>)Conversions.doWrapArray(typeArguments)).size(), actualTypeArguments.size());
  final Procedure2<String, Integer> _function = (String typeArgument, Integer i) -> {
    StringConcatenation _builder = new StringConcatenation();
    String _join = IterableExtensions.join(((Iterable<?>)Conversions.doWrapArray(typeArguments)), ", ");
    _builder.append(_join);
    _builder.append(" vs ");
    final Function1<LightweightTypeReference, String> _function_1 = (LightweightTypeReference it) -> {
      return it.getSimpleName();
    };
    String _join_1 = IterableExtensions.join(ListExtensions.<LightweightTypeReference, String>map(actualTypeArguments, _function_1), ", ");
    _builder.append(_join_1);
    Assert.assertEquals(_builder.toString(), typeArgument, actualTypeArguments.get((i).intValue()).getSimpleName());
  };
  IterableExtensions.<String>forEach(((Iterable<String>)Conversions.doWrapArray(typeArguments)), _function);
}
项目:xtext-core    文件:LanguageServerImpl.java   
@Override
public CompletableFuture<List<? extends TextEdit>> formatting(final DocumentFormattingParams params) {
  final Function1<CancelIndicator, List<? extends TextEdit>> _function = (CancelIndicator cancelIndicator) -> {
    final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri());
    final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
    FormattingService _get = null;
    if (resourceServiceProvider!=null) {
      _get=resourceServiceProvider.<FormattingService>get(FormattingService.class);
    }
    final FormattingService formatterService = _get;
    if ((formatterService == null)) {
      return CollectionLiterals.<TextEdit>emptyList();
    }
    final Function2<Document, XtextResource, List<? extends TextEdit>> _function_1 = (Document document, XtextResource resource) -> {
      return formatterService.format(document, resource, params, cancelIndicator);
    };
    return this.workspaceManager.<List<? extends TextEdit>>doRead(uri, _function_1);
  };
  return this.requestManager.<List<? extends TextEdit>>runRead(_function);
}
项目:xtext-lib    文件:IteratorExtensionsTest.java   
@Test
public void testGroupBy__WhenNoValuesForKey() {
    List<String> names = new ArrayList<String>();
    names.add("Mueller");
    names.add("Schneider");
    names.add("Schmidt");
    names.add("Koch");
    Function1<String, Boolean> computeKeys = new Function1<String, Boolean>() {

        @Override
        public Boolean apply(String p) {
            return p.contains("y");
        }
    };
    Map<Boolean, List<String>> map = IteratorExtensions.groupBy(names.iterator(), computeKeys);
    Assert.assertEquals("Expected grouped map size", 1, map.size());
    Assert.assertTrue("Contains FALSE as key", map.keySet().contains(Boolean.FALSE));
    Assert.assertEquals("Contains 4 entries for key Boolean.FALSE", 4, map.get(Boolean.FALSE).size());
    Assert.assertTrue("Contains entry Mueller for key FALSE", map.get(Boolean.FALSE).contains("Mueller"));
    Assert.assertNull("Contains no entry for key Boolean.TRUE", map.get(Boolean.TRUE));
}
项目:n4js    文件:N4GetterDeclarationImpl.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
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.getDeclaredModifiers().contains(N4Modifier.ABSTRACT));
}
项目:n4js    文件:N4GetterDeclarationImpl.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
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);
}
项目:n4js    文件:BlockImpl.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public Iterator<YieldExpression> getAllVoidYieldExpressions() {
    final Function1<YieldExpression, Boolean> _function = new Function1<YieldExpression, Boolean>() {
        public Boolean apply(final YieldExpression it) {
            Expression _expression = it.getExpression();
            return Boolean.valueOf((_expression == null));
        }
    };
    return IteratorExtensions.<YieldExpression>filter(this.getAllYieldExpressions(), _function);
}
项目:n4js    文件:BlockImpl.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public Iterator<YieldExpression> getAllNonVoidYieldExpressions() {
    final Function1<YieldExpression, Boolean> _function = new Function1<YieldExpression, Boolean>() {
        public Boolean apply(final YieldExpression it) {
            Expression _expression = it.getExpression();
            return Boolean.valueOf((_expression != null));
        }
    };
    return IteratorExtensions.<YieldExpression>filter(this.getAllYieldExpressions(), _function);
}
项目:n4js    文件:BlockImpl.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public Iterator<ReturnStatement> getAllNonVoidReturnStatements() {
    final Function1<ReturnStatement, Boolean> _function = new Function1<ReturnStatement, Boolean>() {
        public Boolean apply(final ReturnStatement it) {
            Expression _expression = it.getExpression();
            return Boolean.valueOf((_expression != null));
        }
    };
    return IteratorExtensions.<ReturnStatement>filter(this.getAllReturnStatements(), _function);
}