@ Check ( CheckType . NORMAL ) 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 JvmOperation operation : jvmContainer . getDeclaredOperations ( ) ) { if ( Utils . isNameForHiddenCapacityImplementationCallingMethod ( operation . getSimpleName ( ) ) ) { importedFeatures . put ( operation . getSimpleName ( ) , operation ) ; } } final boolean isSkill = container instanceof SarlSkill ; int index = 0 ; for ( final JvmTypeReference capacity : uses . getCapacities ( ) ) { final LightweightTypeReference lreference = toLightweightTypeReference ( capacity ) ; if ( isSkill && lreference . isAssignableFrom ( jvmContainer ) ) { addIssue ( MessageFormat . format ( Messages . SARLValidator_22 , capacity . getSimpleName ( ) ) , uses , SARL_CAPACITY_USES__CAPACITIES , index , UNUSED_AGENT_CAPACITY , capacity . getSimpleName ( ) ) ; } else { final String fieldName = Utils . createNameForHiddenCapacityImplementationAttribute ( capacity . getIdentifier ( ) ) ; final String operationName = Utils . createNameForHiddenCapacityImplementationCallingMethodFromFieldName ( fieldName ) ; final JvmOperation operation = importedFeatures . get ( operationName ) ; if ( operation != null && ! isLocallyUsed ( operation , container ) ) { addIssue ( MessageFormat . format ( Messages . SARLValidator_78 , capacity . getSimpleName ( ) ) , uses , SARL_CAPACITY_USES__CAPACITIES , index , UNUSED_AGENT_CAPACITY , capacity . getSimpleName ( ) ) ; } } ++ index ; } } }
Check for unused capacities .