/** Create a SarlCapacityUses. * @param name the types referenced by the SarlCapacityUses. */ public void addSarlCapacityUses(String... name) { if (name != null && name.length > 0) { SarlCapacityUses member = SarlFactory.eINSTANCE.createSarlCapacityUses(); this.sarlAgent.getMembers().add(member); member.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendMember()); Collection<JvmParameterizedTypeReference> thecollection = member.getCapacities(); for (final String aname : name) { if (!Strings.isEmpty(aname)) { thecollection.add(newTypeRef(this.sarlAgent, aname)); } } } }
/** Check for multiple capacity use declaration. * * @param uses the capacity use declaration. */ @Check(CheckType.NORMAL) public void checkMultipleCapacityUses(SarlCapacityUses uses) { if (!isIgnored(REDUNDANT_CAPACITY_USE)) { final XtendTypeDeclaration declaringType = uses.getDeclaringType(); if (declaringType != null) { final Set<String> previousCapacityUses = doGetPreviousCapacities(uses, declaringType.getMembers().iterator()); int index = 0; for (final JvmTypeReference capacity : uses.getCapacities()) { if (previousCapacityUses.contains(capacity.getIdentifier())) { addIssue(MessageFormat.format( Messages.SARLValidator_79, capacity.getSimpleName()), uses, SARL_CAPACITY_USES__CAPACITIES, index, REDUNDANT_CAPACITY_USE, capacity.getSimpleName()); } else { previousCapacityUses.add(capacity.getIdentifier()); } ++index; } } } }
return; for (final JvmTypeReference capacityType : source.getCapacities()) { final JvmType type = capacityType.getType(); if (type instanceof JvmGenericType + ".class)) : $0" + fieldName + ")"; //$NON-NLS-1$ //$NON-NLS-2$; this.inlineExpressionCompiler.appendInlineAnnotation( operation, source.eResource().getResourceSet(), inlineExpression, capacityType); });
private static Set<String> doGetPreviousCapacities(SarlCapacityUses uses, Iterator<XtendMember> iterator) { boolean continueToFill = true; final Set<String> capacityUses = CollectionLiterals.newTreeSet((Comparator<String>) null); while (continueToFill && iterator.hasNext()) { final XtendMember elt = iterator.next(); if (elt instanceof SarlCapacityUses) { final SarlCapacityUses usesElt = (SarlCapacityUses) elt; if (usesElt == uses) { continueToFill = false; } else { for (final JvmTypeReference use : usesElt.getCapacities()) { capacityUses.add(use.getIdentifier()); } } } } return capacityUses; }
public void checkUnusedCapacities(SarlCapacityUses uses) { if (!isIgnored(UNUSED_AGENT_CAPACITY)) { final XtendTypeDeclaration container = uses.getDeclaringType(); final JvmDeclaredType jvmContainer = (JvmDeclaredType) this.associations.getPrimaryJvmElement(container); final Map<String, JvmOperation> importedFeatures = CollectionLiterals.newHashMap(); for (final JvmTypeReference capacity : uses.getCapacities()) { final LightweightTypeReference lreference = toLightweightTypeReference(capacity); if (isSkill && lreference.isAssignableFrom(jvmContainer)) {
/** Mark the functions of the used capacities in order to have a valid feature call within the code. * * @param uses the capacity uses. * @param context the context. */ protected void _before(SarlCapacityUses uses, IExtraLanguageGeneratorContext context) { // Rename the function in order to produce the good features at the calls. for (final JvmTypeReference capacity : uses.getCapacities()) { final JvmType type = capacity.getType(); if (type instanceof JvmDeclaredType) { computeCapacityFunctionMarkers((JvmDeclaredType) type); } } }
/** Create a SarlCapacityUses. * @param name the types referenced by the SarlCapacityUses. */ public void addSarlCapacityUses(String... name) { if (name != null && name.length > 0) { SarlCapacityUses member = SarlFactory.eINSTANCE.createSarlCapacityUses(); this.sarlSkill.getMembers().add(member); member.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendMember()); Collection<JvmParameterizedTypeReference> thecollection = member.getCapacities(); for (final String aname : name) { if (!Strings.isEmpty(aname)) { thecollection.add(newTypeRef(this.sarlSkill, aname)); } } } }
/** Check the type of the capacity uses. * * @param uses the capacity uses. */ @Check(CheckType.FAST) public void checkCapacityTypeForUses(SarlCapacityUses uses) { for (final JvmParameterizedTypeReference usedType : uses.getCapacities()) { final LightweightTypeReference ref = toLightweightTypeReference(usedType); if (ref != null && !this.inheritanceHelper.isSarlCapacity(ref)) { error(MessageFormat.format( Messages.SARLValidator_57, usedType.getQualifiedName(), Messages.SARLValidator_58, this.grammarAccess.getUsesKeyword()), usedType, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, INVALID_CAPACITY_TYPE, usedType.getSimpleName()); } } }
/** Create a SarlCapacityUses. * @param name the types referenced by the SarlCapacityUses. */ public void addSarlCapacityUses(String... name) { if (name != null && name.length > 0) { SarlCapacityUses member = SarlFactory.eINSTANCE.createSarlCapacityUses(); this.sarlBehavior.getMembers().add(member); member.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendMember()); Collection<JvmParameterizedTypeReference> thecollection = member.getCapacities(); for (final String aname : name) { if (!Strings.isEmpty(aname)) { thecollection.add(newTypeRef(this.sarlBehavior, aname)); } } } }
/** Format a capacity use. * * @param capacityUses the capacity uses. * @param document the document. */ protected void _format(SarlCapacityUses capacityUses, IFormattableDocument document) { final ISemanticRegionsFinder regionFor = this.textRegionExtensions.regionFor(capacityUses); document.append(regionFor.keyword(this.keywords.getUsesKeyword()), ONE_SPACE); formatCommaSeparatedList(capacityUses.getCapacities(), document); document.prepend(regionFor.keyword(this.keywords.getSemicolonKeyword()), NO_SPACE); }