| 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 /** | 5 /** |
| 6 * This library contains the infrastructure to parse and integrate patch files. | 6 * This library contains the infrastructure to parse and integrate patch files. |
| 7 * | 7 * |
| 8 * Three types of elements can be patched: [LibraryElement], [ClassElement], | 8 * Three types of elements can be patched: [LibraryElement], [ClassElement], |
| 9 * [FunctionElement]. Patches are introduced in patch libraries which are loaded | 9 * [FunctionElement]. Patches are introduced in patch libraries which are loaded |
| 10 * together with the corresponding origin library. Which libraries that are | 10 * together with the corresponding origin library. Which libraries that are |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 : this._enableConditionalDirectives = enableConditionalDirectives, | 165 : this._enableConditionalDirectives = enableConditionalDirectives, |
| 166 super(compiler); | 166 super(compiler); |
| 167 | 167 |
| 168 /** | 168 /** |
| 169 * Scans a library patch file, applies the method patches and | 169 * Scans a library patch file, applies the method patches and |
| 170 * injections to the library, and returns a list of class | 170 * injections to the library, and returns a list of class |
| 171 * patches. | 171 * patches. |
| 172 */ | 172 */ |
| 173 Future patchLibrary(LibraryLoader loader, | 173 Future patchLibrary(LibraryLoader loader, |
| 174 Uri patchUri, LibraryElement originLibrary) { | 174 Uri patchUri, LibraryElement originLibrary) { |
| 175 return compiler.readScript(originLibrary, patchUri) | 175 return compiler.readScript(patchUri, originLibrary) |
| 176 .then((Script script) { | 176 .then((Script script) { |
| 177 var patchLibrary = new LibraryElementX(script, null, originLibrary); | 177 var patchLibrary = new LibraryElementX(script, null, originLibrary); |
| 178 return reporter.withCurrentElement(patchLibrary, () { | 178 return reporter.withCurrentElement(patchLibrary, () { |
| 179 loader.registerNewLibrary(patchLibrary); | 179 loader.registerNewLibrary(patchLibrary); |
| 180 reporter.withCurrentElement(patchLibrary.entryCompilationUnit, () { | 180 reporter.withCurrentElement(patchLibrary.entryCompilationUnit, () { |
| 181 // This patches the elements of the patch library into [library]. | 181 // This patches the elements of the patch library into [library]. |
| 182 // Injected elements are added directly under the compilation unit. | 182 // Injected elements are added directly under the compilation unit. |
| 183 // Patch elements are stored on the patched functions or classes. | 183 // Patch elements are stored on the patched functions or classes. |
| 184 scanLibraryElements(patchLibrary.entryCompilationUnit); | 184 scanLibraryElements(patchLibrary.entryCompilationUnit); |
| 185 }); | 185 }); |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 | 696 |
| 697 class PatchVersion { | 697 class PatchVersion { |
| 698 final String tag; | 698 final String tag; |
| 699 | 699 |
| 700 const PatchVersion(this.tag); | 700 const PatchVersion(this.tag); |
| 701 | 701 |
| 702 bool isActive(String patchTag) => tag == null || tag == patchTag; | 702 bool isActive(String patchTag) => tag == null || tag == patchTag; |
| 703 | 703 |
| 704 String toString() => 'PatchVersion($tag)'; | 704 String toString() => 'PatchVersion($tag)'; |
| 705 } | 705 } |
| OLD | NEW |