1212 *******************************************************************************/
1313package org .eclipse .jdt .ls .core .internal .handlers ;
1414
15+ import static org .eclipse .jdt .ls .core .internal .handlers .CompletionRanking .MAX_SCORE ;
16+ import static org .eclipse .jdt .ls .core .internal .handlers .CompletionRanking .MIN_SCORE ;
17+
1518import java .util .HashMap ;
1619import java .util .HashSet ;
1720import java .util .Map ;
1821import java .util .Set ;
22+ import java .util .stream .Collectors ;
1923
2024/**
2125 * Aggregated result of all the ranking results from ranking providers.
@@ -41,25 +45,26 @@ public int getScore() {
4145 }
4246
4347 /**
44- * Add score from a ranking provider. The acceptable values are [0, 100].
45- * When adding to the relevance, values larger than 100 will be treated as
46- * 100 and value lower than 0 will be treated as 0.
48+ * Add score from a ranking provider. The acceptable values are [{@link CompletionRanking#MIN_SCORE},
49+ * {@link CompletionRanking#MAX_SCORE}]. When adding to the relevance, values larger than {@link CompletionRanking#MAX_SCORE}
50+ * will be treated as {@link CompletionRanking#MAX_SCORE} and value lower than {@link CompletionRanking#MIN_SCORE}
51+ * will be treated as {@link CompletionRanking#MIN_SCORE}.
4752 * @param score score from a ranking provider.
4853 */
4954 public void addScore (int score ) {
50- if (score <= 0 ) {
55+ if (score <= MIN_SCORE ) {
5156 return ;
5257 }
5358
54- this .score += score > 100 ? 100 : score ;
59+ this .score += score > MAX_SCORE ? MAX_SCORE : score ;
5560 }
5661
5762 /**
5863 * Get the aggregated decorators from all ranking providers.
5964 * The decorator chars will be de-duplicated and sorted.
6065 */
6166 public String getDecorators () {
62- return String . valueOf ( this .decorators .stream ().sorted ().toArray ( Character []:: new ));
67+ return this .decorators .stream ().sorted ().map ( String :: valueOf ). collect ( Collectors . joining ( ));
6368 }
6469
6570 /**
0 commit comments