From 8dd2c86d586f200db80ea041bbd16134ec0e31a4 Mon Sep 17 00:00:00 2001 From: Shi Chen Date: Tue, 14 Sep 2021 14:52:41 +0800 Subject: [PATCH] fix: Offer completion results from supertypes (#987) --- .../gradle/handlers/CompletionHandler.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/gradle-language-server/src/main/java/com/microsoft/gradle/handlers/CompletionHandler.java b/gradle-language-server/src/main/java/com/microsoft/gradle/handlers/CompletionHandler.java index ea2c3b6eb..93cdc1207 100644 --- a/gradle-language-server/src/main/java/com/microsoft/gradle/handlers/CompletionHandler.java +++ b/gradle-language-server/src/main/java/com/microsoft/gradle/handlers/CompletionHandler.java @@ -51,16 +51,24 @@ public List getCompletionItems(MethodCallExpression containingCa if (delegateClass == null) { return Collections.emptyList(); } - return getCompletionItemsFromClass(delegateClass); + return getCompletionItemsFromClass(delegateClass, resolver, new HashSet<>()); } - private List getCompletionItemsFromClass(JavaClass javaClass) { + private List getCompletionItemsFromClass(JavaClass javaClass, GradleLibraryResolver resolver, Set resultSet) { if (javaClass == null) { return Collections.emptyList(); } List results = new ArrayList<>(); + for (String superInterface : javaClass.getInterfaceNames()) { + if (resolver.getGradleLibraries().containsKey(superInterface)) { + results.addAll(getCompletionItemsFromClass(resolver.getGradleLibraries().get(superInterface), resolver, resultSet)); + } + } + String superClass = javaClass.getSuperclassName(); + if (resolver.getGradleLibraries().containsKey(superClass)) { + results.addAll(getCompletionItemsFromClass(resolver.getGradleLibraries().get(superClass), resolver, resultSet)); + } List methodNames = new ArrayList<>(); - Set resultSet = new HashSet<>(); Method[] methods = javaClass.getMethods(); for (Method method : methods) { StringBuilder labelBuilder = new StringBuilder();