@Override public URI appendFragment(String fragment) { return uri.appendFragment(fragment); }
protected URI appendFragment(URI result, String fragment) { if (fragment != null) return result.appendFragment(fragment); else return result; }
private URI appendFragment(URI uri) { // If the hash code is 0 then it's highly likely we've deferred split interning the fragment, so don't use rawAppendFragment in that case. // return hashCode == 0 ? uri.appendFragment(fragment.toString()) : uri.rawAppendFragment(fragment); }
public URI getURI() { URI typeURI = type.getURI(); String typeFragment = typeURI.fragment(); if (operation) { return typeURI.appendFragment(typeFragment + "." + String.valueOf(chars) + "()"); } return typeURI.appendFragment(typeFragment + "." + String.valueOf(chars)); }
/** * @return URI pointing to a type, which is the conatiner type in case of a fragment pointing to a method. */ public URI getTypeURI() { if ((this.idx == (-1))) { return this.uri; } else { final String f = this.uri.fragment(); return this.uri.appendFragment(f.substring(0, this.idx)); } }
protected URI redirect(URI uri) { URI mappedURI = uriMap.get(uri.trimFragment()); return mappedURI == null ? uri : mappedURI.appendFragment(uri.fragment()); }
protected void clearPackage(Resource resource, EPackage pack) { Map<InternalEObject, URI> uris = Maps.newHashMap(); for(EClassifier classifier: pack.getEClassifiers()) { InternalEObject internalEObject = (InternalEObject) classifier; URI appendFragment = resource.getURI().appendFragment(resource.getURIFragment(internalEObject)); uris.put(internalEObject, appendFragment); } pack.getEClassifiers().clear(); for (Map.Entry<InternalEObject, URI> entry : uris.entrySet()) { entry.getKey().eSetProxyURI(entry.getValue()); } }
protected URI getHREF(Resource otherResource, EObject obj) { return otherResource.getURI().appendFragment(getURIFragment(otherResource, obj)); }
public URI findResourceOnClasspath(ClassLoader classLoader, URI classpathUri) throws URISyntaxException { String pathAsString = classpathUri.path(); if (classpathUri.hasAbsolutePath()) { pathAsString = pathAsString.substring(1); } URL resource = classLoader.getResource(pathAsString); if (resource==null) throw new FileNotFoundOnClasspathException("Couldn't find resource on classpath. URI was '"+classpathUri+"'"); URI fileUri = URI.createURI(resource.toString(),true); return fileUri.appendFragment(classpathUri.fragment()); }
protected List<JvmType> createObjectReference(ResourceSet resourceSet) { // no upper bound found - seems to be an invalid - assume object as upper bound JvmType objectType = factory.createJvmGenericType(); String objectClassName = Object.class.getName(); ((InternalEObject) objectType).eSetProxyURI(URIHelperConstants.OBJECTS_URI.appendSegment(objectClassName).appendFragment(objectClassName)); objectType = (JvmType) EcoreUtil.resolve(objectType, resourceSet); return Collections.singletonList(objectType); } }
private JvmTypeReference newObjectReference() { JvmType objectType = typesFactory.createJvmGenericType(); String objectClassName = Object.class.getName(); ((InternalEObject) objectType).eSetProxyURI(URIHelperConstants.OBJECTS_URI.appendSegment(objectClassName).appendFragment(objectClassName)); JvmParameterizedTypeReference result = typesFactory.createJvmParameterizedTypeReference(); result.setType(objectType); return result; }
private LightweightTypeReference findPrimitive(String primitive) { JvmType result = (JvmType) getOwner().getContextResourceSet().getEObject(URIHelperConstants.PRIMITIVES_URI.appendFragment(primitive), true); if (result != null) { return getOwner().newParameterizedTypeReference(result); } throw new IllegalStateException("Cannot find primitive type: " + primitive); }
protected LightweightTypeReference createObjectReference(ITypeReferenceOwner owner, ResourceSet resourceSet) { // no upper bound found - seems to be an invalid - assume object as upper bound JvmType objectType = factory.createJvmGenericType(); String objectClassName = Object.class.getName(); ((InternalEObject) objectType).eSetProxyURI(URIHelperConstants.OBJECTS_URI.appendSegment(objectClassName).appendFragment(objectClassName)); objectType = (JvmType) EcoreUtil.resolve(objectType, resourceSet); return owner.newParameterizedTypeReference(objectType); } }
public static EPackage loadEcoreFile(ClassLoader loader, String string) { URI uri = URI.createURI(string); if (!uri.hasFragment()) uri = uri.appendFragment("/"); URI normalized = new ClassloaderClasspathUriResolver().resolve(loader, uri); return (EPackage) new ResourceSetImpl().getEObject(normalized, true); }
protected EObject createProxy(EObject obj, INode node, EReference eRef) { final Resource resource = obj.eResource(); if (resource == null) throw new IllegalStateException("object must be contained in a resource"); final URI uri = resource.getURI(); final URI encodedLink = uri.appendFragment(encoder.encode(obj, eRef, node)); EClass referenceType = ecoreGenericsUtil.getReferenceType(eRef, obj.eClass()); EClass instantiableType = instantiableSubTypes.get(referenceType); final EObject proxy = EcoreUtil.create(instantiableType); ((InternalEObject) proxy).eSetProxyURI(encodedLink); return proxy; }
protected void unload(EObject object) { InternalEObject internalEObject = (InternalEObject) object; Resource resource = object.eResource(); internalEObject.eSetProxyURI(resource.getURI().appendFragment(resource.getURIFragment(internalEObject))); }
@Override public URI getURI() { BinaryTypeSignature typeErasure = getArrayComponentType().getTypeErasure(); String identifier = typeErasure.toIdentifier(); URI result = URIHelperConstants.OBJECTS_URI.appendSegment(identifier).appendFragment(toIdentifier()); return result; }
private JvmType findTypeByClass(Class<?> clazz) throws UnknownNestedTypeException { IndexedJvmTypeAccess indexedJvmTypeAccess = getIndexedJvmTypeAccess(); URI resourceURI = uriHelper.createResourceURI(clazz); if (indexedJvmTypeAccess != null) { URI proxyURI = resourceURI.appendFragment(uriHelper.getFragment(clazz)); EObject candidate = indexedJvmTypeAccess.getIndexedJvmType(proxyURI, getResourceSet()); if (candidate instanceof JvmType) return (JvmType) candidate; } TypeResource result = (TypeResource) getResourceSet().getResource(resourceURI, true); return findTypeByClass(clazz, result); }
private JvmType findTypeByClass(Class<?> clazz) { IndexedJvmTypeAccess indexedJvmTypeAccess = getIndexedJvmTypeAccess(); URI resourceURI = uriHelper.createResourceURI(clazz); if (indexedJvmTypeAccess != null) { URI proxyURI = resourceURI.appendFragment(uriHelper.getFragment(clazz)); EObject candidate = indexedJvmTypeAccess.getIndexedJvmType(proxyURI, getResourceSet()); if (candidate instanceof JvmType) return (JvmType) candidate; } TypeResource result = (TypeResource) getResourceSet().getResource(resourceURI, true); return findTypeByClass(clazz, result); }
protected FunctionTypeReference getAsProcedureOrNull(ParameterizedTypeReference typeReference) { ITypeReferenceOwner owner = typeReference.getOwner(); JvmType type = typeReference.getType(); FunctionTypeReference functionType = new FunctionTypeReference(owner, type); if (!tryAssignTypeArguments(typeReference.getTypeArguments(), functionType)) return null; JvmType voidType = (JvmType) owner.getContextResourceSet().getEObject(URIHelperConstants.PRIMITIVES_URI.appendFragment("void"), true); functionType.setReturnType(owner.newParameterizedTypeReference(voidType)); return functionType; }