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

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

Issue 214593008: Rollback pkg/analyzer that breaks code_transformers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 bool isLocal(Source source) => source.uriKind != UriKind.DART_URI; 59 bool isLocal(Source source) => source.uriKind != UriKind.DART_URI;
60 } 60 }
61 61
62 /** 62 /**
63 * Instances of the class `FileBasedSource` implement a source that represents a file. 63 * Instances of the class `FileBasedSource` implement a source that represents a file.
64 */ 64 */
65 class FileBasedSource implements Source { 65 class FileBasedSource implements Source {
66 /** 66 /**
67 * The file represented by this source. 67 * The file represented by this source.
68 */ 68 */
69 final JavaFile file; 69 JavaFile _file;
70 70
71 /** 71 /**
72 * The cached encoding for this source. 72 * The cached encoding for this source.
73 */ 73 */
74 String _encoding; 74 String _encoding;
75 75
76 /** 76 /**
77 * The kind of URI from which this source was originally derived. 77 * The kind of URI from which this source was originally derived.
78 */ 78 */
79 final UriKind uriKind; 79 UriKind _uriKind;
80 80
81 /** 81 /**
82 * Initialize a newly created source object. The source object is assumed to n ot be in a system 82 * Initialize a newly created source object. The source object is assumed to n ot be in a system
83 * library. 83 * library.
84 * 84 *
85 * @param file the file represented by this source 85 * @param file the file represented by this source
86 */ 86 */
87 FileBasedSource.con1(JavaFile file) : this.con2(file, UriKind.FILE_URI); 87 FileBasedSource.con1(JavaFile file) : this.con2(file, UriKind.FILE_URI);
88 88
89 /** 89 /**
90 * Initialize a newly created source object. 90 * Initialize a newly created source object.
91 * 91 *
92 * @param file the file represented by this source 92 * @param file the file represented by this source
93 * @param flags `true` if this source is in one of the system libraries 93 * @param flags `true` if this source is in one of the system libraries
94 */ 94 */
95 FileBasedSource.con2(this.file, this.uriKind); 95 FileBasedSource.con2(JavaFile file, UriKind uriKind) {
96 this._file = file;
97 this._uriKind = uriKind;
98 }
96 99
97 @override 100 @override
98 bool operator ==(Object object) => object != null && this.runtimeType == objec t.runtimeType && file == (object as FileBasedSource).file; 101 bool operator ==(Object object) => object != null && this.runtimeType == objec t.runtimeType && _file == (object as FileBasedSource)._file;
99 102
100 @override 103 @override
101 bool exists() => file.isFile(); 104 bool exists() => _file.isFile();
102 105
103 @override 106 @override
104 TimestampedData<String> get contents { 107 TimestampedData<String> get contents {
105 TimeCounter_TimeCounterHandle handle = PerformanceStatistics.io.start(); 108 TimeCounter_TimeCounterHandle handle = PerformanceStatistics.io.start();
106 try { 109 try {
107 return contentsFromFile; 110 return contentsFromFile;
108 } finally { 111 } finally {
109 handle.stop(); 112 handle.stop();
110 } 113 }
111 } 114 }
112 115
113 @override 116 @override
114 String get encoding { 117 String get encoding {
115 if (_encoding == null) { 118 if (_encoding == null) {
116 _encoding = "${uriKind.encoding}${file.toURI().toString()}"; 119 _encoding = "${_uriKind.encoding}${_file.toURI().toString()}";
117 } 120 }
118 return _encoding; 121 return _encoding;
119 } 122 }
120 123
121 @override 124 @override
122 String get fullName => file.getAbsolutePath(); 125 String get fullName => _file.getAbsolutePath();
123 126
124 @override 127 @override
125 int get modificationStamp => file.lastModified(); 128 int get modificationStamp => _file.lastModified();
126 129
127 @override 130 @override
128 String get shortName => file.getName(); 131 String get shortName => _file.getName();
129 132
130 @override 133 @override
131 int get hashCode => file.hashCode; 134 UriKind get uriKind => _uriKind;
132 135
133 @override 136 @override
134 bool get isInSystemLibrary => identical(uriKind, UriKind.DART_URI); 137 int get hashCode => _file.hashCode;
138
139 @override
140 bool get isInSystemLibrary => identical(_uriKind, UriKind.DART_URI);
135 141
136 @override 142 @override
137 Source resolveRelative(Uri containedUri) { 143 Source resolveRelative(Uri containedUri) {
138 try { 144 try {
139 Uri resolvedUri = file.toURI().resolveUri(containedUri); 145 Uri resolvedUri = file.toURI().resolveUri(containedUri);
140 return new FileBasedSource.con2(new JavaFile.fromUri(resolvedUri), uriKind ); 146 return new FileBasedSource.con2(new JavaFile.fromUri(resolvedUri), _uriKin d);
141 } on JavaException catch (exception) { 147 } on JavaException catch (exception) {
142 } 148 }
143 return null; 149 return null;
144 } 150 }
145 151
146 @override 152 @override
147 String toString() { 153 String toString() {
148 if (file == null) { 154 if (_file == null) {
149 return "<unknown source>"; 155 return "<unknown source>";
150 } 156 }
151 return file.getAbsolutePath(); 157 return _file.getAbsolutePath();
152 } 158 }
153 159
154 /** 160 /**
155 * Get the contents and timestamp of the underlying file. 161 * Get the contents and timestamp of the underlying file.
156 * 162 *
157 * Clients should consider using the the method [AnalysisContext#getContents] 163 * Clients should consider using the the method [AnalysisContext#getContents]
158 * because contexts can have local overrides of the content of a source that t he source is not 164 * because contexts can have local overrides of the content of a source that t he source is not
159 * aware of. 165 * aware of.
160 * 166 *
161 * @return the contents of the source paired with the modification stamp of th e source 167 * @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 168 * @throws Exception if the contents of this source could not be accessed
163 * @see #getContents() 169 * @see #getContents()
164 */ 170 */
165 TimestampedData<String> get contentsFromFile { 171 TimestampedData<String> get contentsFromFile {
166 return new TimestampedData<String>(file.lastModified(), file.readAsStringSyn c()); 172 return new TimestampedData<String>(_file.lastModified(), _file.readAsStringS ync());
167 } 173 }
174
175 /**
176 * Return the file represented by this source. This is an internal method that is only intended to
177 * be used by subclasses of [UriResolver] that are designed to work with file- based sources.
178 *
179 * @return the file represented by this source
180 */
181 JavaFile get file => _file;
168 } 182 }
169 183
170 /** 184 /**
171 * Instances of the class `PackageUriResolver` resolve `package` URI's in the co ntext of 185 * Instances of the class `PackageUriResolver` resolve `package` URI's in the co ntext of
172 * an application. 186 * an application.
173 * 187 *
174 * For the purposes of sharing analysis, the path to each package under the "pac kages" directory 188 * 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 189 * 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. 190 * path from the package directory to the leaf should not.
177 */ 191 */
178 class PackageUriResolver extends UriResolver { 192 class PackageUriResolver extends UriResolver {
179 /** 193 /**
180 * The package directories that `package` URI's are assumed to be relative to. 194 * The package directories that `package` URI's are assumed to be relative to.
181 */ 195 */
182 final List<JavaFile> _packagesDirectories; 196 List<JavaFile> _packagesDirectories;
183 197
184 /** 198 /**
185 * The name of the `package` scheme. 199 * The name of the `package` scheme.
186 */ 200 */
187 static String PACKAGE_SCHEME = "package"; 201 static String PACKAGE_SCHEME = "package";
188 202
189 /** 203 /**
190 * Log exceptions thrown with the message "Required key not available" only on ce. 204 * Log exceptions thrown with the message "Required key not available" only on ce.
191 */ 205 */
192 static bool _CanLogRequiredKeyIoException = true; 206 static bool _CanLogRequiredKeyIoException = true;
193 207
194 /** 208 /**
195 * Return `true` if the given URI is a `package` URI. 209 * Return `true` if the given URI is a `package` URI.
196 * 210 *
197 * @param uri the URI being tested 211 * @param uri the URI being tested
198 * @return `true` if the given URI is a `package` URI 212 * @return `true` if the given URI is a `package` URI
199 */ 213 */
200 static bool isPackageUri(Uri uri) => PACKAGE_SCHEME == uri.scheme; 214 static bool isPackageUri(Uri uri) => PACKAGE_SCHEME == uri.scheme;
201 215
202 /** 216 /**
203 * Initialize a newly created resolver to resolve `package` URI's relative to the given 217 * Initialize a newly created resolver to resolve `package` URI's relative to the given
204 * package directories. 218 * package directories.
205 * 219 *
206 * @param packagesDirectories the package directories that `package` URI's are assumed to be 220 * @param packagesDirectories the package directories that `package` URI's are assumed to be
207 * relative to 221 * relative to
208 */ 222 */
209 PackageUriResolver(this._packagesDirectories) { 223 PackageUriResolver(List<JavaFile> packagesDirectories) {
210 if (_packagesDirectories.length < 1) { 224 if (packagesDirectories.length < 1) {
211 throw new IllegalArgumentException("At least one package directory must be provided"); 225 throw new IllegalArgumentException("At least one package directory must be provided");
212 } 226 }
227 this._packagesDirectories = packagesDirectories;
213 } 228 }
214 229
215 @override 230 @override
216 Source fromEncoding(UriKind kind, Uri uri) { 231 Source fromEncoding(UriKind kind, Uri uri) {
217 if (identical(kind, UriKind.PACKAGE_SELF_URI) || identical(kind, UriKind.PAC KAGE_URI)) { 232 if (identical(kind, UriKind.PACKAGE_SELF_URI) || identical(kind, UriKind.PAC KAGE_URI)) {
218 return new FileBasedSource.con2(new JavaFile.fromUri(uri), kind); 233 return new FileBasedSource.con2(new JavaFile.fromUri(uri), kind);
219 } 234 }
220 return null; 235 return null;
221 } 236 }
222 237
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 425 }
411 426
412 @override 427 @override
413 Source resolveAbsolute(Uri uri) { 428 Source resolveAbsolute(Uri uri) {
414 if (!isFileUri(uri)) { 429 if (!isFileUri(uri)) {
415 return null; 430 return null;
416 } 431 }
417 return new FileBasedSource.con1(new JavaFile.fromUri(uri)); 432 return new FileBasedSource.con1(new JavaFile.fromUri(uri));
418 } 433 }
419 } 434 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/source.dart ('k') | pkg/analyzer/lib/src/generated/utilities_collection.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698