org.eclipse.jface.text.codemining.ICodeMining#org.eclipse.xtext.xbase.lib.Functions.Function1源码实例Demo

下面列出了org.eclipse.jface.text.codemining.ICodeMining#org.eclipse.xtext.xbase.lib.Functions.Function1 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: xtext-eclipse   文件: ResourceMoveTest.java
protected void performMove(final IContainer theDestination, final IResource... theResources) {
  try {
    MoveResourcesDescriptor _moveResourcesDescriptor = new MoveResourcesDescriptor();
    final Procedure1<MoveResourcesDescriptor> _function = (MoveResourcesDescriptor it) -> {
      final Function1<IResource, IPath> _function_1 = (IResource it_1) -> {
        return it_1.getFullPath();
      };
      it.setResourcePathsToMove(((IPath[])Conversions.unwrapArray(ListExtensions.<IResource, IPath>map(((List<IResource>)Conversions.doWrapArray(theResources)), _function_1), IPath.class)));
      it.setDestinationPath(theDestination.getFullPath());
    };
    MoveResourcesDescriptor _doubleArrow = ObjectExtensions.<MoveResourcesDescriptor>operator_doubleArrow(_moveResourcesDescriptor, _function);
    this.performRefactoring(_doubleArrow);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
@Test
public void testDeleteElement() {
  try {
    this._parseHelper.parse("foo", this.fooURI, this.rs1).eResource().getContents().clear();
    final Function1<IEObjectDescription, String> _function = (IEObjectDescription it) -> {
      return it.getQualifiedName().toString();
    };
    Assert.assertEquals("", IterableExtensions.join(IterableExtensions.<IEObjectDescription, String>map(this.fooContainer.getExportedObjects(), _function), ","));
    Assert.assertEquals(1, IterableExtensions.size(this.fooContainer.getResourceDescriptions()));
    Assert.assertEquals(1, this.fooContainer.getResourceDescriptionCount());
    Assert.assertEquals(0, IterableExtensions.size(this.fooContainer.getExportedObjects()));
    Assert.assertEquals(1, IterableExtensions.size(this.barContainer.getResourceDescriptions()));
    Assert.assertEquals(1, this.barContainer.getResourceDescriptionCount());
    this.assertGlobalDescriptionsAreUnaffected();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
源代码3 项目: xtext-xtend   文件: TypeLookupImpl.java
private <T extends Object> T recursiveFindType(final String qualifiedName, final Iterable<? extends T> typeDeclarations, final Function1<? super T, ? extends String> qualifiedNameProvider, final Function1<? super T, ? extends Iterable<? extends T>> subTypeProvider) {
  final char dot = '.';
  for (final T type : typeDeclarations) {
    {
      final String name = qualifiedNameProvider.apply(type);
      boolean _equals = Objects.equal(qualifiedName, name);
      if (_equals) {
        return type;
      }
      if ((qualifiedName.startsWith(name) && (qualifiedName.charAt(name.length()) == dot))) {
        return this.<T>recursiveFindType(qualifiedName, subTypeProvider.apply(type), qualifiedNameProvider, subTypeProvider);
      }
    }
  }
  return null;
}
 
public void doTestPerformance(final int max) {
  final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
    final Function1<Integer, URI> _function_1 = (Integer it_1) -> {
      return this.toFile((it_1).intValue(), max);
    };
    it.setDirtyFiles(IterableExtensions.<URI>toList(IterableExtensions.<Integer, URI>map(new IntegerRange(1, max), _function_1)));
  };
  final BuildRequest buildRequest = this.newBuildRequest(_function);
  final Stopwatch sw = Stopwatch.createStarted();
  this.build(buildRequest);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append(max);
  _builder.append(" file took ");
  long _elapsed = sw.elapsed(TimeUnit.MILLISECONDS);
  _builder.append(_elapsed);
  _builder.append(" ms");
  InputOutput.<String>println(_builder.toString());
}
 
源代码5 项目: xtext-lib   文件: IteratorExtensionsTest.java
@Test
public void testToMap() {
	List<Pair<Integer, String>> pairs = new ArrayList<Pair<Integer, String>>();
	pairs.add(new Pair<Integer, String>(1, "A"));
	pairs.add(new Pair<Integer, String>(1, "a"));
	pairs.add(new Pair<Integer, String>(2, "B"));
	pairs.add(new Pair<Integer, String>(2, "b"));
	Function1<Pair<Integer, String>, Integer> computeKeys = new Function1<Pair<Integer, String>, Integer>() {

		@Override
		public Integer apply(Pair<Integer, String> p) {
			return p.getKey();
		}
	};
	Map<Integer, Pair<Integer, String>> map = IteratorExtensions.toMap(pairs.iterator(), computeKeys);
	Assert.assertEquals("Expected grouped map size", 2, map.size());
	Assert.assertTrue("Contains 1 as key", map.keySet().contains(1));
	Assert.assertEquals("Contains entry 1->a for key 1", map.get(1), new Pair<Integer, String>(1, "a"));
	Assert.assertTrue("Contains 2 as key", map.keySet().contains(2));
	Assert.assertEquals("Contains entry 2->b for key 2", map.get(2), new Pair<Integer, String>(2, "b"));
}
 
源代码6 项目: xtext-xtend   文件: CommonSuperTypeTest.java
public String getEquivalent(final ParameterizedTypeReference type) {
  boolean _isEmpty = type.getTypeArguments().isEmpty();
  if (_isEmpty) {
    return type.getType().getSimpleName();
  }
  StringConcatenation _builder = new StringConcatenation();
  String _simpleName = type.getType().getSimpleName();
  _builder.append(_simpleName);
  _builder.append("<");
  final Function1<LightweightTypeReference, CharSequence> _function = (LightweightTypeReference it) -> {
    return it.getSimpleName();
  };
  String _join = IterableExtensions.<LightweightTypeReference>join(type.getTypeArguments(), ", ", _function);
  _builder.append(_join);
  _builder.append(">");
  return _builder.toString();
}
 
public void assertHasErrors(final IFile file, final String msgPart) {
  try {
    final IMarker[] findMarkers = file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
    for (final IMarker iMarker : findMarkers) {
      if (((MarkerUtilities.getSeverity(iMarker) == IMarker.SEVERITY_ERROR) && MarkerUtilities.getMessage(iMarker).contains(msgPart))) {
        return;
      }
    }
    IPath _fullPath = file.getFullPath();
    String _plus = ((("Expected an error marker containing \'" + msgPart) + "\' on ") + _fullPath);
    String _plus_1 = (_plus + " but found ");
    final Function1<IMarker, String> _function = (IMarker it) -> {
      return MarkerUtilities.getMessage(it);
    };
    String _join = IterableExtensions.join(ListExtensions.<IMarker, String>map(((List<IMarker>)Conversions.doWrapArray(findMarkers)), _function), ",");
    String _plus_2 = (_plus_1 + _join);
    Assert.fail(_plus_2);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
源代码8 项目: 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);
      }
    }
  }
}
 
源代码9 项目: xtext-xtend   文件: Solution_021.java
public static Integer sumOfDivisors(final int input) {
  Integer _xblockexpression = null;
  {
    final int sqrt = Double.valueOf(Math.floor(Math.sqrt(input))).intValue();
    final Function1<Integer, Boolean> _function = (Integer div) -> {
      return Boolean.valueOf(((input % (div).intValue()) == 0));
    };
    final Function2<Integer, Integer, Integer> _function_1 = (Integer i1, Integer i2) -> {
      int _xblockexpression_1 = (int) 0;
      {
        final int other = (input / (i2).intValue());
        int _xifexpression = (int) 0;
        if ((other != (i2).intValue())) {
          _xifexpression = (((i1).intValue() + (i2).intValue()) + other);
        } else {
          _xifexpression = ((i1).intValue() + (i2).intValue());
        }
        _xblockexpression_1 = _xifexpression;
      }
      return Integer.valueOf(_xblockexpression_1);
    };
    _xblockexpression = IterableExtensions.<Integer, Integer>fold(IterableExtensions.<Integer>filter(new IntegerRange(2, sqrt), _function), Integer.valueOf(1), _function_1);
  }
  return _xblockexpression;
}
 
源代码10 项目: xtext-xtend   文件: QuickfixTestBuilder.java
public QuickfixTestBuilder assertModelAfterQuickfix(final CharSequence expectedModel) {
  QuickfixTestBuilder _xblockexpression = null;
  {
    final Function1<Issue, List<IssueResolution>> _function = (Issue it) -> {
      return this._issueResolutionProvider.getResolutions(it);
    };
    final List<IssueResolution> resolutions = IterableExtensions.<IssueResolution>toList(Iterables.<IssueResolution>concat(IterableExtensions.<Issue, List<IssueResolution>>map(this.getIssuesAtCaret(), _function)));
    final String originalModel = this.editor.getDocument().get();
    final IssueResolution resolution = IterableExtensions.<IssueResolution>head(resolutions);
    Assert.assertNotNull(resolution);
    resolution.apply();
    Assert.assertEquals(expectedModel.toString(), this.editor.getDocument().get());
    this.editor.getDocument().set(originalModel);
    this._syncUtil.waitForReconciler(this.editor);
    _xblockexpression = this;
  }
  return _xblockexpression;
}
 
源代码11 项目: xtext-xtend   文件: Solution_023.java
public static boolean isAbundant(final int input) {
  final int sqrt = Double.valueOf(Math.floor(Math.sqrt(input))).intValue();
  final Function1<Integer, Boolean> _function = (Integer div) -> {
    return Boolean.valueOf((((div).intValue() != input) && ((input % (div).intValue()) == 0)));
  };
  final Function2<Integer, Integer, Integer> _function_1 = (Integer i1, Integer i2) -> {
    int _xblockexpression = (int) 0;
    {
      final int other = (input / (i2).intValue());
      int _xifexpression = (int) 0;
      if (((other != (i2).intValue()) && (other != input))) {
        _xifexpression = (((i1).intValue() + (i2).intValue()) + other);
      } else {
        _xifexpression = ((i1).intValue() + (i2).intValue());
      }
      _xblockexpression = _xifexpression;
    }
    return Integer.valueOf(_xblockexpression);
  };
  final Integer sumOfDivisors = IterableExtensions.<Integer, Integer>fold(IterableExtensions.<Integer>filter(new IntegerRange(2, sqrt), _function), Integer.valueOf(1), _function_1);
  return ((sumOfDivisors).intValue() > input);
}
 
源代码12 项目: 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;
}
 
源代码13 项目: xtext-xtend   文件: JvmAnnotationReferenceImpl.java
@Override
public Expression getExpression(final String property) {
  final JvmOperation op = this.findOperation(property);
  final Function1<JvmAnnotationValue, Boolean> _function = (JvmAnnotationValue it) -> {
    return Boolean.valueOf((Objects.equal(it.getOperation(), op) || ((it.getOperation() == null) && Objects.equal(op.getSimpleName(), "value"))));
  };
  final JvmAnnotationValue annotationValue = IterableExtensions.<JvmAnnotationValue>findFirst(this.getDelegate().getValues(), _function);
  boolean _matched = false;
  if (annotationValue instanceof JvmCustomAnnotationValue) {
    _matched=true;
    EObject _head = IterableExtensions.<EObject>head(((JvmCustomAnnotationValue)annotationValue).getValues());
    final XExpression expression = ((XExpression) _head);
    if (((expression != null) && this.getCompilationUnit().isBelongedToCompilationUnit(expression))) {
      return this.getCompilationUnit().toExpression(expression);
    }
  }
  return null;
}
 
源代码14 项目: xtext-core   文件: RequestManagerTest.java
@Test(timeout = 1000, expected = ExecutionException.class)
public void testRunReadCatchException() {
  final Runnable _function = () -> {
    try {
      final Function1<CancelIndicator, Object> _function_1 = (CancelIndicator it) -> {
        throw new RuntimeException();
      };
      final CompletableFuture<Object> future = this.requestManager.<Object>runRead(_function_1);
      Assert.assertEquals("Foo", future.get());
    } catch (Throwable _e) {
      throw Exceptions.sneakyThrow(_e);
    }
  };
  LoggingTester.captureLogging(Level.ALL, ReadRequest.class, _function);
  Assert.fail();
}
 
public void hasNoHintsFor(final Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> mapping, final String typeParamName) {
  final Set<JvmTypeParameter> allKeys = mapping.keySet();
  for (final JvmTypeParameter key : allKeys) {
    String _simpleName = key.getSimpleName();
    boolean _equals = Objects.equal(_simpleName, typeParamName);
    if (_equals) {
      LightweightTypeReference _typeReference = mapping.get(key).getTypeReference();
      final UnboundTypeReference unbound = ((UnboundTypeReference) _typeReference);
      boolean _isEmpty = unbound.getAllHints().isEmpty();
      boolean _not = (!_isEmpty);
      if (_not) {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("Unexpected mapping for ");
        _builder.append(typeParamName);
        _builder.append(" in ");
        final Function1<JvmTypeParameter, String> _function = (JvmTypeParameter it) -> {
          return it.getSimpleName();
        };
        Iterable<String> _map = IterableExtensions.<JvmTypeParameter, String>map(mapping.keySet(), _function);
        _builder.append(_map);
        Assert.fail(_builder.toString());
      }
    }
  }
}
 
源代码16 项目: xtext-xtend   文件: JdtFindReferencesTest.java
@Test
public void testClassJavaElements() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Xtend {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendTypeDeclaration clazz = IterableExtensions.<XtendTypeDeclaration>head(this._workbenchTestHelper.xtendFile("Xtend.xtend", _builder.toString()).getXtendTypes());
    IResourcesSetupUtil.waitForBuild();
    Iterable<IJavaElement> _javaElements = this._jvmModelFindReferenceHandler.getJavaElements(clazz);
    final Procedure1<Iterable<IJavaElement>> _function = (Iterable<IJavaElement> it) -> {
      Assert.assertEquals(1, IterableExtensions.size(it));
      final Function1<IJavaElement, Boolean> _function_1 = (IJavaElement it_1) -> {
        return Boolean.valueOf(((it_1 instanceof IType) && Objects.equal(((IType) it_1).getElementName(), "Xtend")));
      };
      Assert.assertTrue(IterableExtensions.<IJavaElement>exists(it, _function_1));
    };
    ObjectExtensions.<Iterable<IJavaElement>>operator_doubleArrow(_javaElements, _function);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
源代码17 项目: xtext-extras   文件: XbaseFormatter2.java
protected void _format(final XFeatureCall expr, final FormattableDocument format) {
  this.formatFeatureCallTypeParameters(expr, format);
  boolean _isExplicitOperationCall = expr.isExplicitOperationCall();
  if (_isExplicitOperationCall) {
    final ILeafNode open = this._nodeModelAccess.nodeForKeyword(expr, "(");
    final Procedure1<FormattingDataInit> _function = (FormattingDataInit it) -> {
      it.noSpace();
    };
    Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _prepend = this._formattingDataFactory.prepend(open, _function);
    format.operator_add(_prepend);
    boolean _isMultiParamInOwnLine = this.isMultiParamInOwnLine(expr, format);
    if (_isMultiParamInOwnLine) {
      this.formatFeatureCallParamsMultiline(open, expr.getFeatureCallArguments(), format);
    } else {
      this.formatFeatureCallParamsWrapIfNeeded(open, expr.getFeatureCallArguments(), format);
    }
  } else {
    EList<XExpression> _featureCallArguments = expr.getFeatureCallArguments();
    for (final XExpression arg : _featureCallArguments) {
      this.format(arg, format);
    }
  }
}
 
源代码18 项目: n4js   文件: N4GetterDeclarationImpl.java
/**
 * <!-- 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());
}
 
源代码19 项目: xtext-core   文件: TracingSugarTest.java
/**
 * manual implementation for unsupported multi cross reference
 */
public IGeneratorNode _type(final Property it, final Function1<? super Type, ? extends String> provider) {
  final ILocationData location = this.location(it, it.eClass().getEStructuralFeature("type"), 0);
  final CompositeGeneratorNode result = this.trace(location);
  this.append(result, provider.apply(IterableExtensions.<Type>head(it.getType())));
  return result;
}
 
源代码20 项目: n4js   文件: BlockImpl.java
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
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);
}
 
源代码21 项目: n4js   文件: BlockImpl.java
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
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);
}
 
源代码22 项目: n4js   文件: N4MemberAnnotationListImpl.java
/**
 * <!-- 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);
}
 
源代码23 项目: xtext-extras   文件: XbaseFormatter2.java
protected void _format(final XThrowExpression expr, final FormattableDocument format) {
  final Procedure1<FormattingDataInit> _function = (FormattingDataInit it) -> {
    it.oneSpace();
  };
  Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _prepend = this._formattingDataFactory.prepend(this._nodeModelAccess.nodeForEObject(expr.getExpression()), _function);
  format.operator_add(_prepend);
  this.format(expr.getExpression(), format);
}
 
源代码24 项目: xtext-lib   文件: IterableExtensionsTest.java
@Test public void testFlatMap () {
	ArrayList<String> list = newArrayList("foo", "bar");
	
	final Functions.Function1<String, Iterable<String>> function = new Functions.Function1<String, Iterable<String>>() {
		@Override
		public Iterable<String> apply(String p) {
			return newArrayList("Hello", p);
		}
	};
	assertEquals(newArrayList("Hello", "foo", "Hello", "bar"), newArrayList(IterableExtensions.flatMap(list, function)));
}
 
源代码25 项目: xtext-extras   文件: FormattingDataFactory.java
protected Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> newFormattingData(final HiddenLeafs leafs, final Procedure1<? super FormattingDataInit> init) {
  Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _xblockexpression = null;
  {
    final FormattingDataInit data = new FormattingDataInit();
    init.apply(data);
    _xblockexpression = this.newFormattingData(leafs, data.key, data);
  }
  return _xblockexpression;
}
 
源代码26 项目: xtext-lib   文件: BaseIterablesIteratorsTest.java
@Test public void testFindFirst_allMatches() {
	Function1<Integer, Boolean> filter = new Functions.Function1<Integer, Boolean>() {
		@Override
		public Boolean apply(Integer p) {
			return true;
		}
	};
	for(IterableOrIterator testMe: testData(first, second, third)) {
		Integer last = findFirst(testMe, filter);
		assertEquals(first, last);
	}
}
 
源代码27 项目: xtext-lib   文件: IteratorExtensionsTest.java
@Test
public void testToMap__WhenEmptyList() {
	List<Pair<Integer, String>> pairs = new ArrayList<Pair<Integer, String>>();
	Function1<Pair<Integer, String>, Integer> computeKeys = new Function1<Pair<Integer, String>, Integer>() {

		@Override
		public Integer apply(Pair<Integer, String> p) {
			return p.getKey();
		}
	};
	Map<Integer, Pair<Integer, String>> map = IteratorExtensions.toMap(pairs.iterator(), computeKeys);
	Assert.assertEquals("Expected grouped map size", 0, map.size());
}
 
源代码28 项目: xtext-core   文件: Ecore2XtextExtensions.java
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;
}
 
/**
 * Execute the given operation in a clustered fashion.
 */
public <T> Iterable<T> executeClustered(Iterable<URI> uris, Function1<? super Resource, ? extends T> operation) {
	int loadedURIsCount = 0;
	Set<URI> sourceLevelURIs = new HashSet<>();
	List<Resource> resources = new ArrayList<>();
	List<T> result = new ArrayList<>();
	Iterator<URI> iter = uris.iterator();
	while (iter.hasNext()) {
		URI uri = iter.next();
		XtextResourceSet resourceSet = context.getResourceSet();
		if (!context.getClusteringPolicy().continueProcessing(resourceSet, uri, loadedURIsCount)) {
			FluentIterable.from(resources).transform(operation::apply).copyInto(result);
			clearResourceSet();
			resources.clear();
			loadedURIsCount = 0;
		}
		loadedURIsCount++;
		if (isSource(uri)) {
			sourceLevelURIs.add(uri);
			Resource existingResource = resourceSet.getResource(uri, false);
			if (existingResource instanceof StorageAwareResource) {
				if (((StorageAwareResource) existingResource).isLoadedFromStorage()) {
					existingResource.unload();
				}
			}
			SourceLevelURIsAdapter.setSourceLevelUrisWithoutCopy(resourceSet, sourceLevelURIs);
		}
		resources.add(resourceSet.getResource(uri, true));
	}
	FluentIterable.from(resources).transform(operation::apply).copyInto(result);
	return result;
}
 
源代码30 项目: xtext-lib   文件: DelegateProcessor.java
public TypeReference replace(final TypeReference target, final TypeReference oldType, final TypeReference newType) {
  boolean _equals = Objects.equal(target, oldType);
  if (_equals) {
    return newType;
  }
  boolean _isEmpty = target.getActualTypeArguments().isEmpty();
  boolean _not = (!_isEmpty);
  if (_not) {
    final Function1<TypeReference, TypeReference> _function = (TypeReference it) -> {
      return this.replace(it, oldType, newType);
    };
    return this.context.newTypeReference(target.getType(), ((TypeReference[])Conversions.unwrapArray(ListExtensions.<TypeReference, TypeReference>map(target.getActualTypeArguments(), _function), TypeReference.class)));
  }
  boolean _isWildCard = target.isWildCard();
  if (_isWildCard) {
    TypeReference _upperBound = target.getUpperBound();
    TypeReference _object = this.context.getObject();
    boolean _notEquals = (!Objects.equal(_upperBound, _object));
    if (_notEquals) {
      return this.context.newWildcardTypeReference(this.replace(target.getUpperBound(), oldType, newType));
    } else {
      boolean _isAnyType = target.getLowerBound().isAnyType();
      boolean _not_1 = (!_isAnyType);
      if (_not_1) {
        return this.context.newWildcardTypeReferenceWithLowerBound(this.replace(target.getLowerBound(), oldType, newType));
      }
    }
  }
  boolean _isArray = target.isArray();
  if (_isArray) {
    return this.context.newArrayTypeReference(this.replace(target.getArrayComponentType(), oldType, newType));
  }
  return target;
}