@@ -43,78 +43,6 @@ abstract class BasicSource extends Source {
4343 bool operator == (Object object) => object is Source && object.uri == uri;
4444}
4545
46- /// A cache used to override the default content of a [Source] .
47- ///
48- /// TODO(scheglov) Remove it.
49- class ContentCache {
50- /// A table mapping the full path of sources to the contents of those sources.
51- /// This is used to override the default contents of a source.
52- final Map <String , String > _contentMap = {};
53-
54- /// A table mapping the full path of sources to the modification stamps of
55- /// those sources. This is used when the default contents of a source has been
56- /// overridden.
57- final Map <String , int > _stampMap = {};
58-
59- int _nextStamp = 0 ;
60-
61- /// Visit all entries of this cache.
62- void accept (ContentCacheVisitor visitor) {
63- _contentMap.forEach ((String fullPath, String contents) {
64- int stamp = _stampMap[fullPath]! ;
65- visitor (fullPath, stamp, contents);
66- });
67- }
68-
69- /// Return the contents of the given [source] , or `null` if this cache does not
70- /// override the contents of the source.
71- ///
72- /// <b>Note:</b> This method is not intended to be used except by
73- /// [AnalysisContext.getContents] .
74- String ? getContents (Source source) => _contentMap[source.fullName];
75-
76- /// Return `true` if the given [source] exists, `false` if it does not exist,
77- /// or `null` if this cache does not override existence of the source.
78- ///
79- /// <b>Note:</b> This method is not intended to be used except by
80- /// [AnalysisContext.exists] .
81- bool ? getExists (Source source) {
82- return _contentMap.containsKey (source.fullName) ? true : null ;
83- }
84-
85- /// Return the modification stamp of the given [source] , or `null` if this
86- /// cache does not override the contents of the source.
87- ///
88- /// <b>Note:</b> This method is not intended to be used except by
89- /// [AnalysisContext.getModificationStamp] .
90- int ? getModificationStamp (Source source) => _stampMap[source.fullName];
91-
92- /// Set the contents of the given [source] to the given [contents] . This has
93- /// the effect of overriding the default contents of the source. If the
94- /// contents are `null` the override is removed so that the default contents
95- /// will be returned.
96- String ? setContents (Source source, String ? contents) {
97- String fullName = source.fullName;
98- if (contents == null ) {
99- _stampMap.remove (fullName);
100- return _contentMap.remove (fullName);
101- } else {
102- int newStamp = _nextStamp++ ;
103- var oldStamp = _stampMap[fullName];
104- _stampMap[fullName] = newStamp;
105- // Occasionally, if this method is called in rapid succession, the
106- // timestamps are equal. Guard against this by artificially incrementing
107- // the new timestamp.
108- if (newStamp == oldStamp) {
109- _stampMap[fullName] = newStamp + 1 ;
110- }
111- var oldContent = _contentMap[fullName];
112- _contentMap[fullName] = contents;
113- return oldContent;
114- }
115- }
116- }
117-
11846/// Instances of the class `DartUriResolver` resolve `dart` URI's.
11947class DartUriResolver extends UriResolver {
12048 /// The name of the `dart` scheme.
0 commit comments