| OLD | NEW | 
|---|
| 1 // Copyright (c) 2017, the Dart project authors.  Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'log.dart'; | 5 import 'log.dart'; | 
| 6 | 6 | 
| 7 final _unittestPattern = "package:unittest"; | 7 final _unittestPattern = "package:unittest"; | 
| 8 final _checkedPattern = new RegExp(r"\bchecked\b"); | 8 final _checkedPattern = new RegExp(r"\bchecked\b"); | 
| 9 final _abstractErrorPattern = | 9 final _abstractErrorPattern = | 
| 10     new RegExp(r"\bAbstractClassInstantiationError\b"); | 10     new RegExp(r"\bAbstractClassInstantiationError\b"); | 
| 11 final _typeErrorPattern = new RegExp(r"\bTypeError\b"); | 11 final _typeErrorPattern = new RegExp(r"\bTypeError\b"); | 
|  | 12 final _typeAssertionsEnabledPattern = new RegExp(r"\btypeAssertionsEnabled\b"); | 
|  | 13 final _checkedModeEnabledPattern = new RegExp(r"\bcheckedModeEnabled\b"); | 
| 12 | 14 | 
| 13 void validateFile(String path, String source, [List<String> todos]) { | 15 void validateFile(String path, String source, [List<String> todos]) { | 
| 14   check(Pattern pattern, String noteMessage, String todo) { | 16   check(Pattern pattern, String noteMessage, String todo) { | 
| 15     if (!source.contains(pattern)) return; | 17     if (!source.contains(pattern)) return; | 
| 16     note("${bold(path)} $noteMessage."); | 18     note("${bold(path)} $noteMessage."); | 
| 17     if (todos != null) todos.add(todo); | 19     if (todos != null) todos.add(todo); | 
| 18   } | 20   } | 
| 19 | 21 | 
| 20   check(_unittestPattern, "uses the unittest package", "Migrate off unittest."); | 22   check(_unittestPattern, "uses the unittest package", "Migrate off unittest."); | 
| 21   check(_checkedPattern, 'mentions "checked"', | 23   check(_checkedPattern, 'mentions "checked"', | 
| 22       'Fix code that mentions "checked" mode.'); | 24       'Fix code that mentions "checked" mode.'); | 
| 23   check(_abstractErrorPattern, 'mentions "AbstractClassInstantiationError"', | 25   check(_abstractErrorPattern, 'mentions "AbstractClassInstantiationError"', | 
| 24       "Remove code that checks for AbstractClassInstantiationError."); | 26       "Remove code that checks for AbstractClassInstantiationError."); | 
| 25   check(_typeErrorPattern, 'mentions "TypeError"', | 27   check(_typeErrorPattern, 'mentions "TypeError"', | 
| 26       "Ensure code that checks for a TypeError uses 2.0 semantics."); | 28       "Ensure code that checks for a TypeError uses 2.0 semantics."); | 
|  | 29   check(_typeAssertionsEnabledPattern, 'mentions "typeAssertionsEnabled"', | 
|  | 30       "Remove checks for typeAssertionsEnabled, they are always enabled in 2.0."
    ); | 
|  | 31   check(_checkedModeEnabledPattern, 'mentions "typeAssertionsEnabled"', | 
|  | 32       "Remove checks for checkedModeEnabled, it is always enabled in 2.0."); | 
| 27 } | 33 } | 
| OLD | NEW | 
|---|