| Index: pkg/analysis_server/lib/src/services/completion/completion_manager.dart
|
| diff --git a/pkg/analysis_server/lib/src/services/completion/completion_manager.dart b/pkg/analysis_server/lib/src/services/completion/completion_manager.dart
|
| index 10b1486de8bdcdfda2e46e90f88aecb7272e03cb..e60f875be8efd23dcf16129828c69da64042065d 100644
|
| --- a/pkg/analysis_server/lib/src/services/completion/completion_manager.dart
|
| +++ b/pkg/analysis_server/lib/src/services/completion/completion_manager.dart
|
| @@ -37,57 +37,60 @@ abstract class CompletionCache {
|
| abstract class CompletionManager {
|
|
|
| /**
|
| + * The context in which the completion was computed.
|
| + */
|
| + final AnalysisContext context;
|
| +
|
| + /**
|
| + * The source in which the completion was computed.
|
| + */
|
| + final Source source;
|
| +
|
| + /**
|
| * The controller used for returning completion results.
|
| */
|
| StreamController<CompletionResult> controller;
|
|
|
| - CompletionManager();
|
| + CompletionManager(this.context, this.source);
|
|
|
| /**
|
| * Create a manager for the given request.
|
| */
|
| factory CompletionManager.create(AnalysisContext context, Source source,
|
| - int offset, SearchEngine searchEngine, CompletionCache cache,
|
| - CompletionPerformance performance) {
|
| + SearchEngine searchEngine, CompletionCache cache) {
|
| if (context != null) {
|
| if (AnalysisEngine.isDartFileName(source.shortName)) {
|
| return new DartCompletionManager.create(
|
| context,
|
| searchEngine,
|
| source,
|
| - offset,
|
| - cache,
|
| - performance);
|
| + cache);
|
| }
|
| if (AnalysisEngine.isHtmlFileName(source.shortName)) {
|
| //TODO (danrubel) implement
|
| // return new HtmlCompletionManager(context, searchEngine, source, offset);
|
| }
|
| }
|
| - return new NoOpCompletionManager(source, offset);
|
| + return new NoOpCompletionManager(source);
|
| }
|
|
|
| /**
|
| - * Return cached information from the current completion operation
|
| - * if there is any. Subclasses may override this method.
|
| - */
|
| - CompletionCache get completionCache => null;
|
| -
|
| - /**
|
| - * Compute completion results and append them to the stream.
|
| + * Compute completion results for the given reqeust and append them to the stream.
|
| * Clients should not call this method directly as it is automatically called
|
| * when a client listens to the stream returned by [results].
|
| * Subclasses should override this method, append at least one result
|
| * to the [controller], and close the controller stream once complete.
|
| */
|
| - void compute();
|
| + void compute(CompletionRequest request);
|
|
|
| /**
|
| * Generate a stream of code completion results.
|
| */
|
| - Stream<CompletionResult> results() {
|
| + Stream<CompletionResult> results(CompletionRequest request) {
|
| controller = new StreamController<CompletionResult>(onListen: () {
|
| - scheduleMicrotask(compute);
|
| + scheduleMicrotask(() {
|
| + compute(request);
|
| + });
|
| });
|
| return controller.stream;
|
| }
|
| @@ -139,6 +142,23 @@ class CompletionPerformance {
|
| }
|
|
|
| /**
|
| + * Encapsulates information specific to a particular completion request.
|
| + */
|
| +class CompletionRequest {
|
| + /**
|
| + * The offset within the source at which the completion is requested.
|
| + */
|
| + final int offset;
|
| +
|
| + /**
|
| + * Performance measurements for this particular request.
|
| + */
|
| + final CompletionPerformance performance;
|
| +
|
| + CompletionRequest(this.offset, this.performance);
|
| +}
|
| +
|
| +/**
|
| * Code completion result generated by an [CompletionManager].
|
| */
|
| class CompletionResult {
|
| @@ -174,14 +194,12 @@ class CompletionResult {
|
| }
|
|
|
| class NoOpCompletionManager extends CompletionManager {
|
| - final Source source;
|
| - final int offset;
|
|
|
| - NoOpCompletionManager(this.source, this.offset);
|
| + NoOpCompletionManager(Source source) : super(null, source);
|
|
|
| @override
|
| - void compute() {
|
| - controller.add(new CompletionResult(offset, 0, [], true));
|
| + void compute(CompletionRequest request) {
|
| + controller.add(new CompletionResult(request.offset, 0, [], true));
|
| }
|
| }
|
|
|
|
|