| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 PatchVersion patchVersion = getPatchVersion(compiler, patch); | 244 PatchVersion patchVersion = getPatchVersion(compiler, patch); |
| 245 if (patchVersion != null) { | 245 if (patchVersion != null) { |
| 246 if (patchVersion.isActive(compiler.patchVersion)) { | 246 if (patchVersion.isActive(compiler.patchVersion)) { |
| 247 Element origin = enclosingClass.origin.localLookup(patch.name); | 247 Element origin = enclosingClass.origin.localLookup(patch.name); |
| 248 patchElement(compiler, reporter, origin, patch); | 248 patchElement(compiler, reporter, origin, patch); |
| 249 enclosingClass.addMember(patch, reporter); | 249 enclosingClass.addMember(patch, reporter); |
| 250 } else { | 250 } else { |
| 251 // Skip this element. | 251 // Skip this element. |
| 252 } | 252 } |
| 253 } else { | 253 } else { |
| 254 if (Name.isPublicName(patch.name)) { |
| 255 reporter.reportErrorMessage(patch, MessageKind.INJECTED_PUBLIC_MEMBER); |
| 256 } |
| 254 enclosingClass.addMember(patch, reporter); | 257 enclosingClass.addMember(patch, reporter); |
| 255 } | 258 } |
| 256 } | 259 } |
| 257 } | 260 } |
| 258 | 261 |
| 259 /** | 262 /** |
| 260 * Partial parser for patch files that also handles the members of class | 263 * Partial parser for patch files that also handles the members of class |
| 261 * declarations. | 264 * declarations. |
| 262 */ | 265 */ |
| 263 class PatchClassElementParser extends PartialParser { | 266 class PatchClassElementParser extends PartialParser { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 288 if (patchVersion.isActive(compiler.patchVersion)) { | 291 if (patchVersion.isActive(compiler.patchVersion)) { |
| 289 LibraryElement originLibrary = compilationUnitElement.library; | 292 LibraryElement originLibrary = compilationUnitElement.library; |
| 290 assert(originLibrary.isPatched); | 293 assert(originLibrary.isPatched); |
| 291 Element origin = originLibrary.localLookup(patch.name); | 294 Element origin = originLibrary.localLookup(patch.name); |
| 292 patchElement(compiler, reporter, origin, patch); | 295 patchElement(compiler, reporter, origin, patch); |
| 293 compilationUnitElement.addMember(patch, reporter); | 296 compilationUnitElement.addMember(patch, reporter); |
| 294 } else { | 297 } else { |
| 295 // Skip this element. | 298 // Skip this element. |
| 296 } | 299 } |
| 297 } else { | 300 } else { |
| 301 if (Name.isPublicName(patch.name)) { |
| 302 reporter.reportErrorMessage(patch, MessageKind.INJECTED_PUBLIC_MEMBER); |
| 303 } |
| 298 compilationUnitElement.addMember(patch, reporter); | 304 compilationUnitElement.addMember(patch, reporter); |
| 299 } | 305 } |
| 300 } | 306 } |
| 301 } | 307 } |
| 302 | 308 |
| 303 void patchElement(Compiler compiler, | 309 void patchElement(Compiler compiler, |
| 304 DiagnosticReporter reporter, | 310 DiagnosticReporter reporter, |
| 305 Element origin, | 311 Element origin, |
| 306 Element patch) { | 312 Element patch) { |
| 307 if (origin == null) { | 313 if (origin == null) { |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 | 688 |
| 683 class PatchVersion { | 689 class PatchVersion { |
| 684 final String tag; | 690 final String tag; |
| 685 | 691 |
| 686 const PatchVersion(this.tag); | 692 const PatchVersion(this.tag); |
| 687 | 693 |
| 688 bool isActive(String patchTag) => tag == null || tag == patchTag; | 694 bool isActive(String patchTag) => tag == null || tag == patchTag; |
| 689 | 695 |
| 690 String toString() => 'PatchVersion($tag)'; | 696 String toString() => 'PatchVersion($tag)'; |
| 691 } | 697 } |
| OLD | NEW |