/** * Remove all references to this schema, and all schemas built in the same resource set It is * important to call this method for every dynamic schema created that is not needed anymore, * because references in the static schema's will otherwise keep it alive forever */ public void dispose() { if (schema != null) { ResourceSet rs = schema.eResource().getResourceSet(); for (Resource r : rs.getResources()) { if (r instanceof XSDResourceImpl) { Schemas.dispose(((XSDResourceImpl) r).getSchema()); } } schema = null; } } }
resource.getResourceSet().getAdapterFactories().add(adapterFactory); return imprt;
ResourceSet resourceSet = xsdSchema.eResource().getResourceSet(); Resource resolvedResource = resourceSet.getResource(
private ResourceSet getResourceSet(Resource resource) { return resource == null ? null : resource.getResourceSet(); }
/** * @noreference This method is called by the framework * @nooverride */ void setContext(Resource resource) { _annotationTypesBuilder = annotationRefBuilderFactory.create(resource.getResourceSet()); _typeReferenceBuilder = typeRefBuilderFactory.create(resource.getResourceSet()); }
protected Profile getUML2Profile(Element element) { Resource eResource = element.eResource(); if (eResource != null) { ResourceSet resourceSet = eResource.getResourceSet(); if (resourceSet != null) { return UML2Util.load(resourceSet, URI .createURI(UML22UMLResource.UML2_PROFILE_URI), UMLPackage.Literals.PROFILE); } } return null; }
protected Profile getEcoreProfile(EObject eObject) { Resource eResource = eObject.eResource(); if (eResource != null) { ResourceSet resourceSet = eResource.getResourceSet(); if (resourceSet != null) { return UML2Util.load(resourceSet, URI .createURI(UMLResource.ECORE_PROFILE_URI), UMLPackage.Literals.PROFILE); } } return null; }
public static Resource getResource(Resource context, String uri) { org.eclipse.emf.common.util.URI newURI = getResolvedImportUri(context, org.eclipse.emf.common.util.URI.createURI(uri)); try { return context.getResourceSet().getResource(newURI, true); } catch (RuntimeException e) { // thrown by org.eclipse.emf.ecore.resource.ResourceSet#getResource(URI, boolean) //log.trace("Cannot load resource: " + newURI, e); } return null; }
private JavaClass getEJBObjectClass(EnterpriseBean bean) { Resource res = bean.eResource(); ResourceSet set = res != null ? res.getResourceSet() : null; return (JavaClass) JavaRefFactory.eINSTANCE.reflectType("javax.ejb", "EJBObject", set); //$NON-NLS-1$ //$NON-NLS-2$ } private JavaClass getEJBLocalObjectClass(EnterpriseBean bean) {
private JavaClass getEJBLocalObjectClass(EnterpriseBean bean) { Resource res = bean.eResource(); ResourceSet set = res != null ? res.getResourceSet() : null; return (JavaClass) JavaRefFactory.eINSTANCE.reflectType("javax.ejb", "EJBLocalObject", set); //$NON-NLS-1$ //$NON-NLS-2$ } private JavaClass getEJBHomeClass(EnterpriseBean bean) {
protected static IFile internalGetFile(Resource aResource) { if (aResource != null) return getFile(aResource.getResourceSet(), aResource.getURI()); return null; }
protected URI getNormalizedURI(Resource resource) { URI uri = resource.getURI(); if (uri != null && !uri.isPlatform() && resource.getResourceSet() != null) return resource.getResourceSet().getURIConverter().normalize(uri); else return uri; }
public JavaHelpers reflectType(String aQualifiedName, EObject relatedObject) { Resource r = relatedObject.eResource(); if (r != null) { ResourceSet rs = r.getResourceSet(); if (rs != null) { return reflectType(aQualifiedName, rs); } } return null; }
/** * @deprecated In EMF 2.2, a {@link org.eclipse.emf.codegen.ecore.generator.GeneratorAdapter GeneratorAdapter} should be used to * implement code generation. {@link org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter AbstractGeneratorAdapter} provides * an equivalent to this method. This method will be removed after 2.2. */ @Deprecated public OutputStream createOutputStream(URI uri) throws Exception { URIConverter uriConverter = eResource().getResourceSet().getURIConverter(); return uriConverter.createOutputStream(uri); }
public static URI getNormalizedURI(EObject eObject) { URI rawURI = EcoreUtil.getURI(eObject); Resource resource = eObject.eResource(); if(resource != null && resource.getResourceSet() != null) { return resource.getResourceSet().getURIConverter().normalize(rawURI); } else { return URIConverter.INSTANCE.normalize(rawURI); } }
protected void setDeclaringClass() { Class declaringType = getSourceType().getDeclaringClass(); if (declaringType != null) { // Need to get it and reflect it so that the declared type of this target is set correctly. We can just // set it ourselves directly because ECore would try to add it to the list of inner classes of the declaring type. This // would cause it to be added twice, once from the reflection caused by the inverse setting, and once from our doing // the inverse setting itself. ResourceSet set = getTargetResource().getResourceSet(); JavaClassImpl declaringClass = (JavaClassImpl) JavaRefFactory.eINSTANCE.reflectType(declaringType.getName(), set); declaringClass.getDeclaredClasses(); // This will cause it to put us into its list and also set our declaring class to this declaring type. } }
public void dispose() { Resource resource = eResource(); ResourceSet resourceSet = resource.getResourceSet(); resourceSet.getResources().remove(resource); }
public void reconcileGenAnnotations(GenBase oldGenBase) { if (!oldGenBase.getGenAnnotations().isEmpty() && eResource() != null && eResource().getResourceSet() != null) { GenAnnotationCopier copier = new GenAnnotationCopier(eResource().getResourceSet(), oldGenBase); Collection<GenAnnotation> genAnnotationsCopy = copier.copyAll(oldGenBase.getGenAnnotations()); copier.copyReferences(); getGenAnnotations().clear(); getGenAnnotations().addAll(genAnnotationsCopy); } }
/** * Returns the resolved features that are defined in the given <code>type</code> and its supertypes. * Considers private methods of super types, too. * @param type the type. Has to be contained in a resource. * @return the resolved features. */ public ResolvedFeatures getResolvedFeatures(JvmDeclaredType type) { ITypeReferenceOwner owner = new StandardTypeReferenceOwner(services, type.eResource().getResourceSet()); LightweightTypeReference contextType = owner.toLightweightTypeReference(type); return getResolvedFeatures(contextType); }
/** * Returns the resolved features targeting a specific Java version in order to support new language features. */ public ResolvedFeatures getResolvedFeatures(JvmDeclaredType type, JavaVersion targetVersion) { ITypeReferenceOwner owner = new StandardTypeReferenceOwner(services, type.eResource().getResourceSet()); LightweightTypeReference contextType = owner.toLightweightTypeReference(type); return getResolvedFeatures(contextType, targetVersion); }