コード例 #1
0
 protected static void doRemoveProxy(InternalEObject p, Resource res) {
   String id = p.eProxyURI().fragment();
   if (res instanceof XMLResource) {
     ((XMLResource) res).setID(p, id);
   }
   p.eSetProxyURI(null);
 }
コード例 #2
0
 protected static void doBecomeProxy(InternalEObject p, Resource res) {
   String id = res.getURIFragment(p);
   p.eSetProxyURI(res.getURI().appendFragment(id));
   if (res instanceof XMLResource) {
     ((XMLResource) res).setID(p, null);
   }
   p.eAdapters().clear();
 }
コード例 #3
0
 @Test
 public void testProxy() throws Exception {
   final XFeatureCall proxy = XbaseFactory.eINSTANCE.createXFeatureCall();
   URI _createURI = URI.createURI("path#fragment");
   ((InternalEObject) proxy).eSetProxyURI(_createURI);
   IBatchTypeResolver _typeResolver = this.getTypeResolver();
   final IResolvedTypes typeResolution = _typeResolver.resolveTypes(proxy);
   Assert.assertNotNull(typeResolution);
   Assert.assertEquals(IResolvedTypes.NULL, typeResolution);
 }
コード例 #4
0
 protected JvmTypeReference getTypeProxy(EObject pointer) {
   JvmParameterizedTypeReference typeReference =
       typesFactory.createJvmParameterizedTypeReference();
   final Resource eResource = pointer.eResource();
   String fragment = eResource.getURIFragment(pointer);
   URI uri = eResource.getURI();
   uri = uri.appendFragment(Xtend2Resource.FRAGMENT_PREFIX + fragment);
   ((InternalEObject) typeReference).eSetProxyURI(uri);
   return typeReference;
 }
コード例 #5
0
 @Test
 public void testBug300216() {
   JvmDeclaredType type = (JvmDeclaredType) getTypeProvider().findTypeByName("java.lang.Object");
   assertTrue(type.getSuperTypes().isEmpty());
   URI unresolveableType = URI.createURI("java:/Objects/Something#Something");
   JvmVoid proxy = TypesFactory.eINSTANCE.createJvmVoid();
   JvmParameterizedTypeReference typeReference =
       TypesFactory.eINSTANCE.createJvmParameterizedTypeReference();
   typeReference.setType(proxy);
   ((InternalEObject) proxy).eSetProxyURI(unresolveableType);
   type.getSuperTypes().add(typeReference);
   assertTrue(type.getSuperTypes().get(0).getType().eIsProxy());
   assertEquals(2, type.eResource().getResourceSet().getResources().size());
 }
コード例 #6
0
ファイル: JSONLoad.java プロジェクト: borlander/emfjson
  private EObject createProxy(Resource resource, EClass eClass, JsonNode node) {
    EObject proxy = null;

    if (isRefNode(node)) {
      final URI objectURI = getEObjectURI(node.get(EJS_REF_KEYWORD), resource.getURI(), nsMap);
      proxy = EcoreUtil.create(eClass);
      ((InternalEObject) proxy).eSetProxyURI(objectURI);

      if (useProxyAttributes) {
        JsonNode refNode = JSUtil.getNode(resource, objectURI, eClass);
        if (refNode != null) fillEAttribute(proxy, refNode);
      }
    }

    return proxy;
  }
コード例 #7
0
  protected void convertContent(Object target) {
    // if a proxy then do no feature conversions as this may load
    // the object
    InternalEObject eObject = objectMapping.get(target);
    final ModelObject<?> modelObject = ModelResolver.getInstance().getModelObject(target);
    if (getProxyObjects().contains(target)) {
      final URI proxyURI = getProxyId(modelObject);
      if (proxyURI != null) {
        eObject.eSetProxyURI(proxyURI);
      }
      return;
    }

    for (final EStructuralFeature eStructuralFeature :
        eObject.eClass().getEAllStructuralFeatures()) {
      if (!eStructuralFeature.isChangeable() || eStructuralFeature.isVolatile()) {
        continue;
      }

      if (FeatureMapUtil.isFeatureMap(eStructuralFeature)) {
        convertFeatureMap(modelObject, eObject, eStructuralFeature);
      } else if (eStructuralFeature.isMany()) {
        if (eStructuralFeature instanceof EAttribute) {
          final EAttribute eAttribute = (EAttribute) eStructuralFeature;
          convertManyEAttribute(modelObject, eObject, eAttribute);
        } else {
          final EReference eReference = (EReference) eStructuralFeature;
          convertManyEReference(modelObject, eObject, eReference);
        }
      } else {
        if (eStructuralFeature instanceof EAttribute) {
          final EAttribute eAttribute = (EAttribute) eStructuralFeature;
          convertSingleEAttribute(modelObject, eObject, eAttribute);
        } else {
          final EReference eReference = (EReference) eStructuralFeature;
          convertSingleEReference(modelObject, eObject, eReference);
        }
      }
    }
  }
コード例 #8
0
ファイル: GbindResource.java プロジェクト: jesusc/bento
 public <
         ContainerType extends org.eclipse.emf.ecore.EObject,
         ReferenceType extends org.eclipse.emf.ecore.EObject>
     void registerContextDependentProxy(
         genericity.language.gbind.IGbindContextDependentURIFragmentFactory<
                 ContainerType, ReferenceType>
             factory,
         ContainerType container,
         org.eclipse.emf.ecore.EReference reference,
         String id,
         org.eclipse.emf.ecore.EObject proxyElement,
         int position) {
   org.eclipse.emf.ecore.InternalEObject proxy =
       (org.eclipse.emf.ecore.InternalEObject) proxyElement;
   String internalURIFragment =
       genericity.language.gbind.IGbindContextDependentURIFragment.INTERNAL_URI_FRAGMENT_PREFIX
           + (proxyCounter++)
           + "_"
           + id;
   genericity.language.gbind.IGbindContextDependentURIFragment<?> uriFragment =
       factory.create(id, container, reference, position, proxy);
   proxy.eSetProxyURI(getURI().appendFragment(internalURIFragment));
   addURIFragment(internalURIFragment, uriFragment);
 }