Skip to content

Commit

Permalink
Increase the context entrypoint chain size
Browse files Browse the repository at this point in the history
This change increase the context specific chain size which use max depth
2 to provide static method completions from static entry points. To get
more matching chains we increase the max chain size for this specific chain
search.
  • Loading branch information
gayanper committed Sep 5, 2023
1 parent 27691eb commit ef32135
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ private List<CompletionItem> executeCallChainSearch() {
try {
List<ChainElement> contextEntrypoint = computeContextEntrypoint(expectedTypes, cu.getJavaProject());
if (!contextEntrypoint.isEmpty()) {
contextFinder.startChainSearch(contextEntrypoint, maxChains, 1, 2);
//todo: move these to jdt ls configuration.
contextFinder.startChainSearch(contextEntrypoint, maxChains * 10, 1, 2);
}
} catch (JavaModelException e) {
// ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;

import java.util.List;
Expand Down Expand Up @@ -265,4 +266,23 @@ public Object newObject() {
completionItems = list.getItems().stream().filter(i -> i.getLabel().contains("newObject")).collect(Collectors.toList());
assertEquals("emptyList completion count [type]", 0, completionItems.size());
}

@Test
public void testChainCompletionsOnContextEntrypointExpectMoreThanMaxChainSize() throws Exception {
//@formatter:off
ICompilationUnit unit = getWorkingCopy(
"src/java/Foo.java",
"""
import java.util.stream.Stream;
public class Foo {
public static void main(String[] args) {
Stream.of("1").collect()
}
}
""");
//@formatter:on
CompletionList list = requestCompletions(unit, "collect(");
List<CompletionItem> completionItems = list.getItems();
assertTrue("completion count greater than 20", completionItems.size() > 20);
}
}

0 comments on commit ef32135

Please sign in to comment.