| 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_services/completion/completion_computer.dart'; | 9 import 'package:analysis_services/completion/completion_computer.dart'; |
| 10 import 'package:analysis_services/completion/completion_suggestion.dart'; | 10 import 'package:analysis_services/completion/completion_suggestion.dart'; |
| 11 import 'package:analysis_services/search/search_engine.dart'; | 11 import 'package:analysis_services/search/search_engine.dart'; |
| 12 import 'package:analysis_services/src/completion/top_level_computer.dart'; | 12 import 'package:analysis_services/src/completion/top_level_computer.dart'; |
| 13 import 'package:analyzer/src/generated/ast.dart'; | 13 import 'package:analyzer/src/generated/ast.dart'; |
| 14 import 'package:analyzer/src/generated/element.dart'; | 14 import 'package:analyzer/src/generated/element.dart'; |
| 15 import 'package:analyzer/src/generated/engine.dart'; | 15 import 'package:analyzer/src/generated/engine.dart'; |
| 16 import 'package:analyzer/src/generated/source.dart'; | 16 import 'package:analyzer/src/generated/source.dart'; |
| 17 import 'package:analysis_services/src/completion/local_computer.dart'; |
| 17 | 18 |
| 18 /** | 19 /** |
| 19 * Manages code completion for a given Dart file completion request. | 20 * Manages code completion for a given Dart file completion request. |
| 20 */ | 21 */ |
| 21 class DartCompletionManager extends CompletionManager { | 22 class DartCompletionManager extends CompletionManager { |
| 22 final AnalysisContext context; | 23 final AnalysisContext context; |
| 23 final Source source; | 24 final Source source; |
| 24 final int offset; | 25 final int offset; |
| 25 final SearchEngine searchEngine; | 26 final SearchEngine searchEngine; |
| 26 final List<CompletionSuggestion> suggestions = []; | 27 final List<CompletionSuggestion> suggestions = []; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 }); | 69 }); |
| 69 }); | 70 }); |
| 70 }); | 71 }); |
| 71 } | 72 } |
| 72 | 73 |
| 73 /** | 74 /** |
| 74 * Build and initialize the list of completion computers | 75 * Build and initialize the list of completion computers |
| 75 */ | 76 */ |
| 76 void initComputers() { | 77 void initComputers() { |
| 77 if (computers == null) { | 78 if (computers == null) { |
| 78 computers = [new TopLevelComputer()]; | 79 computers = [new LocalComputer(), new TopLevelComputer()]; |
| 79 } | 80 } |
| 80 computers.forEach((CompletionComputer c) { | 81 computers.forEach((CompletionComputer c) { |
| 81 c.context = context; | 82 c.context = context; |
| 82 c.source = source; | 83 c.source = source; |
| 83 c.offset = offset; | 84 c.offset = offset; |
| 84 c.searchEngine = searchEngine; | 85 c.searchEngine = searchEngine; |
| 85 }); | 86 }); |
| 86 } | 87 } |
| 87 | 88 |
| 88 /** | 89 /** |
| (...skipping 15 matching lines...) Expand all Loading... |
| 104 if (library != null) { | 105 if (library != null) { |
| 105 var unit = context.getResolvedCompilationUnit(source, library); | 106 var unit = context.getResolvedCompilationUnit(source, library); |
| 106 if (unit != null) { | 107 if (unit != null) { |
| 107 return new Future.value(unit); | 108 return new Future.value(unit); |
| 108 } | 109 } |
| 109 } | 110 } |
| 110 //TODO (danrubel) Determine if analysis is complete but unit not resolved | 111 //TODO (danrubel) Determine if analysis is complete but unit not resolved |
| 111 return new Future(waitForAnalysis); | 112 return new Future(waitForAnalysis); |
| 112 } | 113 } |
| 113 } | 114 } |
| OLD | NEW |