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

Side by Side Diff: pkg/analysis_testing/lib/abstract_context.dart

Issue 427473003: Uncomment and test fixes for importing libraries. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 testing.abstract_context; 5 library testing.abstract_context;
6 6
7 import 'package:analysis_testing/mock_sdk.dart'; 7 import 'package:analysis_testing/mock_sdk.dart';
8 import 'package:analyzer/file_system/file_system.dart'; 8 import 'package:analyzer/file_system/file_system.dart';
9 import 'package:analyzer/file_system/memory_file_system.dart'; 9 import 'package:analyzer/file_system/memory_file_system.dart';
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 Source addSource(String path, String content) { 47 Source addSource(String path, String content) {
48 File file = provider.newFile(path, content); 48 File file = provider.newFile(path, content);
49 Source source = file.createSource(UriKind.FILE_URI); 49 Source source = file.createSource(UriKind.FILE_URI);
50 ChangeSet changeSet = new ChangeSet(); 50 ChangeSet changeSet = new ChangeSet();
51 changeSet.addedSource(source); 51 changeSet.addedSource(source);
52 context.applyChanges(changeSet); 52 context.applyChanges(changeSet);
53 context.setContents(source, content); 53 context.setContents(source, content);
54 return source; 54 return source;
55 } 55 }
56 56
57 void addUriResolvers(List<UriResolver> resolvers) {
58 resolvers.add(new DartUriResolver(SDK));
59 resolvers.add(new ResourceUriResolver(provider));
60 }
61
62 /**
63 * Performs all analysis tasks in [context].
64 */
65 void performAllAnalysisTasks() {
66 while (true) {
67 AnalysisResult result = context.performAnalysisTask();
68 if (!result.hasMoreWork) {
69 break;
70 }
71 }
72 }
73
57 CompilationUnit resolveDartUnit(Source unitSource, Source librarySource) { 74 CompilationUnit resolveDartUnit(Source unitSource, Source librarySource) {
58 return context.resolveCompilationUnit2(unitSource, librarySource); 75 return context.resolveCompilationUnit2(unitSource, librarySource);
59 } 76 }
60 77
61 CompilationUnit resolveLibraryUnit(Source source) { 78 CompilationUnit resolveLibraryUnit(Source source) {
62 return context.resolveCompilationUnit2(source, source); 79 return context.resolveCompilationUnit2(source, source);
63 } 80 }
64 81
65 void setUp() { 82 void setUp() {
66 context = AnalysisEngine.instance.createAnalysisContext(); 83 context = AnalysisEngine.instance.createAnalysisContext();
67 context.sourceFactory = new SourceFactory(<UriResolver>[new DartUriResolver( 84 List<UriResolver> resolvers = <UriResolver>[];
68 SDK), new ResourceUriResolver(provider)]); 85 addUriResolvers(resolvers);
86 context.sourceFactory = new SourceFactory(resolvers);
69 } 87 }
70 88
71 void tearDown() { 89 void tearDown() {
72 context = null; 90 context = null;
73 provider = null; 91 provider = null;
74 } 92 }
75 } 93 }
76 94
77 95
78 /** 96 /**
79 * Wraps the given [_ElementVisitorFunction] into an instance of 97 * Wraps the given [_ElementVisitorFunction] into an instance of
80 * [engine.GeneralizingElementVisitor]. 98 * [engine.GeneralizingElementVisitor].
81 */ 99 */
82 class _ElementVisitorFunctionWrapper extends GeneralizingElementVisitor { 100 class _ElementVisitorFunctionWrapper extends GeneralizingElementVisitor {
83 final _ElementVisitorFunction function; 101 final _ElementVisitorFunction function;
84 _ElementVisitorFunctionWrapper(this.function); 102 _ElementVisitorFunctionWrapper(this.function);
85 visitElement(Element element) { 103 visitElement(Element element) {
86 function(element); 104 function(element);
87 super.visitElement(element); 105 super.visitElement(element);
88 } 106 }
89 } 107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698