OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:collection'; | 9 import 'dart:collection'; |
10 | 10 |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 return mainOutputUnit; | 370 return mainOutputUnit; |
371 } | 371 } |
372 } | 372 } |
373 | 373 |
374 api.DiagnosticHandler createHandler(MockCompiler compiler, String text, | 374 api.DiagnosticHandler createHandler(MockCompiler compiler, String text, |
375 {bool verbose: false}) { | 375 {bool verbose: false}) { |
376 return (uri, int begin, int end, String message, kind) { | 376 return (uri, int begin, int end, String message, kind) { |
377 if (kind == api.Diagnostic.VERBOSE_INFO && !verbose) return; | 377 if (kind == api.Diagnostic.VERBOSE_INFO && !verbose) return; |
378 SourceFile sourceFile; | 378 SourceFile sourceFile; |
379 if (uri == null) { | 379 if (uri == null) { |
380 sourceFile = new StringSourceFile('analysis', text); | 380 sourceFile = new StringSourceFile.fromName('analysis', text); |
381 } else { | 381 } else { |
382 sourceFile = compiler.sourceFiles[uri.toString()]; | 382 sourceFile = compiler.sourceFiles[uri.toString()]; |
383 } | 383 } |
384 if (sourceFile != null && begin != null && end != null) { | 384 if (sourceFile != null && begin != null && end != null) { |
385 print(sourceFile.getLocationMessage(message, begin, end)); | 385 print(sourceFile.getLocationMessage(message, begin, end)); |
386 } else { | 386 } else { |
387 print(message); | 387 print(message); |
388 } | 388 } |
389 }; | 389 }; |
390 } | 390 } |
391 | 391 |
392 class MockElement extends FunctionElementX { | 392 class MockElement extends FunctionElementX { |
393 MockElement(Element enclosingElement) | 393 MockElement(Element enclosingElement) |
394 : super('', ElementKind.FUNCTION, Modifiers.EMPTY, | 394 : super('', ElementKind.FUNCTION, Modifiers.EMPTY, |
395 enclosingElement, false); | 395 enclosingElement, false); |
396 | 396 |
397 get node => null; | 397 get node => null; |
398 | 398 |
399 parseNode(_) => null; | 399 parseNode(_) => null; |
400 | 400 |
401 bool get hasNode => false; | 401 bool get hasNode => false; |
402 } | 402 } |
OLD | NEW |