| 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/combinator_computer.dart
'; |
| 10 import 'package:analysis_server/src/services/completion/completion_manager.dart'
; | 11 import 'package:analysis_server/src/services/completion/completion_manager.dart'
; |
| 11 import 'package:analysis_server/src/services/completion/imported_computer.dart'; | 12 import 'package:analysis_server/src/services/completion/imported_computer.dart'; |
| 12 import 'package:analysis_server/src/services/completion/invocation_computer.dart
'; | 13 import 'package:analysis_server/src/services/completion/invocation_computer.dart
'; |
| 13 import 'package:analysis_server/src/services/completion/keyword_computer.dart'; | 14 import 'package:analysis_server/src/services/completion/keyword_computer.dart'; |
| 14 import 'package:analysis_server/src/services/completion/local_computer.dart'; | 15 import 'package:analysis_server/src/services/completion/local_computer.dart'; |
| 15 import 'package:analysis_server/src/services/search/search_engine.dart'; | 16 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 16 import 'package:analyzer/src/generated/ast.dart'; | 17 import 'package:analyzer/src/generated/ast.dart'; |
| 17 import 'package:analyzer/src/generated/element.dart'; | 18 import 'package:analyzer/src/generated/element.dart'; |
| 18 import 'package:analyzer/src/generated/engine.dart'; | 19 import 'package:analyzer/src/generated/engine.dart'; |
| 19 import 'package:analyzer/src/generated/source.dart'; | 20 import 'package:analyzer/src/generated/source.dart'; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 waitForAnalysis().then((CompilationUnit unit) { | 87 waitForAnalysis().then((CompilationUnit unit) { |
| 87 if (unit == null) { | 88 if (unit == null) { |
| 88 sendResults(true); | 89 sendResults(true); |
| 89 return; | 90 return; |
| 90 } | 91 } |
| 91 request.unit = unit; | 92 request.unit = unit; |
| 92 request.node = new NodeLocator.con1(offset).searchWithin(unit); | 93 request.node = new NodeLocator.con1(offset).searchWithin(unit); |
| 93 int count = computers.length; | 94 int count = computers.length; |
| 94 computers.forEach((c) { | 95 computers.forEach((c) { |
| 95 c.computeFull(request).then((bool changed) { | 96 c.computeFull(request).then((bool changed) { |
| 96 var last = --count == 0; | 97 bool last = --count == 0; |
| 97 if (changed || last) { | 98 if (changed || last) { |
| 98 sendResults(last); | 99 sendResults(last); |
| 99 } | 100 } |
| 100 }); | 101 }); |
| 101 }); | 102 }); |
| 102 }); | 103 }); |
| 103 } | 104 } |
| 104 | 105 |
| 105 /** | 106 /** |
| 106 * Build and initialize the list of completion computers | 107 * Build and initialize the list of completion computers |
| 107 */ | 108 */ |
| 108 void initComputers() { | 109 void initComputers() { |
| 109 if (computers == null) { | 110 if (computers == null) { |
| 110 computers = [ | 111 computers = [ |
| 111 new KeywordComputer(), | 112 new KeywordComputer(), |
| 112 new LocalComputer(), | 113 new LocalComputer(), |
| 114 new CombinatorComputer(), |
| 113 new ImportedComputer(), | 115 new ImportedComputer(), |
| 114 new InvocationComputer()]; | 116 new InvocationComputer()]; |
| 115 } | 117 } |
| 116 } | 118 } |
| 117 | 119 |
| 118 /** | 120 /** |
| 119 * Send the current list of suggestions to the client. | 121 * Send the current list of suggestions to the client. |
| 120 */ | 122 */ |
| 121 void sendResults(bool last) { | 123 void sendResults(bool last) { |
| 122 controller.add( | 124 controller.add( |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 _ReplacementOffsetBuilder(this.request) { | 223 _ReplacementOffsetBuilder(this.request) { |
| 222 request.replacementOffset = request.offset; | 224 request.replacementOffset = request.offset; |
| 223 request.replacementLength = 0; | 225 request.replacementLength = 0; |
| 224 } | 226 } |
| 225 | 227 |
| 226 visitSimpleIdentifier(SimpleIdentifier node) { | 228 visitSimpleIdentifier(SimpleIdentifier node) { |
| 227 request.replacementOffset = node.offset; | 229 request.replacementOffset = node.offset; |
| 228 request.replacementLength = node.length; | 230 request.replacementLength = node.length; |
| 229 } | 231 } |
| 230 } | 232 } |
| OLD | NEW |