/** Replies the resource. */ @Pure public Resource eResource() { return getSarlConstructor().eResource(); }
/** Add a throwable exception. * @param type the fully qualified name of the exception. */ public void addException(String type) { this.sarlConstructor.getExceptions().add(newTypeRef(this.container, type)); }
/** Add a modifier. * @param modifier the modifier to add. */ public void addModifier(String modifier) { if (!Strings.isEmpty(modifier)) { getSarlConstructor().getModifiers().add(modifier); } }
@Override public int compare(SarlConstructor o1, SarlConstructor o2) { if (o1 == o2) { return 0; } if (o1 == null) { return Integer.MIN_VALUE; } if (o2 == null) { return Integer.MAX_VALUE; } return this.comparator.compare(o1.getParameters(), o2.getParameters()); }
/** Create the block of code. * @return the block builder. */ public IBlockExpressionBuilder getExpression() { IBlockExpressionBuilder block = this.blockExpressionProvider.get(); block.eInit(getTypeResolutionContext()); XBlockExpression expr = block.getXBlockExpression(); this.sarlConstructor.setExpression(expr); return block; }
/** 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 SarlConstructor object = getSarlConstructor(); builder.eInit(object, name, getTypeResolutionContext()); object.getTypeParameters().add(builder.getJvmTypeParameter()); return builder; }
/** Initialize the Ecore element. * @param container the container of the SarlConstructor. */ public void eInit(XtendTypeDeclaration container, IJvmTypeProvider context) { setTypeResolutionContext(context); if (this.sarlConstructor == null) { this.container = container; this.sarlConstructor = SarlFactory.eINSTANCE.createSarlConstructor(); this.sarlConstructor.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendMember()); container.getMembers().add(this.sarlConstructor); } }
/** 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)) { getSarlConstructor().eAdapters().removeIf(new Predicate<Adapter>() { public boolean test(Adapter adapter) { return adapter.isAdapterForType(DocumentationAdapter.class); } }); } else { DocumentationAdapter adapter = (DocumentationAdapter) EcoreUtil.getExistingAdapter( getSarlConstructor(), DocumentationAdapter.class); if (adapter == null) { adapter = new DocumentationAdapter(); getSarlConstructor().eAdapters().add(adapter); } adapter.setDocumentation(doc); } }
final XExpression body = constructor.getExpression(); if (body instanceof XBlockExpression) { final XBlockExpression block = (XBlockExpression) body;
/** Generate the given object. * * @param constructor the constructor. * @param it the target for the generated content. * @param context the context. */ protected void _generate(SarlConstructor constructor, PyAppendable it, IExtraLanguageGeneratorContext context) { if (constructor.isStatic()) { generateExecutable("___static_init___", constructor, false, false, null, //$NON-NLS-1$ getTypeBuilder().getDocumentation(constructor), it, context); it.newLine().append("___static_init___()"); //$NON-NLS-1$ } else { generateExecutable("__init__", constructor, true, false, null, //$NON-NLS-1$ getTypeBuilder().getDocumentation(constructor), it, context); } }
/** Replies the resource. */ @Pure public Resource eResource() { return getSarlConstructor().eResource(); }