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

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

Issue 1325583002: improve import uri completions - fixes #24000 (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge and fix test source path Created 5 years, 3 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
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/file_system/file_system.dart'; 7 import 'package:analyzer/file_system/file_system.dart';
8 import 'package:analyzer/file_system/memory_file_system.dart'; 8 import 'package:analyzer/file_system/memory_file_system.dart';
9 import 'package:analyzer/source/package_map_resolver.dart'; 9 import 'package:analyzer/source/package_map_resolver.dart';
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 23 matching lines...) Expand all
34 34
35 /** 35 /**
36 * A function to be called for every [Element]. 36 * A function to be called for every [Element].
37 */ 37 */
38 typedef void _ElementVisitorFunction(Element element); 38 typedef void _ElementVisitorFunction(Element element);
39 39
40 class AbstractContextTest { 40 class AbstractContextTest {
41 static final DartSdk SDK = new MockSdk(); 41 static final DartSdk SDK = new MockSdk();
42 static final UriResolver SDK_RESOLVER = new DartUriResolver(SDK); 42 static final UriResolver SDK_RESOLVER = new DartUriResolver(SDK);
43 43
44 MemoryResourceProvider provider = new MemoryResourceProvider(); 44 MemoryResourceProvider provider;
45 Map<String, List<Folder>> packageMap; 45 Map<String, List<Folder>> packageMap;
46 UriResolver resourceResolver; 46 UriResolver resourceResolver;
47 AnalysisContext context; 47 AnalysisContext context;
48 48
49 Source addPackageSource(String packageName, String filePath, String content) { 49 Source addPackageSource(String packageName, String filePath, String content) {
50 packageMap[packageName] = [(provider.newFolder('/pubcache/$packageName'))]; 50 packageMap[packageName] = [(provider.newFolder('/pubcache/$packageName'))];
51 File file = provider.newFile('/pubcache/$packageName/$filePath', content); 51 File file = provider.newFile('/pubcache/$packageName/$filePath', content);
52 return file.createSource(); 52 return file.createSource();
53 } 53 }
54 54
(...skipping 21 matching lines...) Expand all
76 76
77 CompilationUnit resolveDartUnit(Source unitSource, Source librarySource) { 77 CompilationUnit resolveDartUnit(Source unitSource, Source librarySource) {
78 return context.resolveCompilationUnit2(unitSource, librarySource); 78 return context.resolveCompilationUnit2(unitSource, librarySource);
79 } 79 }
80 80
81 CompilationUnit resolveLibraryUnit(Source source) { 81 CompilationUnit resolveLibraryUnit(Source source) {
82 return context.resolveCompilationUnit2(source, source); 82 return context.resolveCompilationUnit2(source, source);
83 } 83 }
84 84
85 void setUp() { 85 void setUp() {
86 setupResourceProvider();
86 resourceResolver = new ResourceUriResolver(provider); 87 resourceResolver = new ResourceUriResolver(provider);
87 packageMap = new Map<String, List<Folder>>(); 88 packageMap = new Map<String, List<Folder>>();
88 PackageMapUriResolver packageResolver = 89 PackageMapUriResolver packageResolver =
89 new PackageMapUriResolver(provider, packageMap); 90 new PackageMapUriResolver(provider, packageMap);
90 context = AnalysisEngine.instance.createAnalysisContext(); 91 context = AnalysisEngine.instance.createAnalysisContext();
91 context.sourceFactory = 92 context.sourceFactory =
92 new SourceFactory([SDK_RESOLVER, packageResolver, resourceResolver]); 93 new SourceFactory([SDK_RESOLVER, packageResolver, resourceResolver]);
93 } 94 }
94 95
96 void setupResourceProvider() {
97 provider = new MemoryResourceProvider();
98 }
99
95 void tearDown() { 100 void tearDown() {
96 context = null; 101 context = null;
97 provider = null; 102 provider = null;
98 } 103 }
99 } 104 }
100 105
101 /** 106 /**
102 * Wraps the given [_ElementVisitorFunction] into an instance of 107 * Wraps the given [_ElementVisitorFunction] into an instance of
103 * [engine.GeneralizingElementVisitor]. 108 * [engine.GeneralizingElementVisitor].
104 */ 109 */
105 class _ElementVisitorFunctionWrapper extends GeneralizingElementVisitor { 110 class _ElementVisitorFunctionWrapper extends GeneralizingElementVisitor {
106 final _ElementVisitorFunction function; 111 final _ElementVisitorFunction function;
107 _ElementVisitorFunctionWrapper(this.function); 112 _ElementVisitorFunctionWrapper(this.function);
108 visitElement(Element element) { 113 visitElement(Element element) {
109 function(element); 114 function(element);
110 super.visitElement(element); 115 super.visitElement(element);
111 } 116 }
112 } 117 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/pubspec.yaml ('k') | pkg/analysis_server/test/services/completion/import_uri_contributor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698