| 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 analyzer.src.dart.sdk.patch; | 5 library analyzer.src.dart.sdk.patch; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/error/listener.dart'; | 9 import 'package:analyzer/error/listener.dart'; |
| 10 import 'package:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 throw new ArgumentError( | 44 throw new ArgumentError( |
| 45 'The URI of the unit to patch must have the "dart" scheme: $uri'); | 45 'The URI of the unit to patch must have the "dart" scheme: $uri'); |
| 46 } | 46 } |
| 47 List<String> uriSegments = uri.pathSegments; | 47 List<String> uriSegments = uri.pathSegments; |
| 48 String libraryName = uriSegments.first; | 48 String libraryName = uriSegments.first; |
| 49 libraryUriStr = 'dart:$libraryName'; | 49 libraryUriStr = 'dart:$libraryName'; |
| 50 isLibraryDefiningUnit = uriSegments.length == 1; | 50 isLibraryDefiningUnit = uriSegments.length == 1; |
| 51 _allowNewPublicNames = libraryName == '_internal'; | 51 _allowNewPublicNames = libraryName == '_internal'; |
| 52 } | 52 } |
| 53 // Prepare the patch files to apply. | 53 // Prepare the patch files to apply. |
| 54 List<String> patchPaths = allPatchPaths[libraryUriStr] ?? const <String> []; | 54 List<String> patchPaths = allPatchPaths[libraryUriStr] ?? const <String>[]; |
| 55 | 55 |
| 56 for (String path in patchPaths) { | 56 for (String path in patchPaths) { |
| 57 File patchFile = resourceProvider.getFile(path); | 57 File patchFile = resourceProvider.getFile(path); |
| 58 if (!patchFile.exists) { | 58 if (!patchFile.exists) { |
| 59 throw new ArgumentError( | 59 throw new ArgumentError( |
| 60 'The patch file ${patchFile.path} for $source does not exist.'); | 60 'The patch file ${patchFile.path} for $source does not exist.'); |
| 61 } | 61 } |
| 62 Source patchSource = patchFile.createSource(); | 62 Source patchSource = patchFile.createSource(); |
| 63 CompilationUnit patchUnit = parse(patchSource, strongMode, errorListener); | 63 CompilationUnit patchUnit = parse(patchSource, strongMode, errorListener); |
| 64 | 64 |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 } | 459 } |
| 460 | 460 |
| 461 /** | 461 /** |
| 462 * Replace tokens of the [oldNode] with tokens of the [newNode]. | 462 * Replace tokens of the [oldNode] with tokens of the [newNode]. |
| 463 */ | 463 */ |
| 464 static void _replaceNodeTokens(AstNode oldNode, AstNode newNode) { | 464 static void _replaceNodeTokens(AstNode oldNode, AstNode newNode) { |
| 465 oldNode.beginToken.previous.setNext(newNode.beginToken); | 465 oldNode.beginToken.previous.setNext(newNode.beginToken); |
| 466 newNode.endToken.setNext(oldNode.endToken.next); | 466 newNode.endToken.setNext(oldNode.endToken.next); |
| 467 } | 467 } |
| 468 } | 468 } |
| OLD | NEW |