Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: pkg/compiler/lib/src/patch_parser.dart

Issue 2836733002: dart2js: patch file support cleanup (Closed)
Patch Set: remove js_array change Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/startup_emitter/emitter.dart ('k') | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/patch_parser.dart
diff --git a/pkg/compiler/lib/src/patch_parser.dart b/pkg/compiler/lib/src/patch_parser.dart
index f0ba4fc0272a34ddae1718154dc487390591050d..a572d742902b67cb4b35cb3dee1cb45839101aaa 100644
--- a/pkg/compiler/lib/src/patch_parser.dart
+++ b/pkg/compiler/lib/src/patch_parser.dart
@@ -227,15 +227,10 @@ class PatchMemberListener extends MemberListener {
void addMember(Element patch) {
addMetadata(patch);
- PatchVersion patchVersion = getPatchVersion(compiler, patch);
- if (patchVersion != null) {
- if (patchVersion.isActive(compiler.patchVersion)) {
- Element origin = enclosingClass.origin.localLookup(patch.name);
- patchElement(compiler, reporter, origin, patch);
- enclosingClass.addMember(patch, reporter);
- } else {
- // Skip this element.
- }
+ if (_isMarkedAsPatch(compiler, patch)) {
+ Element origin = enclosingClass.origin.localLookup(patch.name);
+ patchElement(compiler, reporter, origin, patch);
+ enclosingClass.addMember(patch, reporter);
} else {
if (Name.isPublicName(patch.name)) {
reporter.reportErrorMessage(patch, MessageKind.INJECTED_PUBLIC_MEMBER);
@@ -261,17 +256,12 @@ class PatchElementListener extends ElementListener implements Listener {
void pushElement(Element patch) {
popMetadata(patch);
- PatchVersion patchVersion = getPatchVersion(compiler, patch);
- if (patchVersion != null) {
- if (patchVersion.isActive(compiler.patchVersion)) {
- LibraryElement originLibrary = compilationUnitElement.library;
- assert(originLibrary.isPatched);
- Element origin = originLibrary.localLookup(patch.name);
- patchElement(compiler, reporter, origin, patch);
- compilationUnitElement.addMember(patch, reporter);
- } else {
- // Skip this element.
- }
+ if (_isMarkedAsPatch(compiler, patch)) {
+ LibraryElement originLibrary = compilationUnitElement.library;
+ assert(originLibrary.isPatched);
+ Element origin = originLibrary.localLookup(patch.name);
+ patchElement(compiler, reporter, origin, patch);
+ compilationUnitElement.addMember(patch, reporter);
} else {
if (Name.isPublicName(patch.name)) {
reporter.reportErrorMessage(patch, MessageKind.INJECTED_PUBLIC_MEMBER);
@@ -381,28 +371,17 @@ abstract class EagerAnnotationHandler<T> {
}
/// Annotation handler for pre-resolution detection of `@patch` annotations.
-class PatchAnnotationHandler extends EagerAnnotationHandler<PatchVersion> {
+class PatchAnnotationHandler extends EagerAnnotationHandler<bool> {
const PatchAnnotationHandler();
- PatchVersion getPatchVersion(MetadataAnnotationX annotation) {
- if (annotation.beginToken != null) {
- if (annotation.beginToken.next.lexeme == 'patch') {
- return const PatchVersion(null);
- } else if (annotation.beginToken.next.lexeme == 'patch_full') {
- return const PatchVersion('full');
- } else if (annotation.beginToken.next.lexeme == 'patch_lazy') {
- return const PatchVersion('lazy');
- } else if (annotation.beginToken.next.lexeme == 'patch_startup') {
- return const PatchVersion('startup');
- }
- }
- return null;
- }
-
@override
- PatchVersion apply(
+ bool apply(
Compiler compiler, Element element, MetadataAnnotation annotation) {
- return getPatchVersion(annotation);
+ MetadataAnnotationX meta = annotation;
+ if (meta.beginToken?.next?.lexeme == 'patch') {
+ return true;
+ }
+ return null;
}
@override
@@ -520,17 +499,8 @@ void patchFunction(DiagnosticReporter reporter, BaseFunctionElementX origin,
origin.applyPatch(patch);
}
-PatchVersion getPatchVersion(Compiler compiler, Element element) {
+bool _isMarkedAsPatch(Compiler compiler, Element element) {
return EagerAnnotationHandler.checkAnnotation(
- compiler, element, const PatchAnnotationHandler());
-}
-
-class PatchVersion {
- final String tag;
-
- const PatchVersion(this.tag);
-
- bool isActive(String patchTag) => tag == null || tag == patchTag;
-
- String toString() => 'PatchVersion($tag)';
+ compiler, element, const PatchAnnotationHandler()) ==
+ true;
}
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/startup_emitter/emitter.dart ('k') | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698