use of org.eclipse.emf.ecore.util.InternalEList in project dsl-devkit by dsldevkit.
the class AbstractResourceDescriptionStrategy method createReferenceDescriptions.
@Override
@SuppressWarnings("unchecked")
public boolean createReferenceDescriptions(final EObject from, final URI exportedContainerURI, final IAcceptor<IReferenceDescription> acceptor) {
final EList<EReference> references = from.eClass().getEAllReferences();
for (EReference eReference : references) {
if (isIndexable(from, eReference)) {
final Object val = from.eGet(eReference, false);
if (val != null) {
if (eReference.isMany()) {
final InternalEList<EObject> list = (InternalEList<EObject>) val;
for (int i = 0; i < list.size(); i++) {
EObject to = list.basicGet(i);
acceptResolvedReference(from, to, eReference, exportedContainerURI, i, acceptor);
}
} else {
final EObject to = (EObject) val;
acceptResolvedReference(from, to, eReference, exportedContainerURI, -1, acceptor);
}
}
}
}
return true;
}
use of org.eclipse.emf.ecore.util.InternalEList in project xtext-core by eclipse.
the class BasicLazyLinkingTest method testLazyMultiRef.
@Test
public void testLazyMultiRef() throws Exception {
XtextResource resource = getResource(new StringInputStream("type A {} type B { A B a; }"));
Model m = (Model) resource.getContents().get(0);
Type t2 = m.getTypes().get(1);
Property property = t2.getProperties().get(0);
EList<Type> types = property.getType();
assertTrue(((InternalEObject) ((InternalEList<Type>) types).basicGet(0)).eIsProxy());
assertTrue(((InternalEObject) ((InternalEList<Type>) types).basicGet(0)).eIsProxy());
assertFalse(((InternalEObject) types.get(0)).eIsProxy());
assertFalse(((InternalEObject) types.get(1)).eIsProxy());
}
use of org.eclipse.emf.ecore.util.InternalEList in project xtext-core by eclipse.
the class LazyLinkingResourceTest method testResolveLazyCrossReferences_02.
@Test
public void testResolveLazyCrossReferences_02() throws Exception {
with(lazyLinkingTestLangaugeSetup());
ResourceSetImpl rs = new ResourceSetImpl();
final Resource res1 = rs.createResource(URI.createURI("file1.lazylinkingtestlanguage"));
Resource res2 = rs.createResource(URI.createURI("file2.lazylinkingtestlanguage"));
res1.load(new StringInputStream("type Foo { } type Baz { Foo Bar prop; } }"), null);
res2.load(new StringInputStream("type Bar { }"), null);
res1.eAdapters().add(notificationAlert);
Model m = (Model) res1.getContents().get(0);
Type t = m.getTypes().get(1);
Property p = t.getProperties().get(0);
final InternalEList<Type> types = (InternalEList<Type>) p.getType();
assertEquals(2, types.size());
for (Iterator<Type> it = types.basicIterator(); it.hasNext(); ) {
final Type tt = it.next();
assertTrue(tt.eIsProxy());
}
((LazyLinkingResource) res1).resolveLazyCrossReferences(CancelIndicator.NullImpl);
assertFalse(types.basicGet(0).eIsProxy());
assertTrue(types.basicGet(1).eIsProxy());
res1.eAdapters().remove(notificationAlert);
EcoreUtil.resolveAll(res1);
assertFalse(types.basicGet(0).eIsProxy());
assertFalse(types.basicGet(1).eIsProxy());
}
use of org.eclipse.emf.ecore.util.InternalEList in project xtext-eclipse by eclipse.
the class JdtBasedTypeFactory method createFormalParameter.
protected JvmFormalParameter createFormalParameter(ITypeBinding parameterType, String paramName, IAnnotationBinding[] annotations) {
JvmFormalParameter result = TypesFactory.eINSTANCE.createJvmFormalParameter();
if (paramName != null)
result.setName(paramName);
result.setParameterType(createTypeReference(parameterType));
if (annotations != null && annotations.length > 0) {
InternalEList<JvmAnnotationReference> parameterAnnotations = (InternalEList<JvmAnnotationReference>) result.getAnnotations();
for (IAnnotationBinding annotation : annotations) {
parameterAnnotations.addUnique(createAnnotationReference(annotation));
}
}
return result;
}
use of org.eclipse.emf.ecore.util.InternalEList in project xtext-eclipse by eclipse.
the class JdtBasedTypeFactory method createNestedTypes.
/**
* @since 2.4
*/
protected void createNestedTypes(ITypeBinding typeBinding, JvmDeclaredType result, String handleIdentifier, List<String> path, StringBuilder fqn) {
resolveMembers.start();
ITypeBinding[] declaredTypes = typeBinding.getDeclaredTypes();
if (declaredTypes.length > 0) {
InternalEList<JvmMember> members = (InternalEList<JvmMember>) result.getMembers();
int length = fqn.length();
for (ITypeBinding declaredType : declaredTypes) {
if (!declaredType.isAnonymous() && !declaredType.isSynthetic()) {
JvmDeclaredType nestedType = createType(declaredType, handleIdentifier, path, fqn);
if (nestedType.eClass() == TypesPackage.Literals.JVM_GENERIC_TYPE) {
if (((JvmGenericType) nestedType).isInterface()) {
nestedType.setStatic(true);
}
} else {
nestedType.setStatic(true);
}
members.addUnique(nestedType);
fqn.setLength(length);
}
}
}
resolveMembers.stop();
}
Aggregations