/** Check if implemented interfaces of a skill are redundant. * * @param skill the skill. */ @Check public void checkRedundantImplementedInterfaces(SarlSkill skill) { checkRedundantInterfaces( skill, SARL_SKILL__IMPLEMENTS, skill.getImplements(), Utils.singletonList(skill.getExtends())); }
/** Check if the supertype of the given skill is a subtype of Skill. * * @param skill the type to test. */ @Check(CheckType.FAST) public void checkSuperType(SarlSkill skill) { final int nbSuperTypes = checkSuperTypes( skill, SARL_SKILL__EXTENDS, Utils.singletonList(skill.getExtends()), Skill.class, false); checkImplementedTypes( skill, SARL_SKILL__IMPLEMENTS, skill.getImplements(), Capacity.class, nbSuperTypes > 0 ? 0 : 1, true); }
/** Generate the given object. * * @param skill the skill. * @param context the context. */ protected void _generate(SarlSkill skill, IExtraLanguageGeneratorContext context) { final JvmDeclaredType jvmType = getJvmModelAssociations().getInferredType(skill); final PyAppendable appendable = createAppendable(jvmType, context); List<JvmTypeReference> superTypes = getSuperTypes(skill.getExtends(), skill.getImplements()); if (superTypes.isEmpty()) { superTypes = Collections.singletonList(getTypeReferences().getTypeForName(Skill.class, skill)); } final String qualifiedName = this.qualifiedNameProvider.getFullyQualifiedName(skill).toString(); if (generateTypeDeclaration( qualifiedName, skill.getName(), skill.isAbstract(), superTypes, getTypeBuilder().getDocumentation(skill), true, skill.getMembers(), appendable, context, (it, context2) -> { generateGuardEvaluators(qualifiedName, it, context2); })) { final QualifiedName name = getQualifiedNameProvider().getFullyQualifiedName(skill); writeFile(name, appendable, context); } }
/** Format the given SARL skill. * * @param skill the SARL component. * @param document the document. */ protected void _format(SarlSkill skill, IFormattableDocument document) { formatAnnotations(skill, document, XbaseFormatterPreferenceKeys.newLineAfterClassAnnotations); formatModifiers(skill, document); final ISemanticRegionsFinder regionFor = this.textRegionExtensions.regionFor(skill); document.append(regionFor.keyword(this.keywords.getSkillKeyword()), ONE_SPACE); document.surround(regionFor.keyword(this.keywords.getExtendsKeyword()), ONE_SPACE); document.format(skill.getExtends()); document.surround(regionFor.keyword(this.keywords.getImplementsKeyword()), ONE_SPACE); formatCommaSeparatedList(skill.getImplements(), document); formatBody(skill, document); }
appendConstrainedExtends(context, inferredJvmType, Skill.class, SarlSkill.class, source.getExtends()); appendConstrainedImplements(context, inferredJvmType, Capacity.class, SarlCapacity.class, source.getImplements());