Skip to content

Commit 65787d4

Browse files
tobias-melchermickaelistria
authored andcommitted
ensure code minings are still drawn when one provider returns null
1 parent 8b4c0b6 commit 65787d4

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.LinkedHashMap;
2020
import java.util.List;
2121
import java.util.Map;
22+
import java.util.Objects;
2223
import java.util.Set;
2324
import java.util.concurrent.CancellationException;
2425
import java.util.concurrent.CompletableFuture;
@@ -194,7 +195,7 @@ private static CompletableFuture<List<? extends ICodeMining>> getCodeMinings(ITe
194195
}))
195196
.collect(Collectors.toList());
196197
return CompletableFuture.allOf(com.toArray(new CompletableFuture[com.size()])).thenApply(
197-
v -> com.stream().map(CompletableFuture::join).flatMap(java.util.Collection::stream).collect(Collectors.toList()));
198+
v -> com.stream().map(CompletableFuture::join).filter(Objects::nonNull).flatMap(java.util.Collection::stream).collect(Collectors.toList()));
198199
}
199200

200201
/**

tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/codemining/CodeMiningTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.eclipse.jface.text.IRegion;
4747
import org.eclipse.jface.text.ITextViewer;
4848
import org.eclipse.jface.text.Position;
49+
import org.eclipse.jface.text.codemining.AbstractCodeMiningProvider;
4950
import org.eclipse.jface.text.codemining.ICodeMining;
5051
import org.eclipse.jface.text.codemining.ICodeMiningProvider;
5152
import org.eclipse.jface.text.reconciler.DirtyRegion;
@@ -126,6 +127,28 @@ protected boolean condition() {
126127
}.waitForCondition(fViewer.getControl().getDisplay(), 3000));
127128
}
128129

130+
@Test
131+
public void testCodeMiningCompletableFutureReturnsNull() {
132+
fViewer.setCodeMiningProviders(new ICodeMiningProvider[] {
133+
new AbstractCodeMiningProvider() {
134+
135+
@Override
136+
public CompletableFuture<List<? extends ICodeMining>> provideCodeMinings(ITextViewer viewer, IProgressMonitor monitor) {
137+
return CompletableFuture.supplyAsync(() -> {
138+
return null;
139+
});
140+
}
141+
},
142+
new DelayedEchoCodeMiningProvider() });
143+
fViewer.getDocument().set("echo");
144+
Assert.assertTrue(new DisplayHelper() {
145+
@Override
146+
protected boolean condition() {
147+
return fViewer.getTextWidget().getLineVerticalIndent(0) > 0;
148+
}
149+
}.waitForCondition(fViewer.getControl().getDisplay(), 3000));
150+
}
151+
129152
@Test
130153
public void testCodeMiningCtrlHome() throws BadLocationException {
131154
Assume.assumeFalse("See bug 541415. For whatever reason, this shortcut doesn't work on Mac", Util.isMac());

0 commit comments

Comments
 (0)