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

Side by Side Diff: pkg/code_transformers/lib/assets.dart

Issue 221673005: Use warning instead of error in a couple places. In polymer we are hitting (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/code_transformers/pubspec.yaml » ('j') | pkg/code_transformers/pubspec.yaml » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 /// Common methods used by transfomers for dealing with asset IDs. 5 /// Common methods used by transfomers for dealing with asset IDs.
6 library code_transformers.assets; 6 library code_transformers.assets;
7 7
8 import 'dart:math' show min, max; 8 import 'dart:math' show min, max;
9 9
10 import 'package:barback/barback.dart'; 10 import 'package:barback/barback.dart';
(...skipping 13 matching lines...) Expand all
24 if (uri.host != '' || uri.scheme != '' || urlBuilder.isAbsolute(url)) { 24 if (uri.host != '' || uri.scheme != '' || urlBuilder.isAbsolute(url)) {
25 if (source.extension == '.dart' && uri.scheme == 'package') { 25 if (source.extension == '.dart' && uri.scheme == 'package') {
26 var index = uri.path.indexOf('/'); 26 var index = uri.path.indexOf('/');
27 if (index != -1) { 27 if (index != -1) {
28 return new AssetId(uri.path.substring(0, index), 28 return new AssetId(uri.path.substring(0, index),
29 'lib${uri.path.substring(index)}'); 29 'lib${uri.path.substring(index)}');
30 } 30 }
31 } 31 }
32 32
33 if (errorOnAbsolute) { 33 if (errorOnAbsolute) {
34 logger.error('absolute paths not allowed: "$url"', span: span); 34 logger.error('absolute paths not allowed: "$url"', span: span);
Siggi Cherem (dart-lang) 2014/04/02 02:56:33 should we turn this into a warning too? If so, sho
blois 2014/04/02 14:58:34 Should probably change it to be a warning, would b
Siggi Cherem (dart-lang) 2014/04/02 16:31:55 Done.
35 } 35 }
36 return null; 36 return null;
37 } 37 }
38 38
39 var targetPath = urlBuilder.normalize( 39 var targetPath = urlBuilder.normalize(
40 urlBuilder.join(urlBuilder.dirname(source.path), url)); 40 urlBuilder.join(urlBuilder.dirname(source.path), url));
41 var segments = urlBuilder.split(targetPath); 41 var segments = urlBuilder.split(targetPath);
42 var sourceSegments = urlBuilder.split(source.path); 42 var sourceSegments = urlBuilder.split(source.path);
43 assert (sourceSegments.length > 0); 43 assert (sourceSegments.length > 0);
44 var topFolder = sourceSegments[0]; 44 var topFolder = sourceSegments[0];
(...skipping 19 matching lines...) Expand all
64 // folder lives (otherwise the app would not work in Dartium). Since 64 // folder lives (otherwise the app would not work in Dartium). Since
65 // [targetPath] has been normalized, "packages" or "assets" should be at 65 // [targetPath] has been normalized, "packages" or "assets" should be at
66 // index 1. 66 // index 1.
67 return _extractOtherPackageId(1, segments, logger, span); 67 return _extractOtherPackageId(1, segments, logger, span);
68 } else { 68 } else {
69 var prefix = segments[index]; 69 var prefix = segments[index];
70 var fixedSegments = []; 70 var fixedSegments = [];
71 fixedSegments.addAll(sourceSegments.map((_) => '..')); 71 fixedSegments.addAll(sourceSegments.map((_) => '..'));
72 fixedSegments.addAll(segments.sublist(index)); 72 fixedSegments.addAll(segments.sublist(index));
73 var fixedUrl = urlBuilder.joinAll(fixedSegments); 73 var fixedUrl = urlBuilder.joinAll(fixedSegments);
74 logger.error('Invalid url to reach to another package: $url. Path ' 74 logger.warning('Invalid url to reach to another package: $url. Path '
75 'reaching to other packages must first reach up all the ' 75 'reaching to other packages must first reach up all the '
76 'way to the $prefix folder. For example, try changing the url above ' 76 'way to the $prefix folder. For example, try changing the url above '
77 'to: $fixedUrl', span: span); 77 'to: $fixedUrl', span: span);
78 return null; 78 return null;
79 } 79 }
80 } 80 }
81 81
82 // Otherwise, resolve as a path in the same package. 82 // Otherwise, resolve as a path in the same package.
83 return new AssetId(source.package, targetPath); 83 return new AssetId(source.package, targetPath);
84 } 84 }
85 85
86 AssetId _extractOtherPackageId(int index, List segments, 86 AssetId _extractOtherPackageId(int index, List segments,
87 TransformLogger logger, Span span) { 87 TransformLogger logger, Span span) {
88 if (index >= segments.length) return null; 88 if (index >= segments.length) return null;
89 var prefix = segments[index]; 89 var prefix = segments[index];
90 if (prefix != 'packages' && prefix != 'assets') return null; 90 if (prefix != 'packages' && prefix != 'assets') return null;
91 var folder = prefix == 'packages' ? 'lib' : 'asset'; 91 var folder = prefix == 'packages' ? 'lib' : 'asset';
92 if (segments.length < index + 3) { 92 if (segments.length < index + 3) {
93 logger.error("incomplete $prefix/ path. It should have at least 3 " 93 logger.warning("incomplete $prefix/ path. It should have at least 3 "
94 "segments $prefix/name/path-from-name's-$folder-dir", span: span); 94 "segments $prefix/name/path-from-name's-$folder-dir", span: span);
95 return null; 95 return null;
96 } 96 }
97 return new AssetId(segments[index + 1], 97 return new AssetId(segments[index + 1],
98 path.url.join(folder, path.url.joinAll(segments.sublist(index + 2)))); 98 path.url.join(folder, path.url.joinAll(segments.sublist(index + 2))));
99 } 99 }
OLDNEW
« no previous file with comments | « no previous file | pkg/code_transformers/pubspec.yaml » ('j') | pkg/code_transformers/pubspec.yaml » ('J')

Powered by Google App Engine
This is Rietveld 408576698