Skip to content

Commit be4839f

Browse files
committed
GH-1545: use specific prompt for explaining mongodb queries
1 parent 26e9d24 commit be4839f

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/handlers/CopilotCodeLensProvider.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,22 @@ private static boolean isQueryAnnotation(Annotation a) {
221221

222222
private QueryType determineQueryType(TextDocument document) {
223223
Optional<IJavaProject> optProject = projectFinder.find(document.getId());
224+
224225
if (optProject.isPresent()) {
225226
IJavaProject jp = optProject.get();
226-
return SpringProjectUtil.hasDependencyStartingWith(jp, "hibernate-core", null) ? QueryType.HQL
227-
: QueryType.JPQL;
227+
228+
if (SpringProjectUtil.hasDependencyStartingWith(jp, "hibernate-core", null)) {
229+
return QueryType.HQL;
230+
}
231+
else if (SpringProjectUtil.hasDependencyStartingWith(jp, "spring-data-mongodb", null)) {
232+
return QueryType.MONGODB;
233+
}
234+
else {
235+
return QueryType.JPQL;
236+
237+
}
228238
}
239+
229240
return QueryType.DEFAULT;
230241
}
231242

headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/handlers/QueryType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public enum QueryType {
44
SPEL("Explain SpEL Expression with Copilot", "Explain the following SpEL Expression with a clear summary first, followed by a breakdown of the expression with details: \n\n"),
55
JPQL("Explain Query with Copilot", "Explain the following JPQL query with a clear summary first, followed by a detailed explanation. If the query contains any SpEL expressions, explain those parts as well: \n\n"),
66
HQL("Explain Query with Copilot", "Explain the following HQL query with a clear summary first, followed by a detailed explanation. If the query contains any SpEL expressions, explain those parts as well: \n\n"),
7+
MONGODB("Explain Query with Copilot", "Explain the following MongoDB query with a clear summary first, followed by a detailed explanation. If the query contains any SpEL expressions, explain those parts as well: \n\n"),
78
AOP("Explain AOP annotation with Copilot", "Explain the following AOP annotation with a clear summary first, followed by a detailed contextual explanation of annotation and its purpose: \n\n"),
89
DEFAULT("Explain Query with Copilot", "Explain the following query with a clear summary first, followed by a detailed explanation: \n\n");
910

0 commit comments

Comments
 (0)