| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 * The partially resolved [CompilationUnit] associated with a unit. | 203 * The partially resolved [CompilationUnit] associated with a unit. |
| 204 * | 204 * |
| 205 * [RESOLVED_UNIT3] with resolved type names. | 205 * [RESOLVED_UNIT3] with resolved type names. |
| 206 * | 206 * |
| 207 * The result is only available for targets representing a unit. | 207 * The result is only available for targets representing a unit. |
| 208 */ | 208 */ |
| 209 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT4 = | 209 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT4 = |
| 210 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT4', null); | 210 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT4', null); |
| 211 | 211 |
| 212 /** | 212 /** |
| 213 * The partially resolved [CompilationUnit] associated with a unit. |
| 214 * |
| 215 * [RESOLVED_UNIT4] plus resolved local variables and formal parameters. |
| 216 * |
| 217 * The result is only available for targets representing a unit. |
| 218 */ |
| 219 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT5 = |
| 220 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT5', null); |
| 221 |
| 222 /** |
| 213 * The [TypeProvider] of the context. | 223 * The [TypeProvider] of the context. |
| 214 */ | 224 */ |
| 215 final ResultDescriptor<TypeProvider> TYPE_PROVIDER = | 225 final ResultDescriptor<TypeProvider> TYPE_PROVIDER = |
| 216 new ResultDescriptor<TypeProvider>('TYPE_PROVIDER', null); | 226 new ResultDescriptor<TypeProvider>('TYPE_PROVIDER', null); |
| 217 | 227 |
| 218 /** | 228 /** |
| 219 * A task that builds implicit constructors for a [ClassElement], or keeps | 229 * A task that builds implicit constructors for a [ClassElement], or keeps |
| 220 * the existing explicit constructors if the class has them. | 230 * the existing explicit constructors if the class has them. |
| 221 */ | 231 */ |
| 222 class BuildClassConstructorsTask extends SourceBasedAnalysisTask { | 232 class BuildClassConstructorsTask extends SourceBasedAnalysisTask { |
| (...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1931 * Create a [ResolveUnitTypeNamesTask] based on the given [target] in | 1941 * Create a [ResolveUnitTypeNamesTask] based on the given [target] in |
| 1932 * the given [context]. | 1942 * the given [context]. |
| 1933 */ | 1943 */ |
| 1934 static ResolveUnitTypeNamesTask createTask( | 1944 static ResolveUnitTypeNamesTask createTask( |
| 1935 AnalysisContext context, AnalysisTarget target) { | 1945 AnalysisContext context, AnalysisTarget target) { |
| 1936 return new ResolveUnitTypeNamesTask(context, target); | 1946 return new ResolveUnitTypeNamesTask(context, target); |
| 1937 } | 1947 } |
| 1938 } | 1948 } |
| 1939 | 1949 |
| 1940 /** | 1950 /** |
| 1951 * A task that builds [RESOLVED_UNIT5] for a unit. |
| 1952 */ |
| 1953 class ResolveVariableReferencesTask extends SourceBasedAnalysisTask { |
| 1954 /** |
| 1955 * The name of the [LIBRARY_ELEMENT6] input. |
| 1956 */ |
| 1957 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; |
| 1958 |
| 1959 /** |
| 1960 * The name of the [RESOLVED_UNIT4] input. |
| 1961 */ |
| 1962 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 1963 |
| 1964 /** |
| 1965 * The task descriptor describing this kind of task. |
| 1966 */ |
| 1967 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 1968 'ResolveVariableReferencesTask', createTask, buildInputs, |
| 1969 <ResultDescriptor>[RESOLVED_UNIT5]); |
| 1970 |
| 1971 ResolveVariableReferencesTask( |
| 1972 InternalAnalysisContext context, AnalysisTarget target) |
| 1973 : super(context, target); |
| 1974 |
| 1975 @override |
| 1976 TaskDescriptor get descriptor => DESCRIPTOR; |
| 1977 |
| 1978 @override |
| 1979 void internalPerform() { |
| 1980 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 1981 // |
| 1982 // Prepare inputs. |
| 1983 // |
| 1984 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT); |
| 1985 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
| 1986 CompilationUnitElement unitElement = unit.element; |
| 1987 // |
| 1988 // Resolve local variables. |
| 1989 // |
| 1990 TypeProvider typeProvider = unitElement.context.typeProvider; |
| 1991 Scope nameScope = new LibraryScope(libraryElement, errorListener); |
| 1992 AstVisitor visitor = new VariableResolverVisitor.con2(libraryElement, |
| 1993 unitElement.source, typeProvider, nameScope, errorListener); |
| 1994 unit.accept(visitor); |
| 1995 // |
| 1996 // Record outputs. |
| 1997 // |
| 1998 outputs[RESOLVED_UNIT5] = unit; |
| 1999 } |
| 2000 |
| 2001 /** |
| 2002 * Return a map from the names of the inputs of this kind of task to the task |
| 2003 * input descriptors describing those inputs for a task with the |
| 2004 * given [target]. |
| 2005 */ |
| 2006 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { |
| 2007 return <String, TaskInput>{ |
| 2008 LIBRARY_INPUT: LIBRARY_ELEMENT6.of(target.library), |
| 2009 UNIT_INPUT: RESOLVED_UNIT4.of(target) |
| 2010 }; |
| 2011 } |
| 2012 |
| 2013 /** |
| 2014 * Create a [ResolveVariableReferencesTask] based on the given [target] in |
| 2015 * the given [context]. |
| 2016 */ |
| 2017 static ResolveVariableReferencesTask createTask( |
| 2018 AnalysisContext context, AnalysisTarget target) { |
| 2019 return new ResolveVariableReferencesTask(context, target); |
| 2020 } |
| 2021 } |
| 2022 |
| 2023 /** |
| 1941 * A task that scans the content of a file, producing a set of Dart tokens. | 2024 * A task that scans the content of a file, producing a set of Dart tokens. |
| 1942 */ | 2025 */ |
| 1943 class ScanDartTask extends SourceBasedAnalysisTask { | 2026 class ScanDartTask extends SourceBasedAnalysisTask { |
| 1944 /** | 2027 /** |
| 1945 * The name of the input whose value is the content of the file. | 2028 * The name of the input whose value is the content of the file. |
| 1946 */ | 2029 */ |
| 1947 static const String CONTENT_INPUT_NAME = 'CONTENT_INPUT_NAME'; | 2030 static const String CONTENT_INPUT_NAME = 'CONTENT_INPUT_NAME'; |
| 1948 | 2031 |
| 1949 /** | 2032 /** |
| 1950 * The task descriptor describing this kind of task. | 2033 * The task descriptor describing this kind of task. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1990 } | 2073 } |
| 1991 | 2074 |
| 1992 /** | 2075 /** |
| 1993 * Create a [ScanDartTask] based on the given [target] in the given [context]. | 2076 * Create a [ScanDartTask] based on the given [target] in the given [context]. |
| 1994 */ | 2077 */ |
| 1995 static ScanDartTask createTask( | 2078 static ScanDartTask createTask( |
| 1996 AnalysisContext context, AnalysisTarget target) { | 2079 AnalysisContext context, AnalysisTarget target) { |
| 1997 return new ScanDartTask(context, target); | 2080 return new ScanDartTask(context, target); |
| 1998 } | 2081 } |
| 1999 } | 2082 } |
| OLD | NEW |