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

Side by Side Diff: tests/compiler/dart2js/mock_compiler.dart

Issue 2123073003: remove dependency on compiler from resolution (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 mock_compiler; 5 library mock_compiler;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:compiler/compiler.dart' as api; 10 import 'package:compiler/compiler.dart' as api;
11 import 'package:compiler/src/common/names.dart' show 11 import 'package:compiler/src/common/names.dart' show Uris;
12 Uris;
13 import 'package:compiler/src/constants/expressions.dart'; 12 import 'package:compiler/src/constants/expressions.dart';
14 import 'package:compiler/src/dart_types.dart' show DartType; 13 import 'package:compiler/src/dart_types.dart' show DartType;
15 import 'package:compiler/src/diagnostics/diagnostic_listener.dart'; 14 import 'package:compiler/src/diagnostics/diagnostic_listener.dart';
16 import 'package:compiler/src/diagnostics/source_span.dart'; 15 import 'package:compiler/src/diagnostics/source_span.dart';
17 import 'package:compiler/src/diagnostics/spannable.dart'; 16 import 'package:compiler/src/diagnostics/spannable.dart';
18 import 'package:compiler/src/elements/elements.dart'; 17 import 'package:compiler/src/elements/elements.dart';
19 import 'package:compiler/src/elements/visitor.dart'; 18 import 'package:compiler/src/elements/visitor.dart';
20 import 'package:compiler/src/js_backend/backend_helpers.dart' show 19 import 'package:compiler/src/js_backend/backend_helpers.dart'
21 BackendHelpers; 20 show BackendHelpers;
22 import 'package:compiler/src/js_backend/lookup_map_analysis.dart' show 21 import 'package:compiler/src/js_backend/lookup_map_analysis.dart'
23 LookupMapAnalysis; 22 show LookupMapAnalysis;
24 import 'package:compiler/src/io/source_file.dart'; 23 import 'package:compiler/src/io/source_file.dart';
25 import 'package:compiler/src/options.dart' show 24 import 'package:compiler/src/options.dart' show CompilerOptions;
26 CompilerOptions;
27 import 'package:compiler/src/resolution/members.dart'; 25 import 'package:compiler/src/resolution/members.dart';
28 import 'package:compiler/src/resolution/registry.dart'; 26 import 'package:compiler/src/resolution/registry.dart';
29 import 'package:compiler/src/resolution/scope.dart'; 27 import 'package:compiler/src/resolution/scope.dart';
30 import 'package:compiler/src/resolution/tree_elements.dart'; 28 import 'package:compiler/src/resolution/tree_elements.dart';
31 import 'package:compiler/src/resolved_uri_translator.dart'; 29 import 'package:compiler/src/resolved_uri_translator.dart';
32 import 'package:compiler/src/script.dart'; 30 import 'package:compiler/src/script.dart';
33 import 'package:compiler/src/tree/tree.dart'; 31 import 'package:compiler/src/tree/tree.dart';
34 import 'package:compiler/src/old_to_new_api.dart'; 32 import 'package:compiler/src/old_to_new_api.dart';
35 import 'parser_helper.dart'; 33 import 'parser_helper.dart';
36 34
37 import 'package:compiler/src/elements/modelx.dart' show 35 import 'package:compiler/src/elements/modelx.dart'
38 ElementX, 36 show ElementX, LibraryElementX, ErroneousElementX, FunctionElementX;
39 LibraryElementX,
40 ErroneousElementX,
41 FunctionElementX;
42 37
43 import 'package:compiler/src/compiler.dart'; 38 import 'package:compiler/src/compiler.dart';
44 import 'package:compiler/src/common/tasks.dart' show Measurer; 39 import 'package:compiler/src/common/tasks.dart' show Measurer;
45 40
46 import 'package:compiler/src/deferred_load.dart' show 41 import 'package:compiler/src/deferred_load.dart'
47 DeferredLoadTask, 42 show DeferredLoadTask, OutputUnit;
48 OutputUnit;
49 43
50 import 'mock_libraries.dart'; 44 import 'mock_libraries.dart';
51 import 'diagnostic_helper.dart'; 45 import 'diagnostic_helper.dart';
52 46
53 export 'diagnostic_helper.dart'; 47 export 'diagnostic_helper.dart';
54 48
55 final Uri PATCH_CORE = new Uri(scheme: 'patch', path: 'core'); 49 final Uri PATCH_CORE = new Uri(scheme: 'patch', path: 'core');
56 50
57 typedef String LibrarySourceProvider(Uri uri); 51 typedef String LibrarySourceProvider(Uri uri);
58 52
59 class MockCompiler extends Compiler { 53 class MockCompiler extends Compiler {
60 api.DiagnosticHandler diagnosticHandler; 54 api.DiagnosticHandler diagnosticHandler;
55
61 /// Expected number of warnings. If `null`, the number of warnings is 56 /// Expected number of warnings. If `null`, the number of warnings is
62 /// not checked. 57 /// not checked.
63 final int expectedWarnings; 58 final int expectedWarnings;
59
64 /// Expected number of errors. If `null`, the number of errors is not checked. 60 /// Expected number of errors. If `null`, the number of errors is not checked.
65 final int expectedErrors; 61 final int expectedErrors;
66 final Map<String, SourceFile> sourceFiles; 62 final Map<String, SourceFile> sourceFiles;
67 Node parsedTree; 63 Node parsedTree;
68 final String testedPatchVersion; 64 final String testedPatchVersion;
69 final LibrarySourceProvider librariesOverride; 65 final LibrarySourceProvider librariesOverride;
70 final DiagnosticCollector diagnosticCollector = new DiagnosticCollector(); 66 final DiagnosticCollector diagnosticCollector = new DiagnosticCollector();
71 final ResolvedUriTranslator resolvedUriTranslator = 67 final ResolvedUriTranslator resolvedUriTranslator =
72 new MockResolvedUriTranslator(); 68 new MockResolvedUriTranslator();
73 final Measurer measurer = new Measurer(); 69 final Measurer measurer = new Measurer();
74 70
75 MockCompiler.internal( 71 MockCompiler.internal(
76 {Map<String, String> coreSource, 72 {Map<String, String> coreSource,
77 bool enableTypeAssertions: false, 73 bool enableTypeAssertions: false,
78 bool enableUserAssertions: false, 74 bool enableUserAssertions: false,
79 bool enableMinification: false, 75 bool enableMinification: false,
80 bool disableTypeInference: false, 76 bool disableTypeInference: false,
81 bool analyzeAll: false, 77 bool analyzeAll: false,
82 bool analyzeOnly: false, 78 bool analyzeOnly: false,
83 bool emitJavaScript: true, 79 bool emitJavaScript: true,
84 bool preserveComments: false, 80 bool preserveComments: false,
85 // Our unit tests check code generation output that is 81 // Our unit tests check code generation output that is
86 // affected by inlining support. 82 // affected by inlining support.
87 bool disableInlining: true, 83 bool disableInlining: true,
88 bool trustTypeAnnotations: false, 84 bool trustTypeAnnotations: false,
89 bool trustJSInteropTypeAnnotations: false, 85 bool trustJSInteropTypeAnnotations: false,
90 bool enableAsyncAwait: false, 86 bool enableAsyncAwait: false,
91 int this.expectedWarnings, 87 int this.expectedWarnings,
92 int this.expectedErrors, 88 int this.expectedErrors,
93 api.CompilerOutputProvider outputProvider, 89 api.CompilerOutputProvider outputProvider,
94 String patchVersion, 90 String patchVersion,
95 LibrarySourceProvider this.librariesOverride}) 91 LibrarySourceProvider this.librariesOverride})
96 : sourceFiles = new Map<String, SourceFile>(), 92 : sourceFiles = new Map<String, SourceFile>(),
97 testedPatchVersion = patchVersion, 93 testedPatchVersion = patchVersion,
98 super(options: new CompilerOptions( 94 super(
99 entryPoint: new Uri(scheme: 'mock'), 95 options: new CompilerOptions(
100 libraryRoot: Uri.parse('placeholder_library_root_for_mock/'), 96 entryPoint: new Uri(scheme: 'mock'),
101 enableTypeAssertions: enableTypeAssertions, 97 libraryRoot: Uri.parse('placeholder_library_root_for_mock/'),
102 enableUserAssertions: enableUserAssertions, 98 enableTypeAssertions: enableTypeAssertions,
103 disableInlining: disableInlining, 99 enableUserAssertions: enableUserAssertions,
104 enableAssertMessage: true, 100 disableInlining: disableInlining,
105 enableMinification: enableMinification, 101 enableAssertMessage: true,
106 disableTypeInference: disableTypeInference, 102 enableMinification: enableMinification,
107 analyzeAll: analyzeAll, 103 disableTypeInference: disableTypeInference,
108 analyzeOnly: analyzeOnly, 104 analyzeAll: analyzeAll,
109 emitJavaScript: emitJavaScript, 105 analyzeOnly: analyzeOnly,
110 preserveComments: preserveComments, 106 emitJavaScript: emitJavaScript,
111 trustTypeAnnotations: trustTypeAnnotations, 107 preserveComments: preserveComments,
112 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations, 108 trustTypeAnnotations: trustTypeAnnotations,
113 shownPackageWarnings: const []), 109 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations,
114 outputProvider: new LegacyCompilerOutput(outputProvider)) { 110 shownPackageWarnings: const []),
115 111 outputProvider: new LegacyCompilerOutput(outputProvider)) {
116 deferredLoadTask = new MockDeferredLoadTask(this); 112 deferredLoadTask = new MockDeferredLoadTask(this);
117 113
118 registerSource(Uris.dart_core, 114 registerSource(
119 buildLibrarySource(DEFAULT_CORE_LIBRARY, coreSource)); 115 Uris.dart_core, buildLibrarySource(DEFAULT_CORE_LIBRARY, coreSource));
120 registerSource(PATCH_CORE, DEFAULT_PATCH_CORE_SOURCE); 116 registerSource(PATCH_CORE, DEFAULT_PATCH_CORE_SOURCE);
121 117
122 registerSource(BackendHelpers.DART_JS_HELPER, 118 registerSource(BackendHelpers.DART_JS_HELPER,
123 buildLibrarySource(DEFAULT_JS_HELPER_LIBRARY)); 119 buildLibrarySource(DEFAULT_JS_HELPER_LIBRARY));
124 registerSource(BackendHelpers.DART_FOREIGN_HELPER, 120 registerSource(BackendHelpers.DART_FOREIGN_HELPER,
125 buildLibrarySource(DEFAULT_FOREIGN_HELPER_LIBRARY)); 121 buildLibrarySource(DEFAULT_FOREIGN_HELPER_LIBRARY));
126 registerSource(BackendHelpers.DART_INTERCEPTORS, 122 registerSource(BackendHelpers.DART_INTERCEPTORS,
127 buildLibrarySource(DEFAULT_INTERCEPTORS_LIBRARY)); 123 buildLibrarySource(DEFAULT_INTERCEPTORS_LIBRARY));
128 registerSource(BackendHelpers.DART_ISOLATE_HELPER, 124 registerSource(BackendHelpers.DART_ISOLATE_HELPER,
129 buildLibrarySource(DEFAULT_ISOLATE_HELPER_LIBRARY)); 125 buildLibrarySource(DEFAULT_ISOLATE_HELPER_LIBRARY));
130 registerSource(Uris.dart_mirrors, DEFAULT_MIRRORS_SOURCE); 126 registerSource(Uris.dart_mirrors, DEFAULT_MIRRORS_SOURCE);
131 registerSource(BackendHelpers.DART_JS_MIRRORS, 127 registerSource(BackendHelpers.DART_JS_MIRRORS, DEFAULT_JS_MIRRORS_SOURCE);
132 DEFAULT_JS_MIRRORS_SOURCE);
133 128
134 Map<String, String> asyncLibrarySource = <String, String>{}; 129 Map<String, String> asyncLibrarySource = <String, String>{};
135 asyncLibrarySource.addAll(DEFAULT_ASYNC_LIBRARY); 130 asyncLibrarySource.addAll(DEFAULT_ASYNC_LIBRARY);
136 if (enableAsyncAwait) { 131 if (enableAsyncAwait) {
137 asyncLibrarySource.addAll(ASYNC_AWAIT_LIBRARY); 132 asyncLibrarySource.addAll(ASYNC_AWAIT_LIBRARY);
138 } 133 }
139 registerSource(Uris.dart_async, 134 registerSource(Uris.dart_async, buildLibrarySource(asyncLibrarySource));
140 buildLibrarySource(asyncLibrarySource));
141 registerSource(LookupMapAnalysis.PACKAGE_LOOKUP_MAP, 135 registerSource(LookupMapAnalysis.PACKAGE_LOOKUP_MAP,
142 buildLibrarySource(DEFAULT_LOOKUP_MAP_LIBRARY)); 136 buildLibrarySource(DEFAULT_LOOKUP_MAP_LIBRARY));
143 } 137 }
144 138
145 String get patchVersion { 139 String get patchVersion {
146 return testedPatchVersion != null ? testedPatchVersion : super.patchVersion; 140 return testedPatchVersion != null ? testedPatchVersion : super.patchVersion;
147 } 141 }
148 142
149 /// Initialize the mock compiler with an empty main library. 143 /// Initialize the mock compiler with an empty main library.
150 Future<Uri> init([String mainSource = ""]) { 144 Future<Uri> init([String mainSource = ""]) {
151 Uri uri = new Uri(scheme: "mock"); 145 Uri uri = new Uri(scheme: "mock");
152 registerSource(uri, mainSource); 146 registerSource(uri, mainSource);
153 return libraryLoader.loadLibrary(uri) 147 return libraryLoader.loadLibrary(uri).then((LibraryElement library) {
154 .then((LibraryElement library) {
155 mainApp = library; 148 mainApp = library;
156 // We need to make sure the Object class is resolved. When registering a 149 // We need to make sure the Object class is resolved. When registering a
157 // dynamic invocation the ArgumentTypesRegistry eventually iterates over 150 // dynamic invocation the ArgumentTypesRegistry eventually iterates over
158 // the interfaces of the Object class which would be 'null' if the class 151 // the interfaces of the Object class which would be 'null' if the class
159 // wasn't resolved. 152 // wasn't resolved.
160 coreClasses.objectClass.ensureResolved(resolution); 153 coreClasses.objectClass.ensureResolved(resolution);
161 }).then((_) => uri); 154 }).then((_) => uri);
162 } 155 }
163 156
164 Future run(Uri uri, [String mainSource = ""]) { 157 Future run(Uri uri, [String mainSource = ""]) {
165 return init(mainSource).then((Uri mainUri) { 158 return init(mainSource).then((Uri mainUri) {
166 return super.run(uri == null ? mainUri : uri); 159 return super.run(uri == null ? mainUri : uri);
167 }).then((result) { 160 }).then((result) {
168 if (expectedErrors != null && 161 if (expectedErrors != null &&
169 expectedErrors != diagnosticCollector.errors.length) { 162 expectedErrors != diagnosticCollector.errors.length) {
170 throw "unexpected error during compilation " 163 throw "unexpected error during compilation "
171 "${diagnosticCollector.errors}"; 164 "${diagnosticCollector.errors}";
172 } else if (expectedWarnings != null && 165 } else if (expectedWarnings != null &&
173 expectedWarnings != diagnosticCollector.warnings.length) { 166 expectedWarnings != diagnosticCollector.warnings.length) {
174 throw "unexpected warnings during compilation " 167 throw "unexpected warnings during compilation "
175 "${diagnosticCollector.warnings}"; 168 "${diagnosticCollector.warnings}";
176 } else { 169 } else {
177 return result; 170 return result;
178 } 171 }
179 }); 172 });
180 } 173 }
181 174
182 /** 175 /**
183 * Registers the [source] with [uri] making it possible load [source] as a 176 * Registers the [source] with [uri] making it possible load [source] as a
184 * library. If an override has been provided in [librariesOverride], that 177 * library. If an override has been provided in [librariesOverride], that
185 * is used instead. 178 * is used instead.
186 */ 179 */
187 void registerSource(Uri uri, String source) { 180 void registerSource(Uri uri, String source) {
188 if (librariesOverride != null) { 181 if (librariesOverride != null) {
189 String override = librariesOverride(uri); 182 String override = librariesOverride(uri);
190 if (override != null) { 183 if (override != null) {
191 source = override; 184 source = override;
192 } 185 }
193 } 186 }
194 sourceFiles[uri.toString()] = new MockFile(source); 187 sourceFiles[uri.toString()] = new MockFile(source);
195 } 188 }
196 189
197 void reportDiagnostic(DiagnosticMessage message, 190 void reportDiagnostic(DiagnosticMessage message,
198 List<DiagnosticMessage> infoMessages, 191 List<DiagnosticMessage> infoMessages, api.Diagnostic kind) {
199 api.Diagnostic kind) {
200
201 void processMessage(DiagnosticMessage message, api.Diagnostic kind) { 192 void processMessage(DiagnosticMessage message, api.Diagnostic kind) {
202 SourceSpan span = message.sourceSpan; 193 SourceSpan span = message.sourceSpan;
203 Uri uri; 194 Uri uri;
204 int begin; 195 int begin;
205 int end; 196 int end;
206 String text = '${message.message}'; 197 String text = '${message.message}';
207 if (span != null) { 198 if (span != null) {
208 uri = span.uri; 199 uri = span.uri;
209 begin = span.begin; 200 begin = span.begin;
210 end = span.end; 201 end = span.end;
211 } 202 }
212 diagnosticCollector.report(message.message, uri, begin, end, text, kind); 203 diagnosticCollector.report(message.message, uri, begin, end, text, kind);
213 if (diagnosticHandler != null) { 204 if (diagnosticHandler != null) {
214 diagnosticHandler(uri, begin, end, text, kind); 205 diagnosticHandler(uri, begin, end, text, kind);
215 } 206 }
216 } 207 }
217 208
218 processMessage(message, kind); 209 processMessage(message, kind);
219 infoMessages.forEach((i) => processMessage(i, api.Diagnostic.INFO)); 210 infoMessages.forEach((i) => processMessage(i, api.Diagnostic.INFO));
220 } 211 }
221 212
222 CollectingTreeElements resolveStatement(String text) { 213 CollectingTreeElements resolveStatement(String text) {
223 parsedTree = parseStatement(text); 214 parsedTree = parseStatement(text);
224 return resolveNodeStatement(parsedTree, new MockElement(mainApp)); 215 return resolveNodeStatement(parsedTree, new MockElement(mainApp));
225 } 216 }
226 217
227 TreeElementMapping resolveNodeStatement(Node tree, 218 TreeElementMapping resolveNodeStatement(
228 ExecutableElement element) { 219 Node tree, ExecutableElement element) {
229 ResolverVisitor visitor = 220 ResolverVisitor visitor = new ResolverVisitor(
230 new ResolverVisitor( 221 this.resolution,
231 this, 222 element,
232 element, 223 new ResolutionRegistry(
233 new ResolutionRegistry(this, 224 this.backend, new CollectingTreeElements(element)),
234 new CollectingTreeElements(element)), 225 scope:
235 scope: new MockTypeVariablesScope( 226 new MockTypeVariablesScope(element.enclosingElement.buildScope()));
236 element.enclosingElement.buildScope()));
237 if (visitor.scope is LibraryScope || 227 if (visitor.scope is LibraryScope ||
238 visitor.scope is MockTypeVariablesScope) { 228 visitor.scope is MockTypeVariablesScope) {
239 visitor.scope = new MethodScope(visitor.scope, element); 229 visitor.scope = new MethodScope(visitor.scope, element);
240 } 230 }
241 visitor.visit(tree); 231 visitor.visit(tree);
242 visitor.scope = new LibraryScope(element.library); 232 visitor.scope = new LibraryScope(element.library);
243 return visitor.registry.mapping; 233 return visitor.registry.mapping;
244 } 234 }
245 235
246 resolverVisitor() { 236 resolverVisitor() {
247 Element mockElement = new MockElement(mainApp.entryCompilationUnit); 237 Element mockElement = new MockElement(mainApp.entryCompilationUnit);
248 ResolverVisitor visitor = 238 ResolverVisitor visitor = new ResolverVisitor(
249 new ResolverVisitor( 239 this.resolution,
250 this, 240 mockElement,
251 mockElement, 241 new ResolutionRegistry(
252 new ResolutionRegistry( 242 this.backend, new CollectingTreeElements(mockElement)),
253 this, new CollectingTreeElements(mockElement)), 243 scope: mockElement.enclosingElement.buildScope());
254 scope: mockElement.enclosingElement.buildScope());
255 visitor.scope = new MethodScope(visitor.scope, mockElement); 244 visitor.scope = new MethodScope(visitor.scope, mockElement);
256 return visitor; 245 return visitor;
257 } 246 }
258 247
259 parseScript(String text, [LibraryElement library]) { 248 parseScript(String text, [LibraryElement library]) {
260 if (library == null) library = mainApp; 249 if (library == null) library = mainApp;
261 parseUnit(text, this, library, registerSource); 250 parseUnit(text, this, library, registerSource);
262 } 251 }
263 252
264 Future scanBuiltinLibraries() { 253 Future scanBuiltinLibraries() {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 // The mock compiler does not split the program in output units. 331 // The mock compiler does not split the program in output units.
343 class MockDeferredLoadTask extends DeferredLoadTask { 332 class MockDeferredLoadTask extends DeferredLoadTask {
344 MockDeferredLoadTask(Compiler compiler) : super(compiler); 333 MockDeferredLoadTask(Compiler compiler) : super(compiler);
345 334
346 OutputUnit getElementOutputUnit(dynamic dependency) { 335 OutputUnit getElementOutputUnit(dynamic dependency) {
347 return mainOutputUnit; 336 return mainOutputUnit;
348 } 337 }
349 } 338 }
350 339
351 api.DiagnosticHandler createHandler(MockCompiler compiler, String text, 340 api.DiagnosticHandler createHandler(MockCompiler compiler, String text,
352 {bool verbose: false}) { 341 {bool verbose: false}) {
353 return (uri, int begin, int end, String message, kind) { 342 return (uri, int begin, int end, String message, kind) {
354 if (kind == api.Diagnostic.VERBOSE_INFO && !verbose) return; 343 if (kind == api.Diagnostic.VERBOSE_INFO && !verbose) return;
355 SourceFile sourceFile; 344 SourceFile sourceFile;
356 if (uri == null) { 345 if (uri == null) {
357 sourceFile = new StringSourceFile.fromName('analysis', text); 346 sourceFile = new StringSourceFile.fromName('analysis', text);
358 } else { 347 } else {
359 sourceFile = compiler.sourceFiles[uri.toString()]; 348 sourceFile = compiler.sourceFiles[uri.toString()];
360 } 349 }
361 if (sourceFile != null && begin != null && end != null) { 350 if (sourceFile != null && begin != null && end != null) {
362 print('${kind}: ${sourceFile.getLocationMessage(message, begin, end)}'); 351 print('${kind}: ${sourceFile.getLocationMessage(message, begin, end)}');
363 } else { 352 } else {
364 print('${kind}: $message'); 353 print('${kind}: $message');
365 } 354 }
366 }; 355 };
367 } 356 }
368 357
369 class MockElement extends FunctionElementX { 358 class MockElement extends FunctionElementX {
370 MockElement(Element enclosingElement) 359 MockElement(Element enclosingElement)
371 : super('', ElementKind.FUNCTION, Modifiers.EMPTY, 360 : super('', ElementKind.FUNCTION, Modifiers.EMPTY, enclosingElement);
372 enclosingElement);
373 361
374 get node => null; 362 get node => null;
375 363
376 parseNode(_) => null; 364 parseNode(_) => null;
377 365
378 bool get hasNode => false; 366 bool get hasNode => false;
379 367
380 accept(ElementVisitor visitor, arg) { 368 accept(ElementVisitor visitor, arg) {
381 return visitor.visitMethodElement(this, arg); 369 return visitor.visitMethodElement(this, arg);
382 } 370 }
383 } 371 }
384 372
385 // TODO(herhut): Disallow warnings and errors during compilation by default. 373 // TODO(herhut): Disallow warnings and errors during compilation by default.
386 MockCompiler compilerFor(String code, Uri uri, 374 MockCompiler compilerFor(String code, Uri uri,
387 {bool analyzeAll: false, 375 {bool analyzeAll: false,
388 bool analyzeOnly: false, 376 bool analyzeOnly: false,
389 Map<String, String> coreSource, 377 Map<String, String> coreSource,
390 bool disableInlining: true, 378 bool disableInlining: true,
391 bool minify: false, 379 bool minify: false,
392 bool trustTypeAnnotations: false, 380 bool trustTypeAnnotations: false,
393 bool enableTypeAssertions: false, 381 bool enableTypeAssertions: false,
394 bool enableUserAssertions: false, 382 bool enableUserAssertions: false,
395 int expectedErrors, 383 int expectedErrors,
396 int expectedWarnings, 384 int expectedWarnings,
397 api.CompilerOutputProvider outputProvider}) { 385 api.CompilerOutputProvider outputProvider}) {
398 MockCompiler compiler = new MockCompiler.internal( 386 MockCompiler compiler = new MockCompiler.internal(
399 analyzeAll: analyzeAll, 387 analyzeAll: analyzeAll,
400 analyzeOnly: analyzeOnly, 388 analyzeOnly: analyzeOnly,
401 coreSource: coreSource, 389 coreSource: coreSource,
402 disableInlining: disableInlining, 390 disableInlining: disableInlining,
403 enableMinification: minify, 391 enableMinification: minify,
404 trustTypeAnnotations: trustTypeAnnotations, 392 trustTypeAnnotations: trustTypeAnnotations,
405 enableTypeAssertions: enableTypeAssertions, 393 enableTypeAssertions: enableTypeAssertions,
406 enableUserAssertions: enableUserAssertions, 394 enableUserAssertions: enableUserAssertions,
407 expectedErrors: expectedErrors, 395 expectedErrors: expectedErrors,
408 expectedWarnings: expectedWarnings, 396 expectedWarnings: expectedWarnings,
409 outputProvider: outputProvider); 397 outputProvider: outputProvider);
410 compiler.registerSource(uri, code); 398 compiler.registerSource(uri, code);
411 compiler.diagnosticHandler = createHandler(compiler, code); 399 compiler.diagnosticHandler = createHandler(compiler, code);
412 return compiler; 400 return compiler;
413 } 401 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698