| Index: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/refactoring/ServerRefactoring.java
|
| diff --git a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/refactoring/ServerRefactoring.java b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/refactoring/ServerRefactoring.java
|
| index f884a64e6cd75d372b147b395f5d9b1ce98b1721..101a5f44d786c0a1b209b1be8991c5ca7f1a457a 100644
|
| --- a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/refactoring/ServerRefactoring.java
|
| +++ b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/refactoring/ServerRefactoring.java
|
| @@ -41,6 +41,8 @@ import java.util.concurrent.TimeUnit;
|
| * @coverage dart.editor.ui.refactoring.ui
|
| */
|
| public abstract class ServerRefactoring extends Refactoring {
|
| + protected static final RefactoringStatus TIMEOUT_STATUS = RefactoringStatus.createFatalErrorStatus("Timeout");
|
| +
|
| public static String[] toStringArray(List<String> list) {
|
| return list.toArray(new String[list.size()]);
|
| }
|
| @@ -51,8 +53,9 @@ public abstract class ServerRefactoring extends Refactoring {
|
| private final int offset;
|
| private final int length;
|
|
|
| - private boolean timeout;
|
| - private RefactoringStatus ltkStatus;
|
| + protected RefactoringStatus ltkInitialStatus;
|
| + protected RefactoringStatus ltkOptionsStatus;
|
| + protected RefactoringStatus ltkFinalStatus;
|
| private Change ltkChange;
|
|
|
| public ServerRefactoring(String kind, String name, String file, int offset, int length) {
|
| @@ -65,17 +68,23 @@ public abstract class ServerRefactoring extends Refactoring {
|
|
|
| @Override
|
| public RefactoringStatus checkFinalConditions(IProgressMonitor pm) {
|
| - return setOptions(true);
|
| + if (!setOptions(true)) {
|
| + return TIMEOUT_STATUS;
|
| + }
|
| + return ltkFinalStatus;
|
| }
|
|
|
| @Override
|
| public RefactoringStatus checkInitialConditions(IProgressMonitor pm) {
|
| - return setOptions(true);
|
| + if (!setOptions(true)) {
|
| + return TIMEOUT_STATUS;
|
| + }
|
| + return ltkInitialStatus;
|
| }
|
|
|
| @Override
|
| public Change createChange(IProgressMonitor pm) {
|
| - setOptions(false);
|
| + boolean timeout = !setOptions(false);
|
| if (timeout) {
|
| throw new OperationCanceledException();
|
| }
|
| @@ -105,7 +114,7 @@ public abstract class ServerRefactoring extends Refactoring {
|
| */
|
| protected abstract void setFeedback(RefactoringFeedback feedback);
|
|
|
| - protected RefactoringStatus setOptions(boolean validateOnly) {
|
| + protected boolean setOptions(boolean validateOnly) {
|
| final CountDownLatch latch = new CountDownLatch(1);
|
| RefactoringOptions options = getOptions();
|
| DartCore.getAnalysisServer().edit_getRefactoring(
|
| @@ -117,19 +126,19 @@ public abstract class ServerRefactoring extends Refactoring {
|
| options,
|
| new GetRefactoringConsumer() {
|
| @Override
|
| - public void computedRefactorings(List<RefactoringProblem> problems,
|
| + public void computedRefactorings(List<RefactoringProblem> initialProblems,
|
| + List<RefactoringProblem> optionsProblems, List<RefactoringProblem> finalProblems,
|
| RefactoringFeedback feedback, SourceChange change, List<String> potentialEdits) {
|
| if (feedback != null) {
|
| setFeedback(feedback);
|
| }
|
| - ltkStatus = toRefactoringStatus(problems);
|
| + ltkInitialStatus = toRefactoringStatus(initialProblems);
|
| + ltkOptionsStatus = toRefactoringStatus(optionsProblems);
|
| + ltkFinalStatus = toRefactoringStatus(finalProblems);
|
| ltkChange = toLTK(change);
|
| latch.countDown();
|
| }
|
| });
|
| - if (Uninterruptibles.awaitUninterruptibly(latch, 100, TimeUnit.MILLISECONDS)) {
|
| - return ltkStatus;
|
| - }
|
| - return RefactoringStatus.createFatalErrorStatus("Timeout");
|
| + return Uninterruptibles.awaitUninterruptibly(latch, 100, TimeUnit.MILLISECONDS);
|
| }
|
| }
|
|
|