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

Side by Side Diff: pkg/analyzer/lib/src/generated/engine.dart

Issue 737673002: add source changed event stream (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address comments Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/engine_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine; 8 library engine;
9 9
10 import "dart:math" as math; 10 import "dart:math" as math;
11 import 'dart:async';
11 import 'dart:collection'; 12 import 'dart:collection';
12 13
13 import 'package:analyzer/src/task/task_dart.dart'; 14 import 'package:analyzer/src/task/task_dart.dart';
14 15
15 import 'ast.dart'; 16 import 'ast.dart';
16 import 'constant.dart'; 17 import 'constant.dart';
17 import 'element.dart'; 18 import 'element.dart';
18 import 'error.dart'; 19 import 'error.dart';
19 import 'error_verifier.dart'; 20 import 'error_verifier.dart';
20 import 'html.dart' as ht; 21 import 'html.dart' as ht;
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 /** 374 /**
374 * Return an array containing all of the sources known to this context that re present the defining 375 * Return an array containing all of the sources known to this context that re present the defining
375 * compilation unit of a library. The contents of the array can be incomplete. 376 * compilation unit of a library. The contents of the array can be incomplete.
376 * 377 *
377 * @return the sources known to this context that represent the defining compi lation unit of a 378 * @return the sources known to this context that represent the defining compi lation unit of a
378 * library 379 * library
379 */ 380 */
380 List<Source> get librarySources; 381 List<Source> get librarySources;
381 382
382 /** 383 /**
384 * The stream that is notified when sources have been added or removed,
385 * or the source's content has changed.
386 */
387 Stream<SourcesChangedEvent> get onSourcesChanged;
388
389 /**
383 * Return an array containing all of the sources known to this context and the ir resolution state 390 * Return an array containing all of the sources known to this context and the ir resolution state
384 * is not valid or flush. So, these sources are not safe to update during refa ctoring, because we 391 * is not valid or flush. So, these sources are not safe to update during refa ctoring, because we
385 * may be don't know all the references in them. 392 * may be don't know all the references in them.
386 * 393 *
387 * @return the sources known to this context and are not safe for refactoring 394 * @return the sources known to this context and are not safe for refactoring
388 */ 395 */
389 List<Source> get refactoringUnsafeSources; 396 List<Source> get refactoringUnsafeSources;
390 397
391 /** 398 /**
392 * Return the source factory used to create the sources that can be analyzed i n this context. 399 * Return the source factory used to create the sources that can be analyzed i n this context.
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 * The object used to manage the list of sources that need to be analyzed. 975 * The object used to manage the list of sources that need to be analyzed.
969 */ 976 */
970 WorkManager _workManager = new WorkManager(); 977 WorkManager _workManager = new WorkManager();
971 978
972 /** 979 /**
973 * The set of [AngularApplication] in this context. 980 * The set of [AngularApplication] in this context.
974 */ 981 */
975 Set<AngularApplication> _angularApplications = new Set(); 982 Set<AngularApplication> _angularApplications = new Set();
976 983
977 /** 984 /**
985 * The controller for sending [SourcesChangedEvent]s.
986 */
987 StreamController<SourcesChangedEvent> _onSourcesChangedController;
988
989 /**
990 * The stream that is notified when sources have been added or removed,
991 * or the source's content has changed.
992 */
993 Stream<SourcesChangedEvent> _onSourcesChanged;
994
995 /**
978 * The listeners that are to be notified when various analysis results are pro duced in this 996 * The listeners that are to be notified when various analysis results are pro duced in this
979 * context. 997 * context.
980 */ 998 */
981 List<AnalysisListener> _listeners = new List<AnalysisListener>(); 999 List<AnalysisListener> _listeners = new List<AnalysisListener>();
982 1000
983 /** 1001 /**
984 * Initialize a newly created analysis context. 1002 * Initialize a newly created analysis context.
985 */ 1003 */
986 AnalysisContextImpl() { 1004 AnalysisContextImpl() {
987 _resultRecorder = new AnalysisContextImpl_AnalysisTaskResultRecorder(this); 1005 _resultRecorder = new AnalysisContextImpl_AnalysisTaskResultRecorder(this);
988 _privatePartition = new UniversalCachePartition( 1006 _privatePartition = new UniversalCachePartition(
989 this, 1007 this,
990 AnalysisOptionsImpl.DEFAULT_CACHE_SIZE, 1008 AnalysisOptionsImpl.DEFAULT_CACHE_SIZE,
991 new AnalysisContextImpl_ContextRetentionPolicy(this)); 1009 new AnalysisContextImpl_ContextRetentionPolicy(this));
992 _cache = createCacheFromSourceFactory(null); 1010 _cache = createCacheFromSourceFactory(null);
1011 _onSourcesChangedController = new StreamController<SourcesChangedEvent>();
1012 _onSourcesChanged = _onSourcesChangedController.stream.asBroadcastStream();
993 } 1013 }
994 1014
995 @override 1015 @override
996 AnalysisOptions get analysisOptions => _options; 1016 AnalysisOptions get analysisOptions => _options;
997 1017
998 @override 1018 @override
999 void set analysisOptions(AnalysisOptions options) { 1019 void set analysisOptions(AnalysisOptions options) {
1000 bool needsRecompute = 1020 bool needsRecompute =
1001 this._options.analyzeAngular != options.analyzeAngular || 1021 this._options.analyzeAngular != options.analyzeAngular ||
1002 this._options.analyzeFunctionBodies != options.analyzeFunctionBodies || 1022 this._options.analyzeFunctionBodies != options.analyzeFunctionBodies ||
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 } 1230 }
1211 if (hasBlockedTask) { 1231 if (hasBlockedTask) {
1212 // All of the analysis work is blocked waiting for an asynchronous task 1232 // All of the analysis work is blocked waiting for an asynchronous task
1213 // to complete. 1233 // to complete.
1214 return WaitForAsyncTask.instance; 1234 return WaitForAsyncTask.instance;
1215 } 1235 }
1216 return null; 1236 return null;
1217 } 1237 }
1218 1238
1219 @override 1239 @override
1240 Stream<SourcesChangedEvent> get onSourcesChanged => _onSourcesChanged;
1241
1242 @override
1220 List<Source> get prioritySources => _priorityOrder; 1243 List<Source> get prioritySources => _priorityOrder;
1221 1244
1222 @override 1245 @override
1223 List<Source> get refactoringUnsafeSources { 1246 List<Source> get refactoringUnsafeSources {
1224 List<Source> sources = new List<Source>(); 1247 List<Source> sources = new List<Source>();
1225 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); 1248 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
1226 while (iterator.moveNext()) { 1249 while (iterator.moveNext()) {
1227 SourceEntry sourceEntry = iterator.value; 1250 SourceEntry sourceEntry = iterator.value;
1228 if (sourceEntry is DartEntry) { 1251 if (sourceEntry is DartEntry) {
1229 Source source = iterator.key; 1252 Source source = iterator.key;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 for (Source source in changeSet.changedSources) { 1401 for (Source source in changeSet.changedSources) {
1379 if (_contentCache.getContents(source) != null) { 1402 if (_contentCache.getContents(source) != null) {
1380 // This source is overridden in the content cache, so the change will 1403 // This source is overridden in the content cache, so the change will
1381 // have no effect. Just ignore it to avoid wasting time doing 1404 // have no effect. Just ignore it to avoid wasting time doing
1382 // re-analysis. 1405 // re-analysis.
1383 continue; 1406 continue;
1384 } 1407 }
1385 _sourceChanged(source); 1408 _sourceChanged(source);
1386 } 1409 }
1387 changeSet.changedContents.forEach((Source key, String value) { 1410 changeSet.changedContents.forEach((Source key, String value) {
1388 setContents(key, value); 1411 _contentsChanged(key, value);
1389 }); 1412 });
1390 changeSet.changedRanges.forEach( 1413 changeSet.changedRanges.forEach(
1391 (Source source, ChangeSet_ContentChange change) { 1414 (Source source, ChangeSet_ContentChange change) {
1392 setChangedContents( 1415 _contentRangeChanged(
1393 source, 1416 source,
1394 change.contents, 1417 change.contents,
1395 change.offset, 1418 change.offset,
1396 change.oldLength, 1419 change.oldLength,
1397 change.newLength); 1420 change.newLength);
1398 }); 1421 });
1399 for (Source source in changeSet.deletedSources) { 1422 for (Source source in changeSet.deletedSources) {
1400 _sourceDeleted(source); 1423 _sourceDeleted(source);
1401 } 1424 }
1402 for (Source source in removedSources) { 1425 for (Source source in removedSources) {
(...skipping 22 matching lines...) Expand all
1425 SourceEntry entry = _getReadableSourceEntry(source); 1448 SourceEntry entry = _getReadableSourceEntry(source);
1426 if (entry is DartEntry) { 1449 if (entry is DartEntry) {
1427 entry.invalidateAllResolutionInformation(false); 1450 entry.invalidateAllResolutionInformation(false);
1428 _workManager.add(source, _computePriority(entry)); 1451 _workManager.add(source, _computePriority(entry));
1429 } else if (entry is HtmlEntry) { 1452 } else if (entry is HtmlEntry) {
1430 entry.invalidateAllResolutionInformation(false); 1453 entry.invalidateAllResolutionInformation(false);
1431 _workManager.add(source, SourcePriority.HTML); 1454 _workManager.add(source, SourcePriority.HTML);
1432 } 1455 }
1433 } 1456 }
1434 } 1457 }
1458 _onSourcesChangedController.add(new SourcesChangedEvent(changeSet));
1435 } 1459 }
1436 1460
1437 @override 1461 @override
1438 String computeDocumentationComment(Element element) { 1462 String computeDocumentationComment(Element element) {
1439 if (element == null) { 1463 if (element == null) {
1440 return null; 1464 return null;
1441 } 1465 }
1442 Source source = element.source; 1466 Source source = element.source;
1443 if (source == null) { 1467 if (source == null) {
1444 return null; 1468 return null;
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
2272 2296
2273 @override 2297 @override
2274 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) { 2298 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) {
2275 computeHtmlElement(htmlSource); 2299 computeHtmlElement(htmlSource);
2276 return parseHtmlUnit(htmlSource); 2300 return parseHtmlUnit(htmlSource);
2277 } 2301 }
2278 2302
2279 @override 2303 @override
2280 void setChangedContents(Source source, String contents, int offset, 2304 void setChangedContents(Source source, String contents, int offset,
2281 int oldLength, int newLength) { 2305 int oldLength, int newLength) {
2282 String originalContents = _contentCache.setContents(source, contents); 2306 if (_contentRangeChanged(source, contents, offset, oldLength, newLength)) {
2283 if (contents != null) { 2307 _onSourcesChangedController.add(
2284 if (contents != originalContents) { 2308 new SourcesChangedEvent.changedRange(
2285 if (_options.incremental) { 2309 source, contents, offset, oldLength, newLength));
2286 _incrementalAnalysisCache = IncrementalAnalysisCache.update(
2287 _incrementalAnalysisCache,
2288 source,
2289 originalContents,
2290 contents,
2291 offset,
2292 oldLength,
2293 newLength,
2294 _getReadableSourceEntry(source));
2295 }
2296 _sourceChanged(source);
2297 SourceEntry sourceEntry = _cache.get(source);
2298 if (sourceEntry != null) {
2299 sourceEntry.modificationTime =
2300 _contentCache.getModificationStamp(source);
2301 sourceEntry.setValue(SourceEntry.CONTENT, contents);
2302 }
2303 }
2304 } else if (originalContents != null) {
2305 _incrementalAnalysisCache =
2306 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source);
2307 _sourceChanged(source);
2308 } 2310 }
2309 } 2311 }
2310 2312
2311 @override 2313 @override
2312 void setContents(Source source, String contents) { 2314 void setContents(Source source, String contents) {
2313 String originalContents = _contentCache.setContents(source, contents); 2315 if (_contentsChanged(source, contents)) {
2314 if (contents != null) { 2316 _onSourcesChangedController.add(
2315 if (contents != originalContents) { 2317 new SourcesChangedEvent.changedContent(source, contents));
2316 _incrementalAnalysisCache =
2317 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source);
2318 _sourceChanged(source);
2319 SourceEntry sourceEntry = _cache.get(source);
2320 if (sourceEntry != null) {
2321 sourceEntry.modificationTime =
2322 _contentCache.getModificationStamp(source);
2323 sourceEntry.setValue(SourceEntry.CONTENT, contents);
2324 }
2325 }
2326 } else if (originalContents != null) {
2327 _incrementalAnalysisCache =
2328 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source);
2329 _sourceChanged(source);
2330 } 2318 }
2331 } 2319 }
2332 2320
2333 @override 2321 @override
2334 void visitCacheItems(void callback(Source source, SourceEntry dartEntry, 2322 void visitCacheItems(void callback(Source source, SourceEntry dartEntry,
2335 DataDescriptor rowDesc, CacheState state)) { 2323 DataDescriptor rowDesc, CacheState state)) {
2336 void handleCacheItem(Source source, SourceEntry dartEntry, 2324 void handleCacheItem(Source source, SourceEntry dartEntry,
2337 DataDescriptor descriptor) { 2325 DataDescriptor descriptor) {
2338 callback(source, dartEntry, descriptor, dartEntry.getState(descriptor)); 2326 callback(source, dartEntry, descriptor, dartEntry.getState(descriptor));
2339 } 2327 }
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
2855 bool _containsAny(List<Source> sources, List<Source> targetSources) { 2843 bool _containsAny(List<Source> sources, List<Source> targetSources) {
2856 for (Source targetSource in targetSources) { 2844 for (Source targetSource in targetSources) {
2857 if (_contains(sources, targetSource)) { 2845 if (_contains(sources, targetSource)) {
2858 return true; 2846 return true;
2859 } 2847 }
2860 } 2848 }
2861 return false; 2849 return false;
2862 } 2850 }
2863 2851
2864 /** 2852 /**
2853 * Set the contents of the given source to the given contents and mark the sou rce as having
2854 * changed. The additional offset and length information is used by the contex t to determine what
2855 * reanalysis is necessary. [setChangedContents] triggers a source changed eve nt
2856 * where as this method does not.
2857 *
2858 * @param source the source whose contents are being overridden
2859 * @param contents the text to replace the range in the current contents
2860 * @param offset the offset into the current contents
2861 * @param oldLength the number of characters in the original contents that wer e replaced
2862 * @param newLength the number of characters in the replacement text
2863 */
2864 bool _contentRangeChanged(Source source, String contents, int offset, int oldL ength, int newLength) {
2865 bool changed = false;
2866 String originalContents = _contentCache.setContents(source, contents);
2867 if (contents != null) {
2868 if (contents != originalContents) {
2869 if (_options.incremental) {
2870 _incrementalAnalysisCache = IncrementalAnalysisCache.update(_increment alAnalysisCache, source, originalContents, contents, offset, oldLength, newLengt h, _getReadableSourceEntry(source));
2871 }
2872 _sourceChanged(source);
2873 changed = true;
2874 SourceEntry sourceEntry = _cache.get(source);
2875 if (sourceEntry != null) {
2876 sourceEntry.modificationTime = _contentCache.getModificationStamp(sour ce);
2877 sourceEntry.setValue(SourceEntry.CONTENT, contents);
2878 }
2879 }
2880 } else if (originalContents != null) {
2881 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalAna lysisCache, source);
2882 _sourceChanged(source);
2883 changed = true;
2884 }
2885 return changed;
2886 }
2887
2888 /**
2889 * Set the contents of the given source to the given contents and mark the sou rce as having
2890 * changed. This has the effect of overriding the default contents of the sour ce. If the contents
2891 * are `null` the override is removed so that the default contents will be ret urned.
2892 * [setContents] triggers a source changed event where as this method does not .
2893 *
2894 * @param source the source whose contents are being overridden
2895 * @param contents the new contents of the source
2896 */
2897 bool _contentsChanged(Source source, String contents) {
2898 bool changed = false;
2899 String originalContents = _contentCache.setContents(source, contents);
2900 if (contents != null) {
2901 if (contents != originalContents) {
2902 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA nalysisCache, source);
2903 _sourceChanged(source);
2904 changed = true;
2905 SourceEntry sourceEntry = _cache.get(source);
2906 if (sourceEntry != null) {
2907 sourceEntry.modificationTime = _contentCache.getModificationStamp(sour ce);
2908 sourceEntry.setValue(SourceEntry.CONTENT, contents);
2909 }
2910 }
2911 } else if (originalContents != null) {
2912 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalAna lysisCache, source);
2913 _sourceChanged(source);
2914 changed = true;
2915 }
2916 return changed;
2917 }
2918
2919 /**
2865 * Create a [BuildUnitElementTask] for the given [source]. 2920 * Create a [BuildUnitElementTask] for the given [source].
2866 */ 2921 */
2867 AnalysisContextImpl_TaskData _createBuildUnitElementTask(Source source, 2922 AnalysisContextImpl_TaskData _createBuildUnitElementTask(Source source,
2868 DartEntry dartEntry, Source librarySource) { 2923 DartEntry dartEntry, Source librarySource) {
2869 CompilationUnit unit = dartEntry.resolvableCompilationUnit; 2924 CompilationUnit unit = dartEntry.resolvableCompilationUnit;
2870 if (unit == null) { 2925 if (unit == null) {
2871 return _createParseDartTask(source, dartEntry); 2926 return _createParseDartTask(source, dartEntry);
2872 } 2927 }
2873 return new AnalysisContextImpl_TaskData( 2928 return new AnalysisContextImpl_TaskData(
2874 new BuildUnitElementTask(this, source, librarySource, unit), 2929 new BuildUnitElementTask(this, source, librarySource, unit),
(...skipping 5553 matching lines...) Expand 10 before | Expand all | Expand 10 after
8428 * 8483 *
8429 * @param source the source associated with the entry 8484 * @param source the source associated with the entry
8430 * @param entry the entry associated with the source 8485 * @param entry the entry associated with the source
8431 */ 8486 */
8432 CycleBuilder_SourceEntryPair(Source source, DartEntry entry) { 8487 CycleBuilder_SourceEntryPair(Source source, DartEntry entry) {
8433 this.source = source; 8488 this.source = source;
8434 this.entry = entry; 8489 this.entry = entry;
8435 } 8490 }
8436 } 8491 }
8437 8492
8438
8439 /** 8493 /**
8440 * A `DartEntry` maintains the information cached by an analysis context about 8494 * A `DartEntry` maintains the information cached by an analysis context about
8441 * an individual Dart file. 8495 * an individual Dart file.
8442 */ 8496 */
8443 class DartEntry extends SourceEntry { 8497 class DartEntry extends SourceEntry {
8444 /** 8498 /**
8445 * The data descriptor representing the errors reported during Angular 8499 * The data descriptor representing the errors reported during Angular
8446 * resolution. 8500 * resolution.
8447 */ 8501 */
8448 static final DataDescriptor<List<AnalysisError>> ANGULAR_ERRORS = 8502 static final DataDescriptor<List<AnalysisError>> ANGULAR_ERRORS =
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
9301 _writeStateOn(buffer, "includedParts", INCLUDED_PARTS); 9355 _writeStateOn(buffer, "includedParts", INCLUDED_PARTS);
9302 _writeStateOn(buffer, "element", ELEMENT); 9356 _writeStateOn(buffer, "element", ELEMENT);
9303 _writeStateOn(buffer, "publicNamespace", PUBLIC_NAMESPACE); 9357 _writeStateOn(buffer, "publicNamespace", PUBLIC_NAMESPACE);
9304 _writeStateOn(buffer, "clientServer", IS_CLIENT); 9358 _writeStateOn(buffer, "clientServer", IS_CLIENT);
9305 _writeStateOn(buffer, "launchable", IS_LAUNCHABLE); 9359 _writeStateOn(buffer, "launchable", IS_LAUNCHABLE);
9306 _writeStateOn(buffer, "angularErrors", ANGULAR_ERRORS); 9360 _writeStateOn(buffer, "angularErrors", ANGULAR_ERRORS);
9307 _resolutionState._writeOn(buffer); 9361 _resolutionState._writeOn(buffer);
9308 } 9362 }
9309 } 9363 }
9310 9364
9365
9311 /** 9366 /**
9312 * Instances of the class `DataDescriptor` are immutable constants representing data that can 9367 * Instances of the class `DataDescriptor` are immutable constants representing data that can
9313 * be stored in the cache. 9368 * be stored in the cache.
9314 */ 9369 */
9315 class DataDescriptor<E> { 9370 class DataDescriptor<E> {
9316 /** 9371 /**
9317 * The name of the descriptor, used for debugging purposes. 9372 * The name of the descriptor, used for debugging purposes.
9318 */ 9373 */
9319 final String _name; 9374 final String _name;
9320 9375
(...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after
10527 if (ret != null) { 10582 if (ret != null) {
10528 instrumentation.metric2("Source-count", ret.length); 10583 instrumentation.metric2("Source-count", ret.length);
10529 } 10584 }
10530 return ret; 10585 return ret;
10531 } finally { 10586 } finally {
10532 instrumentation.log(); 10587 instrumentation.log();
10533 } 10588 }
10534 } 10589 }
10535 10590
10536 @override 10591 @override
10592 Stream<SourcesChangedEvent> get onSourcesChanged => _basis.onSourcesChanged;
10593
10594 @override
10537 List<Source> get prioritySources { 10595 List<Source> get prioritySources {
10538 InstrumentationBuilder instrumentation = 10596 InstrumentationBuilder instrumentation =
10539 Instrumentation.builder2("Analysis-getPrioritySources"); 10597 Instrumentation.builder2("Analysis-getPrioritySources");
10540 _checkThread(instrumentation); 10598 _checkThread(instrumentation);
10541 try { 10599 try {
10542 instrumentation.metric3("contextId", _contextId); 10600 instrumentation.metric3("contextId", _contextId);
10543 return _basis.prioritySources; 10601 return _basis.prioritySources;
10544 } finally { 10602 } finally {
10545 instrumentation.log(); 10603 instrumentation.log();
10546 } 10604 }
(...skipping 3844 matching lines...) Expand 10 before | Expand all | Expand 10 after
14391 PRIORITY_PART, 14449 PRIORITY_PART,
14392 LIBRARY, 14450 LIBRARY,
14393 UNKNOWN, 14451 UNKNOWN,
14394 NORMAL_PART, 14452 NORMAL_PART,
14395 HTML]; 14453 HTML];
14396 14454
14397 const SourcePriority(String name, int ordinal) : super(name, ordinal); 14455 const SourcePriority(String name, int ordinal) : super(name, ordinal);
14398 } 14456 }
14399 14457
14400 /** 14458 /**
14459 * [SourcesChangedEvent] indicates which sources have been added, removed,
14460 * or whose contents have changed.
14461 */
14462 class SourcesChangedEvent {
14463
14464 /**
14465 * The internal representation of what has changed.
14466 * Clients should not access this field directly.
14467 */
14468 final ChangeSet _changeSet;
14469
14470 /**
14471 * Construct an instance representing the given changes.
14472 */
14473 SourcesChangedEvent(ChangeSet changeSet) : _changeSet = changeSet;
14474
14475 /**
14476 * Construct an instance representing a source content change.
14477 */
14478 factory SourcesChangedEvent.changedContent(Source source, String contents) {
14479 ChangeSet changeSet = new ChangeSet();
14480 changeSet.changedContent(source, contents);
14481 return new SourcesChangedEvent(changeSet);
14482 }
14483
14484 /**
14485 * Construct an instance representing a source content change.
14486 */
14487 factory SourcesChangedEvent.changedRange(Source source, String contents,
14488 int offset, int oldLength, int newLength) {
14489 ChangeSet changeSet = new ChangeSet();
14490 changeSet.changedRange(source, contents, offset, oldLength, newLength);
14491 return new SourcesChangedEvent(changeSet);
14492 }
14493
14494 /**
14495 * Return the collection of sources for which content has changed.
14496 */
14497 Iterable<Source> get changedSources {
14498 List<Source> changedSources = new List.from(_changeSet.changedSources);
14499 changedSources.addAll(_changeSet.changedContents.keys);
14500 changedSources.addAll(_changeSet.changedRanges.keys);
14501 return changedSources;
14502 }
14503
14504 /**
14505 * Return `true` if any sources were added.
14506 */
14507 bool get wereSourcesAdded => _changeSet.addedSources.length > 0;
14508
14509 /**
14510 * Return `true` if any sources were removed or deleted.
14511 */
14512 bool get wereSourcesRemovedOrDeleted => _changeSet.removedSources.length > 0
14513 || _changeSet.removedContainers.length > 0
14514 || _changeSet.deletedSources.length > 0;
14515 }
14516
14517 /**
14401 * Instances of the class `TimestampedData` represent analysis data for which we have a 14518 * Instances of the class `TimestampedData` represent analysis data for which we have a
14402 * modification time. 14519 * modification time.
14403 */ 14520 */
14404 class TimestampedData<E> { 14521 class TimestampedData<E> {
14405 /** 14522 /**
14406 * The modification time of the source from which the data was created. 14523 * The modification time of the source from which the data was created.
14407 */ 14524 */
14408 final int modificationTime; 14525 final int modificationTime;
14409 14526
14410 /** 14527 /**
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
14688 14805
14689 @override 14806 @override
14690 Object visitPolymerTagDartElement(PolymerTagDartElement element) { 14807 Object visitPolymerTagDartElement(PolymerTagDartElement element) {
14691 if (element.name == PolymerHtmlUnitBuilder_this._elementName) { 14808 if (element.name == PolymerHtmlUnitBuilder_this._elementName) {
14692 throw new PolymerHtmlUnitBuilder_FoundTagDartElementError( 14809 throw new PolymerHtmlUnitBuilder_FoundTagDartElementError(
14693 element as PolymerTagDartElementImpl); 14810 element as PolymerTagDartElementImpl);
14694 } 14811 }
14695 return null; 14812 return null;
14696 } 14813 }
14697 } 14814 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/engine_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698