use of org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.Import in project xtext-core by eclipse.
the class PartialSerializationTestLanguageReferenceUpdater method update.
@Override
public void update(final IReferenceUpdaterContext context) {
super.update(context);
final Node node = IterableExtensions.<Node>head(Iterables.<Node>filter(context.getResource().getContents(), Node.class));
if ((node == null)) {
return;
}
final HashSet<Import> toDelete = CollectionLiterals.<Import>newHashSet();
final HashSet<QualifiedName> toAdd = CollectionLiterals.<QualifiedName>newHashSet();
final HashMap<Import, QualifiedName> toChange = CollectionLiterals.<Import, QualifiedName>newHashMap();
final Function1<Import, QualifiedName> _function = (Import it) -> {
return this.converter.toQualifiedName(it.getImportedNamespace());
};
final Map<QualifiedName, Import> imports = IterableExtensions.<QualifiedName, Import>toMap(node.getImports(), _function);
List<IUpdatableReference> _updatableReferences = context.getUpdatableReferences();
for (final IUpdatableReference target : _updatableReferences) {
{
final EObjectDescriptionDeltaProvider.Delta delta = this.findContainingDelta(context.getEObjectDescriptionDeltas(), target.getTargetEObject());
if ((delta != null)) {
final QualifiedName original = IterableExtensions.<IEObjectDescription>head(delta.getSnapshot().getDescriptions()).getQualifiedName();
final QualifiedName modified = IterableExtensions.<IEObjectDescription>head(delta.getDescriptions()).getQualifiedName();
boolean _notEquals = (!Objects.equal(original, modified));
if (_notEquals) {
final Import imp = imports.get(original);
if ((imp != null)) {
toChange.put(imp, modified);
}
}
}
}
}
final Runnable _function_1 = () -> {
for (final Import toDel : toDelete) {
EcoreUtil.remove(toDel);
}
Set<Map.Entry<Import, QualifiedName>> _entrySet = toChange.entrySet();
for (final Map.Entry<Import, QualifiedName> toCh : _entrySet) {
{
final Import imp = toCh.getKey();
final QualifiedName name = toCh.getValue();
imp.setImportedNamespace(this.converter.toString(name));
}
}
for (final QualifiedName toA : toAdd) {
EList<Import> _imports = node.getImports();
Import _createImport = PartialSerializationTestLanguageFactory.eINSTANCE.createImport();
final Procedure1<Import> _function_2 = (Import it) -> {
it.setImportedNamespace(this.converter.toString(toA));
};
Import _doubleArrow = ObjectExtensions.<Import>operator_doubleArrow(_createImport, _function_2);
_imports.add(_doubleArrow);
}
};
context.modifyModel(_function_1);
}
Aggregations