GH-1545: use specific prompt for explaining mongodb queries

This commit is contained in:
Martin Lippert
2025-05-16 12:31:32 +02:00
parent 26e9d24f4e
commit be4839fd84
2 changed files with 14 additions and 2 deletions

View File

@@ -221,11 +221,22 @@ public class CopilotCodeLensProvider implements CodeLensProvider {
private QueryType determineQueryType(TextDocument document) {
Optional<IJavaProject> optProject = projectFinder.find(document.getId());
if (optProject.isPresent()) {
IJavaProject jp = optProject.get();
return SpringProjectUtil.hasDependencyStartingWith(jp, "hibernate-core", null) ? QueryType.HQL
: QueryType.JPQL;
if (SpringProjectUtil.hasDependencyStartingWith(jp, "hibernate-core", null)) {
return QueryType.HQL;
}
else if (SpringProjectUtil.hasDependencyStartingWith(jp, "spring-data-mongodb", null)) {
return QueryType.MONGODB;
}
else {
return QueryType.JPQL;
}
}
return QueryType.DEFAULT;
}

View File

@@ -4,6 +4,7 @@ public enum QueryType {
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"),
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"),
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"),
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"),
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"),
DEFAULT("Explain Query with Copilot", "Explain the following query with a clear summary first, followed by a detailed explanation: \n\n");