| 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.util; | 5 library test.services.completion.util; |
| 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'; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 125 |
| 126 bool computeFast() { | 126 bool computeFast() { |
| 127 _computeFastCalled = true; | 127 _computeFastCalled = true; |
| 128 computer | 128 computer |
| 129 ..context = context | 129 ..context = context |
| 130 ..searchEngine = searchEngine | 130 ..searchEngine = searchEngine |
| 131 ..source = testSource | 131 ..source = testSource |
| 132 ..offset = completionOffset; | 132 ..offset = completionOffset; |
| 133 suggestions = []; | 133 suggestions = []; |
| 134 CompilationUnit unit = context.parseCompilationUnit(testSource); | 134 CompilationUnit unit = context.parseCompilationUnit(testSource); |
| 135 return computer.computeFast(unit, suggestions); | 135 AstNode node = new NodeLocator.con1(completionOffset).searchWithin(unit); |
| 136 return computer.computeFast(unit, node, suggestions); |
| 136 } | 137 } |
| 137 | 138 |
| 138 Future<bool> computeFull() { | 139 Future<bool> computeFull() { |
| 139 if (!_computeFastCalled) { | 140 if (!_computeFastCalled) { |
| 140 expect(computeFast(), isFalse); | 141 expect(computeFast(), isFalse); |
| 141 } | 142 } |
| 142 var result = context.performAnalysisTask(); | 143 var result = context.performAnalysisTask(); |
| 143 while (result.hasMoreWork) { | 144 while (result.hasMoreWork) { |
| 144 result.changeNotices.forEach((ChangeNotice notice) { | 145 result.changeNotices.forEach((ChangeNotice notice) { |
| 145 CompilationUnit unit = notice.compilationUnit; | 146 CompilationUnit unit = notice.compilationUnit; |
| 146 if (unit != null) { | 147 if (unit != null) { |
| 147 index.indexUnit(context, unit); | 148 index.indexUnit(context, unit); |
| 148 } | 149 } |
| 149 }); | 150 }); |
| 150 result = context.performAnalysisTask(); | 151 result = context.performAnalysisTask(); |
| 151 } | 152 } |
| 152 LibraryElement library = context.getLibraryElement(testSource); | 153 LibraryElement library = context.getLibraryElement(testSource); |
| 153 expect(library, isNotNull); | 154 expect(library, isNotNull); |
| 154 var unit = context.getResolvedCompilationUnit(testSource, library); | 155 var unit = context.getResolvedCompilationUnit(testSource, library); |
| 155 expect(unit, isNotNull); | 156 expect(unit, isNotNull); |
| 156 return computer.computeFull(unit, suggestions); | 157 AstNode node = new NodeLocator.con1(completionOffset).searchWithin(unit); |
| 158 return computer.computeFull(unit, node, suggestions); |
| 157 } | 159 } |
| 158 | 160 |
| 159 @override | 161 @override |
| 160 void setUp() { | 162 void setUp() { |
| 161 super.setUp(); | 163 super.setUp(); |
| 162 index = createLocalMemoryIndex(); | 164 index = createLocalMemoryIndex(); |
| 163 searchEngine = new SearchEngineImpl(index); | 165 searchEngine = new SearchEngineImpl(index); |
| 164 addResolvedUnit(MockSdk.LIB_CORE.path, MockSdk.LIB_CORE.content); | 166 addResolvedUnit(MockSdk.LIB_CORE.path, MockSdk.LIB_CORE.content); |
| 165 } | 167 } |
| 166 } | 168 } |
| OLD | NEW |