Skip to content

Commit af2ff02

Browse files
committed
Do not wait for AST when copying code in ClipboarOperationAction
Since waiting for the AST could end up blocking the UI thread. Fixes #2028
1 parent 3a6d922 commit af2ff02

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClipboardOperationAction.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,11 @@ private boolean isNonTrivialSelection(ITextSelection selection) {
484484

485485

486486
private ClipboardData getClipboardData(ITypeRoot inputElement, int offset, int length) {
487-
CompilationUnit astRoot= SharedASTProviderCore.getAST(inputElement, SharedASTProviderCore.WAIT_ACTIVE_ONLY, null);
487+
// Since this call happens in the UI thread, pass WAIT_NO as parameter
488+
// so that the call can not reach the wait call that causes UI freezes.
489+
// The cost of doing so is that the method could return null from time
490+
// to time and therefore the imports may not be copied to the clipboard
491+
CompilationUnit astRoot= SharedASTProviderCore.getAST(inputElement, SharedASTProviderCore.WAIT_NO, null);
488492
if (astRoot == null) {
489493
return null;
490494
}

0 commit comments

Comments
 (0)