OLD | NEW |
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; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 221 |
222 CollectingTreeElements resolveStatement(String text) { | 222 CollectingTreeElements resolveStatement(String text) { |
223 parsedTree = parseStatement(text); | 223 parsedTree = parseStatement(text); |
224 return resolveNodeStatement(parsedTree, new MockElement(mainApp)); | 224 return resolveNodeStatement(parsedTree, new MockElement(mainApp)); |
225 } | 225 } |
226 | 226 |
227 TreeElementMapping resolveNodeStatement(Node tree, | 227 TreeElementMapping resolveNodeStatement(Node tree, |
228 ExecutableElement element) { | 228 ExecutableElement element) { |
229 ResolverVisitor visitor = | 229 ResolverVisitor visitor = |
230 new ResolverVisitor( | 230 new ResolverVisitor( |
231 this, | 231 this.resolution, |
232 element, | 232 element, |
233 new ResolutionRegistry(this, | 233 new ResolutionRegistry(this.backend, |
234 new CollectingTreeElements(element)), | 234 new CollectingTreeElements(element)), |
235 scope: new MockTypeVariablesScope( | 235 scope: new MockTypeVariablesScope( |
236 element.enclosingElement.buildScope())); | 236 element.enclosingElement.buildScope())); |
237 if (visitor.scope is LibraryScope || | 237 if (visitor.scope is LibraryScope || |
238 visitor.scope is MockTypeVariablesScope) { | 238 visitor.scope is MockTypeVariablesScope) { |
239 visitor.scope = new MethodScope(visitor.scope, element); | 239 visitor.scope = new MethodScope(visitor.scope, element); |
240 } | 240 } |
241 visitor.visit(tree); | 241 visitor.visit(tree); |
242 visitor.scope = new LibraryScope(element.library); | 242 visitor.scope = new LibraryScope(element.library); |
243 return visitor.registry.mapping; | 243 return visitor.registry.mapping; |
244 } | 244 } |
245 | 245 |
246 resolverVisitor() { | 246 resolverVisitor() { |
247 Element mockElement = new MockElement(mainApp.entryCompilationUnit); | 247 Element mockElement = new MockElement(mainApp.entryCompilationUnit); |
248 ResolverVisitor visitor = | 248 ResolverVisitor visitor = |
249 new ResolverVisitor( | 249 new ResolverVisitor( |
250 this, | 250 this.resolution, |
251 mockElement, | 251 mockElement, |
252 new ResolutionRegistry( | 252 new ResolutionRegistry( |
253 this, new CollectingTreeElements(mockElement)), | 253 this.backend, new CollectingTreeElements(mockElement)), |
254 scope: mockElement.enclosingElement.buildScope()); | 254 scope: mockElement.enclosingElement.buildScope()); |
255 visitor.scope = new MethodScope(visitor.scope, mockElement); | 255 visitor.scope = new MethodScope(visitor.scope, mockElement); |
256 return visitor; | 256 return visitor; |
257 } | 257 } |
258 | 258 |
259 parseScript(String text, [LibraryElement library]) { | 259 parseScript(String text, [LibraryElement library]) { |
260 if (library == null) library = mainApp; | 260 if (library == null) library = mainApp; |
261 parseUnit(text, this, library, registerSource); | 261 parseUnit(text, this, library, registerSource); |
262 } | 262 } |
263 | 263 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 trustTypeAnnotations: trustTypeAnnotations, | 404 trustTypeAnnotations: trustTypeAnnotations, |
405 enableTypeAssertions: enableTypeAssertions, | 405 enableTypeAssertions: enableTypeAssertions, |
406 enableUserAssertions: enableUserAssertions, | 406 enableUserAssertions: enableUserAssertions, |
407 expectedErrors: expectedErrors, | 407 expectedErrors: expectedErrors, |
408 expectedWarnings: expectedWarnings, | 408 expectedWarnings: expectedWarnings, |
409 outputProvider: outputProvider); | 409 outputProvider: outputProvider); |
410 compiler.registerSource(uri, code); | 410 compiler.registerSource(uri, code); |
411 compiler.diagnosticHandler = createHandler(compiler, code); | 411 compiler.diagnosticHandler = createHandler(compiler, code); |
412 return compiler; | 412 return compiler; |
413 } | 413 } |
OLD | NEW |