| 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.task.dart; | 5 library analyzer.src.task.dart; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:math' as math; | 8 import 'dart:math' as math; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 * The partial [LibraryElement] associated with a library. | 151 * The partial [LibraryElement] associated with a library. |
| 152 * | 152 * |
| 153 * Implicit constructors are built for every [ClassElement] requiring them. | 153 * Implicit constructors are built for every [ClassElement] requiring them. |
| 154 * | 154 * |
| 155 * The result is only available for targets representing a Dart library. | 155 * The result is only available for targets representing a Dart library. |
| 156 */ | 156 */ |
| 157 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT6 = | 157 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT6 = |
| 158 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT6', null); | 158 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT6', null); |
| 159 | 159 |
| 160 /** | 160 /** |
| 161 * The errors produced while resolving references. |
| 162 * |
| 163 * The list will be empty if there were no errors, but will not be `null`. |
| 164 * |
| 165 * The result is only available for targets representing a unit. |
| 166 */ |
| 167 final ResultDescriptor<List<AnalysisError>> RESOLVE_REFERENCES_ERRORS = |
| 168 new ResultDescriptor<List<AnalysisError>>( |
| 169 'RESOLVE_REFERENCES_ERRORS', AnalysisError.NO_ERRORS, |
| 170 contributesTo: DART_ERRORS); |
| 171 |
| 172 /** |
| 161 * The errors produced while resolving type names. | 173 * The errors produced while resolving type names. |
| 162 * | 174 * |
| 163 * The list will be empty if there were no errors, but will not be `null`. | 175 * The list will be empty if there were no errors, but will not be `null`. |
| 164 * | 176 * |
| 165 * The result is only available for targets representing a Dart library. | 177 * The result is only available for targets representing a Dart library. |
| 166 */ | 178 */ |
| 167 final ResultDescriptor<List<AnalysisError>> RESOLVE_TYPE_NAMES_ERRORS = | 179 final ResultDescriptor<List<AnalysisError>> RESOLVE_TYPE_NAMES_ERRORS = |
| 168 new ResultDescriptor<List<AnalysisError>>( | 180 new ResultDescriptor<List<AnalysisError>>( |
| 169 'RESOLVE_TYPE_NAMES_ERRORS', AnalysisError.NO_ERRORS, | 181 'RESOLVE_TYPE_NAMES_ERRORS', AnalysisError.NO_ERRORS, |
| 170 contributesTo: DART_ERRORS); | 182 contributesTo: DART_ERRORS); |
| (...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1875 * Create a [ResolveLibraryTypeNamesTask] based on the given [target] in | 1887 * Create a [ResolveLibraryTypeNamesTask] based on the given [target] in |
| 1876 * the given [context]. | 1888 * the given [context]. |
| 1877 */ | 1889 */ |
| 1878 static ResolveLibraryTypeNamesTask createTask( | 1890 static ResolveLibraryTypeNamesTask createTask( |
| 1879 AnalysisContext context, AnalysisTarget target) { | 1891 AnalysisContext context, AnalysisTarget target) { |
| 1880 return new ResolveLibraryTypeNamesTask(context, target); | 1892 return new ResolveLibraryTypeNamesTask(context, target); |
| 1881 } | 1893 } |
| 1882 } | 1894 } |
| 1883 | 1895 |
| 1884 /** | 1896 /** |
| 1897 * A task that builds [RESOLVED_UNIT] for a unit. |
| 1898 */ |
| 1899 class ResolveReferencesTask extends SourceBasedAnalysisTask { |
| 1900 /** |
| 1901 * The name of the [LIBRARY_ELEMENT6] input. |
| 1902 */ |
| 1903 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; |
| 1904 |
| 1905 /** |
| 1906 * The name of the [RESOLVED_UNIT5] input. |
| 1907 */ |
| 1908 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 1909 |
| 1910 /** |
| 1911 * The task descriptor describing this kind of task. |
| 1912 */ |
| 1913 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 1914 'ResolveReferencesTask', createTask, buildInputs, |
| 1915 <ResultDescriptor>[RESOLVED_UNIT]); |
| 1916 |
| 1917 ResolveReferencesTask(InternalAnalysisContext context, AnalysisTarget target) |
| 1918 : super(context, target); |
| 1919 |
| 1920 @override |
| 1921 TaskDescriptor get descriptor => DESCRIPTOR; |
| 1922 |
| 1923 @override |
| 1924 void internalPerform() { |
| 1925 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 1926 // |
| 1927 // Prepare inputs. |
| 1928 // |
| 1929 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT); |
| 1930 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
| 1931 CompilationUnitElement unitElement = unit.element; |
| 1932 TypeProvider typeProvider = unitElement.context.typeProvider; |
| 1933 // |
| 1934 // Resolve references. |
| 1935 // |
| 1936 InheritanceManager inheritanceManager = |
| 1937 new InheritanceManager(libraryElement); |
| 1938 AstVisitor visitor = new ResolverVisitor.con2(libraryElement, |
| 1939 unitElement.source, typeProvider, inheritanceManager, errorListener); |
| 1940 unit.accept(visitor); |
| 1941 // |
| 1942 // Record outputs. |
| 1943 // |
| 1944 outputs[RESOLVE_REFERENCES_ERRORS] = errorListener.errors; |
| 1945 outputs[RESOLVED_UNIT] = unit; |
| 1946 } |
| 1947 |
| 1948 /** |
| 1949 * Return a map from the names of the inputs of this kind of task to the task |
| 1950 * input descriptors describing those inputs for a task with the |
| 1951 * given [target]. |
| 1952 */ |
| 1953 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { |
| 1954 return <String, TaskInput>{ |
| 1955 LIBRARY_INPUT: LIBRARY_ELEMENT6.of(target.library), |
| 1956 UNIT_INPUT: RESOLVED_UNIT5.of(target) |
| 1957 }; |
| 1958 } |
| 1959 |
| 1960 /** |
| 1961 * Create a [ResolveReferencesTask] based on the given [target] in |
| 1962 * the given [context]. |
| 1963 */ |
| 1964 static ResolveReferencesTask createTask( |
| 1965 AnalysisContext context, AnalysisTarget target) { |
| 1966 return new ResolveReferencesTask(context, target); |
| 1967 } |
| 1968 } |
| 1969 |
| 1970 /** |
| 1885 * A task that builds [RESOLVED_UNIT4] for a unit. | 1971 * A task that builds [RESOLVED_UNIT4] for a unit. |
| 1886 */ | 1972 */ |
| 1887 class ResolveUnitTypeNamesTask extends SourceBasedAnalysisTask { | 1973 class ResolveUnitTypeNamesTask extends SourceBasedAnalysisTask { |
| 1888 /** | 1974 /** |
| 1889 * The name of the [RESOLVED_UNIT3] input. | 1975 * The name of the [RESOLVED_UNIT3] input. |
| 1890 */ | 1976 */ |
| 1891 static const String UNIT_INPUT = 'UNIT_INPUT'; | 1977 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 1892 | 1978 |
| 1893 /** | 1979 /** |
| 1894 * The task descriptor describing this kind of task. | 1980 * The task descriptor describing this kind of task. |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2073 } | 2159 } |
| 2074 | 2160 |
| 2075 /** | 2161 /** |
| 2076 * Create a [ScanDartTask] based on the given [target] in the given [context]. | 2162 * Create a [ScanDartTask] based on the given [target] in the given [context]. |
| 2077 */ | 2163 */ |
| 2078 static ScanDartTask createTask( | 2164 static ScanDartTask createTask( |
| 2079 AnalysisContext context, AnalysisTarget target) { | 2165 AnalysisContext context, AnalysisTarget target) { |
| 2080 return new ScanDartTask(context, target); | 2166 return new ScanDartTask(context, target); |
| 2081 } | 2167 } |
| 2082 } | 2168 } |
| OLD | NEW |