Chromium Code Reviews| Index: pkg/analyzer/lib/src/generated/sdk.dart |
| diff --git a/pkg/analyzer/lib/src/generated/sdk.dart b/pkg/analyzer/lib/src/generated/sdk.dart |
| index 7e86d8d965d7f70506c9bfe6da1045f51ab1f55b..8ae3ef8e4a254872195b14c2245bcd797f53c404 100644 |
| --- a/pkg/analyzer/lib/src/generated/sdk.dart |
| +++ b/pkg/analyzer/lib/src/generated/sdk.dart |
| @@ -274,6 +274,7 @@ class SdkDescription { |
| buffer.write(optionName); |
| needsSeparator = true; |
| } |
| + |
| for (String path in paths) { |
| add(path); |
| } |
| @@ -308,6 +309,11 @@ class SdkLibrariesReader_LibraryBuilder extends RecursiveAstVisitor<Object> { |
| static String _DART2JS_PATH = "dart2jsPath"; |
| /** |
| + * The name of the `dart2js` platform. |
| + */ |
| + static String _DART2JS_PLATFORM = 'DART2JS_PLATFORM'; |
| + |
| + /** |
| * The name of the optional parameter used to indicate whether the library is |
| * documented. |
| */ |
| @@ -320,6 +326,12 @@ class SdkLibrariesReader_LibraryBuilder extends RecursiveAstVisitor<Object> { |
| static String _CATEGORIES = "categories"; |
| /** |
| + * The name of the optional parameter used to specify the patches for |
| + * the library. |
| + */ |
| + static String _PATCHES = "patches"; |
| + |
| + /** |
| * The name of the optional parameter used to specify the platforms on which |
| * the library can be used. |
| */ |
| @@ -397,6 +409,17 @@ class SdkLibrariesReader_LibraryBuilder extends RecursiveAstVisitor<Object> { |
| library._implementation = (expression as BooleanLiteral).value; |
| } else if (name == _DOCUMENTED) { |
| library.documented = (expression as BooleanLiteral).value; |
| + } else if (name == _PATCHES) { |
| + if (expression is MapLiteral) { |
| + expression.entries.forEach((MapLiteralEntry entry) { |
| + Expression key = entry.key; |
| + Expression value = entry.value; |
| + if (key is SimpleIdentifier && value is SimpleStringLiteral) { |
|
Paul Berry
2016/10/10 19:14:38
Two issues:
1. The "patches" parameter should be
scheglov
2016/10/10 19:41:52
OK, I see now.
The key of this map must be a combi
|
| + int platform = _convertPlatform(key.name); |
| + library.addPatch(platform, value.value); |
| + } |
| + }); |
| + } |
| } else if (name == _PLATFORMS) { |
| if (expression is SimpleIdentifier) { |
| String identifier = expression.name; |
| @@ -417,6 +440,20 @@ class SdkLibrariesReader_LibraryBuilder extends RecursiveAstVisitor<Object> { |
| } |
| return null; |
| } |
| + |
| + /** |
| + * Return the platform constant value for the [name]. Throw [ArgumentError] |
| + * if the given [name] is not a valid platform name. |
| + */ |
| + static int _convertPlatform(String name) { |
| + if (name == _DART2JS_PLATFORM) { |
| + return SdkLibraryImpl.DART2JS_PLATFORM; |
| + } |
| + if (name == _VM_PLATFORM) { |
| + return SdkLibraryImpl.VM_PLATFORM; |
| + } |
| + throw new ArgumentError('Invalid platform name: $name'); |
| + } |
| } |
| /** |
| @@ -469,6 +506,12 @@ abstract class SdkLibrary { |
| * including `dart:`. |
| */ |
| String get shortName; |
| + |
| + /** |
| + * Return the list of paths to the patch files that should be applied |
| + * to this library for the given [platform], not `null`. |
| + */ |
| + List<String> getPatches(int platform); |
| } |
| /** |
| @@ -521,6 +564,12 @@ class SdkLibraryImpl implements SdkLibrary { |
| int _platforms = 0; |
| /** |
| + * The mapping from the platform to the list of patches that should be |
| + * applied for this library. |
| + */ |
| + final Map<int, List<String>> _patches = new HashMap<int, List<String>>(); |
| + |
| + /** |
| * Initialize a newly created library to represent the library with the given |
| * [name]. |
| */ |
| @@ -552,6 +601,20 @@ class SdkLibraryImpl implements SdkLibrary { |
| bool get isVmLibrary => (_platforms & VM_PLATFORM) != 0; |
| /** |
| + * Add a new patch with the given [path] that should be applied for the |
| + * given [platform]. |
| + */ |
| + void addPatch(int platform, String path) { |
| + assert(path != null); |
| + _patches.putIfAbsent(platform, () => <String>[]).add(path); |
| + } |
| + |
| + @override |
| + List<String> getPatches(int platform) { |
| + return _patches[platform] ?? const <String>[]; |
| + } |
| + |
| + /** |
| * Record that this library can be compiled to JavaScript by dart2js. |
| */ |
| void setDart2JsLibrary() { |