use of org.eclipse.xtext.xbase.imports.TypeUsage in project xtext-xtend by eclipse.
the class TypeUsageCollectorTest method hasUnresolvedType.
private void hasUnresolvedType(final Resource resource, final String... typeNames) {
final TypeUsages typeUsages = this.typeUsageCollector.collectTypeUsages(((XtextResource) resource));
final Function1<TypeUsage, String> _function = (TypeUsage it) -> {
return it.getUsedTypeName();
};
final Set<String> usedNames = IterableExtensions.<String>toSet(ListExtensions.<TypeUsage, String>map(typeUsages.getUnresolvedTypeUsages(), _function));
Assert.assertEquals(IterableExtensions.<String>toSet(((Iterable<String>) Conversions.doWrapArray(typeNames))), usedNames);
}
use of org.eclipse.xtext.xbase.imports.TypeUsage in project xtext-eclipse by eclipse.
the class InteractiveUnresolvedTypeResolver method resolve.
@Override
public void resolve(TypeUsages typeUsages, XtextResource resource) {
if (typeUsages.getUnresolvedTypeUsages().isEmpty() || resource == null)
return;
Multimap<String, TypeUsage> name2usage = LinkedHashMultimap.create();
for (TypeUsage unresolved : typeUsages.getUnresolvedTypeUsages()) {
String text = unresolved.getUsedTypeName();
text = nameValueConverter.toValue(text, null);
name2usage.put(text, unresolved);
}
for (String name : name2usage.keySet()) {
Iterable<TypeUsage> usages = name2usage.get(name);
JvmDeclaredType resolvedType = resolve(name, usages, resource);
if (resolvedType != null) {
for (TypeUsage usage : usages) typeUsages.addTypeUsage(resolvedType, usage.getSuffix(), usage.getTextRegion(), usage.getContext());
}
}
}
use of org.eclipse.xtext.xbase.imports.TypeUsage in project xtext-xtend by eclipse.
the class TypeUsageCollectorTest method hasUnresolvedTypeSuffix.
private void hasUnresolvedTypeSuffix(final CharSequence xtendFile, final String... suffix) {
try {
final Resource resource = this.file(xtendFile.toString()).eResource();
final TypeUsages typeUsages = this.typeUsageCollector.collectTypeUsages(((XtextResource) resource));
final Function1<TypeUsage, String> _function = (TypeUsage it) -> {
return it.getSuffix();
};
final Set<String> foundSuffix = IterableExtensions.<String>toSet(ListExtensions.<TypeUsage, String>map(typeUsages.getUnresolvedTypeUsages(), _function));
Assert.assertEquals(IterableExtensions.<String>toSet(((Iterable<String>) Conversions.doWrapArray(suffix))), foundSuffix);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations