public EObject getIndexedJvmType(QualifiedName qualifiedName, String fragment, ResourceSet resourceSet) throws UnknownNestedTypeException { return getIndexedJvmType(qualifiedName, fragment, resourceSet, false); }
public EObject resolveJavaArrayObject(JvmType rootType, String fragment) { JvmComponentType component = (JvmComponentType) resolveJavaObject(rootType, fragment.substring(0, fragment.length() - 2)); if (component == null) return null; return component.getArrayType(); }
/** * Returns the first type that was found in the index. May be overridden to honor visibility semantics. * The given iterator is never empty. * @since 2.8 */ protected EObject findAccessibleType(String fragment, ResourceSet resourceSet, Iterator<IEObjectDescription> fromIndex) throws UnknownNestedTypeException { IEObjectDescription description = fromIndex.next(); return getAccessibleType(description, fragment, resourceSet); }
return resolveJavaArrayObject(rootType, fragment); return null; String containerFragment = fragment.substring(0, slash); EObject container = resolveJavaObject(rootType, containerFragment); if (container != null) { String parameterName = fragment.substring(slash + 1); EObject container = resolveJavaObject(rootType, subFragment); if (container instanceof JvmDeclaredType) { EList<JvmMember> members = ((JvmDeclaredType) container).getMembers();
public EObject getIndexedJvmType(QualifiedName qualifiedName, String fragment, ResourceSet resourceSet, boolean throwShadowedException) throws UnknownNestedTypeException { if (resourceSet != null) { IResourceDescriptions descriptions = resourceDescriptionsProvider.getResourceDescriptions(resourceSet); Iterable<IEObjectDescription> candidates = descriptions.getExportedObjects(TypesPackage.Literals.JVM_TYPE, qualifiedName, false); Iterator<IEObjectDescription> iterator = candidates.iterator(); if (iterator.hasNext()) { EObject result = findAccessibleType(fragment, resourceSet, iterator); if (result != null) { return result; } } if (throwShadowedException && descriptions instanceof IShadowedResourceDescriptions) { if (((IShadowedResourceDescriptions) descriptions).isShadowed(TypesPackage.Literals.JVM_TYPE, qualifiedName, false)) { throw new ShadowedTypeException("The type '"+qualifiedName+"' is locally shadowed."); } } } return null; }
return resolveJavaArrayObject(rootType, fragment); return null; String containerFragment = fragment.substring(0, slash); EObject container = resolveJavaObject(rootType, containerFragment); if (container != null) { String parameterName = fragment.substring(slash + 1);
/** * Locate and resolve a {@link JvmType} in the context of the given resource set. It'll try to * decode the qualified name from the URI and find an instance with that name in the {@link IResourceDescriptions * index}. Short-circuits to a resource that is already available in the resource set. * * @param javaObjectURI * the uri of the to-be-loaded instance. It is expected to be a Java-scheme URI. May not be * <code>null</code>. * @param resourceSet * the context resource set. May not be <code>null</code>. * @return the located instance. May be <code>null</code>. */ public EObject getIndexedJvmType(URI javaObjectURI, ResourceSet resourceSet) throws UnknownNestedTypeException { return getIndexedJvmType(javaObjectURI, resourceSet, false); }
public EObject resolveJavaArrayObject(JvmType rootType, String fragment) throws UnknownNestedTypeException { JvmComponentType component = (JvmComponentType) resolveJavaObject(rootType, fragment.substring(0, fragment.length() - 2)); if (component == null) return null; return component.getArrayType(); }
private JvmType doTryFindInIndex(String name, IndexedJvmTypeAccess indexAccess) throws UnknownNestedTypeException { int index = name.indexOf('$'); if (index < 0) index = name.indexOf('['); String qualifiedNameString = index < 0 ? name : name.substring(0, index); List<String> nameSegments = Strings.split(qualifiedNameString, '.'); QualifiedName qualifiedName = QualifiedName.create(nameSegments); EObject candidate = indexAccess.getIndexedJvmType(qualifiedName, name, getResourceSet()); if (candidate instanceof JvmType) return (JvmType) candidate; return null; }
public EObject getIndexedJvmType(QualifiedName qualifiedName, String fragment, ResourceSet resourceSet) { if (resourceSet != null) { IResourceDescriptions descriptions = resourceDescriptionsProvider.getResourceDescriptions(resourceSet); Iterable<IEObjectDescription> candidates = descriptions.getExportedObjects(TypesPackage.Literals.JVM_TYPE, qualifiedName, false); Iterator<IEObjectDescription> iterator = candidates.iterator(); if (iterator.hasNext()) { IEObjectDescription description = iterator.next(); EObject typeProxy = description.getEObjectOrProxy(); if (typeProxy.eIsProxy()) { typeProxy = EcoreUtil.resolve(typeProxy, resourceSet); } if (!typeProxy.eIsProxy() && typeProxy instanceof JvmType) { if (fragment != null) { EObject result = resolveJavaObject((JvmType) typeProxy, fragment); if (result != null) return result; } else return typeProxy; } } } return null; }
private JvmType doTryFindInIndex(String name, IndexedJvmTypeAccess indexAccess) { int index = name.indexOf('$'); if (index < 0) index = name.indexOf('['); String qualifiedNameString = index < 0 ? name : name.substring(0, index); List<String> nameSegments = Strings.split(qualifiedNameString, '.'); QualifiedName qualifiedName = QualifiedName.create(nameSegments); EObject candidate = indexAccess.getIndexedJvmType(qualifiedName, name, getResourceSet()); if (candidate instanceof JvmType) return (JvmType) candidate; return null; }
/** * Read and resolve the EObject from the given description and navigate to its children according * to the given fragment. * @since 2.8 */ protected EObject getAccessibleType(IEObjectDescription description, String fragment, ResourceSet resourceSet) throws UnknownNestedTypeException { EObject typeProxy = description.getEObjectOrProxy(); if (typeProxy.eIsProxy()) { typeProxy = EcoreUtil.resolve(typeProxy, resourceSet); } if (!typeProxy.eIsProxy() && typeProxy instanceof JvmType) { if (fragment != null) { EObject result = resolveJavaObject((JvmType) typeProxy, fragment); if (result != null) return result; } else return typeProxy; } return null; }
public EObject resolveJavaObjectURIProxy(InternalEObject proxy, JvmTypeReference sender) { if (indexedJvmTypeAccess != null) { EObject result = indexedJvmTypeAccess.getIndexedJvmType(proxy.eProxyURI(), getResourceSet()); if (result != null) { return result; } } return EcoreUtil.resolve(proxy, sender); }
@Override public EObject resolveJavaObjectURIProxy(InternalEObject proxy, EObject sender) { final URI proxyURI = proxy.eProxyURI(); if (proxyURI != null && URIHelperConstants.PROTOCOL.equals(proxyURI.scheme())) { if ("Objects".equals(proxyURI.segment(0))) { if (indexedJvmTypeAccess != null) { try { EObject result = indexedJvmTypeAccess.getIndexedJvmType(proxy.eProxyURI(), getResourceSet()); if (result != null) { return result; } } catch(UnknownNestedTypeException e) { return proxy; } } return EcoreUtil.resolve(proxy, sender); } } return null; }
public EObject getIndexedJvmType(URI javaObjectURI, ResourceSet resourceSet, boolean throwShadowedException) throws UnknownNestedTypeException { if (resourceSet != null) { URI withoutFragment = javaObjectURI.trimFragment(); if (resourceSet instanceof ResourceSetImpl) { // if the resource uri is already available in the resource set, try to find it directly Map<URI, Resource> resourceMap = ((ResourceSetImpl) resourceSet).getURIResourceMap(); if (resourceMap != null && resourceMap.containsKey(withoutFragment)) { EObject result = resourceSet.getEObject(javaObjectURI, true); if (result != null) { return result; } } } String fqn = withoutFragment.segment(withoutFragment.segmentCount() - 1); final String base = fqn; Iterator<String> variants = innerClassNameVariants.variantsFor(base); EObject jvmType = null; while (jvmType == null && variants.hasNext()) { fqn = variants.next(); List<String> fqnSegments = Strings.split(fqn, '.'); QualifiedName qualifiedName = QualifiedName.create(fqnSegments); jvmType = getIndexedJvmType(qualifiedName, javaObjectURI.fragment(), resourceSet, throwShadowedException); } return jvmType; } return null; }
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 boolean isConflictsWithNonOverridableTypes(Iterable<JvmDeclaredType> types, TypeUsages usages, NonOverridableTypesProvider nonOverridableTypesProvider, String simpleName) { for(JvmDeclaredType type: types) { for(TypeUsage usage: usages.getUsages(type)) { JvmIdentifiableElement visibleType = nonOverridableTypesProvider.getVisibleType(usage.getContext(), simpleName); if(visibleType != null && !visibleType.equals(type)) return true; String contextPackage = usage.getContextPackageName(); if(!isEmpty(contextPackage)) { QualifiedName qualifiedName = qualifiedNameConverter.toQualifiedName(contextPackage + "." + simpleName); try { EObject indexedJvmType = indexedJvmTypeAccess.getIndexedJvmType(qualifiedName, null, usage.getContext().eResource().getResourceSet()); if(indexedJvmType != null && indexedJvmType != type) return true; } catch(UnknownNestedTypeException e) { // ignore } } } } return false; }
List<String> fqnSegments = Strings.split(fqn, '.'); QualifiedName qualifiedName = QualifiedName.create(fqnSegments); return getIndexedJvmType(qualifiedName, javaObjectURI.fragment(), resourceSet);
private JvmType findTypeByClass(BinaryClass clazz) { try { IndexedJvmTypeAccess indexedJvmTypeAccess = getIndexedJvmTypeAccess(); URI resourceURI = clazz.getResourceURI(); if (indexedJvmTypeAccess != null) { URI proxyURI = resourceURI.appendFragment(clazz.getURIFragment()); EObject candidate = indexedJvmTypeAccess.getIndexedJvmType(proxyURI, getResourceSet()); if (candidate instanceof JvmType) return (JvmType) candidate; } TypeResource result = (TypeResource) getResourceSet().getResource(resourceURI, true); return findTypeByClass(clazz, result); } catch(UnknownNestedTypeException e) { return null; } }