@Override protected URI getResourceURIForValidEObject(Object object) { if (object instanceof SarlClass) { final SarlClass clazz = (SarlClass) object; return clazz.eResource().getURI(); } return null; }
/** Generate the given object. * * @param clazz the class. * @param it the target for the generated content. * @param context the context. */ protected void _generate(SarlClass clazz, PyAppendable it, IExtraLanguageGeneratorContext context) { generateTypeDeclaration( this.qualifiedNameProvider.getFullyQualifiedName(clazz).toString(), clazz.getName(), clazz.isAbstract(), getSuperTypes(clazz.getExtends(), clazz.getImplements()), getTypeBuilder().getDocumentation(clazz), true, clazz.getMembers(), it, context, null); }
/** Add a modifier. * @param modifier the modifier to add. */ public void addModifier(String modifier) { if (!Strings.isEmpty(modifier)) { this.sarlClass.getModifiers().add(modifier); } }
/** Check if implemented interfaces of a Xtend Class are redundant. * * @param xtendClass the class. */ @Check public void checkRedundantImplementedInterfaces(SarlClass xtendClass) { checkRedundantInterfaces( xtendClass, XTEND_CLASS__IMPLEMENTS, xtendClass.getImplements(), Utils.singletonList(xtendClass.getExtends())); }
@Override protected boolean isSelectableElement(SarlClass element) { return element != null && !Strings.isNullOrEmpty(element.getName()); }
/** Add an implemented type. * @param type the qualified name of the implemented type. */ public void addImplements(String type) { if (!Strings.isEmpty(type)) { this.sarlClass.getImplements().add(newTypeRef(this.container, type)); } }
/** Initialize the Ecore element when inside a script. */ public void eInit(SarlScript script, String name, IJvmTypeProvider context) { setTypeResolutionContext(context); if (this.sarlClass == null) { this.container = script; this.sarlClass = SarlFactory.eINSTANCE.createSarlClass(); script.getXtendTypes().add(this.sarlClass); this.sarlClass.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendTypeDeclaration()); if (!Strings.isEmpty(name)) { this.sarlClass.setName(name); } } }
/** Add a type parameter. * @param name the simple name of the type parameter. * @return the builder of type parameter. */ public ITypeParameterBuilder addTypeParameter(String name) { ITypeParameterBuilder builder = this.iTypeParameterBuilderProvider.get(); final SarlClass object = getSarlClass(); builder.eInit(object, name, getTypeResolutionContext()); object.getTypeParameters().add(builder.getJvmTypeParameter()); return builder; }
/** Change the documentation of the element. * * <p>The documentation will be displayed just before the element. * * @param doc the documentation. */ public void setDocumentation(String doc) { if (Strings.isEmpty(doc)) { getSarlClass().eAdapters().removeIf(new Predicate<Adapter>() { public boolean test(Adapter adapter) { return adapter.isAdapterForType(DocumentationAdapter.class); } }); } else { DocumentationAdapter adapter = (DocumentationAdapter) EcoreUtil.getExistingAdapter( getSarlClass(), DocumentationAdapter.class); if (adapter == null) { adapter = new DocumentationAdapter(); getSarlClass().eAdapters().add(adapter); } adapter.setDocumentation(doc); } }
/** Generate the given object. * * @param clazz the class. * @param context the context. */ protected void _generate(SarlClass clazz, IExtraLanguageGeneratorContext context) { final JvmDeclaredType jvmType = getJvmModelAssociations().getInferredType(clazz); final PyAppendable appendable = createAppendable(jvmType, context); if (generateTypeDeclaration( this.qualifiedNameProvider.getFullyQualifiedName(clazz).toString(), clazz.getName(), clazz.isAbstract(), getSuperTypes(clazz.getExtends(), clazz.getImplements()), getTypeBuilder().getDocumentation(clazz), true, clazz.getMembers(), appendable, context, null)) { final QualifiedName name = getQualifiedNameProvider().getFullyQualifiedName(clazz); writeFile(name, appendable, context); } }
/** Replies the resource to which the SarlClass is attached. */ @Pure public Resource eResource() { return getSarlClass().eResource(); }
/** Replies the resource to which the SarlClass is attached. */ @Pure public Resource eResource() { return getSarlClass().eResource(); }