@Test void collect() { CodeActionProvider provider1 = mock(CodeActionProvider.class); CodeActionProvider provider2 = mock(CodeActionProvider.class); Set<CodeActionProvider> providers = new HashSet<>(); providers.add(provider1); providers.add(provider2); CodeActionParams params = new CodeActionParams(); CodeAction action1 = new CodeAction(); CodeAction action2 = new CodeAction(); when(provider1.collectCommandsOrActions(params)).thenReturn(singletonList(forRight(action1))); when(provider2.collectCommandsOrActions(params)).thenReturn(singletonList(forRight(action2))); CodeActions actions = new CodeActions(providers); assertEquals(2, actions.collect(new CodeActionParams()).size()); }
public List<Either<Command, CodeAction>> collect(CodeActionParams params) { return providers.stream().map(it -> it.collectCommandsOrActions(params)).flatMap(List::stream).collect(toList()); }
CodeActions { public List<Either<Command, CodeAction>> collect(CodeActionParams params) { return providers.stream().map(it -> it.collectCommandsOrActions(params)).flatMap(List::stream).collect(toList()); } }
CodeActions { public List<Either<Command, CodeAction>> collect(CodeActionParams params) { return providers.stream().map(it -> it.collectCommandsOrActions(params)).flatMap(List::stream).collect(toList()); } @Inject  CodeActions(Set<CodeActionProvider> providers); }
CodeActions { public List<Either<Command, CodeAction>> collect(CodeActionParams params) { return providers.stream().map(it -> it.collectCommandsOrActions(params)).flatMap(List::stream).collect(toList()); } @Inject  CodeActions(Set<CodeActionProvider> providers); List<Either<Command, CodeAction>> collect(CodeActionParams params); }
CodeActions { public List<Either<Command, CodeAction>> collect(CodeActionParams params) { return providers.stream().map(it -> it.collectCommandsOrActions(params)).flatMap(List::stream).collect(toList()); } @Inject  CodeActions(Set<CodeActionProvider> providers); List<Either<Command, CodeAction>> collect(CodeActionParams params);  }