| OLD | NEW |
| 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 Loading... |
| 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<ComputedResult> 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 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1894 _completer.completeError(exception, stackTrace); | 1899 _completer.completeError(exception, stackTrace); |
| 1895 } | 1900 } |
| 1896 } | 1901 } |
| 1897 | 1902 |
| 1898 void _onCancel() { | 1903 void _onCancel() { |
| 1899 _context._cancelFuture(this); | 1904 _context._cancelFuture(this); |
| 1900 } | 1905 } |
| 1901 } | 1906 } |
| 1902 | 1907 |
| 1903 /** | 1908 /** |
| 1904 * [ResultComputedEvent] describes a value computed for a [ResultDescriptor]. | |
| 1905 */ | |
| 1906 class ResultComputedEvent<V> { | |
| 1907 /** | |
| 1908 * The context in which the value was computed. | |
| 1909 */ | |
| 1910 final AnalysisContext context; | |
| 1911 | |
| 1912 /** | |
| 1913 * The descriptor of the result which was computed. | |
| 1914 */ | |
| 1915 final ResultDescriptor<V> descriptor; | |
| 1916 | |
| 1917 /** | |
| 1918 * The target for which the result was computed. | |
| 1919 */ | |
| 1920 final AnalysisTarget target; | |
| 1921 | |
| 1922 /** | |
| 1923 * The computed value. | |
| 1924 */ | |
| 1925 final V value; | |
| 1926 | |
| 1927 ResultComputedEvent(this.context, this.descriptor, this.target, this.value); | |
| 1928 | |
| 1929 @override | |
| 1930 String toString() => '$value for $descriptor of $target in $context'; | |
| 1931 } | |
| 1932 | |
| 1933 /** | |
| 1934 * An [AnalysisContext] that only contains sources for a Dart SDK. | 1909 * An [AnalysisContext] that only contains sources for a Dart SDK. |
| 1935 */ | 1910 */ |
| 1936 class SdkAnalysisContext extends AnalysisContextImpl { | 1911 class SdkAnalysisContext extends AnalysisContextImpl { |
| 1937 @override | 1912 @override |
| 1938 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { | 1913 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { |
| 1939 if (factory == null) { | 1914 if (factory == null) { |
| 1940 return super.createCacheFromSourceFactory(factory); | 1915 return super.createCacheFromSourceFactory(factory); |
| 1941 } | 1916 } |
| 1942 DartSdk sdk = factory.dartSdk; | 1917 DartSdk sdk = factory.dartSdk; |
| 1943 if (sdk == null) { | 1918 if (sdk == null) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1989 PendingFuture pendingFuture = | 1964 PendingFuture pendingFuture = |
| 1990 new PendingFuture<T>(_context, target, computeValue); | 1965 new PendingFuture<T>(_context, target, computeValue); |
| 1991 if (!pendingFuture.evaluate(entry)) { | 1966 if (!pendingFuture.evaluate(entry)) { |
| 1992 _context._pendingFutureTargets | 1967 _context._pendingFutureTargets |
| 1993 .putIfAbsent(target, () => <PendingFuture>[]) | 1968 .putIfAbsent(target, () => <PendingFuture>[]) |
| 1994 .add(pendingFuture); | 1969 .add(pendingFuture); |
| 1995 } | 1970 } |
| 1996 return pendingFuture.future; | 1971 return pendingFuture.future; |
| 1997 } | 1972 } |
| 1998 } | 1973 } |
| OLD | NEW |