features.FeatureHelpers.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lib Show documentation
Show all versions of lib Show documentation
Question authoring library for CS 124.
@file:Suppress("unused")
@file:JvmName("FeatureHelpers")
package edu.illinois.cs.cs125.questioner.lib.features
import edu.illinois.cs.cs125.jeed.core.FeatureName
import edu.illinois.cs.cs125.jeed.core.Features
fun Features.usesLoop() = featureMap[FeatureName.WHILE_LOOPS] > 0
|| featureMap[FeatureName.FOR_LOOPS] > 0
|| featureMap[FeatureName.DO_WHILE_LOOPS] > 0
|| dottedMethodList.contains("forEach")
fun Features.hasFeature(feature: FeatureName) = featureMap[feature] > 0
fun Features.doesNotHaveFeature(feature: FeatureName) = featureMap[feature] == 0
fun Features.hasFeatures(features: List) = features.any { feature -> featureMap[feature] > 0 }
fun Features.doesNotHaveFeatures(features: List) = features.any { feature -> featureMap[feature] == 0 }
fun Features.countFeature(feature: FeatureName) = featureMap[feature] ?: 0