Skip to content

Commit fd17d89

Browse files
committed
Simplify async method call
Replace UI.getDisplay().syncExec(...) with UI.syncRun(...) and simplify code.
1 parent d08a405 commit fd17d89

1 file changed

Lines changed: 2 additions & 18 deletions

File tree

org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/templates/TMTemplateCompletionProcessor.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
*******************************************************************************/
1212
package org.eclipse.tm4e.ui.internal.templates;
1313

14-
import java.util.ArrayList;
15-
import java.util.Collections;
1614
import java.util.List;
1715

1816
import org.eclipse.core.runtime.Platform;
@@ -40,26 +38,12 @@
4038

4139
public class TMTemplateCompletionProcessor extends TemplateCompletionProcessor {
4240

43-
private static final ICompletionProposal[] NO_PROPOSALS = {};
4441
private static final Template[] NO_TEMPLATES = {};
4542

4643
@Override
4744
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer, final int offset) {
48-
// TODO check why Invalid thread access exception occurs here without syncExec()
49-
final ArrayList<ICompletionProposal> templateProposals = new ArrayList<>();
50-
UI.getDisplay().syncExec(() -> {
51-
final ICompletionProposal[] proposalsFromParent = TMTemplateCompletionProcessor.super.computeCompletionProposals(
52-
viewer, offset);
53-
Collections.addAll(templateProposals, proposalsFromParent);
54-
});
55-
56-
if (templateProposals.size() > 0) {
57-
final ICompletionProposal[] proposals = templateProposals
58-
.toArray(new ICompletionProposal[templateProposals.size()]);
59-
return proposals;
60-
}
61-
62-
return NO_PROPOSALS;
45+
// TODO Check why Invalid thread access exception occurs here without UI.runSync()
46+
return UI.runSync(() -> TMTemplateCompletionProcessor.super.computeCompletionProposals(viewer, offset));
6347
}
6448

6549
private static class TmTokenRegion implements IRegion {

0 commit comments

Comments
 (0)