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

Side by Side Diff: pkg/analysis_server/test/abstract_context.dart

Issue 2616493004: Fix part related completion tests with the new analysis driver. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 testing.abstract_context; 5 library testing.abstract_context;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/element/element.dart'; 8 import 'package:analyzer/dart/element/element.dart';
9 import 'package:analyzer/dart/element/visitor.dart'; 9 import 'package:analyzer/dart/element/visitor.dart';
10 import 'package:analyzer/exception/exception.dart'; 10 import 'package:analyzer/exception/exception.dart';
11 import 'package:analyzer/file_system/file_system.dart'; 11 import 'package:analyzer/file_system/file_system.dart';
12 import 'package:analyzer/file_system/memory_file_system.dart'; 12 import 'package:analyzer/file_system/memory_file_system.dart';
13 import 'package:analyzer/file_system/physical_file_system.dart'; 13 import 'package:analyzer/file_system/physical_file_system.dart';
14 import 'package:analyzer/source/package_map_resolver.dart'; 14 import 'package:analyzer/source/package_map_resolver.dart';
15 import 'package:analyzer/src/dart/analysis/byte_store.dart'; 15 import 'package:analyzer/src/dart/analysis/byte_store.dart';
16 import 'package:analyzer/src/dart/analysis/driver.dart'; 16 import 'package:analyzer/src/dart/analysis/driver.dart';
17 import 'package:analyzer/src/dart/analysis/file_state.dart'; 17 import 'package:analyzer/src/dart/analysis/file_state.dart';
18 import 'package:analyzer/src/dart/sdk/sdk.dart'; 18 import 'package:analyzer/src/dart/sdk/sdk.dart';
19 import 'package:analyzer/src/generated/engine.dart'; 19 import 'package:analyzer/src/generated/engine.dart';
20 import 'package:analyzer/src/generated/engine.dart' as engine; 20 import 'package:analyzer/src/generated/engine.dart' as engine;
21 import 'package:analyzer/src/generated/sdk.dart'; 21 import 'package:analyzer/src/generated/sdk.dart';
22 import 'package:analyzer/src/generated/source_io.dart'; 22 import 'package:analyzer/src/generated/source_io.dart';
23 23
24 import 'mock_sdk.dart';
25
26 /** 24 /**
27 * Finds an [Element] with the given [name]. 25 * Finds an [Element] with the given [name].
28 */ 26 */
29 Element findChildElement(Element root, String name, [ElementKind kind]) { 27 Element findChildElement(Element root, String name, [ElementKind kind]) {
30 Element result = null; 28 Element result = null;
31 root.accept(new _ElementVisitorFunctionWrapper((Element element) { 29 root.accept(new _ElementVisitorFunctionWrapper((Element element) {
32 if (element.name != name) { 30 if (element.name != name) {
33 return; 31 return;
34 } 32 }
35 if (kind != null && element.kind != kind) { 33 if (kind != null && element.kind != kind) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 */ 79 */
82 bool get enableNewAnalysisDriver => false; 80 bool get enableNewAnalysisDriver => false;
83 81
84 Source addPackageSource(String packageName, String filePath, String content) { 82 Source addPackageSource(String packageName, String filePath, String content) {
85 packageMap[packageName] = [(newFolder('/pubcache/$packageName'))]; 83 packageMap[packageName] = [(newFolder('/pubcache/$packageName'))];
86 File file = newFile('/pubcache/$packageName/$filePath', content); 84 File file = newFile('/pubcache/$packageName/$filePath', content);
87 return file.createSource(); 85 return file.createSource();
88 } 86 }
89 87
90 Source addSource(String path, String content, [Uri uri]) { 88 Source addSource(String path, String content, [Uri uri]) {
89 File file = newFile(path, content);
91 if (enableNewAnalysisDriver) { 90 if (enableNewAnalysisDriver) {
91 driver.addFile(path);
92 _fileContentOverlay[path] = content; 92 _fileContentOverlay[path] = content;
93 return null; 93 return null;
94 } else { 94 } else {
95 File file = newFile(path, content);
96 Source source = file.createSource(uri); 95 Source source = file.createSource(uri);
97 ChangeSet changeSet = new ChangeSet(); 96 ChangeSet changeSet = new ChangeSet();
98 changeSet.addedSource(source); 97 changeSet.addedSource(source);
99 context.applyChanges(changeSet); 98 context.applyChanges(changeSet);
100 context.setContents(source, content); 99 context.setContents(source, content);
101 return source; 100 return source;
102 } 101 }
103 } 102 }
104 103
105 File newFile(String path, [String content]) => 104 File newFile(String path, [String content]) =>
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 * [engine.GeneralizingElementVisitor]. 198 * [engine.GeneralizingElementVisitor].
200 */ 199 */
201 class _ElementVisitorFunctionWrapper extends GeneralizingElementVisitor { 200 class _ElementVisitorFunctionWrapper extends GeneralizingElementVisitor {
202 final _ElementVisitorFunction function; 201 final _ElementVisitorFunction function;
203 _ElementVisitorFunctionWrapper(this.function); 202 _ElementVisitorFunctionWrapper(this.function);
204 visitElement(Element element) { 203 visitElement(Element element) {
205 function(element); 204 function(element);
206 super.visitElement(element); 205 super.visitElement(element);
207 } 206 }
208 } 207 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698