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

Side by Side Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 214593008: Rollback pkg/analyzer that breaks code_transformers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/lib/src/generated/parser.dart ('k') | pkg/analyzer/lib/src/generated/scanner.dart » ('j') | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.resolver; 8 library engine.resolver;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 */ 212 */
213 static AngularSelectorElement _parseSelectorFromString(SimpleStringLiteral lit eral) { 213 static AngularSelectorElement _parseSelectorFromString(SimpleStringLiteral lit eral) {
214 int offset = literal.valueOffset; 214 int offset = literal.valueOffset;
215 String text = literal.stringValue; 215 String text = literal.stringValue;
216 return parseSelector(offset, text); 216 return parseSelector(offset, text);
217 } 217 }
218 218
219 /** 219 /**
220 * The listener to which errors will be reported. 220 * The listener to which errors will be reported.
221 */ 221 */
222 final AnalysisErrorListener _errorListener; 222 AnalysisErrorListener _errorListener;
223 223
224 /** 224 /**
225 * The source containing the unit that will be analyzed. 225 * The source containing the unit that will be analyzed.
226 */ 226 */
227 final Source _source; 227 Source _source;
228 228
229 /** 229 /**
230 * The compilation unit with built Dart element models. 230 * The compilation unit with built Dart element models.
231 */ 231 */
232 final CompilationUnit _unit; 232 CompilationUnit _unit;
233 233
234 /** 234 /**
235 * The [ClassDeclaration] that is currently being analyzed. 235 * The [ClassDeclaration] that is currently being analyzed.
236 */ 236 */
237 ClassDeclaration _classDeclaration; 237 ClassDeclaration _classDeclaration;
238 238
239 /** 239 /**
240 * The [ClassElementImpl] that is currently being analyzed. 240 * The [ClassElementImpl] that is currently being analyzed.
241 */ 241 */
242 ClassElementImpl _classElement; 242 ClassElementImpl _classElement;
243 243
244 /** 244 /**
245 * The [ToolkitObjectElement]s to set for [classElement]. 245 * The [ToolkitObjectElement]s to set for [classElement].
246 */ 246 */
247 List<ToolkitObjectElement> _classToolkitObjects = []; 247 List<ToolkitObjectElement> _classToolkitObjects = [];
248 248
249 /** 249 /**
250 * The [Annotation] that is currently being analyzed. 250 * The [Annotation] that is currently being analyzed.
251 */ 251 */
252 Annotation _annotation; 252 Annotation _annotation;
253 253
254 /** 254 /**
255 * Initialize a newly created compilation unit element builder. 255 * Initialize a newly created compilation unit element builder.
256 * 256 *
257 * @param errorListener the listener to which errors will be reported. 257 * @param errorListener the listener to which errors will be reported.
258 * @param source the source containing the unit that will be analyzed 258 * @param source the source containing the unit that will be analyzed
259 * @param unit the compilation unit with built Dart element models 259 * @param unit the compilation unit with built Dart element models
260 */ 260 */
261 AngularCompilationUnitBuilder(this._errorListener, this._source, this._unit); 261 AngularCompilationUnitBuilder(AnalysisErrorListener errorListener, Source sour ce, CompilationUnit unit) {
262 this._errorListener = errorListener;
263 this._source = source;
264 this._unit = unit;
265 }
262 266
263 /** 267 /**
264 * Builds Angular specific element models and adds them to the existing Dart e lements. 268 * Builds Angular specific element models and adds them to the existing Dart e lements.
265 */ 269 */
266 void build() { 270 void build() {
267 _parseViews(); 271 _parseViews();
268 // process classes 272 // process classes
269 for (CompilationUnitMember unitMember in _unit.declarations) { 273 for (CompilationUnitMember unitMember in _unit.declarations) {
270 if (unitMember is ClassDeclaration) { 274 if (unitMember is ClassDeclaration) {
271 this._classDeclaration = unitMember; 275 this._classDeclaration = unitMember;
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 1974
1971 /** 1975 /**
1972 * Instances of the class `HtmlUnitBuilder` build an element model for a single HTML unit. 1976 * Instances of the class `HtmlUnitBuilder` build an element model for a single HTML unit.
1973 */ 1977 */
1974 class HtmlUnitBuilder implements ht.XmlVisitor<Object> { 1978 class HtmlUnitBuilder implements ht.XmlVisitor<Object> {
1975 static String _SRC = "src"; 1979 static String _SRC = "src";
1976 1980
1977 /** 1981 /**
1978 * The analysis context in which the element model will be built. 1982 * The analysis context in which the element model will be built.
1979 */ 1983 */
1980 final InternalAnalysisContext _context; 1984 InternalAnalysisContext _context;
1981 1985
1982 /** 1986 /**
1983 * The error listener to which errors will be reported. 1987 * The error listener to which errors will be reported.
1984 */ 1988 */
1985 RecordingErrorListener _errorListener; 1989 RecordingErrorListener _errorListener;
1986 1990
1987 /** 1991 /**
1988 * The modification time of the source for which an element is being built. 1992 * The modification time of the source for which an element is being built.
1989 */ 1993 */
1990 int _modificationStamp = 0; 1994 int _modificationStamp = 0;
(...skipping 16 matching lines...) Expand all
2007 /** 2011 /**
2008 * A set of the libraries that were resolved while resolving the HTML unit. 2012 * A set of the libraries that were resolved while resolving the HTML unit.
2009 */ 2013 */
2010 Set<Library> _resolvedLibraries = new Set<Library>(); 2014 Set<Library> _resolvedLibraries = new Set<Library>();
2011 2015
2012 /** 2016 /**
2013 * Initialize a newly created HTML unit builder. 2017 * Initialize a newly created HTML unit builder.
2014 * 2018 *
2015 * @param context the analysis context in which the element model will be buil t 2019 * @param context the analysis context in which the element model will be buil t
2016 */ 2020 */
2017 HtmlUnitBuilder(this._context) { 2021 HtmlUnitBuilder(InternalAnalysisContext context) {
2022 this._context = context;
2018 this._errorListener = new RecordingErrorListener(); 2023 this._errorListener = new RecordingErrorListener();
2019 } 2024 }
2020 2025
2021 /** 2026 /**
2022 * Build the HTML element for the given source. 2027 * Build the HTML element for the given source.
2023 * 2028 *
2024 * @param source the source describing the compilation unit 2029 * @param source the source describing the compilation unit
2025 * @param modificationStamp the modification time of the source for which an e lement is being 2030 * @param modificationStamp the modification time of the source for which an e lement is being
2026 * built 2031 * built
2027 * @param unit the AST structure representing the HTML 2032 * @param unit the AST structure representing the HTML
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
2242 2247
2243 /** 2248 /**
2244 * The class containing the AST nodes being visited, or `null` if we are not i n the scope of 2249 * The class containing the AST nodes being visited, or `null` if we are not i n the scope of
2245 * a class. 2250 * a class.
2246 */ 2251 */
2247 ClassElement _enclosingClass; 2252 ClassElement _enclosingClass;
2248 2253
2249 /** 2254 /**
2250 * The error reporter by which errors will be reported. 2255 * The error reporter by which errors will be reported.
2251 */ 2256 */
2252 final ErrorReporter _errorReporter; 2257 ErrorReporter _errorReporter;
2253 2258
2254 /** 2259 /**
2255 * Create a new instance of the [BestPracticesVerifier]. 2260 * Create a new instance of the [BestPracticesVerifier].
2256 * 2261 *
2257 * @param errorReporter the error reporter 2262 * @param errorReporter the error reporter
2258 */ 2263 */
2259 BestPracticesVerifier(this._errorReporter); 2264 BestPracticesVerifier(ErrorReporter errorReporter) {
2265 this._errorReporter = errorReporter;
2266 }
2260 2267
2261 @override 2268 @override
2262 Object visitArgumentList(ArgumentList node) { 2269 Object visitArgumentList(ArgumentList node) {
2263 _checkForArgumentTypesNotAssignableInList(node); 2270 _checkForArgumentTypesNotAssignableInList(node);
2264 return super.visitArgumentList(node); 2271 return super.visitArgumentList(node);
2265 } 2272 }
2266 2273
2267 @override 2274 @override
2268 Object visitAsExpression(AsExpression node) { 2275 Object visitAsExpression(AsExpression node) {
2269 _checkForUnnecessaryCast(node); 2276 _checkForUnnecessaryCast(node);
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
2795 } 2802 }
2796 2803
2797 /** 2804 /**
2798 * Instances of the class `Dart2JSVerifier` traverse an AST structure looking fo r hints for 2805 * Instances of the class `Dart2JSVerifier` traverse an AST structure looking fo r hints for
2799 * code that will be compiled to JS, such as [HintCode#IS_DOUBLE]. 2806 * code that will be compiled to JS, such as [HintCode#IS_DOUBLE].
2800 */ 2807 */
2801 class Dart2JSVerifier extends RecursiveAstVisitor<Object> { 2808 class Dart2JSVerifier extends RecursiveAstVisitor<Object> {
2802 /** 2809 /**
2803 * The error reporter by which errors will be reported. 2810 * The error reporter by which errors will be reported.
2804 */ 2811 */
2805 final ErrorReporter _errorReporter; 2812 ErrorReporter _errorReporter;
2806 2813
2807 /** 2814 /**
2808 * The name of the `double` type. 2815 * The name of the `double` type.
2809 */ 2816 */
2810 static String _DOUBLE_TYPE_NAME = "double"; 2817 static String _DOUBLE_TYPE_NAME = "double";
2811 2818
2812 /** 2819 /**
2813 * Create a new instance of the [Dart2JSVerifier]. 2820 * Create a new instance of the [Dart2JSVerifier].
2814 * 2821 *
2815 * @param errorReporter the error reporter 2822 * @param errorReporter the error reporter
2816 */ 2823 */
2817 Dart2JSVerifier(this._errorReporter); 2824 Dart2JSVerifier(ErrorReporter errorReporter) {
2825 this._errorReporter = errorReporter;
2826 }
2818 2827
2819 @override 2828 @override
2820 Object visitIsExpression(IsExpression node) { 2829 Object visitIsExpression(IsExpression node) {
2821 _checkForIsDoubleHints(node); 2830 _checkForIsDoubleHints(node);
2822 return super.visitIsExpression(node); 2831 return super.visitIsExpression(node);
2823 } 2832 }
2824 2833
2825 /** 2834 /**
2826 * Check for instances of `x is double`, `x is int`, `x is! double` and 2835 * Check for instances of `x is double`, `x is int`, `x is! double` and
2827 * `x is! int`. 2836 * `x is! int`.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2863 } 2872 }
2864 2873
2865 /** 2874 /**
2866 * Instances of the class `DeadCodeVerifier` traverse an AST structure looking f or cases of 2875 * Instances of the class `DeadCodeVerifier` traverse an AST structure looking f or cases of
2867 * [HintCode#DEAD_CODE]. 2876 * [HintCode#DEAD_CODE].
2868 */ 2877 */
2869 class DeadCodeVerifier extends RecursiveAstVisitor<Object> { 2878 class DeadCodeVerifier extends RecursiveAstVisitor<Object> {
2870 /** 2879 /**
2871 * The error reporter by which errors will be reported. 2880 * The error reporter by which errors will be reported.
2872 */ 2881 */
2873 final ErrorReporter _errorReporter; 2882 ErrorReporter _errorReporter;
2874 2883
2875 /** 2884 /**
2876 * Create a new instance of the [DeadCodeVerifier]. 2885 * Create a new instance of the [DeadCodeVerifier].
2877 * 2886 *
2878 * @param errorReporter the error reporter 2887 * @param errorReporter the error reporter
2879 */ 2888 */
2880 DeadCodeVerifier(this._errorReporter); 2889 DeadCodeVerifier(ErrorReporter errorReporter) {
2890 this._errorReporter = errorReporter;
2891 }
2881 2892
2882 @override 2893 @override
2883 Object visitBinaryExpression(BinaryExpression node) { 2894 Object visitBinaryExpression(BinaryExpression node) {
2884 sc.Token operator = node.operator; 2895 sc.Token operator = node.operator;
2885 bool isAmpAmp = identical(operator.type, sc.TokenType.AMPERSAND_AMPERSAND); 2896 bool isAmpAmp = identical(operator.type, sc.TokenType.AMPERSAND_AMPERSAND);
2886 bool isBarBar = identical(operator.type, sc.TokenType.BAR_BAR); 2897 bool isBarBar = identical(operator.type, sc.TokenType.BAR_BAR);
2887 if (isAmpAmp || isBarBar) { 2898 if (isAmpAmp || isBarBar) {
2888 Expression lhsCondition = node.leftOperand; 2899 Expression lhsCondition = node.leftOperand;
2889 if (!_isDebugConstant(lhsCondition)) { 2900 if (!_isDebugConstant(lhsCondition)) {
2890 ValidResult lhsResult = _getConstantBooleanValue(lhsCondition); 2901 ValidResult lhsResult = _getConstantBooleanValue(lhsCondition);
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
3179 // If the operator is && and the left hand side is true literal, don't consi der the RHS of the 3190 // If the operator is && and the left hand side is true literal, don't consi der the RHS of the
3180 // binary expression. 3191 // binary expression.
3181 if (identical(operatorType, sc.TokenType.AMPERSAND_AMPERSAND)) { 3192 if (identical(operatorType, sc.TokenType.AMPERSAND_AMPERSAND)) {
3182 if (lhsExpression is BooleanLiteral) { 3193 if (lhsExpression is BooleanLiteral) {
3183 BooleanLiteral booleanLiteral = lhsExpression; 3194 BooleanLiteral booleanLiteral = lhsExpression;
3184 if (booleanLiteral.value) { 3195 if (booleanLiteral.value) {
3185 return false; 3196 return false;
3186 } 3197 }
3187 } 3198 }
3188 } 3199 }
3189 Expression rhsExpression = node.rightOperand; 3200 return lhsExpression.accept(this) || node.rightOperand.accept(this);
3190 return (lhsExpression != null && lhsExpression.accept(this)) || (rhsExpressi on != null && rhsExpression.accept(this));
3191 } 3201 }
3192 3202
3193 @override 3203 @override
3194 bool visitBlock(Block node) => _visitStatements(node.statements); 3204 bool visitBlock(Block node) => _visitStatements(node.statements);
3195 3205
3196 @override 3206 @override
3197 bool visitBlockFunctionBody(BlockFunctionBody node) => node.block.accept(this) ; 3207 bool visitBlockFunctionBody(BlockFunctionBody node) => node.block.accept(this) ;
3198 3208
3199 @override 3209 @override
3200 bool visitBreakStatement(BreakStatement node) { 3210 bool visitBreakStatement(BreakStatement node) {
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
3546 } 3556 }
3547 } 3557 }
3548 3558
3549 /** 3559 /**
3550 * Instances of the class `HintGenerator` traverse a library's worth of dart cod e at a time to 3560 * Instances of the class `HintGenerator` traverse a library's worth of dart cod e at a time to
3551 * generate hints over the set of sources. 3561 * generate hints over the set of sources.
3552 * 3562 *
3553 * @see HintCode 3563 * @see HintCode
3554 */ 3564 */
3555 class HintGenerator { 3565 class HintGenerator {
3556 final List<CompilationUnit> _compilationUnits; 3566 List<CompilationUnit> _compilationUnits;
3557 3567
3558 final AnalysisContext _context; 3568 AnalysisContext _context;
3559 3569
3560 final AnalysisErrorListener _errorListener; 3570 AnalysisErrorListener _errorListener;
3561 3571
3562 ImportsVerifier _importsVerifier; 3572 ImportsVerifier _importsVerifier;
3563 3573
3564 bool _enableDart2JSHints = false; 3574 bool _enableDart2JSHints = false;
3565 3575
3566 /** 3576 /**
3567 * The inheritance manager used to find overridden methods. 3577 * The inheritance manager used to find overridden methods.
3568 */ 3578 */
3569 InheritanceManager _manager; 3579 InheritanceManager _manager;
3570 3580
3571 HintGenerator(this._compilationUnits, this._context, this._errorListener) { 3581 HintGenerator(List<CompilationUnit> compilationUnits, AnalysisContext context, AnalysisErrorListener errorListener) {
3572 LibraryElement library = _compilationUnits[0].element.library; 3582 this._compilationUnits = compilationUnits;
3583 this._context = context;
3584 this._errorListener = errorListener;
3585 LibraryElement library = compilationUnits[0].element.library;
3573 _importsVerifier = new ImportsVerifier(library); 3586 _importsVerifier = new ImportsVerifier(library);
3574 _enableDart2JSHints = _context.analysisOptions.dart2jsHint; 3587 _enableDart2JSHints = context.analysisOptions.dart2jsHint;
3575 _manager = new InheritanceManager(_compilationUnits[0].element.library); 3588 _manager = new InheritanceManager(compilationUnits[0].element.library);
3576 } 3589 }
3577 3590
3578 void generateForLibrary() { 3591 void generateForLibrary() {
3579 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.hints.star t(); 3592 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.hints.star t();
3580 try { 3593 try {
3581 for (int i = 0; i < _compilationUnits.length; i++) { 3594 for (int i = 0; i < _compilationUnits.length; i++) {
3582 CompilationUnitElement element = _compilationUnits[i].element; 3595 CompilationUnitElement element = _compilationUnits[i].element;
3583 if (element != null) { 3596 if (element != null) {
3584 if (i == 0) { 3597 if (i == 0) {
3585 _importsVerifier.inDefiningCompilationUnit = true; 3598 _importsVerifier.inDefiningCompilationUnit = true;
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
3960 } 3973 }
3961 3974
3962 /** 3975 /**
3963 * Instances of the class `OverrideVerifier` visit all of the declarations in a compilation 3976 * Instances of the class `OverrideVerifier` visit all of the declarations in a compilation
3964 * unit to verify that if they have an override annotation it is being used corr ectly. 3977 * unit to verify that if they have an override annotation it is being used corr ectly.
3965 */ 3978 */
3966 class OverrideVerifier extends RecursiveAstVisitor<Object> { 3979 class OverrideVerifier extends RecursiveAstVisitor<Object> {
3967 /** 3980 /**
3968 * The inheritance manager used to find overridden methods. 3981 * The inheritance manager used to find overridden methods.
3969 */ 3982 */
3970 final InheritanceManager _manager; 3983 InheritanceManager _manager;
3971 3984
3972 /** 3985 /**
3973 * The error reporter used to report errors. 3986 * The error reporter used to report errors.
3974 */ 3987 */
3975 final ErrorReporter _errorReporter; 3988 ErrorReporter _errorReporter;
3976 3989
3977 /** 3990 /**
3978 * Initialize a newly created verifier to look for inappropriate uses of the o verride annotation. 3991 * Initialize a newly created verifier to look for inappropriate uses of the o verride annotation.
3979 * 3992 *
3980 * @param manager the inheritance manager used to find overridden methods 3993 * @param manager the inheritance manager used to find overridden methods
3981 * @param errorReporter the error reporter used to report errors 3994 * @param errorReporter the error reporter used to report errors
3982 */ 3995 */
3983 OverrideVerifier(this._manager, this._errorReporter); 3996 OverrideVerifier(InheritanceManager manager, ErrorReporter errorReporter) {
3997 this._manager = manager;
3998 this._errorReporter = errorReporter;
3999 }
3984 4000
3985 @override 4001 @override
3986 Object visitMethodDeclaration(MethodDeclaration node) { 4002 Object visitMethodDeclaration(MethodDeclaration node) {
3987 ExecutableElement element = node.element; 4003 ExecutableElement element = node.element;
3988 if (_isOverride(element)) { 4004 if (_isOverride(element)) {
3989 if (_getOverriddenMember(element) == null) { 4005 if (_getOverriddenMember(element) == null) {
3990 if (element is MethodElement) { 4006 if (element is MethodElement) {
3991 _errorReporter.reportErrorForNode(HintCode.OVERRIDE_ON_NON_OVERRIDING_ METHOD, node.name, []); 4007 _errorReporter.reportErrorForNode(HintCode.OVERRIDE_ON_NON_OVERRIDING_ METHOD, node.name, []);
3992 } else if (element is PropertyAccessorElement) { 4008 } else if (element is PropertyAccessorElement) {
3993 if (element.isGetter) { 4009 if (element.isGetter) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
4031 /** 4047 /**
4032 * Instances of the class `PubVerifier` traverse an AST structure looking for de viations from 4048 * Instances of the class `PubVerifier` traverse an AST structure looking for de viations from
4033 * pub best practices. 4049 * pub best practices.
4034 */ 4050 */
4035 class PubVerifier extends RecursiveAstVisitor<Object> { 4051 class PubVerifier extends RecursiveAstVisitor<Object> {
4036 static String _PUBSPEC_YAML = "pubspec.yaml"; 4052 static String _PUBSPEC_YAML = "pubspec.yaml";
4037 4053
4038 /** 4054 /**
4039 * The analysis context containing the sources to be analyzed 4055 * The analysis context containing the sources to be analyzed
4040 */ 4056 */
4041 final AnalysisContext _context; 4057 AnalysisContext _context;
4042 4058
4043 /** 4059 /**
4044 * The error reporter by which errors will be reported. 4060 * The error reporter by which errors will be reported.
4045 */ 4061 */
4046 final ErrorReporter _errorReporter; 4062 ErrorReporter _errorReporter;
4047 4063
4048 PubVerifier(this._context, this._errorReporter); 4064 PubVerifier(AnalysisContext context, ErrorReporter errorReporter) {
4065 this._context = context;
4066 this._errorReporter = errorReporter;
4067 }
4049 4068
4050 @override 4069 @override
4051 Object visitImportDirective(ImportDirective directive) { 4070 Object visitImportDirective(ImportDirective directive) {
4052 return null; 4071 return null;
4053 } 4072 }
4054 4073
4055 /** 4074 /**
4056 * This verifies that the passed file import directive is not contained in a s ource inside a 4075 * This verifies that the passed file import directive is not contained in a s ource inside a
4057 * package "lib" directory hierarchy referencing a source outside that package "lib" directory 4076 * package "lib" directory hierarchy referencing a source outside that package "lib" directory
4058 * hierarchy. 4077 * hierarchy.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
4187 } 4206 }
4188 } 4207 }
4189 4208
4190 /** 4209 /**
4191 * Instances of the class `ToDoFinder` find to-do comments in Dart code. 4210 * Instances of the class `ToDoFinder` find to-do comments in Dart code.
4192 */ 4211 */
4193 class ToDoFinder { 4212 class ToDoFinder {
4194 /** 4213 /**
4195 * The error reporter by which to-do comments will be reported. 4214 * The error reporter by which to-do comments will be reported.
4196 */ 4215 */
4197 final ErrorReporter _errorReporter; 4216 ErrorReporter _errorReporter;
4198 4217
4199 /** 4218 /**
4200 * Initialize a newly created to-do finder to report to-do comments to the giv en reporter. 4219 * Initialize a newly created to-do finder to report to-do comments to the giv en reporter.
4201 * 4220 *
4202 * @param errorReporter the error reporter by which to-do comments will be rep orted 4221 * @param errorReporter the error reporter by which to-do comments will be rep orted
4203 */ 4222 */
4204 ToDoFinder(this._errorReporter); 4223 ToDoFinder(ErrorReporter errorReporter) {
4224 this._errorReporter = errorReporter;
4225 }
4205 4226
4206 /** 4227 /**
4207 * Search the comments in the given compilation unit for to-do comments and re port an error for 4228 * Search the comments in the given compilation unit for to-do comments and re port an error for
4208 * each. 4229 * each.
4209 * 4230 *
4210 * @param unit the compilation unit containing the to-do comments 4231 * @param unit the compilation unit containing the to-do comments
4211 */ 4232 */
4212 void findIn(CompilationUnit unit) { 4233 void findIn(CompilationUnit unit) {
4213 _gatherTodoComments(unit.beginToken); 4234 _gatherTodoComments(unit.beginToken);
4214 } 4235 }
(...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after
5537 MethodDeclaration method = n as MethodDeclaration; 5558 MethodDeclaration method = n as MethodDeclaration;
5538 return !method.isStatic; 5559 return !method.isStatic;
5539 } 5560 }
5540 } 5561 }
5541 return false; 5562 return false;
5542 } 5563 }
5543 5564
5544 /** 5565 /**
5545 * The resolver driving this participant. 5566 * The resolver driving this participant.
5546 */ 5567 */
5547 final ResolverVisitor _resolver; 5568 ResolverVisitor _resolver;
5548 5569
5549 /** 5570 /**
5550 * The element for the library containing the compilation unit being visited. 5571 * The element for the library containing the compilation unit being visited.
5551 */ 5572 */
5552 LibraryElement _definingLibrary; 5573 LibraryElement _definingLibrary;
5553 5574
5554 /** 5575 /**
5555 * A flag indicating whether we should generate hints. 5576 * A flag indicating whether we should generate hints.
5556 */ 5577 */
5557 bool _enableHints = false; 5578 bool _enableHints = false;
(...skipping 28 matching lines...) Expand all
5586 * The name of the method that will be invoked if an attempt is made to invoke an undefined method 5607 * The name of the method that will be invoked if an attempt is made to invoke an undefined method
5587 * on an object. 5608 * on an object.
5588 */ 5609 */
5589 static String NO_SUCH_METHOD_METHOD_NAME = "noSuchMethod"; 5610 static String NO_SUCH_METHOD_METHOD_NAME = "noSuchMethod";
5590 5611
5591 /** 5612 /**
5592 * Initialize a newly created visitor to resolve the nodes in a compilation un it. 5613 * Initialize a newly created visitor to resolve the nodes in a compilation un it.
5593 * 5614 *
5594 * @param resolver the resolver driving this participant 5615 * @param resolver the resolver driving this participant
5595 */ 5616 */
5596 ElementResolver(this._resolver) { 5617 ElementResolver(ResolverVisitor resolver) {
5597 this._definingLibrary = _resolver.definingLibrary; 5618 this._resolver = resolver;
5619 this._definingLibrary = resolver.definingLibrary;
5598 AnalysisOptions options = _definingLibrary.context.analysisOptions; 5620 AnalysisOptions options = _definingLibrary.context.analysisOptions;
5599 _enableHints = options.hint; 5621 _enableHints = options.hint;
5600 _dynamicType = _resolver.typeProvider.dynamicType; 5622 _dynamicType = resolver.typeProvider.dynamicType;
5601 _typeType = _resolver.typeProvider.typeType; 5623 _typeType = resolver.typeProvider.typeType;
5602 _subtypeManager = new SubtypeManager(); 5624 _subtypeManager = new SubtypeManager();
5603 _promoteManager = _resolver.promoteManager; 5625 _promoteManager = resolver.promoteManager;
5604 } 5626 }
5605 5627
5606 @override 5628 @override
5607 Object visitAssignmentExpression(AssignmentExpression node) { 5629 Object visitAssignmentExpression(AssignmentExpression node) {
5608 sc.Token operator = node.operator; 5630 sc.Token operator = node.operator;
5609 sc.TokenType operatorType = operator.type; 5631 sc.TokenType operatorType = operator.type;
5610 if (operatorType != sc.TokenType.EQ) { 5632 if (operatorType != sc.TokenType.EQ) {
5611 operatorType = _operatorFromCompoundAssignment(operatorType); 5633 operatorType = _operatorFromCompoundAssignment(operatorType);
5612 Expression leftHandSide = node.leftHandSide; 5634 Expression leftHandSide = node.leftHandSide;
5613 if (leftHandSide != null) { 5635 if (leftHandSide != null) {
(...skipping 2130 matching lines...) Expand 10 before | Expand all | Expand 10 after
7744 /** 7766 /**
7745 * Instances of the class `SyntheticIdentifier` implement an identifier that can be used to 7767 * Instances of the class `SyntheticIdentifier` implement an identifier that can be used to
7746 * look up names in the lexical scope when there is no identifier in the AST str ucture. There is 7768 * look up names in the lexical scope when there is no identifier in the AST str ucture. There is
7747 * no identifier in the AST when the parser could not distinguish between a meth od invocation and 7769 * no identifier in the AST when the parser could not distinguish between a meth od invocation and
7748 * an invocation of a top-level function imported with a prefix. 7770 * an invocation of a top-level function imported with a prefix.
7749 */ 7771 */
7750 class ElementResolver_SyntheticIdentifier extends Identifier { 7772 class ElementResolver_SyntheticIdentifier extends Identifier {
7751 /** 7773 /**
7752 * The name of the synthetic identifier. 7774 * The name of the synthetic identifier.
7753 */ 7775 */
7754 final String name; 7776 String name;
7755 7777
7756 /** 7778 /**
7757 * Initialize a newly created synthetic identifier to have the given name. 7779 * Initialize a newly created synthetic identifier to have the given name.
7758 * 7780 *
7759 * @param name the name of the synthetic identifier 7781 * @param name the name of the synthetic identifier
7760 */ 7782 */
7761 ElementResolver_SyntheticIdentifier(this.name); 7783 ElementResolver_SyntheticIdentifier(String name) {
7784 this.name = name;
7785 }
7762 7786
7763 @override 7787 @override
7764 accept(AstVisitor visitor) => null; 7788 accept(AstVisitor visitor) => null;
7765 7789
7766 @override 7790 @override
7767 sc.Token get beginToken => null; 7791 sc.Token get beginToken => null;
7768 7792
7769 @override 7793 @override
7770 Element get bestElement => null; 7794 Element get bestElement => null;
7771 7795
(...skipping 15 matching lines...) Expand all
7787 } 7811 }
7788 7812
7789 /** 7813 /**
7790 * Instances of the class `IncrementalResolver` resolve the smallest portion of an AST 7814 * Instances of the class `IncrementalResolver` resolve the smallest portion of an AST
7791 * structure that we currently know how to resolve. 7815 * structure that we currently know how to resolve.
7792 */ 7816 */
7793 class IncrementalResolver { 7817 class IncrementalResolver {
7794 /** 7818 /**
7795 * The element for the library containing the compilation unit being visited. 7819 * The element for the library containing the compilation unit being visited.
7796 */ 7820 */
7797 final LibraryElement _definingLibrary; 7821 LibraryElement _definingLibrary;
7798 7822
7799 /** 7823 /**
7800 * The source representing the compilation unit being visited. 7824 * The source representing the compilation unit being visited.
7801 */ 7825 */
7802 final Source _source; 7826 Source _source;
7803 7827
7804 /** 7828 /**
7805 * The object used to access the types from the core library. 7829 * The object used to access the types from the core library.
7806 */ 7830 */
7807 final TypeProvider _typeProvider; 7831 TypeProvider _typeProvider;
7808 7832
7809 /** 7833 /**
7810 * The error listener that will be informed of any errors that are found durin g resolution. 7834 * The error listener that will be informed of any errors that are found durin g resolution.
7811 */ 7835 */
7812 final AnalysisErrorListener _errorListener; 7836 AnalysisErrorListener _errorListener;
7813 7837
7814 /** 7838 /**
7815 * Initialize a newly created incremental resolver to resolve a node in the gi ven source in the 7839 * Initialize a newly created incremental resolver to resolve a node in the gi ven source in the
7816 * given library, reporting errors to the given error listener. 7840 * given library, reporting errors to the given error listener.
7817 * 7841 *
7818 * @param definingLibrary the element for the library containing the compilati on unit being 7842 * @param definingLibrary the element for the library containing the compilati on unit being
7819 * visited 7843 * visited
7820 * @param source the source representing the compilation unit being visited 7844 * @param source the source representing the compilation unit being visited
7821 * @param typeProvider the object used to access the types from the core libra ry 7845 * @param typeProvider the object used to access the types from the core libra ry
7822 * @param errorListener the error listener that will be informed of any errors that are found 7846 * @param errorListener the error listener that will be informed of any errors that are found
7823 * during resolution 7847 * during resolution
7824 */ 7848 */
7825 IncrementalResolver(this._definingLibrary, this._source, this._typeProvider, t his._errorListener); 7849 IncrementalResolver(LibraryElement definingLibrary, Source source, TypeProvide r typeProvider, AnalysisErrorListener errorListener) {
7850 this._definingLibrary = definingLibrary;
7851 this._source = source;
7852 this._typeProvider = typeProvider;
7853 this._errorListener = errorListener;
7854 }
7826 7855
7827 /** 7856 /**
7828 * Resolve the given node, reporting any errors or warnings to the given liste ner. 7857 * Resolve the given node, reporting any errors or warnings to the given liste ner.
7829 * 7858 *
7830 * @param node the root of the AST structure to be resolved 7859 * @param node the root of the AST structure to be resolved
7831 * @throws AnalysisException if the node could not be resolved 7860 * @throws AnalysisException if the node could not be resolved
7832 */ 7861 */
7833 void resolve(AstNode node) { 7862 void resolve(AstNode node) {
7834 AstNode rootNode = _findResolutionRoot(node); 7863 AstNode rootNode = _findResolutionRoot(node);
7835 Scope scope = ScopeBuilder.scopeFor(rootNode, _errorListener); 7864 Scope scope = ScopeBuilder.scopeFor(rootNode, _errorListener);
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
8784 8813
8785 /** 8814 /**
8786 * Instances of the class `Library` represent the data about a single library du ring the 8815 * Instances of the class `Library` represent the data about a single library du ring the
8787 * resolution of some (possibly different) library. They are not intended to be used except during 8816 * resolution of some (possibly different) library. They are not intended to be used except during
8788 * the resolution process. 8817 * the resolution process.
8789 */ 8818 */
8790 class Library { 8819 class Library {
8791 /** 8820 /**
8792 * The analysis context in which this library is being analyzed. 8821 * The analysis context in which this library is being analyzed.
8793 */ 8822 */
8794 final InternalAnalysisContext _analysisContext; 8823 InternalAnalysisContext _analysisContext;
8795 8824
8796 /** 8825 /**
8797 * The inheritance manager which is used for this member lookups in this libra ry. 8826 * The inheritance manager which is used for this member lookups in this libra ry.
8798 */ 8827 */
8799 InheritanceManager _inheritanceManager; 8828 InheritanceManager _inheritanceManager;
8800 8829
8801 /** 8830 /**
8802 * The listener to which analysis errors will be reported. 8831 * The listener to which analysis errors will be reported.
8803 */ 8832 */
8804 final AnalysisErrorListener _errorListener; 8833 AnalysisErrorListener _errorListener;
8805 8834
8806 /** 8835 /**
8807 * The source specifying the defining compilation unit of this library. 8836 * The source specifying the defining compilation unit of this library.
8808 */ 8837 */
8809 final Source librarySource; 8838 Source librarySource;
8810 8839
8811 /** 8840 /**
8812 * The library element representing this library. 8841 * The library element representing this library.
8813 */ 8842 */
8814 LibraryElementImpl _libraryElement; 8843 LibraryElementImpl _libraryElement;
8815 8844
8816 /** 8845 /**
8817 * A list containing all of the libraries that are imported into this library. 8846 * A list containing all of the libraries that are imported into this library.
8818 */ 8847 */
8819 List<Library> _importedLibraries = _EMPTY_ARRAY; 8848 List<Library> _importedLibraries = _EMPTY_ARRAY;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
8854 */ 8883 */
8855 static String _DART_EXT_SCHEME = "dart-ext:"; 8884 static String _DART_EXT_SCHEME = "dart-ext:";
8856 8885
8857 /** 8886 /**
8858 * Initialize a newly created data holder that can maintain the data associate d with a library. 8887 * Initialize a newly created data holder that can maintain the data associate d with a library.
8859 * 8888 *
8860 * @param analysisContext the analysis context in which this library is being analyzed 8889 * @param analysisContext the analysis context in which this library is being analyzed
8861 * @param errorListener the listener to which analysis errors will be reported 8890 * @param errorListener the listener to which analysis errors will be reported
8862 * @param librarySource the source specifying the defining compilation unit of this library 8891 * @param librarySource the source specifying the defining compilation unit of this library
8863 */ 8892 */
8864 Library(this._analysisContext, this._errorListener, this.librarySource) { 8893 Library(InternalAnalysisContext analysisContext, AnalysisErrorListener errorLi stener, Source librarySource) {
8865 this._libraryElement = _analysisContext.getLibraryElement(librarySource) as LibraryElementImpl; 8894 this._analysisContext = analysisContext;
8895 this._errorListener = errorListener;
8896 this.librarySource = librarySource;
8897 this._libraryElement = analysisContext.getLibraryElement(librarySource) as L ibraryElementImpl;
8866 } 8898 }
8867 8899
8868 /** 8900 /**
8869 * Return the AST structure associated with the given source. 8901 * Return the AST structure associated with the given source.
8870 * 8902 *
8871 * @param source the source representing the compilation unit whose AST is to be returned 8903 * @param source the source representing the compilation unit whose AST is to be returned
8872 * @return the AST structure associated with the given source 8904 * @return the AST structure associated with the given source
8873 * @throws AnalysisException if an AST structure could not be created for the compilation unit 8905 * @throws AnalysisException if an AST structure could not be created for the compilation unit
8874 */ 8906 */
8875 CompilationUnit getAST(Source source) { 8907 CompilationUnit getAST(Source source) {
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
9088 String toString() => librarySource.shortName; 9120 String toString() => librarySource.shortName;
9089 } 9121 }
9090 9122
9091 /** 9123 /**
9092 * Instances of the class `LibraryElementBuilder` build an element model for a s ingle library. 9124 * Instances of the class `LibraryElementBuilder` build an element model for a s ingle library.
9093 */ 9125 */
9094 class LibraryElementBuilder { 9126 class LibraryElementBuilder {
9095 /** 9127 /**
9096 * The analysis context in which the element model will be built. 9128 * The analysis context in which the element model will be built.
9097 */ 9129 */
9098 final InternalAnalysisContext _analysisContext; 9130 InternalAnalysisContext _analysisContext;
9099 9131
9100 /** 9132 /**
9101 * The listener to which errors will be reported. 9133 * The listener to which errors will be reported.
9102 */ 9134 */
9103 final AnalysisErrorListener _errorListener; 9135 AnalysisErrorListener _errorListener;
9104 9136
9105 /** 9137 /**
9106 * The name of the function used as an entry point. 9138 * The name of the function used as an entry point.
9107 */ 9139 */
9108 static String ENTRY_POINT_NAME = "main"; 9140 static String ENTRY_POINT_NAME = "main";
9109 9141
9110 /** 9142 /**
9111 * Initialize a newly created library element builder. 9143 * Initialize a newly created library element builder.
9112 * 9144 *
9113 * @param analysisContext the analysis context in which the element model will be built 9145 * @param analysisContext the analysis context in which the element model will be built
9114 * @param errorListener the listener to which errors will be reported 9146 * @param errorListener the listener to which errors will be reported
9115 */ 9147 */
9116 LibraryElementBuilder(this._analysisContext, this._errorListener); 9148 LibraryElementBuilder(InternalAnalysisContext analysisContext, AnalysisErrorLi stener errorListener) {
9149 this._analysisContext = analysisContext;
9150 this._errorListener = errorListener;
9151 }
9117 9152
9118 /** 9153 /**
9119 * Build the library element for the given library. 9154 * Build the library element for the given library.
9120 * 9155 *
9121 * @param library the library for which an element model is to be built 9156 * @param library the library for which an element model is to be built
9122 * @return the library element that was built 9157 * @return the library element that was built
9123 * @throws AnalysisException if the analysis could not be performed 9158 * @throws AnalysisException if the analysis could not be performed
9124 */ 9159 */
9125 LibraryElementImpl buildLibrary(Library library) { 9160 LibraryElementImpl buildLibrary(Library library) {
9126 CompilationUnitBuilder builder = new CompilationUnitBuilder(); 9161 CompilationUnitBuilder builder = new CompilationUnitBuilder();
(...skipping 14 matching lines...) Expand all
9141 // the possibility of circular references). 9176 // the possibility of circular references).
9142 // 9177 //
9143 if (directive is LibraryDirective) { 9178 if (directive is LibraryDirective) {
9144 if (libraryNameNode == null) { 9179 if (libraryNameNode == null) {
9145 libraryNameNode = directive.name; 9180 libraryNameNode = directive.name;
9146 directivesToResolve.add(directive); 9181 directivesToResolve.add(directive);
9147 } 9182 }
9148 } else if (directive is PartDirective) { 9183 } else if (directive is PartDirective) {
9149 PartDirective partDirective = directive; 9184 PartDirective partDirective = directive;
9150 StringLiteral partUri = partDirective.uri; 9185 StringLiteral partUri = partDirective.uri;
9151 Source partSource = partDirective.source; 9186 Source partSource = library.getSource(partDirective);
9152 if (_analysisContext.exists(partSource)) { 9187 if (_analysisContext.exists(partSource)) {
9153 hasPartDirective = true; 9188 hasPartDirective = true;
9154 CompilationUnit partUnit = library.getAST(partSource); 9189 CompilationUnit partUnit = library.getAST(partSource);
9155 CompilationUnitElementImpl part = builder.buildCompilationUnit(partSou rce, partUnit); 9190 CompilationUnitElementImpl part = builder.buildCompilationUnit(partSou rce, partUnit);
9156 part.uriOffset = partUri.offset; 9191 part.uriOffset = partUri.offset;
9157 part.uriEnd = partUri.end; 9192 part.uriEnd = partUri.end;
9158 part.uri = library.getUri(partDirective); 9193 part.uri = library.getUri(partDirective);
9159 // 9194 //
9160 // Validate that the part contains a part-of directive with the same n ame as the library. 9195 // Validate that the part contains a part-of directive with the same n ame as the library.
9161 // 9196 //
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
9366 } 9401 }
9367 9402
9368 /** 9403 /**
9369 * Instances of the class `LibraryResolver` are used to resolve one or more mutu ally dependent 9404 * Instances of the class `LibraryResolver` are used to resolve one or more mutu ally dependent
9370 * libraries within a single context. 9405 * libraries within a single context.
9371 */ 9406 */
9372 class LibraryResolver { 9407 class LibraryResolver {
9373 /** 9408 /**
9374 * The analysis context in which the libraries are being analyzed. 9409 * The analysis context in which the libraries are being analyzed.
9375 */ 9410 */
9376 final InternalAnalysisContext analysisContext; 9411 InternalAnalysisContext analysisContext;
9377 9412
9378 /** 9413 /**
9379 * The listener to which analysis errors will be reported, this error listener is either 9414 * The listener to which analysis errors will be reported, this error listener is either
9380 * references [recordingErrorListener], or it unions the passed 9415 * references [recordingErrorListener], or it unions the passed
9381 * [AnalysisErrorListener] with the [recordingErrorListener]. 9416 * [AnalysisErrorListener] with the [recordingErrorListener].
9382 */ 9417 */
9383 RecordingErrorListener _errorListener; 9418 RecordingErrorListener _errorListener;
9384 9419
9385 /** 9420 /**
9386 * A source object representing the core library (dart:core). 9421 * A source object representing the core library (dart:core).
(...skipping 18 matching lines...) Expand all
9405 /** 9440 /**
9406 * A collection containing the libraries that are being resolved together. 9441 * A collection containing the libraries that are being resolved together.
9407 */ 9442 */
9408 Set<Library> _librariesInCycles; 9443 Set<Library> _librariesInCycles;
9409 9444
9410 /** 9445 /**
9411 * Initialize a newly created library resolver to resolve libraries within the given context. 9446 * Initialize a newly created library resolver to resolve libraries within the given context.
9412 * 9447 *
9413 * @param analysisContext the analysis context in which the library is being a nalyzed 9448 * @param analysisContext the analysis context in which the library is being a nalyzed
9414 */ 9449 */
9415 LibraryResolver(this.analysisContext) { 9450 LibraryResolver(InternalAnalysisContext analysisContext) {
9451 this.analysisContext = analysisContext;
9416 this._errorListener = new RecordingErrorListener(); 9452 this._errorListener = new RecordingErrorListener();
9417 _coreLibrarySource = analysisContext.sourceFactory.forUri(DartSdk.DART_CORE) ; 9453 _coreLibrarySource = analysisContext.sourceFactory.forUri(DartSdk.DART_CORE) ;
9418 } 9454 }
9419 9455
9420 /** 9456 /**
9421 * Return the listener to which analysis errors will be reported. 9457 * Return the listener to which analysis errors will be reported.
9422 * 9458 *
9423 * @return the listener to which analysis errors will be reported 9459 * @return the listener to which analysis errors will be reported
9424 */ 9460 */
9425 RecordingErrorListener get errorListener => _errorListener; 9461 RecordingErrorListener get errorListener => _errorListener;
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
9704 * be accessed 9740 * be accessed
9705 */ 9741 */
9706 void _buildDirectiveModels() { 9742 void _buildDirectiveModels() {
9707 for (Library library in _librariesInCycles) { 9743 for (Library library in _librariesInCycles) {
9708 Map<String, PrefixElementImpl> nameToPrefixMap = new Map<String, PrefixEle mentImpl>(); 9744 Map<String, PrefixElementImpl> nameToPrefixMap = new Map<String, PrefixEle mentImpl>();
9709 List<ImportElement> imports = new List<ImportElement>(); 9745 List<ImportElement> imports = new List<ImportElement>();
9710 List<ExportElement> exports = new List<ExportElement>(); 9746 List<ExportElement> exports = new List<ExportElement>();
9711 for (Directive directive in library.definingCompilationUnit.directives) { 9747 for (Directive directive in library.definingCompilationUnit.directives) {
9712 if (directive is ImportDirective) { 9748 if (directive is ImportDirective) {
9713 ImportDirective importDirective = directive; 9749 ImportDirective importDirective = directive;
9714 String uriContent = importDirective.uriContent; 9750 Source importedSource = library.getSource(importDirective);
9715 if (DartUriResolver.isDartExtUri(uriContent)) {
9716 library.libraryElement.hasExtUri = true;
9717 }
9718 Source importedSource = importDirective.source;
9719 if (importedSource != null) { 9751 if (importedSource != null) {
9720 // The imported source will be null if the URI in the import directi ve was invalid. 9752 // The imported source will be null if the URI in the import directi ve was invalid.
9721 Library importedLibrary = _libraryMap[importedSource]; 9753 Library importedLibrary = _libraryMap[importedSource];
9722 if (importedLibrary != null) { 9754 if (importedLibrary != null) {
9723 ImportElementImpl importElement = new ImportElementImpl(directive. offset); 9755 ImportElementImpl importElement = new ImportElementImpl(directive. offset);
9724 StringLiteral uriLiteral = importDirective.uri; 9756 StringLiteral uriLiteral = importDirective.uri;
9725 importElement.uriOffset = uriLiteral.offset; 9757 importElement.uriOffset = uriLiteral.offset;
9726 importElement.uriEnd = uriLiteral.end; 9758 importElement.uriEnd = uriLiteral.end;
9727 importElement.uri = uriContent; 9759 importElement.uri = library.getUri(importDirective);
9728 importElement.combinators = _buildCombinators(importDirective); 9760 importElement.combinators = _buildCombinators(importDirective);
9729 LibraryElement importedLibraryElement = importedLibrary.libraryEle ment; 9761 LibraryElement importedLibraryElement = importedLibrary.libraryEle ment;
9730 if (importedLibraryElement != null) { 9762 if (importedLibraryElement != null) {
9731 importElement.importedLibrary = importedLibraryElement; 9763 importElement.importedLibrary = importedLibraryElement;
9732 } 9764 }
9733 SimpleIdentifier prefixNode = directive.prefix; 9765 SimpleIdentifier prefixNode = directive.prefix;
9734 if (prefixNode != null) { 9766 if (prefixNode != null) {
9735 importElement.prefixOffset = prefixNode.offset; 9767 importElement.prefixOffset = prefixNode.offset;
9736 String prefixName = prefixNode.name; 9768 String prefixName = prefixNode.name;
9737 PrefixElementImpl prefix = nameToPrefixMap[prefixName]; 9769 PrefixElementImpl prefix = nameToPrefixMap[prefixName];
9738 if (prefix == null) { 9770 if (prefix == null) {
9739 prefix = new PrefixElementImpl(prefixNode); 9771 prefix = new PrefixElementImpl(prefixNode);
9740 nameToPrefixMap[prefixName] = prefix; 9772 nameToPrefixMap[prefixName] = prefix;
9741 } 9773 }
9742 importElement.prefix = prefix; 9774 importElement.prefix = prefix;
9743 prefixNode.staticElement = prefix; 9775 prefixNode.staticElement = prefix;
9744 } 9776 }
9745 directive.element = importElement; 9777 directive.element = importElement;
9746 imports.add(importElement); 9778 imports.add(importElement);
9747 if (analysisContext.computeKindOf(importedSource) != SourceKind.LI BRARY) { 9779 if (analysisContext.computeKindOf(importedSource) != SourceKind.LI BRARY) {
9748 _errorListener.onError(new AnalysisError.con2(library.librarySou rce, uriLiteral.offset, uriLiteral.length, CompileTimeErrorCode.IMPORT_OF_NON_LI BRARY, [uriLiteral.toSource()])); 9780 _errorListener.onError(new AnalysisError.con2(library.librarySou rce, uriLiteral.offset, uriLiteral.length, CompileTimeErrorCode.IMPORT_OF_NON_LI BRARY, [uriLiteral.toSource()]));
9749 } 9781 }
9750 } 9782 }
9751 } 9783 }
9752 } else if (directive is ExportDirective) { 9784 } else if (directive is ExportDirective) {
9753 ExportDirective exportDirective = directive; 9785 ExportDirective exportDirective = directive;
9754 Source exportedSource = exportDirective.source; 9786 Source exportedSource = library.getSource(exportDirective);
9755 if (exportedSource != null) { 9787 if (exportedSource != null) {
9756 // The exported source will be null if the URI in the export directi ve was invalid. 9788 // The exported source will be null if the URI in the export directi ve was invalid.
9757 Library exportedLibrary = _libraryMap[exportedSource]; 9789 Library exportedLibrary = _libraryMap[exportedSource];
9758 if (exportedLibrary != null) { 9790 if (exportedLibrary != null) {
9759 ExportElementImpl exportElement = new ExportElementImpl(); 9791 ExportElementImpl exportElement = new ExportElementImpl();
9760 StringLiteral uriLiteral = exportDirective.uri; 9792 StringLiteral uriLiteral = exportDirective.uri;
9761 exportElement.uriOffset = uriLiteral.offset; 9793 exportElement.uriOffset = uriLiteral.offset;
9762 exportElement.uriEnd = uriLiteral.end; 9794 exportElement.uriEnd = uriLiteral.end;
9763 exportElement.uri = exportDirective.uriContent; 9795 exportElement.uri = library.getUri(exportDirective);
9764 exportElement.combinators = _buildCombinators(exportDirective); 9796 exportElement.combinators = _buildCombinators(exportDirective);
9765 LibraryElement exportedLibraryElement = exportedLibrary.libraryEle ment; 9797 LibraryElement exportedLibraryElement = exportedLibrary.libraryEle ment;
9766 if (exportedLibraryElement != null) { 9798 if (exportedLibraryElement != null) {
9767 exportElement.exportedLibrary = exportedLibraryElement; 9799 exportElement.exportedLibrary = exportedLibraryElement;
9768 } 9800 }
9769 directive.element = exportElement; 9801 directive.element = exportElement;
9770 exports.add(exportElement); 9802 exports.add(exportElement);
9771 if (analysisContext.computeKindOf(exportedSource) != SourceKind.LI BRARY) { 9803 if (analysisContext.computeKindOf(exportedSource) != SourceKind.LI BRARY) {
9772 _errorListener.onError(new AnalysisError.con2(library.librarySou rce, uriLiteral.offset, uriLiteral.length, CompileTimeErrorCode.EXPORT_OF_NON_LI BRARY, [uriLiteral.toSource()])); 9804 _errorListener.onError(new AnalysisError.con2(library.librarySou rce, uriLiteral.offset, uriLiteral.length, CompileTimeErrorCode.EXPORT_OF_NON_LI BRARY, [uriLiteral.toSource()]));
9773 } 9805 }
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
10099 } 10131 }
10100 10132
10101 /** 10133 /**
10102 * Instances of the class `LibraryResolver` are used to resolve one or more mutu ally dependent 10134 * Instances of the class `LibraryResolver` are used to resolve one or more mutu ally dependent
10103 * libraries within a single context. 10135 * libraries within a single context.
10104 */ 10136 */
10105 class LibraryResolver2 { 10137 class LibraryResolver2 {
10106 /** 10138 /**
10107 * The analysis context in which the libraries are being analyzed. 10139 * The analysis context in which the libraries are being analyzed.
10108 */ 10140 */
10109 final InternalAnalysisContext analysisContext; 10141 InternalAnalysisContext analysisContext;
10110 10142
10111 /** 10143 /**
10112 * The listener to which analysis errors will be reported, this error listener is either 10144 * The listener to which analysis errors will be reported, this error listener is either
10113 * references [recordingErrorListener], or it unions the passed 10145 * references [recordingErrorListener], or it unions the passed
10114 * [AnalysisErrorListener] with the [recordingErrorListener]. 10146 * [AnalysisErrorListener] with the [recordingErrorListener].
10115 */ 10147 */
10116 RecordingErrorListener _errorListener; 10148 RecordingErrorListener _errorListener;
10117 10149
10118 /** 10150 /**
10119 * A source object representing the core library (dart:core). 10151 * A source object representing the core library (dart:core).
(...skipping 18 matching lines...) Expand all
10138 /** 10170 /**
10139 * A collection containing the libraries that are being resolved together. 10171 * A collection containing the libraries that are being resolved together.
10140 */ 10172 */
10141 List<ResolvableLibrary> _librariesInCycle; 10173 List<ResolvableLibrary> _librariesInCycle;
10142 10174
10143 /** 10175 /**
10144 * Initialize a newly created library resolver to resolve libraries within the given context. 10176 * Initialize a newly created library resolver to resolve libraries within the given context.
10145 * 10177 *
10146 * @param analysisContext the analysis context in which the library is being a nalyzed 10178 * @param analysisContext the analysis context in which the library is being a nalyzed
10147 */ 10179 */
10148 LibraryResolver2(this.analysisContext) { 10180 LibraryResolver2(InternalAnalysisContext analysisContext) {
10181 this.analysisContext = analysisContext;
10149 this._errorListener = new RecordingErrorListener(); 10182 this._errorListener = new RecordingErrorListener();
10150 _coreLibrarySource = analysisContext.sourceFactory.forUri(DartSdk.DART_CORE) ; 10183 _coreLibrarySource = analysisContext.sourceFactory.forUri(DartSdk.DART_CORE) ;
10151 } 10184 }
10152 10185
10153 /** 10186 /**
10154 * Return the listener to which analysis errors will be reported. 10187 * Return the listener to which analysis errors will be reported.
10155 * 10188 *
10156 * @return the listener to which analysis errors will be reported 10189 * @return the listener to which analysis errors will be reported
10157 */ 10190 */
10158 RecordingErrorListener get errorListener => _errorListener; 10191 RecordingErrorListener get errorListener => _errorListener;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
10273 * be accessed 10306 * be accessed
10274 */ 10307 */
10275 void _buildDirectiveModels() { 10308 void _buildDirectiveModels() {
10276 for (ResolvableLibrary library in _librariesInCycle) { 10309 for (ResolvableLibrary library in _librariesInCycle) {
10277 Map<String, PrefixElementImpl> nameToPrefixMap = new Map<String, PrefixEle mentImpl>(); 10310 Map<String, PrefixElementImpl> nameToPrefixMap = new Map<String, PrefixEle mentImpl>();
10278 List<ImportElement> imports = new List<ImportElement>(); 10311 List<ImportElement> imports = new List<ImportElement>();
10279 List<ExportElement> exports = new List<ExportElement>(); 10312 List<ExportElement> exports = new List<ExportElement>();
10280 for (Directive directive in library.definingCompilationUnit.directives) { 10313 for (Directive directive in library.definingCompilationUnit.directives) {
10281 if (directive is ImportDirective) { 10314 if (directive is ImportDirective) {
10282 ImportDirective importDirective = directive; 10315 ImportDirective importDirective = directive;
10283 String uriContent = importDirective.uriContent;
10284 if (DartUriResolver.isDartExtUri(uriContent)) {
10285 library.libraryElement.hasExtUri = true;
10286 }
10287 Source importedSource = importDirective.source; 10316 Source importedSource = importDirective.source;
10288 if (importedSource != null && analysisContext.exists(importedSource)) { 10317 if (importedSource != null && analysisContext.exists(importedSource)) {
10289 // The imported source will be null if the URI in the import directi ve was invalid. 10318 // The imported source will be null if the URI in the import directi ve was invalid.
10290 ResolvableLibrary importedLibrary = _libraryMap[importedSource]; 10319 ResolvableLibrary importedLibrary = _libraryMap[importedSource];
10291 if (importedLibrary != null) { 10320 if (importedLibrary != null) {
10292 ImportElementImpl importElement = new ImportElementImpl(directive. offset); 10321 ImportElementImpl importElement = new ImportElementImpl(directive. offset);
10293 StringLiteral uriLiteral = importDirective.uri; 10322 StringLiteral uriLiteral = importDirective.uri;
10294 if (uriLiteral != null) { 10323 if (uriLiteral != null) {
10295 importElement.uriOffset = uriLiteral.offset; 10324 importElement.uriOffset = uriLiteral.offset;
10296 importElement.uriEnd = uriLiteral.end; 10325 importElement.uriEnd = uriLiteral.end;
10297 } 10326 }
10298 importElement.uri = uriContent; 10327 importElement.uri = importDirective.uriContent;
10299 importElement.combinators = _buildCombinators(importDirective); 10328 importElement.combinators = _buildCombinators(importDirective);
10300 LibraryElement importedLibraryElement = importedLibrary.libraryEle ment; 10329 LibraryElement importedLibraryElement = importedLibrary.libraryEle ment;
10301 if (importedLibraryElement != null) { 10330 if (importedLibraryElement != null) {
10302 importElement.importedLibrary = importedLibraryElement; 10331 importElement.importedLibrary = importedLibraryElement;
10303 } 10332 }
10304 SimpleIdentifier prefixNode = directive.prefix; 10333 SimpleIdentifier prefixNode = directive.prefix;
10305 if (prefixNode != null) { 10334 if (prefixNode != null) {
10306 importElement.prefixOffset = prefixNode.offset; 10335 importElement.prefixOffset = prefixNode.offset;
10307 String prefixName = prefixNode.name; 10336 String prefixName = prefixNode.name;
10308 PrefixElementImpl prefix = nameToPrefixMap[prefixName]; 10337 PrefixElementImpl prefix = nameToPrefixMap[prefixName];
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
10678 * 10707 *
10679 * If we have other conditional error codes in the future, we should have this c lass implement some 10708 * If we have other conditional error codes in the future, we should have this c lass implement some
10680 * ConditionalErrorCode so that after resolution, a list of ConditionalErrorCode can be visited 10709 * ConditionalErrorCode so that after resolution, a list of ConditionalErrorCode can be visited
10681 * instead of multiple lists of *ConditionalErrorCodes. 10710 * instead of multiple lists of *ConditionalErrorCodes.
10682 */ 10711 */
10683 class ProxyConditionalAnalysisError { 10712 class ProxyConditionalAnalysisError {
10684 /** 10713 /**
10685 * The enclosing [ClassElement], this is what will determine if the error code should, or 10714 * The enclosing [ClassElement], this is what will determine if the error code should, or
10686 * should not, be generated on the source. 10715 * should not, be generated on the source.
10687 */ 10716 */
10688 final Element _enclosingElement; 10717 Element _enclosingElement;
10689 10718
10690 /** 10719 /**
10691 * The conditional analysis error. 10720 * The conditional analysis error.
10692 */ 10721 */
10693 final AnalysisError analysisError; 10722 AnalysisError analysisError;
10694 10723
10695 /** 10724 /**
10696 * Instantiate a new [ProxyConditionalAnalysisError] with some enclosing eleme nt and the 10725 * Instantiate a new [ProxyConditionalAnalysisError] with some enclosing eleme nt and the
10697 * conditional analysis error. 10726 * conditional analysis error.
10698 * 10727 *
10699 * @param enclosingElement the enclosing element 10728 * @param enclosingElement the enclosing element
10700 * @param analysisError the conditional analysis error 10729 * @param analysisError the conditional analysis error
10701 */ 10730 */
10702 ProxyConditionalAnalysisError(this._enclosingElement, this.analysisError); 10731 ProxyConditionalAnalysisError(Element enclosingElement, AnalysisError analysis Error) {
10732 this._enclosingElement = enclosingElement;
10733 this.analysisError = analysisError;
10734 }
10703 10735
10704 /** 10736 /**
10705 * Return `true` iff the enclosing class has the proxy annotation. 10737 * Return `true` iff the enclosing class has the proxy annotation.
10706 * 10738 *
10707 * @return `true` iff the enclosing class has the proxy annotation 10739 * @return `true` iff the enclosing class has the proxy annotation
10708 */ 10740 */
10709 bool shouldIncludeErrorCode() { 10741 bool shouldIncludeErrorCode() {
10710 if (_enclosingElement is ClassElement) { 10742 if (_enclosingElement is ClassElement) {
10711 return !(_enclosingElement as ClassElement).isOrInheritsProxy; 10743 return !(_enclosingElement as ClassElement).isOrInheritsProxy;
10712 } 10744 }
10713 return true; 10745 return true;
10714 } 10746 }
10715 } 10747 }
10716 10748
10717 /** 10749 /**
10718 * Instances of the class `Library` represent the data about a single library du ring the 10750 * Instances of the class `Library` represent the data about a single library du ring the
10719 * resolution of some (possibly different) library. They are not intended to be used except during 10751 * resolution of some (possibly different) library. They are not intended to be used except during
10720 * the resolution process. 10752 * the resolution process.
10721 */ 10753 */
10722 class ResolvableLibrary { 10754 class ResolvableLibrary {
10723 /** 10755 /**
10724 * The source specifying the defining compilation unit of this library. 10756 * The source specifying the defining compilation unit of this library.
10725 */ 10757 */
10726 final Source librarySource; 10758 Source librarySource;
10727 10759
10728 /** 10760 /**
10729 * A list containing all of the libraries that are imported into this library. 10761 * A list containing all of the libraries that are imported into this library.
10730 */ 10762 */
10731 List<ResolvableLibrary> _importedLibraries = _EMPTY_ARRAY; 10763 List<ResolvableLibrary> _importedLibraries = _EMPTY_ARRAY;
10732 10764
10733 /** 10765 /**
10734 * A flag indicating whether this library explicitly imports core. 10766 * A flag indicating whether this library explicitly imports core.
10735 */ 10767 */
10736 bool explicitlyImportsCore = false; 10768 bool explicitlyImportsCore = false;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
10770 * The library scope used when resolving elements within this library's compil ation units. 10802 * The library scope used when resolving elements within this library's compil ation units.
10771 */ 10803 */
10772 LibraryScope _libraryScope; 10804 LibraryScope _libraryScope;
10773 10805
10774 /** 10806 /**
10775 * Initialize a newly created data holder that can maintain the data associate d with a library. 10807 * Initialize a newly created data holder that can maintain the data associate d with a library.
10776 * 10808 *
10777 * @param librarySource the source specifying the defining compilation unit of this library 10809 * @param librarySource the source specifying the defining compilation unit of this library
10778 * @param errorListener the listener to which analysis errors will be reported 10810 * @param errorListener the listener to which analysis errors will be reported
10779 */ 10811 */
10780 ResolvableLibrary(this.librarySource); 10812 ResolvableLibrary(Source librarySource) {
10813 this.librarySource = librarySource;
10814 }
10781 10815
10782 /** 10816 /**
10783 * Return the AST structure associated with the given source, or `null` if the source does 10817 * Return the AST structure associated with the given source, or `null` if the source does
10784 * not represent a compilation unit that is included in this library. 10818 * not represent a compilation unit that is included in this library.
10785 * 10819 *
10786 * @param source the source representing the compilation unit whose AST is to be returned 10820 * @param source the source representing the compilation unit whose AST is to be returned
10787 * @return the AST structure associated with the given source 10821 * @return the AST structure associated with the given source
10788 * @throws AnalysisException if an AST structure could not be created for the compilation unit 10822 * @throws AnalysisException if an AST structure could not be created for the compilation unit
10789 */ 10823 */
10790 CompilationUnit getAST(Source source) { 10824 CompilationUnit getAST(Source source) {
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after
12308 */ 12342 */
12309 abstract class ScopedVisitor extends UnifyingAstVisitor<Object> { 12343 abstract class ScopedVisitor extends UnifyingAstVisitor<Object> {
12310 /** 12344 /**
12311 * The element for the library containing the compilation unit being visited. 12345 * The element for the library containing the compilation unit being visited.
12312 */ 12346 */
12313 LibraryElement _definingLibrary; 12347 LibraryElement _definingLibrary;
12314 12348
12315 /** 12349 /**
12316 * The source representing the compilation unit being visited. 12350 * The source representing the compilation unit being visited.
12317 */ 12351 */
12318 final Source source; 12352 Source source;
12319 12353
12320 /** 12354 /**
12321 * The error listener that will be informed of any errors that are found durin g resolution. 12355 * The error listener that will be informed of any errors that are found durin g resolution.
12322 */ 12356 */
12323 AnalysisErrorListener _errorListener; 12357 AnalysisErrorListener _errorListener;
12324 12358
12325 /** 12359 /**
12326 * The scope used to resolve identifiers. 12360 * The scope used to resolve identifiers.
12327 */ 12361 */
12328 Scope _nameScope; 12362 Scope _nameScope;
12329 12363
12330 /** 12364 /**
12331 * The object used to access the types from the core library. 12365 * The object used to access the types from the core library.
12332 */ 12366 */
12333 final TypeProvider typeProvider; 12367 TypeProvider typeProvider;
12334 12368
12335 /** 12369 /**
12336 * The scope used to resolve labels for `break` and `continue` statements, or 12370 * The scope used to resolve labels for `break` and `continue` statements, or
12337 * `null` if no labels have been defined in the current context. 12371 * `null` if no labels have been defined in the current context.
12338 */ 12372 */
12339 LabelScope _labelScope; 12373 LabelScope _labelScope;
12340 12374
12341 /** 12375 /**
12342 * Initialize a newly created visitor to resolve the nodes in a compilation un it. 12376 * Initialize a newly created visitor to resolve the nodes in a compilation un it.
12343 * 12377 *
12344 * @param library the library containing the compilation unit being resolved 12378 * @param library the library containing the compilation unit being resolved
12345 * @param source the source representing the compilation unit being visited 12379 * @param source the source representing the compilation unit being visited
12346 * @param typeProvider the object used to access the types from the core libra ry 12380 * @param typeProvider the object used to access the types from the core libra ry
12347 */ 12381 */
12348 ScopedVisitor.con1(Library library, this.source, this.typeProvider) { 12382 ScopedVisitor.con1(Library library, Source source, TypeProvider typeProvider) {
12349 this._definingLibrary = library.libraryElement; 12383 this._definingLibrary = library.libraryElement;
12384 this.source = source;
12350 LibraryScope libraryScope = library.libraryScope; 12385 LibraryScope libraryScope = library.libraryScope;
12351 this._errorListener = libraryScope.errorListener; 12386 this._errorListener = libraryScope.errorListener;
12352 this._nameScope = libraryScope; 12387 this._nameScope = libraryScope;
12388 this.typeProvider = typeProvider;
12353 } 12389 }
12354 12390
12355 /** 12391 /**
12356 * Initialize a newly created visitor to resolve the nodes in a compilation un it. 12392 * Initialize a newly created visitor to resolve the nodes in a compilation un it.
12357 * 12393 *
12358 * @param definingLibrary the element for the library containing the compilati on unit being 12394 * @param definingLibrary the element for the library containing the compilati on unit being
12359 * visited 12395 * visited
12360 * @param source the source representing the compilation unit being visited 12396 * @param source the source representing the compilation unit being visited
12361 * @param typeProvider the object used to access the types from the core libra ry 12397 * @param typeProvider the object used to access the types from the core libra ry
12362 * @param errorListener the error listener that will be informed of any errors that are found 12398 * @param errorListener the error listener that will be informed of any errors that are found
12363 * during resolution 12399 * during resolution
12364 */ 12400 */
12365 ScopedVisitor.con2(LibraryElement definingLibrary, this.source, this.typeProvi der, AnalysisErrorListener errorListener) { 12401 ScopedVisitor.con2(LibraryElement definingLibrary, Source source, TypeProvider typeProvider, AnalysisErrorListener errorListener) {
12366 this._definingLibrary = definingLibrary; 12402 this._definingLibrary = definingLibrary;
12403 this.source = source;
12367 this._errorListener = errorListener; 12404 this._errorListener = errorListener;
12368 this._nameScope = new LibraryScope(definingLibrary, errorListener); 12405 this._nameScope = new LibraryScope(definingLibrary, errorListener);
12406 this.typeProvider = typeProvider;
12369 } 12407 }
12370 12408
12371 /** 12409 /**
12372 * Initialize a newly created visitor to resolve the nodes in a compilation un it. 12410 * Initialize a newly created visitor to resolve the nodes in a compilation un it.
12373 * 12411 *
12374 * @param definingLibrary the element for the library containing the compilati on unit being 12412 * @param definingLibrary the element for the library containing the compilati on unit being
12375 * visited 12413 * visited
12376 * @param source the source representing the compilation unit being visited 12414 * @param source the source representing the compilation unit being visited
12377 * @param typeProvider the object used to access the types from the core libra ry 12415 * @param typeProvider the object used to access the types from the core libra ry
12378 * @param nameScope the scope used to resolve identifiers in the node that wil l first be visited 12416 * @param nameScope the scope used to resolve identifiers in the node that wil l first be visited
12379 * @param errorListener the error listener that will be informed of any errors that are found 12417 * @param errorListener the error listener that will be informed of any errors that are found
12380 * during resolution 12418 * during resolution
12381 */ 12419 */
12382 ScopedVisitor.con3(LibraryElement definingLibrary, this.source, this.typeProvi der, Scope nameScope, AnalysisErrorListener errorListener) { 12420 ScopedVisitor.con3(LibraryElement definingLibrary, Source source, TypeProvider typeProvider, Scope nameScope, AnalysisErrorListener errorListener) {
12383 this._definingLibrary = definingLibrary; 12421 this._definingLibrary = definingLibrary;
12422 this.source = source;
12384 this._errorListener = errorListener; 12423 this._errorListener = errorListener;
12385 this._nameScope = nameScope; 12424 this._nameScope = nameScope;
12425 this.typeProvider = typeProvider;
12386 } 12426 }
12387 12427
12388 /** 12428 /**
12389 * Initialize a newly created visitor to resolve the nodes in a compilation un it. 12429 * Initialize a newly created visitor to resolve the nodes in a compilation un it.
12390 * 12430 *
12391 * @param library the library containing the compilation unit being resolved 12431 * @param library the library containing the compilation unit being resolved
12392 * @param source the source representing the compilation unit being visited 12432 * @param source the source representing the compilation unit being visited
12393 * @param typeProvider the object used to access the types from the core libra ry 12433 * @param typeProvider the object used to access the types from the core libra ry
12394 */ 12434 */
12395 ScopedVisitor.con4(ResolvableLibrary library, this.source, this.typeProvider) { 12435 ScopedVisitor.con4(ResolvableLibrary library, Source source, TypeProvider type Provider) {
12396 this._definingLibrary = library.libraryElement; 12436 this._definingLibrary = library.libraryElement;
12437 this.source = source;
12397 LibraryScope libraryScope = library.libraryScope; 12438 LibraryScope libraryScope = library.libraryScope;
12398 this._errorListener = libraryScope.errorListener; 12439 this._errorListener = libraryScope.errorListener;
12399 this._nameScope = libraryScope; 12440 this._nameScope = libraryScope;
12441 this.typeProvider = typeProvider;
12400 } 12442 }
12401 12443
12402 /** 12444 /**
12403 * Return the library element for the library containing the compilation unit being resolved. 12445 * Return the library element for the library containing the compilation unit being resolved.
12404 * 12446 *
12405 * @return the library element for the library containing the compilation unit being resolved 12447 * @return the library element for the library containing the compilation unit being resolved
12406 */ 12448 */
12407 LibraryElement get definingLibrary => _definingLibrary; 12449 LibraryElement get definingLibrary => _definingLibrary;
12408 12450
12409 /** 12451 /**
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
12998 map["title"] = "TitleElement"; 13040 map["title"] = "TitleElement";
12999 map["track"] = "TrackElement"; 13041 map["track"] = "TrackElement";
13000 map["ul"] = "UListElement"; 13042 map["ul"] = "UListElement";
13001 map["video"] = "VideoElement"; 13043 map["video"] = "VideoElement";
13002 return map; 13044 return map;
13003 } 13045 }
13004 13046
13005 /** 13047 /**
13006 * The resolver driving the resolution and type analysis. 13048 * The resolver driving the resolution and type analysis.
13007 */ 13049 */
13008 final ResolverVisitor _resolver; 13050 ResolverVisitor _resolver;
13009 13051
13010 /** 13052 /**
13011 * The object providing access to the types defined by the language. 13053 * The object providing access to the types defined by the language.
13012 */ 13054 */
13013 TypeProvider _typeProvider; 13055 TypeProvider _typeProvider;
13014 13056
13015 /** 13057 /**
13016 * The type representing the type 'dynamic'. 13058 * The type representing the type 'dynamic'.
13017 */ 13059 */
13018 DartType _dynamicType; 13060 DartType _dynamicType;
(...skipping 23 matching lines...) Expand all
13042 * A table mapping HTML tag names to the names of the classes (in 'dart:html') that implement 13084 * A table mapping HTML tag names to the names of the classes (in 'dart:html') that implement
13043 * those tags. 13085 * those tags.
13044 */ 13086 */
13045 static Map<String, String> _HTML_ELEMENT_TO_CLASS_MAP = _createHtmlTagToClassM ap(); 13087 static Map<String, String> _HTML_ELEMENT_TO_CLASS_MAP = _createHtmlTagToClassM ap();
13046 13088
13047 /** 13089 /**
13048 * Initialize a newly created type analyzer. 13090 * Initialize a newly created type analyzer.
13049 * 13091 *
13050 * @param resolver the resolver driving this participant 13092 * @param resolver the resolver driving this participant
13051 */ 13093 */
13052 StaticTypeAnalyzer(this._resolver) { 13094 StaticTypeAnalyzer(ResolverVisitor resolver) {
13053 _typeProvider = _resolver.typeProvider; 13095 this._resolver = resolver;
13096 _typeProvider = resolver.typeProvider;
13054 _dynamicType = _typeProvider.dynamicType; 13097 _dynamicType = _typeProvider.dynamicType;
13055 _overrideManager = _resolver.overrideManager; 13098 _overrideManager = resolver.overrideManager;
13056 _promoteManager = _resolver.promoteManager; 13099 _promoteManager = resolver.promoteManager;
13057 } 13100 }
13058 13101
13059 /** 13102 /**
13060 * Set the type of the class being analyzed to the given type. 13103 * Set the type of the class being analyzed to the given type.
13061 * 13104 *
13062 * @param thisType the type representing the class containing the nodes being analyzed 13105 * @param thisType the type representing the class containing the nodes being analyzed
13063 */ 13106 */
13064 void set thisType(InterfaceType thisType) { 13107 void set thisType(InterfaceType thisType) {
13065 this._thisType = thisType; 13108 this._thisType = thisType;
13066 } 13109 }
(...skipping 1808 matching lines...) Expand 10 before | Expand all | Expand 10 after
14875 } 14918 }
14876 14919
14877 /** 14920 /**
14878 * Instances of the class `TypeOverrideScope` represent a scope in which the typ es of 14921 * Instances of the class `TypeOverrideScope` represent a scope in which the typ es of
14879 * elements can be overridden. 14922 * elements can be overridden.
14880 */ 14923 */
14881 class TypeOverrideManager_TypeOverrideScope { 14924 class TypeOverrideManager_TypeOverrideScope {
14882 /** 14925 /**
14883 * The outer scope in which types might be overridden. 14926 * The outer scope in which types might be overridden.
14884 */ 14927 */
14885 final TypeOverrideManager_TypeOverrideScope _outerScope; 14928 TypeOverrideManager_TypeOverrideScope _outerScope;
14886 14929
14887 /** 14930 /**
14888 * A table mapping elements to the overridden type of that element. 14931 * A table mapping elements to the overridden type of that element.
14889 */ 14932 */
14890 Map<Element, DartType> _overridenTypes = new Map<Element, DartType>(); 14933 Map<Element, DartType> _overridenTypes = new Map<Element, DartType>();
14891 14934
14892 /** 14935 /**
14893 * Initialize a newly created scope to be an empty child of the given scope. 14936 * Initialize a newly created scope to be an empty child of the given scope.
14894 * 14937 *
14895 * @param outerScope the outer scope in which types might be overridden 14938 * @param outerScope the outer scope in which types might be overridden
14896 */ 14939 */
14897 TypeOverrideManager_TypeOverrideScope(this._outerScope); 14940 TypeOverrideManager_TypeOverrideScope(TypeOverrideManager_TypeOverrideScope ou terScope) {
14941 this._outerScope = outerScope;
14942 }
14898 14943
14899 /** 14944 /**
14900 * Apply a set of overrides that were previously captured. 14945 * Apply a set of overrides that were previously captured.
14901 * 14946 *
14902 * @param overrides the overrides to be applied 14947 * @param overrides the overrides to be applied
14903 */ 14948 */
14904 void applyOverrides(Map<Element, DartType> overrides) { 14949 void applyOverrides(Map<Element, DartType> overrides) {
14905 for (MapEntry<Element, DartType> entry in getMapEntrySet(overrides)) { 14950 for (MapEntry<Element, DartType> entry in getMapEntrySet(overrides)) {
14906 _overridenTypes[entry.getKey()] = entry.getValue(); 14951 _overridenTypes[entry.getKey()] = entry.getValue();
14907 } 14952 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
15043 } 15088 }
15044 15089
15045 /** 15090 /**
15046 * Instances of the class `TypePromoteScope` represent a scope in which the type s of 15091 * Instances of the class `TypePromoteScope` represent a scope in which the type s of
15047 * elements can be promoted. 15092 * elements can be promoted.
15048 */ 15093 */
15049 class TypePromotionManager_TypePromoteScope { 15094 class TypePromotionManager_TypePromoteScope {
15050 /** 15095 /**
15051 * The outer scope in which types might be promoter. 15096 * The outer scope in which types might be promoter.
15052 */ 15097 */
15053 final TypePromotionManager_TypePromoteScope _outerScope; 15098 TypePromotionManager_TypePromoteScope _outerScope;
15054 15099
15055 /** 15100 /**
15056 * A table mapping elements to the promoted type of that element. 15101 * A table mapping elements to the promoted type of that element.
15057 */ 15102 */
15058 Map<Element, DartType> _promotedTypes = new Map<Element, DartType>(); 15103 Map<Element, DartType> _promotedTypes = new Map<Element, DartType>();
15059 15104
15060 /** 15105 /**
15061 * Initialize a newly created scope to be an empty child of the given scope. 15106 * Initialize a newly created scope to be an empty child of the given scope.
15062 * 15107 *
15063 * @param outerScope the outer scope in which types might be promoted 15108 * @param outerScope the outer scope in which types might be promoted
15064 */ 15109 */
15065 TypePromotionManager_TypePromoteScope(this._outerScope); 15110 TypePromotionManager_TypePromoteScope(TypePromotionManager_TypePromoteScope ou terScope) {
15111 this._outerScope = outerScope;
15112 }
15066 15113
15067 /** 15114 /**
15068 * Returns the elements with promoted types. 15115 * Returns the elements with promoted types.
15069 */ 15116 */
15070 Iterable<Element> get promotedElements => _promotedTypes.keys.toSet(); 15117 Iterable<Element> get promotedElements => _promotedTypes.keys.toSet();
15071 15118
15072 /** 15119 /**
15073 * Return the promoted type of the given element, or `null` if the type of the element has 15120 * Return the promoted type of the given element, or `null` if the type of the element has
15074 * not been promoted. 15121 * not been promoted.
15075 * 15122 *
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
15582 } 15629 }
15583 } 15630 }
15584 _resolve(classElement, node.withClause, node.implementsClause); 15631 _resolve(classElement, node.withClause, node.implementsClause);
15585 return null; 15632 return null;
15586 } 15633 }
15587 15634
15588 @override 15635 @override
15589 Object visitConstructorDeclaration(ConstructorDeclaration node) { 15636 Object visitConstructorDeclaration(ConstructorDeclaration node) {
15590 super.visitConstructorDeclaration(node); 15637 super.visitConstructorDeclaration(node);
15591 ExecutableElementImpl element = node.element as ExecutableElementImpl; 15638 ExecutableElementImpl element = node.element as ExecutableElementImpl;
15592 if (element != null) { 15639 ClassElement definingClass = element.enclosingElement as ClassElement;
15593 // TODO(brianwilkerson) Figure out how the element could ever be null. 15640 element.returnType = definingClass.type;
15594 ClassElement definingClass = element.enclosingElement as ClassElement; 15641 FunctionTypeImpl type = new FunctionTypeImpl.con1(element);
15595 element.returnType = definingClass.type; 15642 type.typeArguments = definingClass.type.typeArguments;
15596 FunctionTypeImpl type = new FunctionTypeImpl.con1(element); 15643 element.type = type;
15597 type.typeArguments = definingClass.type.typeArguments;
15598 element.type = type;
15599 }
15600 return null; 15644 return null;
15601 } 15645 }
15602 15646
15603 @override 15647 @override
15604 Object visitDeclaredIdentifier(DeclaredIdentifier node) { 15648 Object visitDeclaredIdentifier(DeclaredIdentifier node) {
15605 super.visitDeclaredIdentifier(node); 15649 super.visitDeclaredIdentifier(node);
15606 DartType declaredType; 15650 DartType declaredType;
15607 TypeName typeName = node.type; 15651 TypeName typeName = node.type;
15608 if (typeName == null) { 15652 if (typeName == null) {
15609 declaredType = _dynamicType; 15653 declaredType = _dynamicType;
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
16472 } 16516 }
16473 } 16517 }
16474 element.type = type; 16518 element.type = type;
16475 } 16519 }
16476 } 16520 }
16477 16521
16478 /** 16522 /**
16479 * Kind of the redirecting constructor. 16523 * Kind of the redirecting constructor.
16480 */ 16524 */
16481 class RedirectingConstructorKind extends Enum<RedirectingConstructorKind> { 16525 class RedirectingConstructorKind extends Enum<RedirectingConstructorKind> {
16482 static const RedirectingConstructorKind CONST = const RedirectingConstructorKi nd('CONST', 0); 16526 static final RedirectingConstructorKind CONST = new RedirectingConstructorKind ('CONST', 0);
16483 16527
16484 static const RedirectingConstructorKind NORMAL = const RedirectingConstructorK ind('NORMAL', 1); 16528 static final RedirectingConstructorKind NORMAL = new RedirectingConstructorKin d('NORMAL', 1);
16485 16529
16486 static const List<RedirectingConstructorKind> values = const [CONST, NORMAL]; 16530 static final List<RedirectingConstructorKind> values = [CONST, NORMAL];
16487 16531
16488 const RedirectingConstructorKind(String name, int ordinal) : super(name, ordin al); 16532 RedirectingConstructorKind(String name, int ordinal) : super(name, ordinal);
16489 } 16533 }
16490 16534
16491 class UnifyingAstVisitor_TypeResolverVisitor_visitClassDeclarationInScope extend s UnifyingAstVisitor<Object> { 16535 class UnifyingAstVisitor_TypeResolverVisitor_visitClassDeclarationInScope extend s UnifyingAstVisitor<Object> {
16492 final TypeResolverVisitor TypeResolverVisitor_this; 16536 final TypeResolverVisitor TypeResolverVisitor_this;
16493 16537
16494 List<ClassMember> nonFields; 16538 List<ClassMember> nonFields;
16495 16539
16496 UnifyingAstVisitor_TypeResolverVisitor_visitClassDeclarationInScope(this.TypeR esolverVisitor_this, this.nonFields) : super(); 16540 UnifyingAstVisitor_TypeResolverVisitor_visitClassDeclarationInScope(this.TypeR esolverVisitor_this, this.nonFields) : super();
16497 16541
16498 @override 16542 @override
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
16690 } 16734 }
16691 16735
16692 /** 16736 /**
16693 * Instances of the class `EnclosedScope` implement a scope that is lexically en closed in 16737 * Instances of the class `EnclosedScope` implement a scope that is lexically en closed in
16694 * another scope. 16738 * another scope.
16695 */ 16739 */
16696 class EnclosedScope extends Scope { 16740 class EnclosedScope extends Scope {
16697 /** 16741 /**
16698 * The scope in which this scope is lexically enclosed. 16742 * The scope in which this scope is lexically enclosed.
16699 */ 16743 */
16700 final Scope enclosingScope; 16744 Scope enclosingScope;
16701 16745
16702 /** 16746 /**
16703 * A table mapping names that will be defined in this scope, but right now are not initialized. 16747 * A table mapping names that will be defined in this scope, but right now are not initialized.
16704 * According to the scoping rules these names are hidden, even if they were de fined in an outer 16748 * According to the scoping rules these names are hidden, even if they were de fined in an outer
16705 * scope. 16749 * scope.
16706 */ 16750 */
16707 Map<String, Element> _hiddenElements = new Map<String, Element>(); 16751 Map<String, Element> _hiddenElements = new Map<String, Element>();
16708 16752
16709 /** 16753 /**
16710 * A flag indicating whether there are any names defined in this scope. 16754 * A flag indicating whether there are any names defined in this scope.
16711 */ 16755 */
16712 bool _hasHiddenName = false; 16756 bool _hasHiddenName = false;
16713 16757
16714 /** 16758 /**
16715 * Initialize a newly created scope enclosed within another scope. 16759 * Initialize a newly created scope enclosed within another scope.
16716 * 16760 *
16717 * @param enclosingScope the scope in which this scope is lexically enclosed 16761 * @param enclosingScope the scope in which this scope is lexically enclosed
16718 */ 16762 */
16719 EnclosedScope(this.enclosingScope); 16763 EnclosedScope(Scope enclosingScope) {
16764 this.enclosingScope = enclosingScope;
16765 }
16720 16766
16721 @override 16767 @override
16722 AnalysisErrorListener get errorListener => enclosingScope.errorListener; 16768 AnalysisErrorListener get errorListener => enclosingScope.errorListener;
16723 16769
16724 /** 16770 /**
16725 * Record that given element is declared in this scope, but hasn't been initia lized yet, so it is 16771 * Record that given element is declared in this scope, but hasn't been initia lized yet, so it is
16726 * error to use. If there is already an element with the given name defined in an outer scope, 16772 * error to use. If there is already an element with the given name defined in an outer scope,
16727 * then it will become unavailable. 16773 * then it will become unavailable.
16728 * 16774 *
16729 * @param element the element declared, but not initialized in this scope 16775 * @param element the element declared, but not initialized in this scope
(...skipping 24 matching lines...) Expand all
16754 } 16800 }
16755 // Check enclosing scope. 16801 // Check enclosing scope.
16756 return enclosingScope.internalLookup(identifier, name, referencingLibrary); 16802 return enclosingScope.internalLookup(identifier, name, referencingLibrary);
16757 } 16803 }
16758 } 16804 }
16759 16805
16760 /** 16806 /**
16761 * Instances of the class `FunctionScope` implement the scope defined by a funct ion. 16807 * Instances of the class `FunctionScope` implement the scope defined by a funct ion.
16762 */ 16808 */
16763 class FunctionScope extends EnclosedScope { 16809 class FunctionScope extends EnclosedScope {
16764 final ExecutableElement _functionElement; 16810 ExecutableElement _functionElement;
16765 16811
16766 bool _parametersDefined = false; 16812 bool _parametersDefined = false;
16767 16813
16768 /** 16814 /**
16769 * Initialize a newly created scope enclosed within another scope. 16815 * Initialize a newly created scope enclosed within another scope.
16770 * 16816 *
16771 * @param enclosingScope the scope in which this scope is lexically enclosed 16817 * @param enclosingScope the scope in which this scope is lexically enclosed
16772 * @param functionElement the element representing the type represented by thi s scope 16818 * @param functionElement the element representing the type represented by thi s scope
16773 */ 16819 */
16774 FunctionScope(Scope enclosingScope, this._functionElement) : super(new Enclose dScope(enclosingScope)) { 16820 FunctionScope(Scope enclosingScope, ExecutableElement functionElement) : super (new EnclosedScope(enclosingScope)) {
16775 if (_functionElement == null) { 16821 if (functionElement == null) {
16776 throw new IllegalArgumentException("function element cannot be null"); 16822 throw new IllegalArgumentException("function element cannot be null");
16777 } 16823 }
16824 this._functionElement = functionElement;
16778 } 16825 }
16779 16826
16780 /** 16827 /**
16781 * Define the parameters for the given function in the scope that encloses thi s function. 16828 * Define the parameters for the given function in the scope that encloses thi s function.
16782 */ 16829 */
16783 void defineParameters() { 16830 void defineParameters() {
16784 if (_parametersDefined) { 16831 if (_parametersDefined) {
16785 return; 16832 return;
16786 } 16833 }
16787 _parametersDefined = true; 16834 _parametersDefined = true;
(...skipping 10 matching lines...) Expand all
16798 } 16845 }
16799 } 16846 }
16800 } 16847 }
16801 } 16848 }
16802 16849
16803 /** 16850 /**
16804 * Instances of the class `FunctionTypeScope` implement the scope defined by a f unction type 16851 * Instances of the class `FunctionTypeScope` implement the scope defined by a f unction type
16805 * alias. 16852 * alias.
16806 */ 16853 */
16807 class FunctionTypeScope extends EnclosedScope { 16854 class FunctionTypeScope extends EnclosedScope {
16808 final FunctionTypeAliasElement _typeElement; 16855 FunctionTypeAliasElement _typeElement;
16809 16856
16810 bool _parametersDefined = false; 16857 bool _parametersDefined = false;
16811 16858
16812 /** 16859 /**
16813 * Initialize a newly created scope enclosed within another scope. 16860 * Initialize a newly created scope enclosed within another scope.
16814 * 16861 *
16815 * @param enclosingScope the scope in which this scope is lexically enclosed 16862 * @param enclosingScope the scope in which this scope is lexically enclosed
16816 * @param typeElement the element representing the type alias represented by t his scope 16863 * @param typeElement the element representing the type alias represented by t his scope
16817 */ 16864 */
16818 FunctionTypeScope(Scope enclosingScope, this._typeElement) : super(new Enclose dScope(enclosingScope)) { 16865 FunctionTypeScope(Scope enclosingScope, FunctionTypeAliasElement typeElement) : super(new EnclosedScope(enclosingScope)) {
16866 this._typeElement = typeElement;
16819 _defineTypeParameters(); 16867 _defineTypeParameters();
16820 } 16868 }
16821 16869
16822 /** 16870 /**
16823 * Define the parameters for the function type alias. 16871 * Define the parameters for the function type alias.
16824 * 16872 *
16825 * @param typeElement the element representing the type represented by this sc ope 16873 * @param typeElement the element representing the type represented by this sc ope
16826 */ 16874 */
16827 void defineParameters() { 16875 void defineParameters() {
16828 if (_parametersDefined) { 16876 if (_parametersDefined) {
(...skipping 18 matching lines...) Expand all
16847 } 16895 }
16848 } 16896 }
16849 16897
16850 /** 16898 /**
16851 * Instances of the class `LabelScope` represent a scope in which a single label is defined. 16899 * Instances of the class `LabelScope` represent a scope in which a single label is defined.
16852 */ 16900 */
16853 class LabelScope { 16901 class LabelScope {
16854 /** 16902 /**
16855 * The label scope enclosing this label scope. 16903 * The label scope enclosing this label scope.
16856 */ 16904 */
16857 final LabelScope _outerScope; 16905 LabelScope _outerScope;
16858 16906
16859 /** 16907 /**
16860 * The label defined in this scope. 16908 * The label defined in this scope.
16861 */ 16909 */
16862 final String _label; 16910 String _label;
16863 16911
16864 /** 16912 /**
16865 * The element to which the label resolves. 16913 * The element to which the label resolves.
16866 */ 16914 */
16867 final LabelElement _element; 16915 LabelElement _element;
16868 16916
16869 /** 16917 /**
16870 * The marker used to look up a label element for an unlabeled `break` or `con tinue`. 16918 * The marker used to look up a label element for an unlabeled `break` or `con tinue`.
16871 */ 16919 */
16872 static String EMPTY_LABEL = ""; 16920 static String EMPTY_LABEL = "";
16873 16921
16874 /** 16922 /**
16875 * The label element returned for scopes that can be the target of an unlabele d `break` or 16923 * The label element returned for scopes that can be the target of an unlabele d `break` or
16876 * `continue`. 16924 * `continue`.
16877 */ 16925 */
(...skipping 10 matching lines...) Expand all
16888 */ 16936 */
16889 LabelScope.con1(LabelScope outerScope, bool onSwitchStatement, bool onSwitchMe mber) : this.con2(outerScope, EMPTY_LABEL, new LabelElementImpl(_EMPTY_LABEL_IDE NTIFIER, onSwitchStatement, onSwitchMember)); 16937 LabelScope.con1(LabelScope outerScope, bool onSwitchStatement, bool onSwitchMe mber) : this.con2(outerScope, EMPTY_LABEL, new LabelElementImpl(_EMPTY_LABEL_IDE NTIFIER, onSwitchStatement, onSwitchMember));
16890 16938
16891 /** 16939 /**
16892 * Initialize a newly created scope to represent the given label. 16940 * Initialize a newly created scope to represent the given label.
16893 * 16941 *
16894 * @param outerScope the label scope enclosing the new label scope 16942 * @param outerScope the label scope enclosing the new label scope
16895 * @param label the label defined in this scope 16943 * @param label the label defined in this scope
16896 * @param element the element to which the label resolves 16944 * @param element the element to which the label resolves
16897 */ 16945 */
16898 LabelScope.con2(this._outerScope, this._label, this._element); 16946 LabelScope.con2(LabelScope outerScope, String label, LabelElement element) {
16947 this._outerScope = outerScope;
16948 this._label = label;
16949 this._element = element;
16950 }
16899 16951
16900 /** 16952 /**
16901 * Return the label element corresponding to the given label, or `null` if the given label 16953 * Return the label element corresponding to the given label, or `null` if the given label
16902 * is not defined in this scope. 16954 * is not defined in this scope.
16903 * 16955 *
16904 * @param targetLabel the label being looked up 16956 * @param targetLabel the label being looked up
16905 * @return the label element corresponding to the given label 16957 * @return the label element corresponding to the given label
16906 */ 16958 */
16907 LabelElement lookup(String targetLabel) { 16959 LabelElement lookup(String targetLabel) {
16908 if (_label == targetLabel) { 16960 if (_label == targetLabel) {
16909 return _element; 16961 return _element;
16910 } else if (_outerScope != null) { 16962 } else if (_outerScope != null) {
16911 return _outerScope.lookup(targetLabel); 16963 return _outerScope.lookup(targetLabel);
16912 } else { 16964 } else {
16913 return null; 16965 return null;
16914 } 16966 }
16915 } 16967 }
16916 } 16968 }
16917 16969
16918 /** 16970 /**
16919 * Instances of the class `LibraryImportScope` represent the scope containing al l of the names 16971 * Instances of the class `LibraryImportScope` represent the scope containing al l of the names
16920 * available from imported libraries. 16972 * available from imported libraries.
16921 */ 16973 */
16922 class LibraryImportScope extends Scope { 16974 class LibraryImportScope extends Scope {
16923 /** 16975 /**
16924 * The element representing the library in which this scope is enclosed. 16976 * The element representing the library in which this scope is enclosed.
16925 */ 16977 */
16926 final LibraryElement _definingLibrary; 16978 LibraryElement _definingLibrary;
16927 16979
16928 /** 16980 /**
16929 * The listener that is to be informed when an error is encountered. 16981 * The listener that is to be informed when an error is encountered.
16930 */ 16982 */
16931 final AnalysisErrorListener errorListener; 16983 AnalysisErrorListener errorListener;
16932 16984
16933 /** 16985 /**
16934 * A list of the namespaces representing the names that are available in this scope from imported 16986 * A list of the namespaces representing the names that are available in this scope from imported
16935 * libraries. 16987 * libraries.
16936 */ 16988 */
16937 List<Namespace> _importedNamespaces; 16989 List<Namespace> _importedNamespaces;
16938 16990
16939 /** 16991 /**
16940 * Initialize a newly created scope representing the names imported into the g iven library. 16992 * Initialize a newly created scope representing the names imported into the g iven library.
16941 * 16993 *
16942 * @param definingLibrary the element representing the library that imports th e names defined in 16994 * @param definingLibrary the element representing the library that imports th e names defined in
16943 * this scope 16995 * this scope
16944 * @param errorListener the listener that is to be informed when an error is e ncountered 16996 * @param errorListener the listener that is to be informed when an error is e ncountered
16945 */ 16997 */
16946 LibraryImportScope(this._definingLibrary, this.errorListener) { 16998 LibraryImportScope(LibraryElement definingLibrary, AnalysisErrorListener error Listener) {
16947 _createImportedNamespaces(_definingLibrary); 16999 this._definingLibrary = definingLibrary;
17000 this.errorListener = errorListener;
17001 _createImportedNamespaces(definingLibrary);
16948 } 17002 }
16949 17003
16950 @override 17004 @override
16951 void define(Element element) { 17005 void define(Element element) {
16952 if (!Scope.isPrivateName(element.displayName)) { 17006 if (!Scope.isPrivateName(element.displayName)) {
16953 super.define(element); 17007 super.define(element);
16954 } 17008 }
16955 } 17009 }
16956 17010
16957 @override 17011 @override
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
17140 17194
17141 /** 17195 /**
17142 * Instances of the class `Namespace` implement a mapping of identifiers to the elements 17196 * Instances of the class `Namespace` implement a mapping of identifiers to the elements
17143 * represented by those identifiers. Namespaces are the building blocks for scop es. 17197 * represented by those identifiers. Namespaces are the building blocks for scop es.
17144 */ 17198 */
17145 class Namespace { 17199 class Namespace {
17146 /** 17200 /**
17147 * A table mapping names that are defined in this namespace to the element rep resenting the thing 17201 * A table mapping names that are defined in this namespace to the element rep resenting the thing
17148 * declared with that name. 17202 * declared with that name.
17149 */ 17203 */
17150 final Map<String, Element> _definedNames; 17204 Map<String, Element> _definedNames;
17151 17205
17152 /** 17206 /**
17153 * An empty namespace. 17207 * An empty namespace.
17154 */ 17208 */
17155 static Namespace EMPTY = new Namespace(new Map<String, Element>()); 17209 static Namespace EMPTY = new Namespace(new Map<String, Element>());
17156 17210
17157 /** 17211 /**
17158 * Initialize a newly created namespace to have the given defined names. 17212 * Initialize a newly created namespace to have the given defined names.
17159 * 17213 *
17160 * @param definedNames the mapping from names that are defined in this namespa ce to the 17214 * @param definedNames the mapping from names that are defined in this namespa ce to the
17161 * corresponding elements 17215 * corresponding elements
17162 */ 17216 */
17163 Namespace(this._definedNames); 17217 Namespace(Map<String, Element> definedNames) {
17218 this._definedNames = definedNames;
17219 }
17164 17220
17165 /** 17221 /**
17166 * Return the element in this namespace that is available to the containing sc ope using the given 17222 * Return the element in this namespace that is available to the containing sc ope using the given
17167 * name. 17223 * name.
17168 * 17224 *
17169 * @param name the name used to reference the 17225 * @param name the name used to reference the
17170 * @return the element represented by the given identifier 17226 * @return the element represented by the given identifier
17171 */ 17227 */
17172 Element get(String name) => _definedNames[name]; 17228 Element get(String name) => _definedNames[name];
17173 17229
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
17626 if (parent == null) { 17682 if (parent == null) {
17627 throw new AnalysisException.con1("Cannot create scope: node is not part of a CompilationUnit"); 17683 throw new AnalysisException.con1("Cannot create scope: node is not part of a CompilationUnit");
17628 } 17684 }
17629 ScopeBuilder builder = new ScopeBuilder(errorListener); 17685 ScopeBuilder builder = new ScopeBuilder(errorListener);
17630 return builder._scopeForAstNode(parent); 17686 return builder._scopeForAstNode(parent);
17631 } 17687 }
17632 17688
17633 /** 17689 /**
17634 * The listener to which analysis errors will be reported. 17690 * The listener to which analysis errors will be reported.
17635 */ 17691 */
17636 final AnalysisErrorListener _errorListener; 17692 AnalysisErrorListener _errorListener;
17637 17693
17638 /** 17694 /**
17639 * Initialize a newly created scope builder to generate a scope that will repo rt errors to the 17695 * Initialize a newly created scope builder to generate a scope that will repo rt errors to the
17640 * given listener. 17696 * given listener.
17641 * 17697 *
17642 * @param errorListener the listener to which analysis errors will be reported 17698 * @param errorListener the listener to which analysis errors will be reported
17643 */ 17699 */
17644 ScopeBuilder(this._errorListener); 17700 ScopeBuilder(AnalysisErrorListener errorListener) {
17701 this._errorListener = errorListener;
17702 }
17645 17703
17646 /** 17704 /**
17647 * Return the scope in which the given AST structure should be resolved. 17705 * Return the scope in which the given AST structure should be resolved.
17648 * 17706 *
17649 * <b>Note:</b> This method needs to be kept in sync with 17707 * <b>Note:</b> This method needs to be kept in sync with
17650 * [IncrementalResolver#canBeResolved]. 17708 * [IncrementalResolver#canBeResolved].
17651 * 17709 *
17652 * @param node the root of the AST structure to be resolved 17710 * @param node the root of the AST structure to be resolved
17653 * @return the scope in which the given AST structure should be resolved 17711 * @return the scope in which the given AST structure should be resolved
17654 * @throws AnalysisException if the AST structure has not been resolved or is not part of a 17712 * @throws AnalysisException if the AST structure has not been resolved or is not part of a
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
17720 17778
17721 /** 17779 /**
17722 * Instances of the class `ConstantVerifier` traverse an AST structure looking f or additional 17780 * Instances of the class `ConstantVerifier` traverse an AST structure looking f or additional
17723 * errors and warnings not covered by the parser and resolver. In particular, it looks for errors 17781 * errors and warnings not covered by the parser and resolver. In particular, it looks for errors
17724 * and warnings related to constant expressions. 17782 * and warnings related to constant expressions.
17725 */ 17783 */
17726 class ConstantVerifier extends RecursiveAstVisitor<Object> { 17784 class ConstantVerifier extends RecursiveAstVisitor<Object> {
17727 /** 17785 /**
17728 * The error reporter by which errors will be reported. 17786 * The error reporter by which errors will be reported.
17729 */ 17787 */
17730 final ErrorReporter _errorReporter; 17788 ErrorReporter _errorReporter;
17731 17789
17732 /** 17790 /**
17733 * The type provider used to access the known types. 17791 * The type provider used to access the known types.
17734 */ 17792 */
17735 final TypeProvider _typeProvider; 17793 TypeProvider _typeProvider;
17736 17794
17737 /** 17795 /**
17738 * The type representing the type 'bool'. 17796 * The type representing the type 'bool'.
17739 */ 17797 */
17740 InterfaceType _boolType; 17798 InterfaceType _boolType;
17741 17799
17742 /** 17800 /**
17743 * The type representing the type 'int'. 17801 * The type representing the type 'int'.
17744 */ 17802 */
17745 InterfaceType _intType; 17803 InterfaceType _intType;
17746 17804
17747 /** 17805 /**
17748 * The type representing the type 'num'. 17806 * The type representing the type 'num'.
17749 */ 17807 */
17750 InterfaceType _numType; 17808 InterfaceType _numType;
17751 17809
17752 /** 17810 /**
17753 * The type representing the type 'string'. 17811 * The type representing the type 'string'.
17754 */ 17812 */
17755 InterfaceType _stringType; 17813 InterfaceType _stringType;
17756 17814
17757 /** 17815 /**
17758 * Initialize a newly created constant verifier. 17816 * Initialize a newly created constant verifier.
17759 * 17817 *
17760 * @param errorReporter the error reporter by which errors will be reported 17818 * @param errorReporter the error reporter by which errors will be reported
17761 */ 17819 */
17762 ConstantVerifier(this._errorReporter, this._typeProvider) { 17820 ConstantVerifier(ErrorReporter errorReporter, TypeProvider typeProvider) {
17763 this._boolType = _typeProvider.boolType; 17821 this._errorReporter = errorReporter;
17764 this._intType = _typeProvider.intType; 17822 this._typeProvider = typeProvider;
17765 this._numType = _typeProvider.numType; 17823 this._boolType = typeProvider.boolType;
17766 this._stringType = _typeProvider.stringType; 17824 this._intType = typeProvider.intType;
17825 this._numType = typeProvider.numType;
17826 this._stringType = typeProvider.stringType;
17767 } 17827 }
17768 17828
17769 @override 17829 @override
17770 Object visitAnnotation(Annotation node) { 17830 Object visitAnnotation(Annotation node) {
17771 super.visitAnnotation(node); 17831 super.visitAnnotation(node);
17772 // check annotation creation 17832 // check annotation creation
17773 Element element = node.element; 17833 Element element = node.element;
17774 if (element is ConstructorElement) { 17834 if (element is ConstructorElement) {
17775 ConstructorElement constructorElement = element; 17835 ConstructorElement constructorElement = element;
17776 // should 'const' constructor 17836 // should 'const' constructor
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
18081 } 18141 }
18082 18142
18083 /** 18143 /**
18084 * Instances of the class `ErrorVerifier` traverse an AST structure looking for additional 18144 * Instances of the class `ErrorVerifier` traverse an AST structure looking for additional
18085 * errors and warnings not covered by the parser and resolver. 18145 * errors and warnings not covered by the parser and resolver.
18086 */ 18146 */
18087 class ErrorVerifier extends RecursiveAstVisitor<Object> { 18147 class ErrorVerifier extends RecursiveAstVisitor<Object> {
18088 /** 18148 /**
18089 * The error reporter by which errors will be reported. 18149 * The error reporter by which errors will be reported.
18090 */ 18150 */
18091 final ErrorReporter _errorReporter; 18151 ErrorReporter _errorReporter;
18092 18152
18093 /** 18153 /**
18094 * The current library that is being analyzed. 18154 * The current library that is being analyzed.
18095 */ 18155 */
18096 final LibraryElement _currentLibrary; 18156 LibraryElement _currentLibrary;
18097 18157
18098 /** 18158 /**
18099 * The type representing the type 'dynamic'. 18159 * The type representing the type 'dynamic'.
18100 */ 18160 */
18101 DartType _dynamicType; 18161 DartType _dynamicType;
18102 18162
18103 /** 18163 /**
18104 * The type representing the type 'bool'. 18164 * The type representing the type 'bool'.
18105 */ 18165 */
18106 InterfaceType _boolType; 18166 InterfaceType _boolType;
18107 18167
18108 /** 18168 /**
18109 * The type representing the type 'int'. 18169 * The type representing the type 'int'.
18110 */ 18170 */
18111 InterfaceType _intType; 18171 InterfaceType _intType;
18112 18172
18113 /** 18173 /**
18114 * The object providing access to the types defined by the language. 18174 * The object providing access to the types defined by the language.
18115 */ 18175 */
18116 final TypeProvider _typeProvider; 18176 TypeProvider _typeProvider;
18117 18177
18118 /** 18178 /**
18119 * The manager for the inheritance mappings. 18179 * The manager for the inheritance mappings.
18120 */ 18180 */
18121 final InheritanceManager _inheritanceManager; 18181 InheritanceManager _inheritanceManager;
18122 18182
18123 /** 18183 /**
18124 * This is set to `true` iff the visitor is currently visiting children nodes of a 18184 * This is set to `true` iff the visitor is currently visiting children nodes of a
18125 * [ConstructorDeclaration] and the constructor is 'const'. 18185 * [ConstructorDeclaration] and the constructor is 'const'.
18126 * 18186 *
18127 * @see #visitConstructorDeclaration(ConstructorDeclaration) 18187 * @see #visitConstructorDeclaration(ConstructorDeclaration)
18128 */ 18188 */
18129 bool _isEnclosingConstructorConst = false; 18189 bool _isEnclosingConstructorConst = false;
18130 18190
18131 /** 18191 /**
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
18261 * A set of the names of the variable initializers we are visiting now. 18321 * A set of the names of the variable initializers we are visiting now.
18262 */ 18322 */
18263 Set<String> _namesForReferenceToDeclaredVariableInInitializer = new Set<String >(); 18323 Set<String> _namesForReferenceToDeclaredVariableInInitializer = new Set<String >();
18264 18324
18265 /** 18325 /**
18266 * A list of types used by the [CompileTimeErrorCode#EXTENDS_DISALLOWED_CLASS] and 18326 * A list of types used by the [CompileTimeErrorCode#EXTENDS_DISALLOWED_CLASS] and
18267 * [CompileTimeErrorCode#IMPLEMENTS_DISALLOWED_CLASS] error codes. 18327 * [CompileTimeErrorCode#IMPLEMENTS_DISALLOWED_CLASS] error codes.
18268 */ 18328 */
18269 List<InterfaceType> _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT; 18329 List<InterfaceType> _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT;
18270 18330
18271 ErrorVerifier(this._errorReporter, this._currentLibrary, this._typeProvider, t his._inheritanceManager) { 18331 ErrorVerifier(ErrorReporter errorReporter, LibraryElement currentLibrary, Type Provider typeProvider, InheritanceManager inheritanceManager) {
18272 this._isInSystemLibrary = _currentLibrary.source.isInSystemLibrary; 18332 this._errorReporter = errorReporter;
18273 this._hasExtUri = _currentLibrary.hasExtUri; 18333 this._currentLibrary = currentLibrary;
18334 this._isInSystemLibrary = currentLibrary.source.isInSystemLibrary;
18335 this._hasExtUri = currentLibrary.hasExtUri;
18336 this._typeProvider = typeProvider;
18337 this._inheritanceManager = inheritanceManager;
18274 _isEnclosingConstructorConst = false; 18338 _isEnclosingConstructorConst = false;
18275 _isInCatchClause = false; 18339 _isInCatchClause = false;
18276 _isInStaticVariableDeclaration = false; 18340 _isInStaticVariableDeclaration = false;
18277 _isInInstanceVariableDeclaration = false; 18341 _isInInstanceVariableDeclaration = false;
18278 _isInInstanceVariableInitializer = false; 18342 _isInInstanceVariableInitializer = false;
18279 _isInConstructorInitializer = false; 18343 _isInConstructorInitializer = false;
18280 _isInStaticMethod = false; 18344 _isInStaticMethod = false;
18281 _boolType = _typeProvider.boolType; 18345 _boolType = typeProvider.boolType;
18282 _intType = _typeProvider.intType; 18346 _intType = typeProvider.intType;
18283 _dynamicType = _typeProvider.dynamicType; 18347 _dynamicType = typeProvider.dynamicType;
18284 _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT = <InterfaceType> [ 18348 _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT = <InterfaceType> [
18285 _typeProvider.nullType, 18349 typeProvider.nullType,
18286 _typeProvider.numType, 18350 typeProvider.numType,
18287 _intType, 18351 _intType,
18288 _typeProvider.doubleType, 18352 typeProvider.doubleType,
18289 _boolType, 18353 _boolType,
18290 _typeProvider.stringType]; 18354 typeProvider.stringType];
18291 } 18355 }
18292 18356
18293 @override 18357 @override
18294 Object visitArgumentList(ArgumentList node) { 18358 Object visitArgumentList(ArgumentList node) {
18295 _checkForArgumentTypesNotAssignableInList(node); 18359 _checkForArgumentTypesNotAssignableInList(node);
18296 return super.visitArgumentList(node); 18360 return super.visitArgumentList(node);
18297 } 18361 }
18298 18362
18299 @override 18363 @override
18300 Object visitAssertStatement(AssertStatement node) { 18364 Object visitAssertStatement(AssertStatement node) {
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
18714 _enclosingFunction = node.element; 18778 _enclosingFunction = node.element;
18715 SimpleIdentifier identifier = node.name; 18779 SimpleIdentifier identifier = node.name;
18716 String methodName = ""; 18780 String methodName = "";
18717 if (identifier != null) { 18781 if (identifier != null) {
18718 methodName = identifier.name; 18782 methodName = identifier.name;
18719 } 18783 }
18720 if (node.isSetter || node.isGetter) { 18784 if (node.isSetter || node.isGetter) {
18721 _checkForMismatchedAccessorTypes(node, methodName); 18785 _checkForMismatchedAccessorTypes(node, methodName);
18722 } 18786 }
18723 if (node.isGetter) { 18787 if (node.isGetter) {
18724 _checkForVoidReturnType(node);
18725 _checkForConflictingStaticGetterAndInstanceSetter(node); 18788 _checkForConflictingStaticGetterAndInstanceSetter(node);
18726 } else if (node.isSetter) { 18789 } else if (node.isSetter) {
18727 _checkForWrongNumberOfParametersForSetter(node.name, node.parameters); 18790 _checkForWrongNumberOfParametersForSetter(node.name, node.parameters);
18728 _checkForNonVoidReturnTypeForSetter(node.returnType); 18791 _checkForNonVoidReturnTypeForSetter(node.returnType);
18729 _checkForConflictingStaticSetterAndInstanceMember(node); 18792 _checkForConflictingStaticSetterAndInstanceMember(node);
18730 } else if (node.isOperator) { 18793 } else if (node.isOperator) {
18731 _checkForOptionalParameterInOperator(node); 18794 _checkForOptionalParameterInOperator(node);
18732 _checkForWrongNumberOfParametersForOperator(node); 18795 _checkForWrongNumberOfParametersForOperator(node);
18733 _checkForNonVoidReturnTypeForOperator(node); 18796 _checkForNonVoidReturnTypeForOperator(node);
18734 } 18797 }
(...skipping 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after
20241 return false; 20304 return false;
20242 } 20305 }
20243 ConstructorElement unnamedConstructor = supertype.element.unnamedConstructor ; 20306 ConstructorElement unnamedConstructor = supertype.element.unnamedConstructor ;
20244 if (unnamedConstructor == null) { 20307 if (unnamedConstructor == null) {
20245 return false; 20308 return false;
20246 } 20309 }
20247 if (unnamedConstructor.isConst) { 20310 if (unnamedConstructor.isConst) {
20248 return false; 20311 return false;
20249 } 20312 }
20250 // default constructor is not 'const', report problem 20313 // default constructor is not 'const', report problem
20251 _errorReporter.reportErrorForNode(CompileTimeErrorCode.CONST_CONSTRUCTOR_WIT H_NON_CONST_SUPER, node.returnType, []); 20314 _errorReporter.reportErrorForNode(CompileTimeErrorCode.CONST_CONSTRUCTOR_WIT H_NON_CONST_SUPER, node, []);
20252 return true; 20315 return true;
20253 } 20316 }
20254 20317
20255 /** 20318 /**
20256 * This verifies that if the passed constructor declaration is 'const' then th ere are no non-final 20319 * This verifies that if the passed constructor declaration is 'const' then th ere are no non-final
20257 * instance variable. 20320 * instance variable.
20258 * 20321 *
20259 * @param node the constructor declaration to evaluate 20322 * @param node the constructor declaration to evaluate
20260 * @return `true` if and only if an error code is generated on the passed node 20323 * @return `true` if and only if an error code is generated on the passed node
20261 * @see CompileTimeErrorCode#CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD 20324 * @see CompileTimeErrorCode#CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD
(...skipping 2206 matching lines...) Expand 10 before | Expand all | Expand 10 after
22468 _errorReporter.reportErrorForNode(CompileTimeErrorCode.INITIALIZING_ FORMAL_FOR_NON_EXISTANT_FIELD, node, [node.identifier.name]); 22531 _errorReporter.reportErrorForNode(CompileTimeErrorCode.INITIALIZING_ FORMAL_FOR_NON_EXISTANT_FIELD, node, [node.identifier.name]);
22469 } else if (fieldElement.isStatic) { 22532 } else if (fieldElement.isStatic) {
22470 _errorReporter.reportErrorForNode(CompileTimeErrorCode.INITIALIZING_ FORMAL_FOR_STATIC_FIELD, node, [node.identifier.name]); 22533 _errorReporter.reportErrorForNode(CompileTimeErrorCode.INITIALIZING_ FORMAL_FOR_STATIC_FIELD, node, [node.identifier.name]);
22471 } 22534 }
22472 } 22535 }
22473 } 22536 }
22474 } 22537 }
22475 } 22538 }
22476 22539
22477 /** 22540 /**
22478 * This verifies that the given getter does not have a return type of 'void'.
22479 *
22480 * @param node the method declaration to evaluate
22481 * @return `true` if and only if an error code is generated on the passed node
22482 * @see StaticWarningCode#VOID_RETURN_FOR_GETTER
22483 */
22484 bool _checkForVoidReturnType(MethodDeclaration node) {
22485 TypeName returnType = node.returnType;
22486 if (returnType == null || returnType.name.name != "void") {
22487 return false;
22488 }
22489 _errorReporter.reportErrorForNode(StaticWarningCode.VOID_RETURN_FOR_GETTER, returnType, []);
22490 return true;
22491 }
22492
22493 /**
22494 * This verifies the passed operator-method declaration, has correct number of parameters. 22541 * This verifies the passed operator-method declaration, has correct number of parameters.
22495 * 22542 *
22496 * This method assumes that the method declaration was tested to be an operato r declaration before 22543 * This method assumes that the method declaration was tested to be an operato r declaration before
22497 * being called. 22544 * being called.
22498 * 22545 *
22499 * @param node the method declaration to evaluate 22546 * @param node the method declaration to evaluate
22500 * @return `true` if and only if an error code is generated on the passed node 22547 * @return `true` if and only if an error code is generated on the passed node
22501 * @see CompileTimeErrorCode#WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR 22548 * @see CompileTimeErrorCode#WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR
22502 */ 22549 */
22503 bool _checkForWrongNumberOfParametersForOperator(MethodDeclaration node) { 22550 bool _checkForWrongNumberOfParametersForOperator(MethodDeclaration node) {
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
22951 return false; 22998 return false;
22952 } 22999 }
22953 } 23000 }
22954 23001
22955 /** 23002 /**
22956 * This enum holds one of four states of a field initialization state through a constructor 23003 * This enum holds one of four states of a field initialization state through a constructor
22957 * signature, not initialized, initialized in the field declaration, initialized in the field 23004 * signature, not initialized, initialized in the field declaration, initialized in the field
22958 * formal, and finally, initialized in the initializers list. 23005 * formal, and finally, initialized in the initializers list.
22959 */ 23006 */
22960 class INIT_STATE extends Enum<INIT_STATE> { 23007 class INIT_STATE extends Enum<INIT_STATE> {
22961 static const INIT_STATE NOT_INIT = const INIT_STATE('NOT_INIT', 0); 23008 static final INIT_STATE NOT_INIT = new INIT_STATE('NOT_INIT', 0);
22962 23009
22963 static const INIT_STATE INIT_IN_DECLARATION = const INIT_STATE('INIT_IN_DECLAR ATION', 1); 23010 static final INIT_STATE INIT_IN_DECLARATION = new INIT_STATE('INIT_IN_DECLARAT ION', 1);
22964 23011
22965 static const INIT_STATE INIT_IN_FIELD_FORMAL = const INIT_STATE('INIT_IN_FIELD _FORMAL', 2); 23012 static final INIT_STATE INIT_IN_FIELD_FORMAL = new INIT_STATE('INIT_IN_FIELD_F ORMAL', 2);
22966 23013
22967 static const INIT_STATE INIT_IN_INITIALIZERS = const INIT_STATE('INIT_IN_INITI ALIZERS', 3); 23014 static final INIT_STATE INIT_IN_INITIALIZERS = new INIT_STATE('INIT_IN_INITIAL IZERS', 3);
22968 23015
22969 static const List<INIT_STATE> values = const [ 23016 static final List<INIT_STATE> values = [
22970 NOT_INIT, 23017 NOT_INIT,
22971 INIT_IN_DECLARATION, 23018 INIT_IN_DECLARATION,
22972 INIT_IN_FIELD_FORMAL, 23019 INIT_IN_FIELD_FORMAL,
22973 INIT_IN_INITIALIZERS]; 23020 INIT_IN_INITIALIZERS];
22974 23021
22975 const INIT_STATE(String name, int ordinal) : super(name, ordinal); 23022 INIT_STATE(String name, int ordinal) : super(name, ordinal);
22976 } 23023 }
22977 23024
22978 class GeneralizingElementVisitor_ErrorVerifier_hasTypedefSelfReference extends G eneralizingElementVisitor<Object> { 23025 class GeneralizingElementVisitor_ErrorVerifier_hasTypedefSelfReference extends G eneralizingElementVisitor<Object> {
22979 Element target; 23026 Element target;
22980 23027
22981 List<Element> toCheck; 23028 List<Element> toCheck;
22982 23029
22983 GeneralizingElementVisitor_ErrorVerifier_hasTypedefSelfReference(this.target, this.toCheck) : super(); 23030 GeneralizingElementVisitor_ErrorVerifier_hasTypedefSelfReference(this.target, this.toCheck) : super();
22984 23031
22985 bool _inClass = false; 23032 bool _inClass = false;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
23052 } 23099 }
23053 } 23100 }
23054 23101
23055 /** 23102 /**
23056 * The enumeration `ResolverErrorCode` defines the error codes used for errors d etected by the 23103 * The enumeration `ResolverErrorCode` defines the error codes used for errors d etected by the
23057 * resolver. The convention for this class is for the name of the error code to indicate the problem 23104 * resolver. The convention for this class is for the name of the error code to indicate the problem
23058 * that caused the error to be generated and for the error message to explain wh at is wrong and, 23105 * that caused the error to be generated and for the error message to explain wh at is wrong and,
23059 * when appropriate, how the problem can be corrected. 23106 * when appropriate, how the problem can be corrected.
23060 */ 23107 */
23061 class ResolverErrorCode extends Enum<ResolverErrorCode> implements ErrorCode { 23108 class ResolverErrorCode extends Enum<ResolverErrorCode> implements ErrorCode {
23062 static const ResolverErrorCode BREAK_LABEL_ON_SWITCH_MEMBER = const ResolverEr rorCode.con1('BREAK_LABEL_ON_SWITCH_MEMBER', 0, ErrorType.COMPILE_TIME_ERROR, "B reak label resolves to case or default statement"); 23109 static final ResolverErrorCode BREAK_LABEL_ON_SWITCH_MEMBER = new ResolverErro rCode.con1('BREAK_LABEL_ON_SWITCH_MEMBER', 0, ErrorType.COMPILE_TIME_ERROR, "Bre ak label resolves to case or default statement");
23063 23110
23064 static const ResolverErrorCode CONTINUE_LABEL_ON_SWITCH = const ResolverErrorC ode.con1('CONTINUE_LABEL_ON_SWITCH', 1, ErrorType.COMPILE_TIME_ERROR, "A continu e label resolves to switch, must be loop or switch member"); 23111 static final ResolverErrorCode CONTINUE_LABEL_ON_SWITCH = new ResolverErrorCod e.con1('CONTINUE_LABEL_ON_SWITCH', 1, ErrorType.COMPILE_TIME_ERROR, "A continue label resolves to switch, must be loop or switch member");
23065 23112
23066 static const ResolverErrorCode MISSING_LIBRARY_DIRECTIVE_WITH_PART = const Res olverErrorCode.con1('MISSING_LIBRARY_DIRECTIVE_WITH_PART', 2, ErrorType.COMPILE_ TIME_ERROR, "Libraries that have parts must have a library directive"); 23113 static final ResolverErrorCode MISSING_LIBRARY_DIRECTIVE_WITH_PART = new Resol verErrorCode.con1('MISSING_LIBRARY_DIRECTIVE_WITH_PART', 2, ErrorType.COMPILE_TI ME_ERROR, "Libraries that have parts must have a library directive");
23067 23114
23068 static const List<ResolverErrorCode> values = const [ 23115 static final List<ResolverErrorCode> values = [
23069 BREAK_LABEL_ON_SWITCH_MEMBER, 23116 BREAK_LABEL_ON_SWITCH_MEMBER,
23070 CONTINUE_LABEL_ON_SWITCH, 23117 CONTINUE_LABEL_ON_SWITCH,
23071 MISSING_LIBRARY_DIRECTIVE_WITH_PART]; 23118 MISSING_LIBRARY_DIRECTIVE_WITH_PART];
23072 23119
23073 /** 23120 /**
23074 * The type of this error. 23121 * The type of this error.
23075 */ 23122 */
23076 final ErrorType type; 23123 ErrorType type;
23077 23124
23078 /** 23125 /**
23079 * The template used to create the message to be displayed for this error. 23126 * The template used to create the message to be displayed for this error.
23080 */ 23127 */
23081 final String message; 23128 String message;
23082 23129
23083 /** 23130 /**
23084 * The template used to create the correction to be displayed for this error, or `null` if 23131 * The template used to create the correction to be displayed for this error, or `null` if
23085 * there is no correction information for this error. 23132 * there is no correction information for this error.
23086 */ 23133 */
23087 final String correction; 23134 String correction9;
23088 23135
23089 /** 23136 /**
23090 * Initialize a newly created error code to have the given type and message. 23137 * Initialize a newly created error code to have the given type and message.
23091 * 23138 *
23092 * @param type the type of this error 23139 * @param type the type of this error
23093 * @param message the message template used to create the message to be displa yed for the error 23140 * @param message the message template used to create the message to be displa yed for the error
23094 */ 23141 */
23095 const ResolverErrorCode.con1(String name, int ordinal, ErrorType type, String message) : this.con2(name, ordinal, type, message, null); 23142 ResolverErrorCode.con1(String name, int ordinal, ErrorType type, String messag e) : super(name, ordinal) {
23143 this.type = type;
23144 this.message = message;
23145 }
23096 23146
23097 /** 23147 /**
23098 * Initialize a newly created error code to have the given type, message and c orrection. 23148 * Initialize a newly created error code to have the given type, message and c orrection.
23099 * 23149 *
23100 * @param type the type of this error 23150 * @param type the type of this error
23101 * @param message the template used to create the message to be displayed for the error 23151 * @param message the template used to create the message to be displayed for the error
23102 * @param correction the template used to create the correction to be displaye d for the error 23152 * @param correction the template used to create the correction to be displaye d for the error
23103 */ 23153 */
23104 const ResolverErrorCode.con2(String name, int ordinal, this.type, this.message , this.correction) : super(name, ordinal); 23154 ResolverErrorCode.con2(String name, int ordinal, ErrorType type, String messag e, String correction) : super(name, ordinal) {
23155 this.type = type;
23156 this.message = message;
23157 this.correction9 = correction;
23158 }
23159
23160 @override
23161 String get correction => correction9;
23105 23162
23106 @override 23163 @override
23107 ErrorSeverity get errorSeverity => type.severity; 23164 ErrorSeverity get errorSeverity => type.severity;
23108 } 23165 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/parser.dart ('k') | pkg/analyzer/lib/src/generated/scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698