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

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

Issue 12838003: Rename analyzer-experimental to analyzer_experimental. (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
(Empty)
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.
3
4 library engine.source.io;
5
6 import 'source.dart';
7 import 'dart:io';
8 import 'dart:uri';
9 import 'java_core.dart';
10 import 'java_io.dart';
11 import 'package:analyzer-experimental/src/generated/sdk.dart' show DartSdk;
12 export 'source.dart';
13
14 /**
15 * Instances of the class {@code FileBasedSource} implement a source that repres ents a file.
16 * @coverage dart.engine.source
17 */
18 class FileBasedSource implements Source {
19 /**
20 * The source factory that created this source and that should be used to reso lve URI's against
21 * this source.
22 */
23 SourceFactory _factory;
24 /**
25 * The file represented by this source.
26 */
27 JavaFile _file;
28 /**
29 * A flag indicating whether this source is in one of the system libraries.
30 */
31 bool _inSystemLibrary = false;
32 /**
33 * Initialize a newly created source object. The source object is assumed to n ot be in a system
34 * library.
35 * @param factory the source factory that created this source
36 * @param file the file represented by this source
37 */
38 FileBasedSource.con1(SourceFactory factory, JavaFile file) {
39 _jtd_constructor_285_impl(factory, file);
40 }
41 _jtd_constructor_285_impl(SourceFactory factory, JavaFile file) {
42 _jtd_constructor_286_impl(factory, file, false);
43 }
44 /**
45 * Initialize a newly created source object.
46 * @param factory the source factory that created this source
47 * @param file the file represented by this source
48 * @param inSystemLibrary {@code true} if this source is in one of the system libraries
49 */
50 FileBasedSource.con2(SourceFactory factory2, JavaFile file3, bool inSystemLibr ary2) {
51 _jtd_constructor_286_impl(factory2, file3, inSystemLibrary2);
52 }
53 _jtd_constructor_286_impl(SourceFactory factory2, JavaFile file3, bool inSyste mLibrary2) {
54 this._factory = factory2;
55 this._file = file3;
56 this._inSystemLibrary = inSystemLibrary2;
57 }
58 bool operator ==(Object object) => object != null && identical(this.runtimeTyp e, object.runtimeType) && _file == ((object as FileBasedSource))._file;
59 bool exists() => _file.exists();
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 }
68 receiver.accept2(_file.readAsStringSync());
69 }
70 String get encoding => _file.toURI().toString();
71 String get fullName => _file.getAbsolutePath();
72 int get modificationStamp {
73 int stamp = _factory.getModificationStamp(this);
74 if (stamp != null) {
75 return stamp;
76 }
77 return _file.lastModified();
78 }
79 String get shortName => _file.getName();
80 int get hashCode => _file.hashCode;
81 bool isInSystemLibrary() => _inSystemLibrary;
82 Source resolve(String uri) => _factory.resolveUri(this, uri);
83 Source resolveRelative(Uri containedUri) {
84 try {
85 Uri resolvedUri = file.toURI().resolveUri(containedUri);
86 return new FileBasedSource.con1(_factory, new JavaFile.fromUri(resolvedUri ));
87 } on JavaException catch (exception) {
88 }
89 return null;
90 }
91 String toString() {
92 if (_file == null) {
93 return "<unknown source>";
94 }
95 return _file.getAbsolutePath();
96 }
97 /**
98 * Return the file represented by this source. This is an internal method that is only intended to
99 * be used by {@link UriResolver}.
100 * @return the file represented by this source
101 */
102 JavaFile get file => _file;
103 }
104 /**
105 * Instances of the class {@code DartUriResolver} resolve {@code dart} URI's.
106 * @coverage dart.engine.source
107 */
108 class DartUriResolver extends UriResolver {
109 /**
110 * The Dart SDK against which URI's are to be resolved.
111 */
112 DartSdk _sdk;
113 /**
114 * The name of the {@code dart} scheme.
115 */
116 static String _DART_SCHEME = "dart";
117 /**
118 * Return {@code true} if the given URI is a {@code dart:} URI.
119 * @param uri the URI being tested
120 * @return {@code true} if the given URI is a {@code dart:} URI
121 */
122 static bool isDartUri(Uri uri) => uri.scheme == _DART_SCHEME;
123 /**
124 * Initialize a newly created resolver to resolve Dart URI's against the given platform within the
125 * given Dart SDK.
126 * @param sdk the Dart SDK against which URI's are to be resolved
127 */
128 DartUriResolver(DartSdk sdk) {
129 this._sdk = sdk;
130 }
131 Source resolveAbsolute(SourceFactory factory, Uri uri) {
132 if (!isDartUri(uri)) {
133 return null;
134 }
135 JavaFile resolvedFile = _sdk.mapDartUri(uri.toString());
136 return new FileBasedSource.con2(factory, resolvedFile, true);
137 }
138 }
139 /**
140 * Instances of the class {@code PackageUriResolver} resolve {@code package} URI 's in the context of
141 * an application.
142 * @coverage dart.engine.source
143 */
144 class PackageUriResolver extends UriResolver {
145 /**
146 * The package directories that {@code package} URI's are assumed to be relati ve to.
147 */
148 List<JavaFile> _packagesDirectories;
149 /**
150 * The name of the {@code package} scheme.
151 */
152 static String _PACKAGE_SCHEME = "package";
153 /**
154 * Return {@code true} if the given URI is a {@code package} URI.
155 * @param uri the URI being tested
156 * @return {@code true} if the given URI is a {@code package} URI
157 */
158 static bool isPackageUri(Uri uri) => uri.scheme == _PACKAGE_SCHEME;
159 /**
160 * Initialize a newly created resolver to resolve {@code package} URI's relati ve to the given
161 * package directories.
162 * @param packagesDirectories the package directories that {@code package} URI 's are assumed to be
163 * relative to
164 */
165 PackageUriResolver(List<JavaFile> packagesDirectories) {
166 if (packagesDirectories.length < 1) {
167 throw new IllegalArgumentException("At least one package directory must be provided");
168 }
169 this._packagesDirectories = packagesDirectories;
170 }
171 Source resolveAbsolute(SourceFactory factory, Uri uri) {
172 if (!isPackageUri(uri)) {
173 return null;
174 }
175 String path4 = uri.path;
176 if (path4 == null) {
177 path4 = uri.path;
178 if (path4 == null) {
179 return null;
180 }
181 }
182 for (JavaFile packagesDirectory in _packagesDirectories) {
183 JavaFile resolvedFile = new JavaFile.relative(packagesDirectory, path4);
184 if (resolvedFile.exists()) {
185 return new FileBasedSource.con1(factory, resolvedFile);
186 }
187 }
188 return new FileBasedSource.con1(factory, new JavaFile.relative(_packagesDire ctories[0], path4));
189 }
190 }
191 /**
192 * Instances of the class {@link DirectoryBasedSourceContainer} represent a sour ce container that
193 * contains all sources within a given directory.
194 * @coverage dart.engine.source
195 */
196 class DirectoryBasedSourceContainer implements SourceContainer {
197 /**
198 * Append the system file separator to the given path unless the path already ends with a
199 * separator.
200 * @param path the path to which the file separator is to be added
201 * @return a path that ends with the system file separator
202 */
203 static String appendFileSeparator(String path) {
204 if (path == null || path.length <= 0 || path.codeUnitAt(path.length - 1) == JavaFile.separatorChar) {
205 return path;
206 }
207 return "${path}${JavaFile.separator}";
208 }
209 /**
210 * The container's path (not {@code null}).
211 */
212 String _path;
213 /**
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,
215 * fully equivalent to {@link DirectoryBasedSourceContainer#DirectoryBasedSour ceContainer(String)}.
216 * @param directory the directory (not {@code null})
217 */
218 DirectoryBasedSourceContainer.con1(JavaFile directory) {
219 _jtd_constructor_283_impl(directory);
220 }
221 _jtd_constructor_283_impl(JavaFile directory) {
222 _jtd_constructor_284_impl(directory.getPath());
223 }
224 /**
225 * Construct a container representing the specified path and containing any so urces whose{@link Source#getFullName()} starts with the specified path.
226 * @param path the path (not {@code null} and not empty)
227 */
228 DirectoryBasedSourceContainer.con2(String path3) {
229 _jtd_constructor_284_impl(path3);
230 }
231 _jtd_constructor_284_impl(String path3) {
232 this._path = appendFileSeparator(path3);
233 }
234 bool contains(Source source) => source.fullName.startsWith(_path);
235 bool operator ==(Object obj) => (obj is DirectoryBasedSourceContainer) && ((ob j as DirectoryBasedSourceContainer)).path == path;
236 /**
237 * Answer the receiver's path, used to determine if a source is contained in t he receiver.
238 * @return the path (not {@code null}, not empty)
239 */
240 String get path => _path;
241 int get hashCode => _path.hashCode;
242 }
243 /**
244 * Instances of the class {@code FileUriResolver} resolve {@code file} URI's.
245 * @coverage dart.engine.source
246 */
247 class FileUriResolver extends UriResolver {
248 /**
249 * The name of the {@code file} scheme.
250 */
251 static String _FILE_SCHEME = "file";
252 /**
253 * Return {@code true} if the given URI is a {@code file} URI.
254 * @param uri the URI being tested
255 * @return {@code true} if the given URI is a {@code file} URI
256 */
257 static bool isFileUri(Uri uri) => uri.scheme == _FILE_SCHEME;
258 /**
259 * Initialize a newly created resolver to resolve {@code file} URI's relative to the given root
260 * directory.
261 */
262 FileUriResolver() : super() {
263 }
264 Source resolveAbsolute(SourceFactory factory, Uri uri) {
265 if (!isFileUri(uri)) {
266 return null;
267 }
268 return new FileBasedSource.con1(factory, new JavaFile.fromUri(uri));
269 }
270 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698