| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library test.services.completion.dart; | 5 library test.services.completion.dart; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart'; | 9 import 'package:analysis_server/src/protocol.dart'; |
| 10 import 'package:analysis_server/src/services/completion/completion_manager.dart'
; | 10 import 'package:analysis_server/src/services/completion/completion_manager.dart'
; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 } | 66 } |
| 67 | 67 |
| 68 /** | 68 /** |
| 69 * Compute suggestions based upon cached information only | 69 * Compute suggestions based upon cached information only |
| 70 * then send an initial response to the client. | 70 * then send an initial response to the client. |
| 71 */ | 71 */ |
| 72 void computeFast() { | 72 void computeFast() { |
| 73 CompilationUnit unit = context.parseCompilationUnit(source); | 73 CompilationUnit unit = context.parseCompilationUnit(source); |
| 74 request.unit = unit; | 74 request.unit = unit; |
| 75 request.node = new NodeLocator.con1(offset).searchWithin(unit); | 75 request.node = new NodeLocator.con1(offset).searchWithin(unit); |
| 76 if (request.node != null) { | 76 request.node.accept(new _ReplacementOffsetBuilder(request)); |
| 77 request.node.accept(new _ReplacementOffsetBuilder(request)); | |
| 78 } | |
| 79 computers.removeWhere((DartCompletionComputer c) => c.computeFast(request)); | 77 computers.removeWhere((DartCompletionComputer c) => c.computeFast(request)); |
| 80 sendResults(computers.isEmpty); | 78 sendResults(computers.isEmpty); |
| 81 } | 79 } |
| 82 | 80 |
| 83 /** | 81 /** |
| 84 * If there is remaining work to be done, then wait for the unit to be | 82 * If there is remaining work to be done, then wait for the unit to be |
| 85 * resolved and request that each remaining computer finish their work. | 83 * resolved and request that each remaining computer finish their work. |
| 86 */ | 84 */ |
| 87 void computeFull() { | 85 void computeFull() { |
| 88 waitForAnalysis().then((CompilationUnit unit) { | 86 waitForAnalysis().then((CompilationUnit unit) { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 _ReplacementOffsetBuilder(this.request) { | 221 _ReplacementOffsetBuilder(this.request) { |
| 224 request.replacementOffset = request.offset; | 222 request.replacementOffset = request.offset; |
| 225 request.replacementLength = 0; | 223 request.replacementLength = 0; |
| 226 } | 224 } |
| 227 | 225 |
| 228 visitSimpleIdentifier(SimpleIdentifier node) { | 226 visitSimpleIdentifier(SimpleIdentifier node) { |
| 229 request.replacementOffset = node.offset; | 227 request.replacementOffset = node.offset; |
| 230 request.replacementLength = node.length; | 228 request.replacementLength = node.length; |
| 231 } | 229 } |
| 232 } | 230 } |
| OLD | NEW |