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

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

Issue 1317213004: Use contributed ResultDescriptor(s) while computing DART_ERRORS. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « pkg/analyzer/lib/src/plugin/engine_plugin.dart ('k') | no next file » | 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) 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 8
9 import 'package:analyzer/src/context/cache.dart'; 9 import 'package:analyzer/src/context/cache.dart';
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 12 matching lines...) Expand all
23 import 'package:analyzer/src/generated/source.dart'; 23 import 'package:analyzer/src/generated/source.dart';
24 import 'package:analyzer/src/task/driver.dart'; 24 import 'package:analyzer/src/task/driver.dart';
25 import 'package:analyzer/src/task/general.dart'; 25 import 'package:analyzer/src/task/general.dart';
26 import 'package:analyzer/src/task/html.dart'; 26 import 'package:analyzer/src/task/html.dart';
27 import 'package:analyzer/src/task/inputs.dart'; 27 import 'package:analyzer/src/task/inputs.dart';
28 import 'package:analyzer/src/task/model.dart'; 28 import 'package:analyzer/src/task/model.dart';
29 import 'package:analyzer/src/task/strong_mode.dart'; 29 import 'package:analyzer/src/task/strong_mode.dart';
30 import 'package:analyzer/task/dart.dart'; 30 import 'package:analyzer/task/dart.dart';
31 import 'package:analyzer/task/general.dart'; 31 import 'package:analyzer/task/general.dart';
32 import 'package:analyzer/task/model.dart'; 32 import 'package:analyzer/task/model.dart';
33 import 'package:analyzer/src/plugin/engine_plugin.dart';
33 34
34 /** 35 /**
35 * The [ResultCachingPolicy] for ASTs. 36 * The [ResultCachingPolicy] for ASTs.
36 */ 37 */
37 const ResultCachingPolicy AST_CACHING_POLICY = 38 const ResultCachingPolicy AST_CACHING_POLICY =
38 const SimpleResultCachingPolicy(8192, 8192); 39 const SimpleResultCachingPolicy(8192, 8192);
39 40
40 /** 41 /**
41 * The [ResultCachingPolicy] for [Element]s. 42 * The [ResultCachingPolicy] for [Element]s.
42 */ 43 */
(...skipping 1872 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 return DeltaResult.INVALIDATE; 1916 return DeltaResult.INVALIDATE;
1916 } 1917 }
1917 } 1918 }
1918 1919
1919 /** 1920 /**
1920 * A task that merges all of the errors for a single source into a single list 1921 * A task that merges all of the errors for a single source into a single list
1921 * of errors. 1922 * of errors.
1922 */ 1923 */
1923 class DartErrorsTask extends SourceBasedAnalysisTask { 1924 class DartErrorsTask extends SourceBasedAnalysisTask {
1924 /** 1925 /**
1925 * The name of the [BUILD_DIRECTIVES_ERRORS] input.
1926 */
1927 static const String BUILD_DIRECTIVES_ERRORS_INPUT = 'BUILD_DIRECTIVES_ERRORS';
1928
1929 /**
1930 * The name of the [BUILD_LIBRARY_ERRORS] input.
1931 */
1932 static const String BUILD_LIBRARY_ERRORS_INPUT = 'BUILD_LIBRARY_ERRORS';
1933
1934 /**
1935 * The name of the [LIBRARY_UNIT_ERRORS] input.
1936 */
1937 static const String LIBRARY_UNIT_ERRORS_INPUT = 'LIBRARY_UNIT_ERRORS';
1938
1939 /**
1940 * The name of the [PARSE_ERRORS] input.
1941 */
1942 static const String PARSE_ERRORS_INPUT = 'PARSE_ERRORS';
1943
1944 /**
1945 * The name of the [SCAN_ERRORS] input.
1946 */
1947 static const String SCAN_ERRORS_INPUT = 'SCAN_ERRORS';
1948
1949 /**
1950 * The task descriptor describing this kind of task. 1926 * The task descriptor describing this kind of task.
1951 */ 1927 */
1952 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor('DartErrorsTask', 1928 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor('DartErrorsTask',
1953 createTask, buildInputs, <ResultDescriptor>[DART_ERRORS]); 1929 createTask, buildInputs, <ResultDescriptor>[DART_ERRORS]);
1954 1930
1955 DartErrorsTask(InternalAnalysisContext context, AnalysisTarget target) 1931 DartErrorsTask(InternalAnalysisContext context, AnalysisTarget target)
1956 : super(context, target); 1932 : super(context, target);
1957 1933
1958 @override 1934 @override
1959 TaskDescriptor get descriptor => DESCRIPTOR; 1935 TaskDescriptor get descriptor => DESCRIPTOR;
1960 1936
1961 @override 1937 @override
1962 void internalPerform() { 1938 void internalPerform() {
1939 List<List<AnalysisError>> errorLists = <List<AnalysisError>>[];
1963 // 1940 //
1964 // Prepare inputs. 1941 // Prepare inputs.
1965 // 1942 //
1966 List<List<AnalysisError>> errorLists = <List<AnalysisError>>[]; 1943 EnginePlugin enginePlugin = AnalysisEngine.instance.enginePlugin;
1967 errorLists.add(getRequiredInput(BUILD_DIRECTIVES_ERRORS_INPUT)); 1944 for (ResultDescriptor result in enginePlugin.dartErrorsForSource) {
1968 errorLists.add(getRequiredInput(BUILD_LIBRARY_ERRORS_INPUT)); 1945 String inputName = result.name + '_input';
1969 errorLists.add(getRequiredInput(PARSE_ERRORS_INPUT)); 1946 errorLists.add(getRequiredInput(inputName));
1970 errorLists.add(getRequiredInput(SCAN_ERRORS_INPUT)); 1947 }
1971 Map<Source, List<AnalysisError>> unitErrors = 1948 for (ResultDescriptor result in enginePlugin.dartErrorsForUnit) {
1972 getRequiredInput(LIBRARY_UNIT_ERRORS_INPUT); 1949 String inputName = result.name + '_input';
1973 for (List<AnalysisError> errors in unitErrors.values) { 1950 Map<Source, List<AnalysisError>> errorMap = getRequiredInput(inputName);
1974 errorLists.add(errors); 1951 for (List<AnalysisError> errors in errorMap.values) {
1952 errorLists.add(errors);
1953 }
1975 } 1954 }
1976 // 1955 //
1977 // Record outputs. 1956 // Record outputs.
1978 // 1957 //
1979 outputs[DART_ERRORS] = AnalysisError.mergeLists(errorLists); 1958 outputs[DART_ERRORS] = AnalysisError.mergeLists(errorLists);
1980 } 1959 }
1981 1960
1982 /** 1961 /**
1983 * Return a map from the names of the inputs of this kind of task to the task 1962 * Return a map from the names of the inputs of this kind of task to the task
1984 * input descriptors describing those inputs for a task with the 1963 * input descriptors describing those inputs for a task with the
1985 * given [target]. 1964 * given [target].
1986 */ 1965 */
1987 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { 1966 static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
1988 Source source = target; 1967 Source source = target;
1989 return <String, TaskInput>{ 1968 Map<String, TaskInput> inputs = <String, TaskInput>{};
1990 BUILD_DIRECTIVES_ERRORS_INPUT: BUILD_DIRECTIVES_ERRORS.of(source), 1969 EnginePlugin enginePlugin = AnalysisEngine.instance.enginePlugin;
1991 BUILD_LIBRARY_ERRORS_INPUT: BUILD_LIBRARY_ERRORS.of(source), 1970 // for Source
1992 PARSE_ERRORS_INPUT: PARSE_ERRORS.of(source), 1971 for (ResultDescriptor result in enginePlugin.dartErrorsForSource) {
1993 SCAN_ERRORS_INPUT: SCAN_ERRORS.of(source), 1972 String inputName = result.name + '_input';
1994 LIBRARY_UNIT_ERRORS_INPUT: 1973 inputs[inputName] = result.of(source);
1974 }
1975 // for LibrarySpecificUnit
1976 for (ResultDescriptor result in enginePlugin.dartErrorsForUnit) {
1977 String inputName = result.name + '_input';
1978 inputs[inputName] =
1995 CONTAINING_LIBRARIES.of(source).toMap((Source library) { 1979 CONTAINING_LIBRARIES.of(source).toMap((Source library) {
1996 LibrarySpecificUnit unit = new LibrarySpecificUnit(library, source); 1980 LibrarySpecificUnit unit = new LibrarySpecificUnit(library, source);
1997 return LIBRARY_UNIT_ERRORS.of(unit); 1981 return result.of(unit);
1998 }) 1982 });
1999 }; 1983 }
1984 return inputs;
2000 } 1985 }
2001 1986
2002 /** 1987 /**
2003 * Create a [DartErrorsTask] based on the given [target] in the given 1988 * Create a [DartErrorsTask] based on the given [target] in the given
2004 * [context]. 1989 * [context].
2005 */ 1990 */
2006 static DartErrorsTask createTask( 1991 static DartErrorsTask createTask(
2007 AnalysisContext context, AnalysisTarget target) { 1992 AnalysisContext context, AnalysisTarget target) {
2008 return new DartErrorsTask(context, target); 1993 return new DartErrorsTask(context, target);
2009 } 1994 }
(...skipping 2099 matching lines...) Expand 10 before | Expand all | Expand 10 after
4109 4094
4110 @override 4095 @override
4111 bool moveNext() { 4096 bool moveNext() {
4112 if (_newSources.isEmpty) { 4097 if (_newSources.isEmpty) {
4113 return false; 4098 return false;
4114 } 4099 }
4115 currentTarget = _newSources.removeLast(); 4100 currentTarget = _newSources.removeLast();
4116 return true; 4101 return true;
4117 } 4102 }
4118 } 4103 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/plugin/engine_plugin.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698