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

Side by Side Diff: pkg/analyzer/lib/src/context/context.dart

Issue 1181603004: Add AnalysisContext.onResultComputed(). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library analyzer.src.context.context; 5 library analyzer.src.context.context;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/instrumentation/instrumentation.dart'; 10 import 'package:analyzer/instrumentation/instrumentation.dart';
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 return entry.getValue(IS_CLIENT) && entry.getValue(IS_LAUNCHABLE); 1008 return entry.getValue(IS_CLIENT) && entry.getValue(IS_LAUNCHABLE);
1009 } 1009 }
1010 1010
1011 @override 1011 @override
1012 bool isServerLibrary(Source librarySource) { 1012 bool isServerLibrary(Source librarySource) {
1013 CacheEntry entry = _cache.get(librarySource); 1013 CacheEntry entry = _cache.get(librarySource);
1014 return !entry.getValue(IS_CLIENT) && entry.getValue(IS_LAUNCHABLE); 1014 return !entry.getValue(IS_CLIENT) && entry.getValue(IS_LAUNCHABLE);
1015 } 1015 }
1016 1016
1017 @override 1017 @override
1018 Stream<ResultComputedEvent> onResultComputed(ResultDescriptor descriptor) {
1019 return driver.onResultComputed(descriptor);
1020 }
1021
1022 @override
1018 CompilationUnit parseCompilationUnit(Source source) { 1023 CompilationUnit parseCompilationUnit(Source source) {
1019 if (!AnalysisEngine.isDartFileName(source.shortName)) { 1024 if (!AnalysisEngine.isDartFileName(source.shortName)) {
1020 return null; 1025 return null;
1021 } 1026 }
1022 try { 1027 try {
1023 getContents(source); 1028 getContents(source);
1024 } catch (exception, stackTrace) { 1029 } catch (exception, stackTrace) {
1025 throw new AnalysisException('Could not get contents of $source', 1030 throw new AnalysisException('Could not get contents of $source',
1026 new CaughtException(exception, stackTrace)); 1031 new CaughtException(exception, stackTrace));
1027 } 1032 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 entry = getCacheEntry(unit); 1107 entry = getCacheEntry(unit);
1103 setValue(HINTS, AnalysisError.NO_ERRORS); 1108 setValue(HINTS, AnalysisError.NO_ERRORS);
1104 // dartEntry.setValue(LINTS, AnalysisError.NO_ERRORS); 1109 // dartEntry.setValue(LINTS, AnalysisError.NO_ERRORS);
1105 entry.setState(RESOLVE_REFERENCES_ERRORS, CacheState.FLUSHED); 1110 entry.setState(RESOLVE_REFERENCES_ERRORS, CacheState.FLUSHED);
1106 entry.setState(RESOLVED_UNIT, CacheState.FLUSHED); 1111 entry.setState(RESOLVED_UNIT, CacheState.FLUSHED);
1107 entry.setState(RESOLVED_UNIT1, CacheState.FLUSHED); 1112 entry.setState(RESOLVED_UNIT1, CacheState.FLUSHED);
1108 entry.setState(RESOLVED_UNIT2, CacheState.FLUSHED); 1113 entry.setState(RESOLVED_UNIT2, CacheState.FLUSHED);
1109 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED); 1114 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED);
1110 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED); 1115 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED);
1111 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED); 1116 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED);
1112 entry.setState(RESOLVED_UNIT6, CacheState.FLUSHED); 1117 entry.setState(RESOLVED_UNIT_NO_CONSTANTS, CacheState.FLUSHED);
1113 // USED_IMPORTED_ELEMENTS 1118 // USED_IMPORTED_ELEMENTS
1114 // USED_LOCAL_ELEMENTS 1119 // USED_LOCAL_ELEMENTS
1115 setValue(VERIFY_ERRORS, AnalysisError.NO_ERRORS); 1120 setValue(VERIFY_ERRORS, AnalysisError.NO_ERRORS);
1116 }); 1121 });
1117 1122
1118 CacheEntry entry = getCacheEntry(AnalysisContextTarget.request); 1123 CacheEntry entry = getCacheEntry(AnalysisContextTarget.request);
1119 entry.setValue(TYPE_PROVIDER, typeProvider, TargetedResult.EMPTY_LIST); 1124 entry.setValue(TYPE_PROVIDER, typeProvider, TargetedResult.EMPTY_LIST);
1120 } 1125 }
1121 1126
1122 @override 1127 @override
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
1907 _completer.completeError(exception, stackTrace); 1912 _completer.completeError(exception, stackTrace);
1908 } 1913 }
1909 } 1914 }
1910 1915
1911 void _onCancel() { 1916 void _onCancel() {
1912 _context._cancelFuture(this); 1917 _context._cancelFuture(this);
1913 } 1918 }
1914 } 1919 }
1915 1920
1916 /** 1921 /**
1917 * [ResultComputedEvent] describes a value computed for a [ResultDescriptor].
1918 */
1919 class ResultComputedEvent<V> {
1920 /**
1921 * The context in which the value was computed.
1922 */
1923 final AnalysisContext context;
1924
1925 /**
1926 * The descriptor of the result which was computed.
1927 */
1928 final ResultDescriptor<V> descriptor;
1929
1930 /**
1931 * The target for which the result was computed.
1932 */
1933 final AnalysisTarget target;
1934
1935 /**
1936 * The computed value.
1937 */
1938 final V value;
1939
1940 ResultComputedEvent(this.context, this.descriptor, this.target, this.value);
1941
1942 @override
1943 String toString() => '$value for $descriptor of $target in $context';
1944 }
1945
1946 /**
1947 * An [AnalysisContext] that only contains sources for a Dart SDK. 1922 * An [AnalysisContext] that only contains sources for a Dart SDK.
1948 */ 1923 */
1949 class SdkAnalysisContext extends AnalysisContextImpl { 1924 class SdkAnalysisContext extends AnalysisContextImpl {
1950 @override 1925 @override
1951 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { 1926 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) {
1952 if (factory == null) { 1927 if (factory == null) {
1953 return super.createCacheFromSourceFactory(factory); 1928 return super.createCacheFromSourceFactory(factory);
1954 } 1929 }
1955 DartSdk sdk = factory.dartSdk; 1930 DartSdk sdk = factory.dartSdk;
1956 if (sdk == null) { 1931 if (sdk == null) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 PendingFuture pendingFuture = 1977 PendingFuture pendingFuture =
2003 new PendingFuture<T>(_context, target, computeValue); 1978 new PendingFuture<T>(_context, target, computeValue);
2004 if (!pendingFuture.evaluate(entry)) { 1979 if (!pendingFuture.evaluate(entry)) {
2005 _context._pendingFutureTargets 1980 _context._pendingFutureTargets
2006 .putIfAbsent(target, () => <PendingFuture>[]) 1981 .putIfAbsent(target, () => <PendingFuture>[])
2007 .add(pendingFuture); 1982 .add(pendingFuture);
2008 } 1983 }
2009 return pendingFuture.future; 1984 return pendingFuture.future;
2010 } 1985 }
2011 } 1986 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698