Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Side by Side Diff: pkg/analysis_services/test/completion/completion_test_util.dart

Issue 428313002: refactor code completion to allow for multiple suggestion computers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.toplevel; 5 library test.services.completion.util;
6 6
7 import 'dart:async';
8
9 import 'package:analysis_services/completion/completion_computer.dart';
7 import 'package:analysis_services/completion/completion_suggestion.dart'; 10 import 'package:analysis_services/completion/completion_suggestion.dart';
8 import 'package:analysis_services/completion/top_level_computer.dart';
9 import 'package:analysis_services/index/index.dart'; 11 import 'package:analysis_services/index/index.dart';
10 import 'package:analysis_services/index/local_memory_index.dart'; 12 import 'package:analysis_services/index/local_memory_index.dart';
11 import 'package:analysis_services/src/search/search_engine.dart'; 13 import 'package:analysis_services/src/search/search_engine.dart';
12 import 'package:analysis_testing/abstract_single_unit.dart'; 14 import 'package:analysis_testing/abstract_single_unit.dart';
13 import 'package:analysis_testing/reflective_tests.dart';
14 import 'package:unittest/unittest.dart'; 15 import 'package:unittest/unittest.dart';
15 import 'dart:async';
16 16
17 main() { 17 class AbstractCompletionTest extends AbstractSingleUnitTest {
18 groupSep = ' | ';
19 runReflectiveTests(TopLevelComputerTest);
20 }
21
22 @ReflectiveTestCase()
23 class TopLevelComputerTest extends AbstractSingleUnitTest {
24 Index index; 18 Index index;
25 SearchEngineImpl searchEngine; 19 SearchEngineImpl searchEngine;
26 TopLevelComputer computer; 20 CompletionComputer computer;
27 List<CompletionSuggestion> suggestions; 21 List<CompletionSuggestion> suggestions;
28 22
29 test_class() {
30 addTestUnit('class B {boolean v;}');
31 return compute().then((_) {
32 assertHasResult(CompletionSuggestionKind.CLASS, 'B');
33 assertNoResult('v');
34 });
35 }
36
37 void addTestUnit(String code) { 23 void addTestUnit(String code) {
38 resolveTestUnit(code); 24 resolveTestUnit(code);
39 index.indexUnit(context, testUnit); 25 index.indexUnit(context, testUnit);
40 } 26 }
41 27
42 void assertHasResult(CompletionSuggestionKind kind, String completion, 28 void assertHasResult(CompletionSuggestionKind kind, String completion,
43 [CompletionRelevance relevance = CompletionRelevance.DEFAULT, 29 [CompletionRelevance relevance = CompletionRelevance.DEFAULT,
44 bool isDeprecated = false, bool isPotential = false]) { 30 bool isDeprecated = false, bool isPotential = false]) {
45 var cs = suggestions.firstWhere((cs) => cs.completion == completion, orElse: () { 31 var cs = suggestions.firstWhere((cs) => cs.completion == completion, orElse: () {
46 var completions = suggestions.map((s) => s.completion).toList(); 32 var completions = suggestions.map((s) => s.completion).toList();
(...skipping 17 matching lines...) Expand all
64 return computer.compute().then((List<CompletionSuggestion> results) { 50 return computer.compute().then((List<CompletionSuggestion> results) {
65 this.suggestions = results; 51 this.suggestions = results;
66 }); 52 });
67 } 53 }
68 54
69 @override 55 @override
70 void setUp() { 56 void setUp() {
71 super.setUp(); 57 super.setUp();
72 index = createLocalMemoryIndex(); 58 index = createLocalMemoryIndex();
73 searchEngine = new SearchEngineImpl(index); 59 searchEngine = new SearchEngineImpl(index);
74 computer = new TopLevelComputer(searchEngine);
75 verifyNoTestUnitErrors = false; 60 verifyNoTestUnitErrors = false;
76 } 61 }
77 } 62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698