Skip to content
Snippets Groups Projects
Commit 5ee3c3b1 authored by Etienne Kneuss's avatar Etienne Kneuss
Browse files

Fix name lookup w.r.t. encoding

parent 5a6ac7f4
No related branches found
No related tags found
No related merge requests found
...@@ -112,8 +112,25 @@ object OptionsHelpers { ...@@ -112,8 +112,25 @@ object OptionsHelpers {
val regexPatterns = patterns map { s => val regexPatterns = patterns map { s =>
import java.util.regex.Pattern import java.util.regex.Pattern
val p = "(.+\\.)?"+s.replaceAll("\\.", "\\\\.").replaceAll("_", ".+") // We encode the user query, reverting the encoding for . as those are
Pattern.compile(p) // not encoded in our fullnames
val encoded = scala.reflect.NameTransformer.encode(s).replaceAll("\\$u002E", ".")
// wildcards become ".*", rest is quoted.
var p = encoded.split("_").toList.map(Pattern.quote).mkString(".*")
// We account for _ at begining and end
if (encoded.endsWith("_")) {
p += ".*"
}
if (encoded.startsWith("_")) {
p = ".*"+p
}
// Finally, we match qualified suffixes (e.g. searching for 'size' will
// match 'List.size' but not 'thesize')
Pattern.compile("(.+\\.)?"+p)
} }
{ (name: String) => regexPatterns.exists(p => p.matcher(name).matches()) } { (name: String) => regexPatterns.exists(p => p.matcher(name).matches()) }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment