}
@Check
public void checkSameIDForAllLocationWithSameURI(final TargetPlatform targetPlatform) {
final ListMultimap<String, Location> locationsByURI = this.indexBuilder.getLocationIndex(targetPlatform);
final Resource resource = targetPlatform.eResource();
Set<String> _keySet = locationsByURI.keySet();
for (final String locationURI : _keySet) {
{
List<Location> _get = locationsByURI.get(locationURI);
final Function1<Location, Boolean> _function = new Function1<Location, Boolean>() {
public Boolean apply(final Location it) {
Resource _eResource = it.eResource();
return Boolean.valueOf((!Objects.equal(_eResource, resource)));
}
};
final Iterable<Location> externalLocations = IterableExtensions.<Location>filter(_get, _function);
final Function1<Location, String> _function_1 = new Function1<Location, String>() {
public String apply(final Location it) {
String _iD = it.getID();
return Strings.nullToEmpty(_iD);
}
};
Iterable<String> _map = IterableExtensions.<Location, String>map(externalLocations, _function_1);
final Set<String> externalIDs = IterableExtensions.<String>toSet(_map);
List<Location> _get_1 = locationsByURI.get(locationURI);
final Function1<Location, Boolean> _function_2 = new Function1<Location, Boolean>() {
public Boolean apply(final Location it) {
Resource _eResource = it.eResource();
return Boolean.valueOf(Objects.equal(_eResource, resource));
}
};
final Iterable<Location> internalLocations = IterableExtensions.<Location>filter(_get_1, _function_2);
final Function1<Location, String> _function_3 = new Function1<Location, String>() {
public String apply(final Location it) {
String _iD = it.getID();
return Strings.nullToEmpty(_iD);
}
};
Iterable<String> _map_1 = IterableExtensions.<Location, String>map(internalLocations, _function_3);
final Set<String> internalIDs = IterableExtensions.<String>toSet(_map_1);
int _size = externalIDs.size();
boolean _greaterThan = (_size > 1);
if (_greaterThan) {
final Function1<Location, Boolean> _function_4 = new Function1<Location, Boolean>() {
public Boolean apply(final Location it) {
String _iD = it.getID();
return Boolean.valueOf(externalIDs.contains(_iD));
}
};
final Iterable<Location> externalLocationsWithConflictualID = IterableExtensions.<Location>filter(externalLocations, _function_4);
StringConcatenation _builder = new StringConcatenation();
_builder.append("The ID for location \'");
_builder.append(locationURI, "");
_builder.append("\' must be unique. Found \'");
String _join = IterableExtensions.join(externalIDs, "\', \'");
_builder.append(_join, "");
_builder.append("\' in \'");
final Function1<Location, String> _function_5 = new Function1<Location, String>() {
public String apply(final Location it) {
Resource _eResource = it.eResource();
URI _uRI = _eResource.getURI();
return _uRI.toString();
}
};
Iterable<String> _map_2 = IterableExtensions.<Location, String>map(externalLocationsWithConflictualID, _function_5);
Set<String> _set = IterableExtensions.<String>toSet(_map_2);
String _join_1 = IterableExtensions.join(_set, "\', \'");
_builder.append(_join_1, "");
_builder.append("\'.");
final String msg = _builder.toString();
final Function1<Location, Iterable<IncludeDeclaration>> _function_6 = new Function1<Location, Iterable<IncludeDeclaration>>() {
public Iterable<IncludeDeclaration> apply(final Location location) {
EList<IncludeDeclaration> _includes = targetPlatform.getIncludes();
final Function1<IncludeDeclaration, Boolean> _function = new Function1<IncludeDeclaration, Boolean>() {
public Boolean apply(final IncludeDeclaration it) {
boolean _xblockexpression = false;
{
final TargetPlatform direct = TargetPlatformValidator.this.indexBuilder.getImportedTargetPlatform(resource, it);
boolean _or = false;
EList<Location> _locations = direct.getLocations();
boolean _contains = _locations.contains(location);
if (_contains) {
_or = true;
} else {
LinkedList<TargetPlatform> _importedTargetPlatforms = TargetPlatformValidator.this.indexBuilder.getImportedTargetPlatforms(direct);
final Function1<TargetPlatform, EList<Location>> _function = new Function1<TargetPlatform, EList<Location>>() {
public EList<Location> apply(final TargetPlatform it) {
return it.getLocations();
}
};
List<EList<Location>> _map = ListExtensions.<TargetPlatform, EList<Location>>map(_importedTargetPlatforms, _function);
Iterable<Location> _flatten = Iterables.<Location>concat(_map);
Set<Location> _set = IterableExtensions.<Location>toSet(_flatten);
boolean _contains_1 = _set.contains(location);
_or = _contains_1;
}
_xblockexpression = _or;
}
return Boolean.valueOf(_xblockexpression);
}
};
return IterableExtensions.<IncludeDeclaration>filter(_includes, _function);
}
};
Iterable<Iterable<IncludeDeclaration>> _map_3 = IterableExtensions.<Location, Iterable<IncludeDeclaration>>map(externalLocationsWithConflictualID, _function_6);
Iterable<IncludeDeclaration> _flatten = Iterables.<IncludeDeclaration>concat(_map_3);
final Set<IncludeDeclaration> conflictualInclude = IterableExtensions.<IncludeDeclaration>toSet(_flatten);
final Procedure1<IncludeDeclaration> _function_7 = new Procedure1<IncludeDeclaration>() {
public void apply(final IncludeDeclaration it) {
TargetPlatformValidator.this.error(msg, it,
TargetPlatformPackage.Literals.INCLUDE_DECLARATION__IMPORT_URI,
TargetPlatformValidator.CHECK__CONFLICTUAL_ID__BETWEEN_INCLUDED_LOCATION);
}
};
IterableExtensions.<IncludeDeclaration>forEach(conflictualInclude, _function_7);
}
int _size_1 = externalIDs.size();
boolean _equals = (_size_1 == 1);
if (_equals) {
final Sets.SetView<String> diff = Sets.<String>symmetricDifference(externalIDs, internalIDs);
boolean _isEmpty = diff.isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("The ID for location \'");
_builder_1.append(locationURI, "");
_builder_1.append("\' must be unique across included target platforms and the current one. Found \'");
String _head = IterableExtensions.<String>head(externalIDs);
_builder_1.append(_head, "");
_builder_1.append("\' in \'");
final Function1<Location, String> _function_8 = new Function1<Location, String>() {
public String apply(final Location it) {
Resource _eResource = it.eResource();
URI _uRI = _eResource.getURI();
return _uRI.toString();
}
};
Iterable<String> _map_4 = IterableExtensions.<Location, String>map(externalLocations, _function_8);
Set<String> _set_1 = IterableExtensions.<String>toSet(_map_4);