use of org.eclipse.xtext.xbase.typesystem.IResolvedTypes in project xtext-xtend by eclipse.
the class Oven method fireproof.
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);
}
}
}
use of org.eclipse.xtext.xbase.typesystem.IResolvedTypes in project xtext-xtend by eclipse.
the class XtendResourceDescription method getImportedNames.
@Override
public Iterable<QualifiedName> getImportedNames() {
if ((this.importedNames != null)) {
return this.importedNames;
}
final HashSet<QualifiedName> result = CollectionLiterals.<QualifiedName>newHashSet();
final EObject astRoot = IterableExtensions.<EObject>head(this.getResource().getContents());
if ((astRoot != null)) {
final IResolvedTypes types = this.typeResolver.resolveTypes(astRoot);
Iterable<XExpression> _filter = Iterables.<XExpression>filter(IteratorExtensions.<Object>toIterable(EcoreUtil.<Object>getAllContents(astRoot, true)), XExpression.class);
for (final XExpression expression : _filter) {
{
boolean _matched = false;
if (expression instanceof XMemberFeatureCall) {
if ((((((XMemberFeatureCall) expression).getFeature() != null) && ((XMemberFeatureCall) expression).getFeature().eIsProxy()) && (!((XMemberFeatureCall) expression).isExplicitOperationCallOrBuilderSyntax()))) {
_matched = true;
final XExpression receiver = ((XMemberFeatureCall) expression).getActualReceiver();
boolean _matched_1 = false;
if (receiver instanceof XAbstractFeatureCall) {
boolean _isTypeLiteral = ((XAbstractFeatureCall) receiver).isTypeLiteral();
if (_isTypeLiteral) {
_matched_1 = true;
final JvmIdentifiableElement type = ((XAbstractFeatureCall) receiver).getFeature();
String _identifier = type.getIdentifier();
String _plus = (_identifier + "$");
String _concreteSyntaxFeatureName = ((XMemberFeatureCall) expression).getConcreteSyntaxFeatureName();
String _plus_1 = (_plus + _concreteSyntaxFeatureName);
QualifiedName _lowerCase = this.nameConverter.toQualifiedName(_plus_1).toLowerCase();
result.add(_lowerCase);
}
}
}
}
if (!_matched) {
if (expression instanceof XAbstractFeatureCall) {
boolean _isTypeLiteral = ((XAbstractFeatureCall) expression).isTypeLiteral();
if (_isTypeLiteral) {
_matched = true;
final JvmIdentifiableElement type = ((XAbstractFeatureCall) expression).getFeature();
if ((type instanceof JvmDeclaredType)) {
final Function1<String, Boolean> _function = (String it) -> {
QualifiedName _lowerCase = this.nameConverter.toQualifiedName(it).toLowerCase();
return Boolean.valueOf(result.add(_lowerCase));
};
this.registerAllTypes(((JvmType) type), _function);
}
}
}
}
final LightweightTypeReference typeRef = types.getActualType(expression);
if ((typeRef != null)) {
final Function1<String, Boolean> _function = (String it) -> {
QualifiedName _lowerCase = this.nameConverter.toQualifiedName(it).toLowerCase();
return Boolean.valueOf(result.add(_lowerCase));
};
this.registerAllTypes(typeRef.getType(), _function);
}
}
}
EList<EObject> _contents = this.getResource().getContents();
for (final EObject eobject : _contents) {
{
final Function1<JvmIdentifiableElement, LightweightTypeReference> _function = (JvmIdentifiableElement it) -> {
LightweightTypeReference _xifexpression = null;
if (((!(it instanceof JvmType)) || (it instanceof JvmDeclaredType))) {
_xifexpression = types.getActualType(it);
}
return _xifexpression;
};
final Iterable<LightweightTypeReference> typesOfIdentifiables = IteratorExtensions.<LightweightTypeReference>toIterable(IteratorExtensions.<JvmIdentifiableElement, LightweightTypeReference>map(Iterators.<JvmIdentifiableElement>filter(EcoreUtil.<Object>getAllContents(eobject, true), JvmIdentifiableElement.class), _function));
for (final LightweightTypeReference typeRef : typesOfIdentifiables) {
if ((typeRef != null)) {
final Function1<String, Boolean> _function_1 = (String it) -> {
QualifiedName _lowerCase = this.nameConverter.toQualifiedName(it).toLowerCase();
return Boolean.valueOf(result.add(_lowerCase));
};
this.registerAllTypes(typeRef.getType(), _function_1);
}
}
}
}
}
Iterables.<QualifiedName>addAll(result, super.getImportedNames());
final Function1<QualifiedName, Boolean> _function = (QualifiedName it) -> {
boolean _contains = XtendResourceDescription.primitivesFilter.contains(it.getLastSegment());
return Boolean.valueOf((!_contains));
};
this.importedNames = IterableExtensions.<QualifiedName>toSet(IterableExtensions.<QualifiedName>filter(result, _function));
return this.importedNames;
}
Aggregations