Java Code Examples for org.eclipse.xtext.xbase.lib.IteratorExtensions#toIterable()

The following examples show how to use org.eclipse.xtext.xbase.lib.IteratorExtensions#toIterable() . 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: CachingResourceValidatorImpl.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
private void addWarningsForOrphanedJvmElements(final Resource resource, final CancelIndicator monitor, final IAcceptor<Issue> acceptor) {
  final IssueSeverities issueSeverities = this.issueSeveritiesProvider.getIssueSeverities(resource);
  final Severity severity = issueSeverities.getSeverity(IssueCodes.ORPHAN_ELEMENT);
  boolean _equals = Objects.equal(severity, Severity.IGNORE);
  if (_equals) {
    return;
  }
  Iterable<JvmDeclaredType> _filter = Iterables.<JvmDeclaredType>filter(IterableExtensions.<EObject>tail(resource.getContents()), JvmDeclaredType.class);
  for (final JvmDeclaredType jvmType : _filter) {
    final Function1<JvmMember, Boolean> _function = (JvmMember it) -> {
      boolean _isSynthetic = this._jvmTypeExtensions.isSynthetic(it);
      return Boolean.valueOf((!_isSynthetic));
    };
    Iterable<JvmMember> _iterable = IteratorExtensions.<JvmMember>toIterable(IteratorExtensions.<JvmMember>filter(Iterators.<JvmMember>filter(jvmType.eAllContents(), JvmMember.class), _function));
    for (final JvmMember jvmMember : _iterable) {
      {
        this.operationCanceledManager.checkCanceled(monitor);
        final EObject sourceElement = this._iJvmModelAssociations.getPrimarySourceElement(jvmMember);
        if ((sourceElement == null)) {
          this.addWarningForOrphanedJvmElement(resource, jvmMember, severity, acceptor);
        }
      }
    }
  }
}
 
Example 2
Source File: Oven.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public void fireproof(String input) throws Exception {
	try {
		EObject file = parseHelper.parse(input);
		IResolvedTypes resolvedTypes = typeResolver.resolveTypes(file);
		Assert.assertNotNull(resolvedTypes);
		if (file == null) {
			return;
		}
		for (EObject content : IteratorExtensions.toIterable(file.eAllContents())) {
			if (content instanceof XAbstractFeatureCall) {
				assertExpressionTypeIsResolved(((XExpression) content), resolvedTypes);
				XAbstractFeatureCall abstractFeatureCall = (XAbstractFeatureCall) content;
				if (abstractFeatureCall.getImplicitReceiver() != null) {
					assertExpressionTypeIsResolved(abstractFeatureCall.getImplicitReceiver(), resolvedTypes);
				}
				if (abstractFeatureCall.getImplicitFirstArgument() != null) {
					assertExpressionTypeIsResolved(abstractFeatureCall.getImplicitFirstArgument(), resolvedTypes);
				}
			} else if (content instanceof XClosure) {
				assertExpressionTypeIsResolved(((XExpression) content), resolvedTypes);
				((XClosure) content).getImplicitFormalParameters()
						.forEach((JvmFormalParameter it) -> assertIdentifiableTypeIsResolved(it, resolvedTypes));
			} else if (content instanceof XExpression) {
				assertExpressionTypeIsResolved(((XExpression) content), resolvedTypes);
			} else if (content instanceof JvmIdentifiableElement) {
				assertIdentifiableTypeIsResolved(((JvmIdentifiableElement) content), resolvedTypes);
			}
		}
	} catch (Throwable e) {
		ComparisonFailure error = new ComparisonFailure(e.getMessage(), input, "");
		error.setStackTrace(e.getStackTrace());
		throw error;
	}
}
 
Example 3
Source File: IteratorExtensionsTest.java    From xtext-lib with Eclipse Public License 2.0 4 votes vote down vote up
@Test public void testToIterable() throws Exception {
	ArrayList<String> list = newArrayList("A","B");
	for (String s : IteratorExtensions.toIterable(list.iterator())) {
		assertTrue(list.contains(s));
	}
}
 
Example 4
Source File: Oven.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public void fireproof(final String input) throws Exception {
  try {
    final EObject file = this._parseHelper.parse(input);
    final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(file);
    Assert.assertNotNull(resolvedTypes);
    if ((file != null)) {
      Iterable<EObject> _iterable = IteratorExtensions.<EObject>toIterable(file.eAllContents());
      for (final EObject content : _iterable) {
        boolean _matched = false;
        if (content instanceof XAbstractFeatureCall) {
          _matched=true;
          this.assertExpressionTypeIsResolved(((XExpression)content), resolvedTypes);
          XExpression _implicitReceiver = ((XAbstractFeatureCall)content).getImplicitReceiver();
          boolean _tripleNotEquals = (_implicitReceiver != null);
          if (_tripleNotEquals) {
            this.assertExpressionTypeIsResolved(((XAbstractFeatureCall)content).getImplicitReceiver(), resolvedTypes);
          }
          XExpression _implicitFirstArgument = ((XAbstractFeatureCall)content).getImplicitFirstArgument();
          boolean _tripleNotEquals_1 = (_implicitFirstArgument != null);
          if (_tripleNotEquals_1) {
            this.assertExpressionTypeIsResolved(((XAbstractFeatureCall)content).getImplicitFirstArgument(), resolvedTypes);
          }
        }
        if (!_matched) {
          if (content instanceof XClosure) {
            _matched=true;
            this.assertExpressionTypeIsResolved(((XExpression)content), resolvedTypes);
            final Consumer<JvmFormalParameter> _function = (JvmFormalParameter it) -> {
              this.assertIdentifiableTypeIsResolved(it, resolvedTypes);
            };
            ((XClosure)content).getImplicitFormalParameters().forEach(_function);
          }
        }
        if (!_matched) {
          if (content instanceof XExpression) {
            _matched=true;
            this.assertExpressionTypeIsResolved(((XExpression)content), resolvedTypes);
          }
        }
        if (!_matched) {
          if (content instanceof JvmIdentifiableElement) {
            _matched=true;
            this.assertIdentifiableTypeIsResolved(((JvmIdentifiableElement)content), resolvedTypes);
          }
        }
      }
    }
  } catch (final Throwable _t) {
    if (_t instanceof Throwable) {
      final Throwable e = (Throwable)_t;
      String _message = e.getMessage();
      final ComparisonFailure error = new ComparisonFailure(_message, input, "");
      error.setStackTrace(e.getStackTrace());
      throw error;
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  }
}