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

Unified Diff: pkg/analyzer/lib/src/dart/sdk/patch.dart

Issue 2413403002: Allow new public names in patches for the dart:_internal library. (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | pkg/analyzer/test/src/dart/sdk/patch_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/sdk/patch.dart
diff --git a/pkg/analyzer/lib/src/dart/sdk/patch.dart b/pkg/analyzer/lib/src/dart/sdk/patch.dart
index f6b8a3bdb358894f4b26552026bf946e694aa70e..88a122eecf2423a57cc680fb4b15873553790c4e 100644
--- a/pkg/analyzer/lib/src/dart/sdk/patch.dart
+++ b/pkg/analyzer/lib/src/dart/sdk/patch.dart
@@ -21,6 +21,7 @@ import 'package:path/src/context.dart';
* [SdkPatcher] applies patches to SDK [CompilationUnit].
*/
class SdkPatcher {
+ bool _allowNewPublicNames;
String _baseDesc;
String _patchDesc;
CompilationUnit _patchUnit;
@@ -46,8 +47,10 @@ class SdkPatcher {
'The URI of the unit to patch must have the "dart" scheme: $uri');
}
List<String> uriSegments = uri.pathSegments;
- libraryUriStr = 'dart:${uriSegments.first}';
+ String libraryName = uriSegments.first;
+ libraryUriStr = 'dart:$libraryName';
isLibraryDefiningUnit = uriSegments.length == 1;
+ _allowNewPublicNames = libraryName == '_internal';
}
// Prepare the patch files to apply.
List<String> patchPaths;
@@ -90,6 +93,9 @@ class SdkPatcher {
}
void _failIfPublicName(AstNode node, String name) {
+ if (_allowNewPublicNames) {
+ return;
+ }
if (!Identifier.isPrivateName(name)) {
_failInPatch('contains a public declaration "$name"', node.offset);
}
@@ -121,9 +127,9 @@ class SdkPatcher {
patchMember.offset);
}
String name = fields[0].name.name;
- if (!Identifier.isPrivateName(className) &&
+ if (!_allowNewPublicNames &&
+ !Identifier.isPrivateName(className) &&
!Identifier.isPrivateName(name)) {
- // TODO(scheglov) allow adding public fields into dart:_internal
_failInPatch('contains a public field', patchMember.offset);
}
membersToAppend.add(patchMember);
@@ -206,7 +212,7 @@ class SdkPatcher {
}
} else {
if (name == null) {
- if (!Identifier.isPrivateName(className)) {
+ if (!_allowNewPublicNames && !Identifier.isPrivateName(className)) {
_failInPatch(
'contains an unnamed public constructor', patchMember.offset);
}
« no previous file with comments | « no previous file | pkg/analyzer/test/src/dart/sdk/patch_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698