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

Side by Side Diff: pkg/front_end/lib/src/base/source.dart

Issue 2486923007: Create pkg/front_end/src/base and begin populating with general use classes. (Closed)
Patch Set: Fix formatting Created 4 years, 1 month 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
OLDNEW
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
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.
4
5 import 'package:front_end/src/base/analysis_target.dart';
6 import 'package:front_end/src/base/timestamped_data.dart';
7 import 'package:front_end/src/base/uri_kind.dart';
8
9 /**
10 * The interface `Source` defines the behavior of objects representing source co de that can be
11 * analyzed by the analysis engine.
12 *
13 * Implementations of this interface need to be aware of some assumptions made b y the analysis
14 * engine concerning sources:
15 * * Sources are not required to be unique. That is, there can be multiple insta nces representing
16 * the same source.
17 * * Sources are long lived. That is, the engine is allowed to hold on to a sour ce for an extended
18 * period of time and that source must continue to report accurate and up-to-dat e information.
19 * Because of these assumptions, most implementations will not maintain any stat e but will delegate
20 * to an authoritative system of record in order to implement this API. For exam ple, a source that
21 * represents files on disk would typically query the file system to determine t he state of the
22 * file.
23 *
24 * If the instances that implement this API are the system of record, then they will typically be
25 * unique. In that case, sources that are created that represent non-existent fi les must also be
26 * retained so that if those files are created at a later date the long-lived so urces representing
27 * those files will know that they now exist.
28 */
29 abstract class Source implements AnalysisTarget {
30 /**
31 * An empty list of sources.
32 */
33 static const List<Source> EMPTY_LIST = const <Source>[];
34
35 /**
36 * Get the contents and timestamp of this source.
37 *
38 * Clients should consider using the method [AnalysisContext.getContents]
39 * because contexts can have local overrides of the content of a source that t he source is not
40 * aware of.
41 *
42 * @return the contents and timestamp of the source
43 * @throws Exception if the contents of this source could not be accessed
44 */
45 TimestampedData<String> get contents;
46
47 /**
48 * Return an encoded representation of this source that can be used to create a source that is
49 * equal to this source.
50 *
51 * @return an encoded representation of this source
52 * See [SourceFactory.fromEncoding].
53 */
54 String get encoding;
55
56 /**
57 * Return the full (long) version of the name that can be displayed to the use r to denote this
58 * source. For example, for a source representing a file this would typically be the absolute path
59 * of the file.
60 *
61 * @return a name that can be displayed to the user to denote this source
62 */
63 String get fullName;
64
65 /**
66 * Return a hash code for this source.
67 *
68 * @return a hash code for this source
69 * See [Object.hashCode].
70 */
71 @override
72 int get hashCode;
73
74 /**
75 * Return `true` if this source is in one of the system libraries.
76 *
77 * @return `true` if this is in a system library
78 */
79 bool get isInSystemLibrary;
80
81 @override
82 Source get librarySource => null;
83
84 /**
85 * Return the modification stamp for this source, or a negative value if the
86 * source does not exist. A modification stamp is a non-negative integer with
87 * the property that if the contents of the source have not been modified
88 * since the last time the modification stamp was accessed then the same value
89 * will be returned, but if the contents of the source have been modified one
90 * or more times (even if the net change is zero) the stamps will be different .
91 *
92 * Clients should consider using the method
93 * [AnalysisContext.getModificationStamp] because contexts can have local
94 * overrides of the content of a source that the source is not aware of.
95 */
96 int get modificationStamp;
97
98 /**
99 * Return a short version of the name that can be displayed to the user to den ote this source. For
100 * example, for a source representing a file this would typically be the name of the file.
101 *
102 * @return a name that can be displayed to the user to denote this source
103 */
104 String get shortName;
105
106 @override
107 Source get source => this;
108
109 /**
110 * Return the URI from which this source was originally derived.
111 *
112 * @return the URI from which this source was originally derived
113 */
114 Uri get uri;
115
116 /**
117 * Return the kind of URI from which this source was originally derived. If th is source was
118 * created from an absolute URI, then the returned kind will reflect the schem e of the absolute
119 * URI. If it was created from a relative URI, then the returned kind will be the same as the kind
120 * of the source against which the relative URI was resolved.
121 *
122 * @return the kind of URI from which this source was originally derived
123 */
124 UriKind get uriKind;
125
126 /**
127 * Return `true` if the given object is a source that represents the same sour ce code as
128 * this source.
129 *
130 * @param object the object to be compared with this object
131 * @return `true` if the given object is a source that represents the same sou rce code as
132 * this source
133 * See [Object.==].
134 */
135 @override
136 bool operator ==(Object object);
137
138 /**
139 * Return `true` if this source exists.
140 *
141 * Clients should consider using the method [AnalysisContext.exists] because
142 * contexts can have local overrides of the content of a source that the sourc e is not aware of
143 * and a source with local content is considered to exist even if there is no file on disk.
144 *
145 * @return `true` if this source exists
146 */
147 bool exists();
148 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/base/errors.dart ('k') | pkg/front_end/lib/src/base/syntactic_entity.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698