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

Side by Side Diff: pkg/analysis_server/test/services/completion/dart/completion_manager_test.dart

Issue 2551023005: Prepare for decoupling analyzer ASTs from element model. (Closed)
Patch Set: Address review comments Created 4 years 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
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.dart.manager; 5 library test.services.completion.dart.manager;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/provisional/completion/dart/completion_dart. dart'; 9 import 'package:analysis_server/src/provisional/completion/dart/completion_dart. dart';
10 import 'package:analysis_server/src/services/completion/completion_core.dart'; 10 import 'package:analysis_server/src/services/completion/completion_core.dart';
11 import 'package:analysis_server/src/services/completion/completion_performance.d art'; 11 import 'package:analysis_server/src/services/completion/completion_performance.d art';
12 import 'package:analysis_server/src/services/completion/dart/completion_manager. dart'; 12 import 'package:analysis_server/src/services/completion/dart/completion_manager. dart';
13 import 'package:analysis_server/src/services/completion/dart/imported_reference_ contributor.dart'; 13 import 'package:analysis_server/src/services/completion/dart/imported_reference_ contributor.dart';
14 import 'package:analyzer/dart/ast/standard_resolution_map.dart';
14 import 'package:analyzer/dart/element/element.dart'; 15 import 'package:analyzer/dart/element/element.dart';
15 import 'package:analyzer/src/task/dart.dart'; 16 import 'package:analyzer/src/task/dart.dart';
16 import 'package:test/test.dart'; 17 import 'package:test/test.dart';
17 import 'package:test_reflective_loader/test_reflective_loader.dart'; 18 import 'package:test_reflective_loader/test_reflective_loader.dart';
18 19
19 import 'completion_contributor_util.dart'; 20 import 'completion_contributor_util.dart';
20 21
21 main() { 22 main() {
22 defineReflectiveSuite(() { 23 defineReflectiveSuite(() {
23 defineReflectiveTests(CompletionManagerTest); 24 defineReflectiveTests(CompletionManagerTest);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 .from(baseRequest, resultDescriptor: RESOLVED_UNIT1) 70 .from(baseRequest, resultDescriptor: RESOLVED_UNIT1)
70 .then((DartCompletionRequest request) { 71 .then((DartCompletionRequest request) {
71 requestCompleter.complete(request); 72 requestCompleter.complete(request);
72 }); 73 });
73 request = await performAnalysis(200, requestCompleter); 74 request = await performAnalysis(200, requestCompleter);
74 75
75 // Get the unresolved directives 76 // Get the unresolved directives
76 var directives = request.target.unit.directives; 77 var directives = request.target.unit.directives;
77 78
78 // Assert that the import does not have an export namespace 79 // Assert that the import does not have an export namespace
79 expect(directives[0].element?.library?.exportNamespace, isNull); 80 Element element = resolutionMap.elementDeclaredByDirective(directives[0]);
81 expect(element?.library?.exportNamespace, isNull);
80 82
81 // Resolve directives 83 // Resolve directives
82 var importCompleter = new Completer<List<ImportElement>>(); 84 var importCompleter = new Completer<List<ImportElement>>();
83 request.resolveImports().then((List<ImportElement> elements) { 85 request.resolveImports().then((List<ImportElement> elements) {
84 importCompleter.complete(elements); 86 importCompleter.complete(elements);
85 }); 87 });
86 List<ImportElement> imports = await performAnalysis(200, importCompleter); 88 List<ImportElement> imports = await performAnalysis(200, importCompleter);
87 expect(imports, hasLength(directives.length + 1)); 89 expect(imports, hasLength(directives.length + 1));
88 90
89 ImportElement importNamed(String expectedUri) { 91 ImportElement importNamed(String expectedUri) {
90 return imports.firstWhere((elem) => elem.uri == expectedUri, orElse: () { 92 return imports.firstWhere((elem) => elem.uri == expectedUri, orElse: () {
91 var importedNames = imports.map((elem) => elem.uri); 93 var importedNames = imports.map((elem) => elem.uri);
92 fail('Failed to find $expectedUri in $importedNames'); 94 fail('Failed to find $expectedUri in $importedNames');
93 }); 95 });
94 } 96 }
95 97
96 void assertImportedLib(String expectedUri) { 98 void assertImportedLib(String expectedUri) {
97 ImportElement importElem = importNamed(expectedUri); 99 ImportElement importElem = importNamed(expectedUri);
98 expect(importElem.importedLibrary.exportNamespace, isNotNull); 100 expect(importElem.importedLibrary.exportNamespace, isNotNull);
99 } 101 }
100 102
101 // Assert that the new imports each have an export namespace 103 // Assert that the new imports each have an export namespace
102 assertImportedLib(null /* dart:core */); 104 assertImportedLib(null /* dart:core */);
103 assertImportedLib('/libA.dart'); 105 assertImportedLib('/libA.dart');
104 } 106 }
105 } 107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698