/** Check if the supertype of the given capacity is a subtype of Capacity. * * @param capacity the type to test. */ @Check(CheckType.FAST) public void checkSuperTypes(SarlCapacity capacity) { checkSuperTypes( capacity, SARL_CAPACITY__EXTENDS, capacity.getExtends(), Capacity.class, false); }
/** Add the super type. * @param superType the qualified name of the super type. */ public void addExtends(String superType) { if (!Strings.isEmpty(superType) && !Capacity.class.getName().equals(superType)) { JvmParameterizedTypeReference superTypeRef = newTypeRef(this.sarlCapacity, superType); JvmTypeReference baseTypeRef = findType(this.sarlCapacity, Capacity.class.getCanonicalName()); if (isSubTypeOf(this.sarlCapacity, superTypeRef, baseTypeRef)) { this.sarlCapacity.getExtends().add(superTypeRef); return; } } }
/** Generate the given object. * * @param capacity the capacity. * @param context the context. */ protected void _generate(SarlCapacity capacity, IExtraLanguageGeneratorContext context) { final JvmDeclaredType jvmType = getJvmModelAssociations().getInferredType(capacity); final PyAppendable appendable = createAppendable(jvmType, context); final List<? extends JvmTypeReference> superTypes; if (!capacity.getExtends().isEmpty()) { superTypes = capacity.getExtends(); } else { superTypes = Collections.singletonList(getTypeReferences().getTypeForName(Capacity.class, capacity)); } if (generateTypeDeclaration( this.qualifiedNameProvider.getFullyQualifiedName(capacity).toString(), capacity.getName(), true, superTypes, getTypeBuilder().getDocumentation(capacity), true, capacity.getMembers(), appendable, context, null)) { final QualifiedName name = getQualifiedNameProvider().getFullyQualifiedName(capacity); writeFile(name, appendable, context); } }
/** Format the given SARL capacity. * * @param capacity the SARL component. * @param document the document. */ protected void _format(SarlCapacity capacity, IFormattableDocument document) { formatAnnotations(capacity, document, XbaseFormatterPreferenceKeys.newLineAfterClassAnnotations); formatModifiers(capacity, document); final ISemanticRegionsFinder regionFor = this.textRegionExtensions.regionFor(capacity); document.append(regionFor.keyword(this.keywords.getCapacityKeyword()), ONE_SPACE); document.surround(regionFor.keyword(this.keywords.getExtendsKeyword()), ONE_SPACE); formatCommaSeparatedList(capacity.getExtends(), document); formatBody(capacity, document); }
appendConstrainedExtends(context, inferredJvmType, Capacity.class, SarlCapacity.class, source.getExtends());