/** Create a JvmType for a Python type. * * @param pythonName the python type name. * @return the type. */ @SuppressWarnings("static-method") protected JvmType newType(String pythonName) { final JvmGenericType type = TypesFactory.eINSTANCE.createJvmGenericType(); final int index = pythonName.indexOf("."); //$NON-NLS-1$ if (index <= 0) { type.setSimpleName(pythonName); } else { type.setPackageName(pythonName.substring(0, index - 1)); type.setSimpleName(pythonName.substring(index + 1)); } return type; }
protected List<JvmType> createObjectReference(Resource resource) { if (resource != null) { // 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, resource); return Collections.singletonList(objectType); } return Collections.emptyList(); } }
protected List<JvmType> createObjectReference(Resource resource) { if (resource != null) { // no upper bound found - seems to be an invalid - assume object as upper bound URI objectURI = new ClassURIHelper().getFullURI(Object.class); JvmType objectType = factory.createJvmGenericType(); ((InternalEObject)objectType).eSetProxyURI(objectURI); objectType = (JvmType) EcoreUtil.resolve(objectType, resource); return Collections.singletonList(objectType); } return Collections.emptyList(); } }
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); } }
@Override public void registerInterface(final String qualifiedName) throws IllegalArgumentException { final JvmGenericType newType = TypesFactory.eINSTANCE.createJvmGenericType(); newType.setVisibility(JvmVisibility.PUBLIC); newType.setInterface(true); this.setNameAndAccept(newType, qualifiedName); }
/** * {@inheritDoc} * * Returns the value of the 'Type' reference. If there is no type set, * a reference to <code>java.lang.Object</code> is assumed as soon as there is more * than one contained reference. * If there is only one contained reference, its type is returned. */ @Override public JvmType getType() { if (references != null && !references.isEmpty()) { if (references.size() == 1) { return references.get(0).getType(); } if (type == null) { JvmGenericType objectType = TypesFactory.eINSTANCE.createJvmGenericType(); String objectClassName = Object.class.getName(); ((InternalEObject) objectType).eSetProxyURI(URIHelperConstants.OBJECTS_URI.appendSegment(objectClassName).appendFragment(objectClassName)); type = objectType; } } return super.getType(); }
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); } }
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; }
/** * {@inheritDoc} * * Returns the value of the 'Type' reference. If there is no type set, * a reference to <code>java.lang.Object</code> is assumed as soon as there is more * than one contained reference. * If there is only one contained reference, its type is returned. */ @Override public JvmType getType() { if (references != null && !references.isEmpty()) { if (references.size() == 1) { return references.get(0).getType(); } if (type == null) { JvmGenericType objectType = TypesFactory.eINSTANCE.createJvmGenericType(); ((InternalEObject) objectType).eSetProxyURI(new ClassURIHelper().getFullURI(Object.class)); type = objectType; } } return super.getType(); }
/** * {@inheritDoc} * * Returns the value of the 'Type' reference. If there is no type set, * a reference to <code>java.lang.Object</code> is assumed. */ @Override public JvmType getType() { if (type == null) { JvmGenericType objectType = TypesFactory.eINSTANCE.createJvmGenericType(); String objectClassName = Object.class.getName(); ((InternalEObject) objectType).eSetProxyURI(URIHelperConstants.OBJECTS_URI.appendSegment(objectClassName).appendFragment(objectClassName)); setType(objectType); } return super.getType(); }
@Override public void registerClass(final String qualifiedName) throws IllegalArgumentException { final JvmGenericType newType = TypesFactory.eINSTANCE.createJvmGenericType(); newType.setVisibility(JvmVisibility.PUBLIC); EList<JvmTypeReference> _superTypes = newType.getSuperTypes(); JvmTypeReference _typeForName = this.compilationUnit.getTypeReferences().getTypeForName(Object.class, this.compilationUnit.getXtendFile()); _superTypes.add(_typeForName); this.setNameAndAccept(newType, qualifiedName); }
protected JvmTypeReference createObjectReference(Resource resource) { // 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)); if (resource != null) { objectType = (JvmType) EcoreUtil.resolve(objectType, resource); } JvmParameterizedTypeReference result = factory.createJvmParameterizedTypeReference(); result.setType(objectType); return result; } }
protected JvmTypeReference createObjectReference(Resource resource) { // 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)); if (resource != null) { objectType = (JvmType) EcoreUtil.resolve(objectType, resource); } JvmParameterizedTypeReference result = factory.createJvmParameterizedTypeReference(); result.setType(objectType); return result; } }
/** * {@inheritDoc} * * Returns the value of the 'Type' reference. If there is no type set, * a reference to <code>java.lang.Object</code> is assumed. */ @Override public JvmType getType() { if (type == null) { JvmGenericType objectType = TypesFactory.eINSTANCE.createJvmGenericType(); ((InternalEObject) objectType).eSetProxyURI(new ClassURIHelper().getFullURI(Object.class)); setType(objectType); } return super.getType(); }
protected JvmTypeReference createObjectReference(Resource resource) { // no upper bound found - seems to be an invalid - assume object as upper bound URI objectURI = new ClassURIHelper().getFullURI(Object.class); JvmType objectType = factory.createJvmGenericType(); ((InternalEObject)objectType).eSetProxyURI(objectURI); if (resource != null) { objectType = (JvmType) EcoreUtil.resolve(objectType, resource); } JvmParameterizedTypeReference result = factory.createJvmParameterizedTypeReference(); result.setType(objectType); return result; } }
protected JvmTypeReference getJavaLangObjectTypeRef(JvmType rawType, TypesFactory typesFactory) { ResourceSet rs = EcoreUtil2.getResourceSet(rawType); JvmParameterizedTypeReference refToObject = typesFactory.createJvmParameterizedTypeReference(); if (rs != null) { EObject javaLangObject = rs.getEObject(javaLangObjectURI, true); if (javaLangObject instanceof JvmType) { JvmType objectDeclaration = (JvmType) javaLangObject; refToObject.setType(objectDeclaration); return refToObject; } } JvmGenericType proxy = typesFactory.createJvmGenericType(); ((InternalEObject)proxy).eSetProxyURI(javaLangObjectURI); refToObject.setType(proxy); return refToObject; }
protected JvmGenericType createJvmGenericType(/* @Nullable */ EObject sourceElement, /* @Nullable */ String name) { if (sourceElement == null || name == null) return null; Pair<String, String> fullName = splitQualifiedName(name); final JvmGenericType result = typesFactory.createJvmGenericType(); result.setSimpleName(fullName.getSecond()); if (fullName.getFirst() != null) result.setPackageName(fullName.getFirst()); result.setVisibility(JvmVisibility.PUBLIC); return result; }
return createEnumerationType(clazz); final JvmGenericType result = TypesFactory.eINSTANCE.createJvmGenericType(); result.setInterface(clazz.isInterface()); result.setStrictFloatingPoint(Modifier.isStrict(clazz.getModifiers()));
result = TypesFactory.eINSTANCE.createJvmAnnotationType(); } else { JvmGenericType generic = TypesFactory.eINSTANCE.createJvmGenericType(); result = generic;
String localClassName, JvmFeature container) { final JvmGenericType inferredType = typesFactory.createJvmGenericType(); inferredType.setSimpleName(localClassName); inferredType.setAnonymous(!hasAdditionalMembers(anonymousClass));