in modules/core/src/main/scala/org/scalasteward/core/edit/update/Selector.scala [135:169]
private def heuristic2SearchTerms(update: Update.Single): List[String] =
util.string.extractWords(update.mainArtifactId).filterNot(isCommonWord)
private def heuristic3SearchTerms(update: Update.Single): List[String] =
update.mainArtifactId.toSeq.sliding(5).map(_.unwrap).filterNot(isCommonWord).toList
private def heuristic4SearchTerms(update: Update.Single): List[String] =
List(update.groupId.value)
private def heuristic5SearchTerms(update: Update.Single): List[String] =
update.groupId.value
.split('.')
.toList
.drop(1)
.flatMap(util.string.extractWords)
.filter(_.length > 3)
private def searchTermsAsRegex(terms: List[String]): Option[Pattern] =
Nel
.fromList(terms.map(removeCommonSuffix).map(toFlexibleRegex).filter(_.nonEmpty))
.map(ts => Pattern.compile("(?i)" + alternation(ts)))
private def removeCommonSuffix(str: String): String =
util.string.removeSuffix(str, Update.commonSuffixes)
/** Removes punctuation from the input and returns it as regex that allows punctuation between
* characters.
*/
private def toFlexibleRegex(string: String): String = {
val punctuation = List('.', '-', '_')
val allowPunctuation = "[\\.\\-_]*"
string.toList
.collect { case c if !punctuation.contains_(c) => Regex.quote(c.toString) }
.intercalate(allowPunctuation)
}