use of org.eclipse.xtext.naming.QualifiedName 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);
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.
the class DefaultReferenceDescriptionTest method createResourceDescription.
protected IResourceDescription createResourceDescription(Resource testResource) {
DefaultResourceDescriptionStrategy strategy = new DefaultResourceDescriptionStrategy();
strategy.setQualifiedNameProvider(new IQualifiedNameProvider.AbstractImpl() {
@Override
public QualifiedName getFullyQualifiedName(EObject obj) {
String name = SimpleAttributeResolver.NAME_RESOLVER.apply(obj);
return (name != null) ? QualifiedName.create(name) : null;
}
});
strategy.setLazyURIEncoder(new LazyURIEncoder());
IResourceDescription resourceDescription = new DefaultResourceDescription(testResource, strategy);
return resourceDescription;
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.
the class DefaultResourceDescription2Test method testValidExternalLink.
@Test
public void testValidExternalLink() throws Exception {
XtextResourceSet rs = get(XtextResourceSet.class);
Resource res1 = rs.createResource(URI.createURI("foo.langatestlanguage"));
res1.load(new StringInputStream("type Foo"), null);
XtextResource res2 = (XtextResource) rs.createResource(URI.createURI("bar.langatestlanguage"));
res2.load(new StringInputStream("import 'foo.langatestlanguage'" + "type Bar extends Foo"), null);
EcoreUtil.resolveAll(res2);
Iterable<QualifiedName> names = res2.getResourceServiceProvider().getResourceDescriptionManager().getResourceDescription(res2).getImportedNames();
assertEquals(QualifiedName.create("foo"), names.iterator().next());
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.
the class DefaultResourceDescription2Test method testValidLocalLink.
@Test
public void testValidLocalLink() throws Exception {
XtextResourceSet rs = get(XtextResourceSet.class);
Resource res1 = rs.createResource(URI.createURI("foo.langatestlanguage"));
res1.load(new StringInputStream("type Foo"), null);
XtextResource res2 = (XtextResource) rs.createResource(URI.createURI("bar.langatestlanguage"));
res2.load(new StringInputStream("import 'foo.langatestlanguage'" + "type Foo type Bar extends Foo"), null);
EcoreUtil.resolveAll(res2);
Iterable<QualifiedName> names = res2.getResourceServiceProvider().getResourceDescriptionManager().getResourceDescription(res2).getImportedNames();
assertFalse(names.iterator().hasNext());
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.
the class DefaultResourceDescription2Test method testNotYetLinked.
@Test
public void testNotYetLinked() throws Exception {
XtextResourceSet rs = get(XtextResourceSet.class);
Resource res1 = rs.createResource(URI.createURI("foo.langatestlanguage"));
res1.load(new StringInputStream("type Foo"), null);
XtextResource res2 = (XtextResource) rs.createResource(URI.createURI("bar.langatestlanguage"));
res2.load(new StringInputStream("import 'foo.langatestlanguage'" + "type Bar extends Foo"), null);
Iterable<QualifiedName> names = res2.getResourceServiceProvider().getResourceDescriptionManager().getResourceDescription(res2).getImportedNames();
assertTrue(names.iterator().hasNext());
}
Aggregations