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

Side by Side Diff: lib/src/barback/transformer_config.dart

Issue 2184303002: Make pub strong-mode clean. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « lib/src/barback/pub_package_provider.dart ('k') | lib/src/barback/transformer_isolate.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import 'package:glob/glob.dart'; 5 import 'package:glob/glob.dart';
6 import 'package:path/path.dart' as p; 6 import 'package:path/path.dart' as p;
7 import 'package:source_span/source_span.dart'; 7 import 'package:source_span/source_span.dart';
8 import 'package:yaml/yaml.dart'; 8 import 'package:yaml/yaml.dart';
9 9
10 import 'transformer_id.dart'; 10 import 'transformer_id.dart';
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 /// Parses [identifier] as a [TransformerId] with [configuration]. 73 /// Parses [identifier] as a [TransformerId] with [configuration].
74 /// 74 ///
75 /// [identifierSpan] is the source span for [identifier]. 75 /// [identifierSpan] is the source span for [identifier].
76 factory TransformerConfig.parse(String identifier, SourceSpan identifierSpan, 76 factory TransformerConfig.parse(String identifier, SourceSpan identifierSpan,
77 YamlMap configuration) => 77 YamlMap configuration) =>
78 new TransformerConfig(new TransformerId.parse(identifier, identifierSpan), 78 new TransformerConfig(new TransformerId.parse(identifier, identifierSpan),
79 configuration); 79 configuration);
80 80
81 factory TransformerConfig(TransformerId id, YamlMap configurationNode) { 81 factory TransformerConfig(TransformerId id, YamlMap configurationNode) {
82 parseField(key) { 82 Set<Glob> parseField(String key) {
83 if (!configurationNode.containsKey(key)) return null; 83 if (!configurationNode.containsKey(key)) return null;
84 var fieldNode = configurationNode.nodes[key]; 84 var fieldNode = configurationNode.nodes[key];
85 var field = fieldNode.value; 85 var field = fieldNode.value;
86 86
87 if (field is String) { 87 if (field is String) {
88 return new Set.from([new Glob(field, context: p.url, recursive: true)]); 88 return new Set.from([new Glob(field, context: p.url, recursive: true)]);
89 } 89 }
90 90
91 if (field is! List) { 91 if (field is! List) {
92 throw new SourceSpanFormatException( 92 throw new SourceSpanFormatException(
93 '"$key" field must be a string or list.', fieldNode.span); 93 '"$key" field must be a string or list.', fieldNode.span);
94 } 94 }
95 95
96 return new Set.from(field.nodes.map((node) { 96 return new Set.from(field.nodes.map((node) {
97 if (node.value is String) { 97 if (node.value is String) {
98 return new Glob(node.value, context: p.url, recursive: true); 98 return new Glob(node.value, context: p.url, recursive: true);
99 } 99 }
100 100
101 throw new SourceSpanFormatException( 101 throw new SourceSpanFormatException(
102 '"$key" field may contain only strings.', node.span); 102 '"$key" field may contain only strings.', node.span);
103 })); 103 }));
104 } 104 }
105 105
106 var includes = null; 106 Set<Glob> includes;
107 var excludes = null; 107 Set<Glob> excludes;
108 108 Map configuration;
109 var configuration; 109 SourceSpan span;
110 var span;
111 if (configurationNode == null) { 110 if (configurationNode == null) {
112 configuration = {}; 111 configuration = {};
113 span = id.span; 112 span = id.span;
114 } else { 113 } else {
115 // Don't write to the immutable YAML map. 114 // Don't write to the immutable YAML map.
116 configuration = new Map.from(configurationNode); 115 configuration = new Map.from(configurationNode);
117 span = configurationNode.span; 116 span = configurationNode.span;
118 117
119 // Pull out the exclusions/inclusions. 118 // Pull out the exclusions/inclusions.
120 includes = parseField("\$include"); 119 includes = parseField("\$include");
(...skipping 28 matching lines...) Expand all
149 for (var exclude in excludes) { 148 for (var exclude in excludes) {
150 if (exclude.matches(pathWithinPackage)) return false; 149 if (exclude.matches(pathWithinPackage)) return false;
151 } 150 }
152 } 151 }
153 152
154 // If there are any includes, it must match one of them. 153 // If there are any includes, it must match one of them.
155 return includes == null || 154 return includes == null ||
156 includes.any((include) => include.matches(pathWithinPackage)); 155 includes.any((include) => include.matches(pathWithinPackage));
157 } 156 }
158 } 157 }
OLDNEW
« no previous file with comments | « lib/src/barback/pub_package_provider.dart ('k') | lib/src/barback/transformer_isolate.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698