Skip to content

Commit

Permalink
Use indexOf instead of startWith + contains
Browse files Browse the repository at this point in the history
Co-authored-by: Vadim Chelyshov <[email protected]>
  • Loading branch information
tgodzik and dos65 committed Aug 7, 2023
1 parent d653eca commit a829a6a
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ class JavaCompletionProvider(

private def identifierScore(element: Element): Int = {
val name = element.getSimpleName().toString().toLowerCase()
if (name.startsWith(identifier)) 0
else if (name.contains(identifier)) 1
else 2
name.indexOf(identifier) match {
case 0 => 0
case -1 => 2
case _ => 1
}
}

private def memberScore(element: Element, containingElement: Element): Int = {
Expand Down

0 comments on commit a829a6a

Please sign in to comment.