bringing back an order in completion proposals, got lost due to random hashmap ordering

This commit is contained in:
Martin Lippert
2024-09-26 13:42:25 +02:00
parent fa71281711
commit 8544efa73b
9 changed files with 30 additions and 20 deletions

View File

@@ -12,6 +12,7 @@ package org.springframework.ide.vscode.boot.java.annotations;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -127,7 +128,7 @@ public class AnnotationAttributeCompletionProcessor implements CompletionProvide
Map<String, String> filteredProposals = proposals.entrySet().stream()
.filter(candidate -> candidate.getKey().toLowerCase().contains(filterPrefix.toLowerCase()))
.filter(candidate -> !alreadyMentionedValues.contains(candidate.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (u, v) -> u, LinkedHashMap::new));
double score = filteredProposals.size();
for (Map.Entry<String, String> entry : filteredProposals.entrySet()) {
String candidate = entry.getKey();

View File

@@ -11,6 +11,7 @@
package org.springframework.ide.vscode.boot.java.beans;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;
@@ -240,7 +241,7 @@ public class DependsOnCompletionProcessor implements AnnotationAttributeCompleti
return Arrays.stream(this.springIndex.getBeansOfProject(project.getElementName()))
.map(bean -> bean.getName())
.distinct()
.collect(Collectors.toMap(key -> key, value -> value));
.collect(Collectors.toMap(key -> key, value -> value, (u, v) -> u, LinkedHashMap::new));
}

View File

@@ -11,6 +11,7 @@
package org.springframework.ide.vscode.boot.java.beans;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -41,7 +42,7 @@ public class NamedCompletionProvider implements AnnotationAttributeCompletionPro
findAllNamedValues(beans),
Arrays.stream(beans).map(bean -> bean.getName()))
.distinct()
.collect(Collectors.toMap(key -> key, value -> value));
.collect(Collectors.toMap(key -> key, value -> value, (u, v) -> u, LinkedHashMap::new));
}
private Stream<String> findAllNamedValues(Bean[] beans) {

View File

@@ -11,6 +11,7 @@
package org.springframework.ide.vscode.boot.java.beans;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -39,7 +40,7 @@ public class ProfileCompletionProvider implements AnnotationAttributeCompletionP
return findAllProfiles(beans)
.distinct()
.collect(Collectors.toMap(key -> key, value -> value));
.collect(Collectors.toMap(key -> key, value -> value, (u, v) -> u, LinkedHashMap::new));
}
private Stream<String> findAllProfiles(Bean[] beans) {

View File

@@ -11,6 +11,7 @@
package org.springframework.ide.vscode.boot.java.beans;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -41,7 +42,7 @@ public class QualifierCompletionProvider implements AnnotationAttributeCompletio
findAllQualifiers(beans),
Arrays.stream(beans).map(bean -> bean.getName()))
.distinct()
.collect(Collectors.toMap(key -> key, value -> value));
.collect(Collectors.toMap(key -> key, value -> value, (u, v) -> u, LinkedHashMap::new));
}
private Stream<String> findAllQualifiers(Bean[] beans) {

View File

@@ -11,6 +11,7 @@
package org.springframework.ide.vscode.boot.java.beans;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;
@@ -37,7 +38,7 @@ public class ResourceCompletionProvider implements AnnotationAttributeCompletion
return Arrays.stream(beans).map(bean -> bean.getName())
.distinct()
.collect(Collectors.toMap(key -> key, value -> value));
.collect(Collectors.toMap(key -> key, value -> value, (u, v) -> u, LinkedHashMap::new));
}
}

View File

@@ -12,6 +12,7 @@ package org.springframework.ide.vscode.boot.java.conditionalonresource;
import java.nio.file.Paths;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;
@@ -35,7 +36,7 @@ public class ConditionalOnResourceCompletionProcessor implements AnnotationAttri
})
.map(r -> r.replaceAll("\\\\", "/"))
.map(r -> "classpath:" + r)
.collect(Collectors.toMap(key -> key, value -> value));
.collect(Collectors.toMap(key -> key, value -> value, (u, v) -> u, LinkedHashMap::new));
return resources;
}

View File

@@ -11,11 +11,11 @@ public class CronExpressionCompletionProvider implements AnnotationAttributeComp
private static final Map<String, String> CRON_EXPRESSIONS_MAP = new LinkedHashMap<>();
static {
CRON_EXPRESSIONS_MAP.put("0 0 * * * 1-5", "every hour every day between Monday and Friday");
CRON_EXPRESSIONS_MAP.put("0 */5 * * * *", "every 5 minutes");
CRON_EXPRESSIONS_MAP.put("0 * * * * *", "every minute");
CRON_EXPRESSIONS_MAP.put("0 0 */6 * * *", "every 6 hours at minute 0");
CRON_EXPRESSIONS_MAP.put("0 0 * * * *", "every hour");
CRON_EXPRESSIONS_MAP.put("0 0 * * * 1-5", "every hour every day between Monday and Friday");
CRON_EXPRESSIONS_MAP.put("0 * * * * *", "every minute");
CRON_EXPRESSIONS_MAP.put("0 */5 * * * *", "every 5 minutes");
CRON_EXPRESSIONS_MAP.put("0 0 */6 * * *", "every 6 hours at minute 0");
CRON_EXPRESSIONS_MAP.put("0 0 * * * SUN", "every hour at Sunday day");
CRON_EXPRESSIONS_MAP.put("0 0 0 * * *", "at 00:00");
CRON_EXPRESSIONS_MAP.put("0 0 0 * * SAT,SUN", "at 00:00 on Saturday and Sunday");

View File

@@ -10,6 +10,7 @@
*******************************************************************************/
package org.springframework.ide.vscode.boot.java.scope;
import java.util.LinkedHashMap;
import java.util.Map;
import org.springframework.ide.vscode.boot.java.annotations.AnnotationAttributeCompletionProvider;
@@ -20,15 +21,17 @@ import org.springframework.ide.vscode.commons.java.IJavaProject;
*/
public class ScopeCompletionProcessor implements AnnotationAttributeCompletionProvider {
private static final Map<String, String> SCOPE_COMPLETIONS = Map.of(
"application", "application",
"globalSession", "globalSession",
"prototype", "prototype",
"request", "request",
"session", "session",
"singleton", "singleton",
"websocket", "websocket"
);
private static final Map<String, String> SCOPE_COMPLETIONS = new LinkedHashMap<>();
static {
SCOPE_COMPLETIONS.put("application", "application");
SCOPE_COMPLETIONS.put("globalSession", "globalSession");
SCOPE_COMPLETIONS.put("prototype", "prototype");
SCOPE_COMPLETIONS.put("request", "request");
SCOPE_COMPLETIONS.put("session", "session");
SCOPE_COMPLETIONS.put("singleton", "singleton");
SCOPE_COMPLETIONS.put("websocket", "websocket");
}
@Override
public Map<String, String> getCompletionCandidates(IJavaProject project) {