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

Side by Side Diff: lib/assets.dart

Issue 1830403002: switch package to strong mode (Closed) Base URL: git@github.com:dart-lang/code_transformers.git@master
Patch Set: Created 4 years, 9 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 | « CHANGELOG.md ('k') | lib/messages/build_logger.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) 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } else if (index == 1 && segments[0] == '..') { 76 } else if (index == 1 && segments[0] == '..') {
77 // Relative URLs of the form "../../packages/foo/bar" in an asset under 77 // Relative URLs of the form "../../packages/foo/bar" in an asset under
78 // lib/ or asset/ are also resolved as an asset in another package, but we 78 // lib/ or asset/ are also resolved as an asset in another package, but we
79 // check that the relative path goes all the way out where the packages 79 // check that the relative path goes all the way out where the packages
80 // folder lives (otherwise the app would not work in Dartium). Since 80 // folder lives (otherwise the app would not work in Dartium). Since
81 // [targetPath] has been normalized, "packages" or "assets" should be at 81 // [targetPath] has been normalized, "packages" or "assets" should be at
82 // index 1. 82 // index 1.
83 return _extractOtherPackageId(1, segments, logger, span); 83 return _extractOtherPackageId(1, segments, logger, span);
84 } else { 84 } else {
85 var prefix = segments[index]; 85 var prefix = segments[index];
86 var fixedSegments = []; 86 var fixedSegments = <String>[];
87 fixedSegments.addAll(sourceSegments.map((_) => '..')); 87 fixedSegments.addAll(sourceSegments.map((_) => '..'));
88 fixedSegments.addAll(segments.sublist(index)); 88 fixedSegments.addAll(segments.sublist(index));
89 var fixedUrl = urlBuilder.joinAll(fixedSegments); 89 var fixedUrl = urlBuilder.joinAll(fixedSegments);
90 var msg = INVALID_URL_TO_OTHER_PACKAGE 90 var msg = INVALID_URL_TO_OTHER_PACKAGE
91 .create({'url': url, 'prefix': prefix, 'fixedUrl': fixedUrl}); 91 .create({'url': url, 'prefix': prefix, 'fixedUrl': fixedUrl});
92 logger.warning(logger is BuildLogger ? msg : msg.snippet, span: span); 92 logger.warning(logger is BuildLogger ? msg : msg.snippet, span: span);
93 return null; 93 return null;
94 } 94 }
95 } 95 }
96 96
97 // Otherwise, resolve as a path in the same package. 97 // Otherwise, resolve as a path in the same package.
98 return new AssetId(source.package, targetPath); 98 return new AssetId(source.package, targetPath);
99 } 99 }
100 100
101 AssetId _extractOtherPackageId( 101 AssetId _extractOtherPackageId(
102 int index, List segments, TransformLogger logger, SourceSpan span) { 102 int index, List<String> segments, TransformLogger logger, SourceSpan span) {
103 if (index >= segments.length) return null; 103 if (index >= segments.length) return null;
104 var prefix = segments[index]; 104 var prefix = segments[index];
105 if (prefix != 'packages' && prefix != 'assets') return null; 105 if (prefix != 'packages' && prefix != 'assets') return null;
106 var folder = prefix == 'packages' ? 'lib' : 'asset'; 106 var folder = prefix == 'packages' ? 'lib' : 'asset';
107 if (segments.length < index + 3) { 107 if (segments.length < index + 3) {
108 var msg = INVALID_PREFIX_PATH.create({'prefix': prefix, 'folder': folder}); 108 var msg = INVALID_PREFIX_PATH.create({'prefix': prefix, 'folder': folder});
109 logger.warning(logger is BuildLogger ? msg : msg.snippet, span: span); 109 logger.warning(logger is BuildLogger ? msg : msg.snippet, span: span);
110 return null; 110 return null;
111 } 111 }
112 return new AssetId(segments[index + 1], 112 return new AssetId(segments[index + 1],
(...skipping 28 matching lines...) Expand all
141 } 141 }
142 return new Uri( 142 return new Uri(
143 path: path.url.relative(assetId.path, from: path.url.dirname(from.pa th))) 143 path: path.url.relative(assetId.path, from: path.url.dirname(from.pa th)))
144 .toString(); 144 .toString();
145 } 145 }
146 146
147 return Uri 147 return Uri
148 .parse('package:${assetId.package}/${assetId.path.substring(4)}') 148 .parse('package:${assetId.package}/${assetId.path.substring(4)}')
149 .toString(); 149 .toString();
150 } 150 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/messages/build_logger.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698