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

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

Issue 12671003: Push new analyzer-experimental with Resolver and ResolverTest. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 3
4 library engine.source.io; 4 library engine.source.io;
5 5
6 import 'source.dart'; 6 import 'source.dart';
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:uri'; 8 import 'dart:uri';
9 import 'java_core.dart'; 9 import 'java_core.dart';
10 import 'java_io.dart'; 10 import 'java_io.dart';
11 import 'package:analyzer-experimental/src/generated/sdk.dart' show DartSdk; 11 import 'package:analyzer-experimental/src/generated/sdk.dart' show DartSdk;
12 export 'source.dart'; 12 export 'source.dart';
13 13
14 /** 14 /**
15 * Instances of the class {@code FileBasedSource} implement a source that repres ents a file. 15 * Instances of the class {@code FileBasedSource} implement a source that repres ents a file.
16 * @coverage dart.engine.source
16 */ 17 */
17 class FileBasedSource implements Source { 18 class FileBasedSource implements Source {
18 /** 19 /**
19 * The source factory that created this source and that should be used to reso lve URI's against 20 * The source factory that created this source and that should be used to reso lve URI's against
20 * this source. 21 * this source.
21 */ 22 */
22 SourceFactory _factory; 23 SourceFactory _factory;
23 /** 24 /**
24 * The file represented by this source. 25 * The file represented by this source.
25 */ 26 */
26 JavaFile _file; 27 JavaFile _file;
27 /** 28 /**
28 * A flag indicating whether this source is in one of the system libraries. 29 * A flag indicating whether this source is in one of the system libraries.
29 */ 30 */
30 bool _inSystemLibrary = false; 31 bool _inSystemLibrary = false;
31 /** 32 /**
32 * Initialize a newly created source object. The source object is assumed to n ot be in a system 33 * Initialize a newly created source object. The source object is assumed to n ot be in a system
33 * library. 34 * library.
34 * @param factory the source factory that created this source 35 * @param factory the source factory that created this source
35 * @param file the file represented by this source 36 * @param file the file represented by this source
36 */ 37 */
37 FileBasedSource.con1(SourceFactory factory, JavaFile file) { 38 FileBasedSource.con1(SourceFactory factory, JavaFile file) {
38 _jtd_constructor_279_impl(factory, file); 39 _jtd_constructor_285_impl(factory, file);
39 } 40 }
40 _jtd_constructor_279_impl(SourceFactory factory, JavaFile file) { 41 _jtd_constructor_285_impl(SourceFactory factory, JavaFile file) {
41 _jtd_constructor_280_impl(factory, file, false); 42 _jtd_constructor_286_impl(factory, file, false);
42 } 43 }
43 /** 44 /**
44 * Initialize a newly created source object. 45 * Initialize a newly created source object.
45 * @param factory the source factory that created this source 46 * @param factory the source factory that created this source
46 * @param file the file represented by this source 47 * @param file the file represented by this source
47 * @param inSystemLibrary {@code true} if this source is in one of the system libraries 48 * @param inSystemLibrary {@code true} if this source is in one of the system libraries
48 */ 49 */
49 FileBasedSource.con2(SourceFactory factory2, JavaFile file3, bool inSystemLibr ary2) { 50 FileBasedSource.con2(SourceFactory factory2, JavaFile file3, bool inSystemLibr ary2) {
50 _jtd_constructor_280_impl(factory2, file3, inSystemLibrary2); 51 _jtd_constructor_286_impl(factory2, file3, inSystemLibrary2);
51 } 52 }
52 _jtd_constructor_280_impl(SourceFactory factory2, JavaFile file3, bool inSyste mLibrary2) { 53 _jtd_constructor_286_impl(SourceFactory factory2, JavaFile file3, bool inSyste mLibrary2) {
53 this._factory = factory2; 54 this._factory = factory2;
54 this._file = file3; 55 this._file = file3;
55 this._inSystemLibrary = inSystemLibrary2; 56 this._inSystemLibrary = inSystemLibrary2;
56 } 57 }
57 bool operator ==(Object object) => object != null && identical(this.runtimeTyp e, object.runtimeType) && _file == ((object as FileBasedSource))._file; 58 bool operator ==(Object object) => object != null && identical(this.runtimeTyp e, object.runtimeType) && _file == ((object as FileBasedSource))._file;
58 bool exists() => _file.exists(); 59 bool exists() => _file.exists();
59 void getContents(Source_ContentReceiver receiver) { 60 void getContents(Source_ContentReceiver receiver) {
61 {
62 String contents = _factory.getContents(this);
63 if (contents != null) {
64 receiver.accept2(contents);
65 return;
66 }
67 }
60 receiver.accept2(_file.readAsStringSync()); 68 receiver.accept2(_file.readAsStringSync());
61 } 69 }
62 String get encoding => _file.toURI().toString(); 70 String get encoding => _file.toURI().toString();
63 String get fullName => _file.getAbsolutePath(); 71 String get fullName => _file.getAbsolutePath();
64 int get modificationStamp { 72 int get modificationStamp {
65 int stamp = _factory.getModificationStamp(this); 73 int stamp = _factory.getModificationStamp(this);
66 if (stamp != null) { 74 if (stamp != null) {
67 return stamp; 75 return stamp;
68 } 76 }
69 return _file.lastModified(); 77 return _file.lastModified();
(...skipping 18 matching lines...) Expand all
88 } 96 }
89 /** 97 /**
90 * Return the file represented by this source. This is an internal method that is only intended to 98 * Return the file represented by this source. This is an internal method that is only intended to
91 * be used by {@link UriResolver}. 99 * be used by {@link UriResolver}.
92 * @return the file represented by this source 100 * @return the file represented by this source
93 */ 101 */
94 JavaFile get file => _file; 102 JavaFile get file => _file;
95 } 103 }
96 /** 104 /**
97 * Instances of the class {@code DartUriResolver} resolve {@code dart} URI's. 105 * Instances of the class {@code DartUriResolver} resolve {@code dart} URI's.
106 * @coverage dart.engine.source
98 */ 107 */
99 class DartUriResolver extends UriResolver { 108 class DartUriResolver extends UriResolver {
100 /** 109 /**
101 * The Dart SDK against which URI's are to be resolved. 110 * The Dart SDK against which URI's are to be resolved.
102 */ 111 */
103 DartSdk _sdk; 112 DartSdk _sdk;
104 /** 113 /**
105 * The name of the {@code dart} scheme. 114 * The name of the {@code dart} scheme.
106 */ 115 */
107 static String _DART_SCHEME = "dart"; 116 static String _DART_SCHEME = "dart";
(...skipping 15 matching lines...) Expand all
123 if (!isDartUri(uri)) { 132 if (!isDartUri(uri)) {
124 return null; 133 return null;
125 } 134 }
126 JavaFile resolvedFile = _sdk.mapDartUri(uri.toString()); 135 JavaFile resolvedFile = _sdk.mapDartUri(uri.toString());
127 return new FileBasedSource.con2(factory, resolvedFile, true); 136 return new FileBasedSource.con2(factory, resolvedFile, true);
128 } 137 }
129 } 138 }
130 /** 139 /**
131 * Instances of the class {@code PackageUriResolver} resolve {@code package} URI 's in the context of 140 * Instances of the class {@code PackageUriResolver} resolve {@code package} URI 's in the context of
132 * an application. 141 * an application.
142 * @coverage dart.engine.source
133 */ 143 */
134 class PackageUriResolver extends UriResolver { 144 class PackageUriResolver extends UriResolver {
135 /** 145 /**
136 * The package directories that {@code package} URI's are assumed to be relati ve to. 146 * The package directories that {@code package} URI's are assumed to be relati ve to.
137 */ 147 */
138 List<JavaFile> _packagesDirectories; 148 List<JavaFile> _packagesDirectories;
139 /** 149 /**
140 * The name of the {@code package} scheme. 150 * The name of the {@code package} scheme.
141 */ 151 */
142 static String _PACKAGE_SCHEME = "package"; 152 static String _PACKAGE_SCHEME = "package";
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 if (resolvedFile.exists()) { 184 if (resolvedFile.exists()) {
175 return new FileBasedSource.con1(factory, resolvedFile); 185 return new FileBasedSource.con1(factory, resolvedFile);
176 } 186 }
177 } 187 }
178 return new FileBasedSource.con1(factory, new JavaFile.relative(_packagesDire ctories[0], path4)); 188 return new FileBasedSource.con1(factory, new JavaFile.relative(_packagesDire ctories[0], path4));
179 } 189 }
180 } 190 }
181 /** 191 /**
182 * Instances of the class {@link DirectoryBasedSourceContainer} represent a sour ce container that 192 * Instances of the class {@link DirectoryBasedSourceContainer} represent a sour ce container that
183 * contains all sources within a given directory. 193 * contains all sources within a given directory.
194 * @coverage dart.engine.source
184 */ 195 */
185 class DirectoryBasedSourceContainer implements SourceContainer { 196 class DirectoryBasedSourceContainer implements SourceContainer {
186 /** 197 /**
187 * Append the system file separator to the given path unless the path already ends with a 198 * Append the system file separator to the given path unless the path already ends with a
188 * separator. 199 * separator.
189 * @param path the path to which the file separator is to be added 200 * @param path the path to which the file separator is to be added
190 * @return a path that ends with the system file separator 201 * @return a path that ends with the system file separator
191 */ 202 */
192 static String appendFileSeparator(String path) { 203 static String appendFileSeparator(String path) {
193 if (path == null || path.length <= 0 || path.codeUnitAt(path.length - 1) == JavaFile.separatorChar) { 204 if (path == null || path.length <= 0 || path.codeUnitAt(path.length - 1) == JavaFile.separatorChar) {
194 return path; 205 return path;
195 } 206 }
196 return "${path}${JavaFile.separator}"; 207 return "${path}${JavaFile.separator}";
197 } 208 }
198 /** 209 /**
199 * The container's path (not {@code null}). 210 * The container's path (not {@code null}).
200 */ 211 */
201 String _path; 212 String _path;
202 /** 213 /**
203 * Construct a container representing the specified directory and containing a ny sources whose{@link Source#getFullName()} starts with the directory's path. T his is a convenience method, 214 * Construct a container representing the specified directory and containing a ny sources whose{@link Source#getFullName()} starts with the directory's path. T his is a convenience method,
204 * fully equivalent to {@link DirectoryBasedSourceContainer#DirectoryBasedSour ceContainer(String)}. 215 * fully equivalent to {@link DirectoryBasedSourceContainer#DirectoryBasedSour ceContainer(String)}.
205 * @param directory the directory (not {@code null}) 216 * @param directory the directory (not {@code null})
206 */ 217 */
207 DirectoryBasedSourceContainer.con1(JavaFile directory) { 218 DirectoryBasedSourceContainer.con1(JavaFile directory) {
208 _jtd_constructor_277_impl(directory); 219 _jtd_constructor_283_impl(directory);
209 } 220 }
210 _jtd_constructor_277_impl(JavaFile directory) { 221 _jtd_constructor_283_impl(JavaFile directory) {
211 _jtd_constructor_278_impl(directory.getPath()); 222 _jtd_constructor_284_impl(directory.getPath());
212 } 223 }
213 /** 224 /**
214 * Construct a container representing the specified path and containing any so urces whose{@link Source#getFullName()} starts with the specified path. 225 * Construct a container representing the specified path and containing any so urces whose{@link Source#getFullName()} starts with the specified path.
215 * @param path the path (not {@code null} and not empty) 226 * @param path the path (not {@code null} and not empty)
216 */ 227 */
217 DirectoryBasedSourceContainer.con2(String path3) { 228 DirectoryBasedSourceContainer.con2(String path3) {
218 _jtd_constructor_278_impl(path3); 229 _jtd_constructor_284_impl(path3);
219 } 230 }
220 _jtd_constructor_278_impl(String path3) { 231 _jtd_constructor_284_impl(String path3) {
221 this._path = appendFileSeparator(path3); 232 this._path = appendFileSeparator(path3);
222 } 233 }
223 bool contains(Source source) => source.fullName.startsWith(_path); 234 bool contains(Source source) => source.fullName.startsWith(_path);
224 bool operator ==(Object obj) => (obj is DirectoryBasedSourceContainer) && ((ob j as DirectoryBasedSourceContainer)).path == path; 235 bool operator ==(Object obj) => (obj is DirectoryBasedSourceContainer) && ((ob j as DirectoryBasedSourceContainer)).path == path;
225 /** 236 /**
226 * Answer the receiver's path, used to determine if a source is contained in t he receiver. 237 * Answer the receiver's path, used to determine if a source is contained in t he receiver.
227 * @return the path (not {@code null}, not empty) 238 * @return the path (not {@code null}, not empty)
228 */ 239 */
229 String get path => _path; 240 String get path => _path;
230 int get hashCode => _path.hashCode; 241 int get hashCode => _path.hashCode;
231 } 242 }
232 /** 243 /**
233 * Instances of the class {@code FileUriResolver} resolve {@code file} URI's. 244 * Instances of the class {@code FileUriResolver} resolve {@code file} URI's.
245 * @coverage dart.engine.source
234 */ 246 */
235 class FileUriResolver extends UriResolver { 247 class FileUriResolver extends UriResolver {
236 /** 248 /**
237 * The name of the {@code file} scheme. 249 * The name of the {@code file} scheme.
238 */ 250 */
239 static String _FILE_SCHEME = "file"; 251 static String _FILE_SCHEME = "file";
240 /** 252 /**
241 * Return {@code true} if the given URI is a {@code file} URI. 253 * Return {@code true} if the given URI is a {@code file} URI.
242 * @param uri the URI being tested 254 * @param uri the URI being tested
243 * @return {@code true} if the given URI is a {@code file} URI 255 * @return {@code true} if the given URI is a {@code file} URI
244 */ 256 */
245 static bool isFileUri(Uri uri) => uri.scheme == _FILE_SCHEME; 257 static bool isFileUri(Uri uri) => uri.scheme == _FILE_SCHEME;
246 /** 258 /**
247 * Initialize a newly created resolver to resolve {@code file} URI's relative to the given root 259 * Initialize a newly created resolver to resolve {@code file} URI's relative to the given root
248 * directory. 260 * directory.
249 */ 261 */
250 FileUriResolver() : super() { 262 FileUriResolver() : super() {
251 } 263 }
252 Source resolveAbsolute(SourceFactory factory, Uri uri) { 264 Source resolveAbsolute(SourceFactory factory, Uri uri) {
253 if (!isFileUri(uri)) { 265 if (!isFileUri(uri)) {
254 return null; 266 return null;
255 } 267 }
256 return new FileBasedSource.con1(factory, new JavaFile.fromUri(uri)); 268 return new FileBasedSource.con1(factory, new JavaFile.fromUri(uri));
257 } 269 }
258 } 270 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698