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

Side by Side Diff: pkg/analyzer/lib/src/generated/source_io.dart

Issue 243263004: New analyzer snapshot. (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 | « pkg/analyzer/lib/src/generated/sdk_io.dart ('k') | pkg/analyzer/pubspec.yaml » ('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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.source.io; 8 library engine.source.io;
9 9
10 import 'source.dart'; 10 import 'source.dart';
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 * @return the contents of the source paired with the modification stamp of th e source 161 * @return the contents of the source paired with the modification stamp of th e source
162 * @throws Exception if the contents of this source could not be accessed 162 * @throws Exception if the contents of this source could not be accessed
163 * @see #getContents() 163 * @see #getContents()
164 */ 164 */
165 TimestampedData<String> get contentsFromFile { 165 TimestampedData<String> get contentsFromFile {
166 return new TimestampedData<String>(file.lastModified(), file.readAsStringSyn c()); 166 return new TimestampedData<String>(file.lastModified(), file.readAsStringSyn c());
167 } 167 }
168 } 168 }
169 169
170 /** 170 /**
171 * An implementation of an non-existing [Source].
172 */
173 class NonExistingSource implements Source {
174 final String _name;
175
176 final UriKind uriKind;
177
178 NonExistingSource(this._name, this.uriKind);
179
180 @override
181 bool exists() => false;
182
183 @override
184 TimestampedData<String> get contents {
185 throw new UnsupportedOperationException("${_name}does not exist.");
186 }
187
188 @override
189 String get encoding {
190 throw new UnsupportedOperationException("${_name}does not exist.");
191 }
192
193 @override
194 String get fullName => _name;
195
196 @override
197 int get modificationStamp => 0;
198
199 @override
200 String get shortName => _name;
201
202 @override
203 bool get isInSystemLibrary => false;
204
205 @override
206 Source resolveRelative(Uri relativeUri) {
207 throw new UnsupportedOperationException("${_name}does not exist.");
208 }
209 }
210
211 /**
212 * Instances of the class `RelativeFileUriResolver` resolve `file` URI's.
213 */
214 class RelativeFileUriResolver extends UriResolver {
215 /**
216 * The name of the `file` scheme.
217 */
218 static String FILE_SCHEME = "file";
219
220 /**
221 * Return `true` if the given URI is a `file` URI.
222 *
223 * @param uri the URI being tested
224 * @return `true` if the given URI is a `file` URI
225 */
226 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME;
227
228 /**
229 * The directories for the relatvie URI's
230 */
231 final List<JavaFile> _relativeDirectories;
232
233 /**
234 * The root directory for all the source trees
235 */
236 final JavaFile _rootDirectory;
237
238 /**
239 * Initialize a newly created resolver to resolve `file` URI's relative to the given root
240 * directory.
241 */
242 RelativeFileUriResolver(this._rootDirectory, this._relativeDirectories) : supe r();
243
244 @override
245 Source fromEncoding(UriKind kind, Uri uri) {
246 if (kind == UriKind.FILE_URI) {
247 return new FileBasedSource.con2(new JavaFile.fromUri(uri), kind);
248 }
249 return null;
250 }
251
252 @override
253 Source resolveAbsolute(Uri uri) {
254 String rootPath = _rootDirectory.toURI().path;
255 String uriPath = uri.path;
256 if (uriPath != null && uriPath.startsWith(rootPath)) {
257 String filePath = uri.path.substring(rootPath.length);
258 for (JavaFile dir in _relativeDirectories) {
259 JavaFile file = new JavaFile.relative(dir, filePath);
260 if (file.exists()) {
261 return new FileBasedSource.con2(file, UriKind.FILE_URI);
262 }
263 }
264 }
265 return null;
266 }
267 }
268
269 /**
171 * Instances of the class `PackageUriResolver` resolve `package` URI's in the co ntext of 270 * Instances of the class `PackageUriResolver` resolve `package` URI's in the co ntext of
172 * an application. 271 * an application.
173 * 272 *
174 * For the purposes of sharing analysis, the path to each package under the "pac kages" directory 273 * For the purposes of sharing analysis, the path to each package under the "pac kages" directory
175 * should be canonicalized, but to preserve relative links within a package, the remainder of the 274 * should be canonicalized, but to preserve relative links within a package, the remainder of the
176 * path from the package directory to the leaf should not. 275 * path from the package directory to the leaf should not.
177 */ 276 */
178 class PackageUriResolver extends UriResolver { 277 class PackageUriResolver extends UriResolver {
179 /** 278 /**
180 * The package directories that `package` URI's are assumed to be relative to. 279 * The package directories that `package` URI's are assumed to be relative to.
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 509 }
411 510
412 @override 511 @override
413 Source resolveAbsolute(Uri uri) { 512 Source resolveAbsolute(Uri uri) {
414 if (!isFileUri(uri)) { 513 if (!isFileUri(uri)) {
415 return null; 514 return null;
416 } 515 }
417 return new FileBasedSource.con1(new JavaFile.fromUri(uri)); 516 return new FileBasedSource.con1(new JavaFile.fromUri(uri));
418 } 517 }
419 } 518 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/sdk_io.dart ('k') | pkg/analyzer/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698