Chromium Code Reviews| Index: pkg/analysis_services/lib/refactoring/progress_monitor.dart |
| diff --git a/pkg/analysis_services/lib/refactoring/progress_monitor.dart b/pkg/analysis_services/lib/refactoring/progress_monitor.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..06bbaaf28e6fa55224a83dbb6d9a8016577c7a73 |
| --- /dev/null |
| +++ b/pkg/analysis_services/lib/refactoring/progress_monitor.dart |
| @@ -0,0 +1,113 @@ |
| +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library services.refactoring.progress_monitor; |
| + |
| + |
| +/** |
| + * A [ProgressMonitor] which ignores interactions. |
| + */ |
| +class NullProgressMonitor implements ProgressMonitor { |
|
Brian Wilkerson
2014/08/11 16:27:47
I don't understand the value of a progress monitor
scheglov
2014/08/11 18:06:25
Good point.
We don't need it / not useful in Dart.
|
| + @override |
| + bool get isCanceled => false; |
| + |
| + @override |
| + void beginTask(String name, int totalWork) { |
| + } |
| + |
| + @override |
| + void done() { |
| + } |
| + |
| + @override |
| + void internalWorked(double work) { |
| + } |
| + |
| + @override |
| + void setCanceled() { |
| + } |
| + |
| + @override |
| + void subTask(String name) { |
| + } |
| + |
| + @override |
| + void worked(int work) { |
| + } |
| +} |
| + |
| + |
| +/** |
| + * This exception is thrown when the user cancels a long-running operation. |
| + */ |
| +class OperationCanceledException { |
| + final String message; |
| + OperationCanceledException([this.message = '']); |
| + String toString() => "OperationCanceledException: $message"; |
| +} |
| + |
| + |
| +/** |
| + * An interface for monitoring the progress of an activity. |
| + * Its methods are invoked by code that performs the activity. |
| + */ |
| +abstract class ProgressMonitor { |
| + /** |
| + * Returns whether cancelation of current operation has been requested. |
| + * |
| + * Long-running operations should poll to see if cancelation has been |
| + * requested. |
| + */ |
| + bool get isCanceled; |
| + |
| + /** |
| + * Notifies that the main task is beginning. |
| + * |
| + * This must only be called once on a given progress monitor instance. |
| + */ |
| + void beginTask(String name, int totalWork); |
| + |
| + /** |
| + * Notifies that the main task is completed. |
| + * |
| + * This must only be called once on a given progress monitor instance. |
| + */ |
| + void done(); |
| + |
| + /** |
| + * Internal method to handle scaling correctly. |
| + * |
| + * This method must not be called by a client. |
| + * |
| + * Clients should always use the method [worked]. |
| + * |
| + * [work] - the amount of work done. |
| + */ |
| + void internalWorked(double work); |
| + |
| + /** |
| + * Sets the cancel state to the given value. |
| + */ |
| + void setCanceled(); |
| + |
| + /** |
| + * Notifies that a subtask of the main task is beginning. |
| + * |
| + * Subtasks are optional; the main task might not have subtasks. |
| + * |
| + * [name] - the name (or description) of the subtask. |
| + */ |
| + void subTask(String name); |
| + |
| + /** |
| + * Notifies that a given number of work unit of the main task has been |
| + * completed. |
| + * |
| + * Note that this amount represents an installment, as opposed to a cumulative |
| + * amount of work done to date. |
| + * |
| + * [work] - a non-negative number of work units just completed. |
| + */ |
| + void worked(int work); |
| +} |