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