OLD | NEW |
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 */ | 16 */ |
17 class FileBasedSource implements Source { | 17 class FileBasedSource implements Source { |
18 /** | 18 /** |
19 * The source factory that created this source and that should be used to reso
lve URI's against | 19 * The source factory that created this source and that should be used to reso
lve URI's against |
20 * this source. | 20 * this source. |
21 */ | 21 */ |
22 SourceFactory _factory; | 22 SourceFactory _factory; |
23 /** | 23 /** |
24 * The file represented by this source. | 24 * The file represented by this source. |
25 */ | 25 */ |
26 File _file; | 26 JavaFile _file; |
27 /** | 27 /** |
28 * A flag indicating whether this source is in one of the system libraries. | 28 * A flag indicating whether this source is in one of the system libraries. |
29 */ | 29 */ |
30 bool _inSystemLibrary = false; | 30 bool _inSystemLibrary = false; |
31 /** | 31 /** |
32 * Initialize a newly created source object. The source object is assumed to n
ot be in a system | 32 * Initialize a newly created source object. The source object is assumed to n
ot be in a system |
33 * library. | 33 * library. |
34 * @param factory the source factory that created this source | 34 * @param factory the source factory that created this source |
35 * @param file the file represented by this source | 35 * @param file the file represented by this source |
36 */ | 36 */ |
37 FileBasedSource.con1(SourceFactory factory, File file) { | 37 FileBasedSource.con1(SourceFactory factory, JavaFile file) { |
38 _jtd_constructor_278_impl(factory, file); | 38 _jtd_constructor_278_impl(factory, file); |
39 } | 39 } |
40 _jtd_constructor_278_impl(SourceFactory factory, File file) { | 40 _jtd_constructor_278_impl(SourceFactory factory, JavaFile file) { |
41 _jtd_constructor_279_impl(factory, file, false); | 41 _jtd_constructor_279_impl(factory, file, false); |
42 } | 42 } |
43 /** | 43 /** |
44 * Initialize a newly created source object. | 44 * Initialize a newly created source object. |
45 * @param factory the source factory that created this source | 45 * @param factory the source factory that created this source |
46 * @param file the file represented by this source | 46 * @param file the file represented by this source |
47 * @param inSystemLibrary {@code true} if this source is in one of the system
libraries | 47 * @param inSystemLibrary {@code true} if this source is in one of the system
libraries |
48 */ | 48 */ |
49 FileBasedSource.con2(SourceFactory factory2, File file3, bool inSystemLibrary2
) { | 49 FileBasedSource.con2(SourceFactory factory2, JavaFile file3, bool inSystemLibr
ary2) { |
50 _jtd_constructor_279_impl(factory2, file3, inSystemLibrary2); | 50 _jtd_constructor_279_impl(factory2, file3, inSystemLibrary2); |
51 } | 51 } |
52 _jtd_constructor_279_impl(SourceFactory factory2, File file3, bool inSystemLib
rary2) { | 52 _jtd_constructor_279_impl(SourceFactory factory2, JavaFile file3, bool inSyste
mLibrary2) { |
53 this._factory = factory2; | 53 this._factory = factory2; |
54 this._file = file3; | 54 this._file = file3; |
55 this._inSystemLibrary = inSystemLibrary2; | 55 this._inSystemLibrary = inSystemLibrary2; |
56 } | 56 } |
57 bool operator ==(Object object) => object != null && identical(this.runtimeTyp
e, object.runtimeType) && _file == ((object as FileBasedSource))._file; | 57 bool operator ==(Object object) => object != null && identical(this.runtimeTyp
e, object.runtimeType) && _file == ((object as FileBasedSource))._file; |
58 bool exists() => _file.existsSync(); | 58 bool exists() => _file.exists(); |
59 void getContents(Source_ContentReceiver receiver) { | 59 void getContents(Source_ContentReceiver receiver) { |
60 receiver.accept2(_file.readAsStringSync()); | 60 receiver.accept2(_file.readAsStringSync()); |
61 } | 61 } |
62 String get encoding => newUriFromFile(_file).toString(); | 62 String get encoding => _file.toURI().toString(); |
63 String get fullName => _file.fullPathSync(); | 63 String get fullName => _file.getAbsolutePath(); |
64 String get shortName => _file.path; | 64 String get shortName => _file.getName(); |
65 int get hashCode => _file.hashCode; | 65 int get hashCode => _file.hashCode; |
66 bool isInSystemLibrary() => _inSystemLibrary; | 66 bool isInSystemLibrary() => _inSystemLibrary; |
67 Source resolve(String uri) => _factory.resolveUri(this, uri); | 67 Source resolve(String uri) => _factory.resolveUri(this, uri); |
68 Source resolveRelative(Uri containedUri) { | 68 Source resolveRelative(Uri containedUri) { |
69 try { | 69 try { |
70 Uri resolvedUri = newUriFromFile(file).resolveUri(containedUri); | 70 Uri resolvedUri = file.toURI().resolveUri(containedUri); |
71 return new FileBasedSource.con1(_factory, newFileFromUri(resolvedUri)); | 71 return new FileBasedSource.con1(_factory, new JavaFile.fromUri(resolvedUri
)); |
72 } on JavaException catch (exception) { | 72 } on JavaException catch (exception) { |
73 } | 73 } |
74 return null; | 74 return null; |
75 } | 75 } |
76 String toString() { | 76 String toString() { |
77 if (_file == null) { | 77 if (_file == null) { |
78 return "<unknown source>"; | 78 return "<unknown source>"; |
79 } | 79 } |
80 return _file.fullPathSync(); | 80 return _file.getAbsolutePath(); |
81 } | 81 } |
82 /** | 82 /** |
83 * Return the file represented by this source. This is an internal method that
is only intended to | 83 * Return the file represented by this source. This is an internal method that
is only intended to |
84 * be used by {@link UriResolver}. | 84 * be used by {@link UriResolver}. |
85 * @return the file represented by this source | 85 * @return the file represented by this source |
86 */ | 86 */ |
87 File get file => _file; | 87 JavaFile get file => _file; |
88 } | 88 } |
89 /** | 89 /** |
90 * Instances of the class {@code DartUriResolver} resolve {@code dart} URI's. | 90 * Instances of the class {@code DartUriResolver} resolve {@code dart} URI's. |
91 */ | 91 */ |
92 class DartUriResolver extends UriResolver { | 92 class DartUriResolver extends UriResolver { |
93 /** | 93 /** |
94 * The Dart SDK against which URI's are to be resolved. | 94 * The Dart SDK against which URI's are to be resolved. |
95 */ | 95 */ |
96 DartSdk _sdk; | 96 DartSdk _sdk; |
97 /** | 97 /** |
(...skipping 11 matching lines...) Expand all Loading... |
109 * given Dart SDK. | 109 * given Dart SDK. |
110 * @param sdk the Dart SDK against which URI's are to be resolved | 110 * @param sdk the Dart SDK against which URI's are to be resolved |
111 */ | 111 */ |
112 DartUriResolver(DartSdk sdk) { | 112 DartUriResolver(DartSdk sdk) { |
113 this._sdk = sdk; | 113 this._sdk = sdk; |
114 } | 114 } |
115 Source resolveAbsolute(SourceFactory factory, Uri uri) { | 115 Source resolveAbsolute(SourceFactory factory, Uri uri) { |
116 if (!isDartUri(uri)) { | 116 if (!isDartUri(uri)) { |
117 return null; | 117 return null; |
118 } | 118 } |
119 File resolvedFile = _sdk.mapDartUri(uri.toString()); | 119 JavaFile resolvedFile = _sdk.mapDartUri(uri.toString()); |
120 return new FileBasedSource.con2(factory, resolvedFile, true); | 120 return new FileBasedSource.con2(factory, resolvedFile, true); |
121 } | 121 } |
122 } | 122 } |
123 /** | 123 /** |
124 * Instances of the class {@code PackageUriResolver} resolve {@code package} URI
's in the context of | 124 * Instances of the class {@code PackageUriResolver} resolve {@code package} URI
's in the context of |
125 * an application. | 125 * an application. |
126 */ | 126 */ |
127 class PackageUriResolver extends UriResolver { | 127 class PackageUriResolver extends UriResolver { |
128 /** | 128 /** |
129 * The package directories that {@code package} URI's are assumed to be relati
ve to. | 129 * The package directories that {@code package} URI's are assumed to be relati
ve to. |
130 */ | 130 */ |
131 List<File> _packagesDirectories; | 131 List<JavaFile> _packagesDirectories; |
132 /** | 132 /** |
133 * The name of the {@code package} scheme. | 133 * The name of the {@code package} scheme. |
134 */ | 134 */ |
135 static String _PACKAGE_SCHEME = "package"; | 135 static String _PACKAGE_SCHEME = "package"; |
136 /** | 136 /** |
137 * Return {@code true} if the given URI is a {@code package} URI. | 137 * Return {@code true} if the given URI is a {@code package} URI. |
138 * @param uri the URI being tested | 138 * @param uri the URI being tested |
139 * @return {@code true} if the given URI is a {@code package} URI | 139 * @return {@code true} if the given URI is a {@code package} URI |
140 */ | 140 */ |
141 static bool isPackageUri(Uri uri) => uri.scheme == _PACKAGE_SCHEME; | 141 static bool isPackageUri(Uri uri) => uri.scheme == _PACKAGE_SCHEME; |
142 /** | 142 /** |
143 * Initialize a newly created resolver to resolve {@code package} URI's relati
ve to the given | 143 * Initialize a newly created resolver to resolve {@code package} URI's relati
ve to the given |
144 * package directories. | 144 * package directories. |
145 * @param packagesDirectories the package directories that {@code package} URI
's are assumed to be | 145 * @param packagesDirectories the package directories that {@code package} URI
's are assumed to be |
146 * relative to | 146 * relative to |
147 */ | 147 */ |
148 PackageUriResolver(List<File> packagesDirectories) { | 148 PackageUriResolver(List<JavaFile> packagesDirectories) { |
149 if (packagesDirectories.length < 1) { | 149 if (packagesDirectories.length < 1) { |
150 throw new IllegalArgumentException("At least one package directory must be
provided"); | 150 throw new IllegalArgumentException("At least one package directory must be
provided"); |
151 } | 151 } |
152 this._packagesDirectories = packagesDirectories; | 152 this._packagesDirectories = packagesDirectories; |
153 } | 153 } |
154 Source resolveAbsolute(SourceFactory factory, Uri uri) { | 154 Source resolveAbsolute(SourceFactory factory, Uri uri) { |
155 if (!isPackageUri(uri)) { | 155 if (!isPackageUri(uri)) { |
156 return null; | 156 return null; |
157 } | 157 } |
158 String path4 = uri.path; | 158 String path4 = uri.path; |
159 if (path4 == null) { | 159 if (path4 == null) { |
160 path4 = uri.path; | 160 path4 = uri.path; |
161 if (path4 == null) { | 161 if (path4 == null) { |
162 return null; | 162 return null; |
163 } | 163 } |
164 } | 164 } |
165 for (File packagesDirectory in _packagesDirectories) { | 165 for (JavaFile packagesDirectory in _packagesDirectories) { |
166 File resolvedFile = newRelativeFile(packagesDirectory, path4); | 166 JavaFile resolvedFile = new JavaFile.relative(packagesDirectory, path4); |
167 if (resolvedFile.existsSync()) { | 167 if (resolvedFile.exists()) { |
168 return new FileBasedSource.con1(factory, resolvedFile); | 168 return new FileBasedSource.con1(factory, resolvedFile); |
169 } | 169 } |
170 } | 170 } |
171 return new FileBasedSource.con1(factory, newRelativeFile(_packagesDirectorie
s[0], path4)); | 171 return new FileBasedSource.con1(factory, new JavaFile.relative(_packagesDire
ctories[0], path4)); |
172 } | 172 } |
173 } | 173 } |
174 /** | 174 /** |
175 * Instances of the class {@link DirectoryBasedSourceContainer} represent a sour
ce container that | 175 * Instances of the class {@link DirectoryBasedSourceContainer} represent a sour
ce container that |
176 * contains all sources within a given directory. | 176 * contains all sources within a given directory. |
177 */ | 177 */ |
178 class DirectoryBasedSourceContainer implements SourceContainer { | 178 class DirectoryBasedSourceContainer implements SourceContainer { |
179 /** | 179 /** |
180 * Append the system file separator to the given path unless the path already
ends with a | 180 * Append the system file separator to the given path unless the path already
ends with a |
181 * separator. | 181 * separator. |
182 * @param path the path to which the file separator is to be added | 182 * @param path the path to which the file separator is to be added |
183 * @return a path that ends with the system file separator | 183 * @return a path that ends with the system file separator |
184 */ | 184 */ |
185 static String appendFileSeparator(String path) { | 185 static String appendFileSeparator(String path) { |
186 if (path == null || path.length <= 0 || path.codeUnitAt(path.length - 1) ==
JavaSystemIO.pathSeparatorChar) { | 186 if (path == null || path.length <= 0 || path.codeUnitAt(path.length - 1) ==
JavaFile.separatorChar) { |
187 return path; | 187 return path; |
188 } | 188 } |
189 return "${path}${JavaSystemIO.pathSeparator}"; | 189 return "${path}${JavaFile.separator}"; |
190 } | 190 } |
191 /** | 191 /** |
192 * The container's path (not {@code null}). | 192 * The container's path (not {@code null}). |
193 */ | 193 */ |
194 String _path; | 194 String _path; |
195 /** | 195 /** |
196 * 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, | 196 * 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, |
197 * fully equivalent to {@link DirectoryBasedSourceContainer#DirectoryBasedSour
ceContainer(String)}. | 197 * fully equivalent to {@link DirectoryBasedSourceContainer#DirectoryBasedSour
ceContainer(String)}. |
198 * @param directory the directory (not {@code null}) | 198 * @param directory the directory (not {@code null}) |
199 */ | 199 */ |
200 DirectoryBasedSourceContainer.con1(File directory) { | 200 DirectoryBasedSourceContainer.con1(JavaFile directory) { |
201 _jtd_constructor_276_impl(directory); | 201 _jtd_constructor_276_impl(directory); |
202 } | 202 } |
203 _jtd_constructor_276_impl(File directory) { | 203 _jtd_constructor_276_impl(JavaFile directory) { |
204 _jtd_constructor_277_impl(directory.fullPathSync()); | 204 _jtd_constructor_277_impl(directory.getPath()); |
205 } | 205 } |
206 /** | 206 /** |
207 * Construct a container representing the specified path and containing any so
urces whose{@link Source#getFullName()} starts with the specified path. | 207 * Construct a container representing the specified path and containing any so
urces whose{@link Source#getFullName()} starts with the specified path. |
208 * @param path the path (not {@code null} and not empty) | 208 * @param path the path (not {@code null} and not empty) |
209 */ | 209 */ |
210 DirectoryBasedSourceContainer.con2(String path3) { | 210 DirectoryBasedSourceContainer.con2(String path3) { |
211 _jtd_constructor_277_impl(path3); | 211 _jtd_constructor_277_impl(path3); |
212 } | 212 } |
213 _jtd_constructor_277_impl(String path3) { | 213 _jtd_constructor_277_impl(String path3) { |
214 this._path = appendFileSeparator(path3); | 214 this._path = appendFileSeparator(path3); |
(...skipping 24 matching lines...) Expand all Loading... |
239 /** | 239 /** |
240 * Initialize a newly created resolver to resolve {@code file} URI's relative
to the given root | 240 * Initialize a newly created resolver to resolve {@code file} URI's relative
to the given root |
241 * directory. | 241 * directory. |
242 */ | 242 */ |
243 FileUriResolver() : super() { | 243 FileUriResolver() : super() { |
244 } | 244 } |
245 Source resolveAbsolute(SourceFactory factory, Uri uri) { | 245 Source resolveAbsolute(SourceFactory factory, Uri uri) { |
246 if (!isFileUri(uri)) { | 246 if (!isFileUri(uri)) { |
247 return null; | 247 return null; |
248 } | 248 } |
249 return new FileBasedSource.con1(factory, newFileFromUri(uri)); | 249 return new FileBasedSource.con1(factory, new JavaFile.fromUri(uri)); |
250 } | 250 } |
251 } | 251 } |
OLD | NEW |