org.eclipse.emf.ecore.impl.EClassImpl Java Examples

The following examples show how to use org.eclipse.emf.ecore.impl.EClassImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LazyLinkingResource.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * resolves any lazy cross references in this resource, adding Issues for unresolvable elements to this resource.
 * This resource might still contain resolvable proxies after this method has been called.
 * 
 * @param mon a {@link CancelIndicator} can be used to stop the resolution.
 */
public void resolveLazyCrossReferences(final CancelIndicator mon) {
	final CancelIndicator monitor = mon == null ? CancelIndicator.NullImpl : mon;
	TreeIterator<Object> iterator = EcoreUtil.getAllContents(this, true);
	while (iterator.hasNext()) {
		operationCanceledManager.checkCanceled(monitor);
		InternalEObject source = (InternalEObject) iterator.next();
		EStructuralFeature[] eStructuralFeatures = ((EClassImpl.FeatureSubsetSupplier) source.eClass()
				.getEAllStructuralFeatures()).crossReferences();
		if (eStructuralFeatures != null) {
			for (EStructuralFeature crossRef : eStructuralFeatures) {
				operationCanceledManager.checkCanceled(monitor);
				resolveLazyCrossReference(source, crossRef);
			}
		}
	}
}
 
Example #2
Source File: EcoreUtil2.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @since 2.6
 */
public static Iterator<EObject> getNonDerivedContents(EObject eObject) {
	EClassImpl.FeatureSubsetSupplier featureSupplier = (EClassImpl.FeatureSubsetSupplier) eObject.eClass().getEAllStructuralFeatures();
	EStructuralFeature[] eStructuralFeatures = featureSupplier.containments();

	return (eStructuralFeatures == null 
			? EContentsEList.<EObject> emptyContentsEList()
			: new EContentsEList<EObject>(eObject, eStructuralFeatures) {
				@Override
				protected ListIterator<EObject> newResolvingListIterator() {
					return new ResolvingFeatureIteratorImpl<EObject>(eObject, eStructuralFeatures) {
						@Override
						protected boolean isIncluded(EStructuralFeature eStructuralFeature) {
							return !eStructuralFeature.isDerived();
						}
					};
				}
			}).iterator();
}
 
Example #3
Source File: AbstractSCTResource.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
public void resolveLazyCrossReferences(CancelIndicator monitor) {
	TreeIterator<Object> iterator = EcoreUtil.getAllContents(this, true);
	while (iterator.hasNext()) {
		InternalEObject source = (InternalEObject) iterator.next();
		EStructuralFeature[] eStructuralFeatures = ((EClassImpl.FeatureSubsetSupplier) source.eClass()
				.getEAllStructuralFeatures()).crossReferences();
		if (eStructuralFeatures != null) {
			for (EStructuralFeature crossRef : eStructuralFeatures) {
				if (monitor.isCanceled()) {
					return;
				}
				resolveLazyCrossReference(source, crossRef, monitor);
			}
		}
	}
}
 
Example #4
Source File: EMFGeneratorFragment2.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
private void replaceReferencesInGeneratedPackages(final List<EPackage> generatedPackages, final Map<EObject, EObject> eNamedElementMapping) {
  final TreeIterator<EObject> packageContentIterator = EcoreUtil.<EObject>getAllContents(generatedPackages);
  while (packageContentIterator.hasNext()) {
    {
      final EObject current = packageContentIterator.next();
      EList<EStructuralFeature> _eAllStructuralFeatures = current.eClass().getEAllStructuralFeatures();
      final EStructuralFeature[] crossReferenceFeatures = ((EClassImpl.FeatureSubsetSupplier) _eAllStructuralFeatures).crossReferences();
      if ((crossReferenceFeatures != null)) {
        for (final EStructuralFeature crossReferenceFeature : crossReferenceFeatures) {
          boolean _isChangeable = crossReferenceFeature.isChangeable();
          if (_isChangeable) {
            final EReference reference = ((EReference) crossReferenceFeature);
            boolean _isMany = reference.isMany();
            if (_isMany) {
              Object _eGet = current.eGet(reference);
              final List<EObject> values = ((List<EObject>) _eGet);
              for (final EObject value : values) {
                boolean _containsKey = eNamedElementMapping.containsKey(value);
                if (_containsKey) {
                  EcoreUtil.replace(current, reference, value, eNamedElementMapping.get(value));
                }
              }
            } else {
              Object _eGet_1 = current.eGet(reference);
              final EObject value_1 = ((EObject) _eGet_1);
              boolean _containsKey_1 = eNamedElementMapping.containsKey(value_1);
              if (_containsKey_1) {
                EcoreUtil.replace(current, reference, value_1, eNamedElementMapping.get(value_1));
              }
            }
          }
        }
      }
    }
  }
}
 
Example #5
Source File: InstanceImpl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public EList<EObject> eContents() {
    if (getType().getModel().isReflection()) {
        final EStructuralFeature[] features = ((EClassImpl.FeatureSubsetSupplier) getEClass()
                .getEAllStructuralFeatures()).containments();
        return new EContentsEList<EObject>(this, features);
    }
    return super.eContents();
}
 
Example #6
Source File: InstanceImpl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public EList<EObject> eCrossReferences() {
    if (getType().getModel().isReflection()) {
        final EStructuralFeature[] features = ((EClassImpl.FeatureSubsetSupplier) getEClass()
                .getEAllStructuralFeatures()).crossReferences();
        return new EContentsEList<EObject>(this, features);
    }
    return super.eCrossReferences();
}