use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.
the class MultimapBasedScope method isShadowed.
@Override
protected boolean isShadowed(IEObjectDescription fromParent) {
QualifiedName name = fromParent.getName();
if (isIgnoreCase()) {
name = name.toLowerCase();
}
boolean result = elements.containsKey(name);
return result;
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.
the class ResourceSetGlobalScopeProvider method createScopeWithQualifiedNames.
protected IScope createScopeWithQualifiedNames(final IScope parent, final Resource resource, final Predicate<IEObjectDescription> filter, ResourceSet resourceSet, EClass type, boolean ignoreCase) {
final Iterable<ISelectable> resourceDescriptions = Iterables.transform(resourceSet.getResources(), new Function<Resource, ISelectable>() {
@Override
public ISelectable apply(Resource from) {
return resourceDecriptionProvider.getResourceDescription(from);
}
});
ISelectable compound = new ISelectable() {
@Override
public boolean isEmpty() {
for (ISelectable description : resourceDescriptions) {
if (!description.isEmpty())
return false;
}
return true;
}
@Override
public Iterable<IEObjectDescription> getExportedObjectsByType(final EClass type) {
return Iterables.concat(Iterables.transform(resourceDescriptions, new Function<ISelectable, Iterable<IEObjectDescription>>() {
@Override
public Iterable<IEObjectDescription> apply(ISelectable from) {
return from.getExportedObjectsByType(type);
}
}));
}
@Override
public Iterable<IEObjectDescription> getExportedObjectsByObject(final EObject object) {
return Iterables.concat(Iterables.transform(resourceDescriptions, new Function<ISelectable, Iterable<IEObjectDescription>>() {
@Override
public Iterable<IEObjectDescription> apply(ISelectable from) {
return from.getExportedObjectsByObject(object);
}
}));
}
@Override
public Iterable<IEObjectDescription> getExportedObjects(final EClass type, final QualifiedName name, final boolean ignoreCase) {
return Iterables.concat(Iterables.transform(resourceDescriptions, new Function<ISelectable, Iterable<IEObjectDescription>>() {
@Override
public Iterable<IEObjectDescription> apply(ISelectable from) {
return from.getExportedObjects(type, name, ignoreCase);
}
}));
}
@Override
public Iterable<IEObjectDescription> getExportedObjects() {
return Iterables.concat(Iterables.transform(resourceDescriptions, new Function<ISelectable, Iterable<IEObjectDescription>>() {
@Override
public Iterable<IEObjectDescription> apply(ISelectable from) {
return from.getExportedObjects();
}
}));
}
};
return SelectableBasedScope.createScope(parent, compound, filter, type, ignoreCase);
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.
the class SerializableResourceDescriptionTest method testSerialization.
@Test
public void testSerialization() {
try {
final URI uri = URI.createURI("file:/foo/bar.baz.foo");
SerializableResourceDescription _serializableResourceDescription = new SerializableResourceDescription();
final Procedure1<SerializableResourceDescription> _function = (SerializableResourceDescription it) -> {
it.setURI(uri);
SerializableReferenceDescription _serializableReferenceDescription = new SerializableReferenceDescription();
final Procedure1<SerializableReferenceDescription> _function_1 = (SerializableReferenceDescription it_1) -> {
it_1.setSourceEObjectUri(uri.appendFragment("foo"));
it_1.setTargetEObjectUri(uri.appendFragment("hubble"));
it_1.setContainerEObjectURI(uri.appendFragment("baz"));
it_1.setEReference(EcorePackage.eINSTANCE.getEAnnotation_Contents());
it_1.setIndexInList(1);
};
SerializableReferenceDescription _doubleArrow = ObjectExtensions.<SerializableReferenceDescription>operator_doubleArrow(_serializableReferenceDescription, _function_1);
SerializableReferenceDescription _serializableReferenceDescription_1 = new SerializableReferenceDescription();
final Procedure1<SerializableReferenceDescription> _function_2 = (SerializableReferenceDescription it_1) -> {
it_1.setSourceEObjectUri(uri.appendFragment("foo2"));
it_1.setTargetEObjectUri(uri.appendFragment("hubble2"));
it_1.setContainerEObjectURI(uri.appendFragment("baz2"));
it_1.setEReference(EcorePackage.eINSTANCE.getEAnnotation_Contents());
it_1.setIndexInList(2);
};
SerializableReferenceDescription _doubleArrow_1 = ObjectExtensions.<SerializableReferenceDescription>operator_doubleArrow(_serializableReferenceDescription_1, _function_2);
it.setReferences(Collections.<SerializableReferenceDescription>unmodifiableList(CollectionLiterals.<SerializableReferenceDescription>newArrayList(_doubleArrow, _doubleArrow_1)));
SerializableEObjectDescription _serializableEObjectDescription = new SerializableEObjectDescription();
final Procedure1<SerializableEObjectDescription> _function_3 = (SerializableEObjectDescription it_1) -> {
it_1.setEObjectURI(uri.appendFragment("baz"));
it_1.qualifiedName = QualifiedName.create("foo", "baz");
it_1.setEClass(EcorePackage.eINSTANCE.getEAttribute());
Pair<String, String> _mappedTo = Pair.<String, String>of("myKey", "myValue");
it_1.userData = CollectionLiterals.<String, String>newHashMap(_mappedTo);
};
SerializableEObjectDescription _doubleArrow_2 = ObjectExtensions.<SerializableEObjectDescription>operator_doubleArrow(_serializableEObjectDescription, _function_3);
it.setDescriptions(Collections.<SerializableEObjectDescription>unmodifiableList(CollectionLiterals.<SerializableEObjectDescription>newArrayList(_doubleArrow_2)));
QualifiedName _create = QualifiedName.create("foo");
QualifiedName _create_1 = QualifiedName.create("foo", "bar");
it.setImportedNames(Collections.<QualifiedName>unmodifiableList(CollectionLiterals.<QualifiedName>newArrayList(_create, _create_1)));
};
final SerializableResourceDescription before = ObjectExtensions.<SerializableResourceDescription>operator_doubleArrow(_serializableResourceDescription, _function);
final ByteArrayOutputStream bout = new ByteArrayOutputStream();
final ObjectOutputStream objectOut = new ObjectOutputStream(bout);
objectOut.writeObject(before);
byte[] _byteArray = bout.toByteArray();
ByteArrayInputStream _byteArrayInputStream = new ByteArrayInputStream(_byteArray);
final ObjectInputStream in = new ObjectInputStream(_byteArrayInputStream);
Object _readObject = in.readObject();
final SerializableResourceDescription after = ((SerializableResourceDescription) _readObject);
this.assertDescriptionsEqual(before, after);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.
the class DefaultResourceDescription2Test 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;
}
});
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 testBrokenLink.
@Test
public void testBrokenLink() 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 Baz"), null);
EcoreUtil.resolveAll(res2);
Iterable<QualifiedName> names = res2.getResourceServiceProvider().getResourceDescriptionManager().getResourceDescription(res2).getImportedNames();
assertEquals(QualifiedName.create("baz"), names.iterator().next());
}
Aggregations