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

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

Issue 1424793008: Remove unused support for disabling error messages (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/error.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 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 library engine.resolver; 5 library engine.resolver;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/src/generated/scanner.dart'; 9 import 'package:analyzer/src/generated/scanner.dart';
10 10
(...skipping 9728 matching lines...) Expand 10 before | Expand all | Expand 10 after
9739 /** 9739 /**
9740 * The static variables and fields that have an initializer. These are the 9740 * The static variables and fields that have an initializer. These are the
9741 * variables that need to be re-resolved after static variables have their 9741 * variables that need to be re-resolved after static variables have their
9742 * types inferred. A subset of these variables are those whose types should 9742 * types inferred. A subset of these variables are those whose types should
9743 * be inferred. The list will be empty unless the resolver is being run in 9743 * be inferred. The list will be empty unless the resolver is being run in
9744 * strong mode. 9744 * strong mode.
9745 */ 9745 */
9746 final List<VariableElement> variablesAndFields = <VariableElement>[]; 9746 final List<VariableElement> variablesAndFields = <VariableElement>[];
9747 9747
9748 /** 9748 /**
9749 * A flag indicating whether we should discard errors while resolving the
9750 * initializer for variable declarations. We do this for top-level variables
9751 * and fields because their initializer will be re-resolved at a later time.
9752 */
9753 bool discardErrorsInInitializer = false;
9754
9755 /**
9756 * Initialize a newly created visitor to resolve the nodes in an AST node. 9749 * Initialize a newly created visitor to resolve the nodes in an AST node.
9757 * 9750 *
9758 * The [definingLibrary] is the element for the library containing the node 9751 * The [definingLibrary] is the element for the library containing the node
9759 * being visited. The [source] is the source representing the compilation unit 9752 * being visited. The [source] is the source representing the compilation unit
9760 * containing the node being visited. The [typeProvider] is the object used to 9753 * containing the node being visited. The [typeProvider] is the object used to
9761 * access the types from the core library. The [errorListener] is the error 9754 * access the types from the core library. The [errorListener] is the error
9762 * listener that will be informed of any errors that are found during 9755 * listener that will be informed of any errors that are found during
9763 * resolution. The [nameScope] is the scope used to resolve identifiers in the 9756 * resolution. The [nameScope] is the scope used to resolve identifiers in the
9764 * node that will first be visited. If `null` or unspecified, a new 9757 * node that will first be visited. If `null` or unspecified, a new
9765 * [LibraryScope] will be created based on [definingLibrary] and 9758 * [LibraryScope] will be created based on [definingLibrary] and
9766 * [typeProvider]. The [inheritanceManager] is used to perform inheritance 9759 * [typeProvider]. The [inheritanceManager] is used to perform inheritance
9767 * lookups. If `null` or unspecified, a new [InheritanceManager] will be 9760 * lookups. If `null` or unspecified, a new [InheritanceManager] will be
9768 * created based on [definingLibrary]. The [typeAnalyzerFactory] is used to 9761 * created based on [definingLibrary]. The [typeAnalyzerFactory] is used to
9769 * create the type analyzer. If `null` or unspecified, a type analyzer of 9762 * create the type analyzer. If `null` or unspecified, a type analyzer of
9770 * type [StaticTypeAnalyzer] will be created. 9763 * type [StaticTypeAnalyzer] will be created.
9771 */ 9764 */
9772 PartialResolverVisitor(LibraryElement definingLibrary, Source source, 9765 PartialResolverVisitor(LibraryElement definingLibrary, Source source,
9773 TypeProvider typeProvider, AnalysisErrorListener errorListener, 9766 TypeProvider typeProvider, AnalysisErrorListener errorListener,
9774 {Scope nameScope, 9767 {Scope nameScope,
9775 InheritanceManager inheritanceManager, 9768 InheritanceManager inheritanceManager,
9776 StaticTypeAnalyzerFactory typeAnalyzerFactory}) 9769 StaticTypeAnalyzerFactory typeAnalyzerFactory})
9777 : strongMode = definingLibrary.context.analysisOptions.strongMode, 9770 : strongMode = definingLibrary.context.analysisOptions.strongMode,
9778 super(definingLibrary, source, typeProvider, 9771 super(definingLibrary, source, typeProvider, errorListener);
9779 new DisablableErrorListener(errorListener));
9780 9772
9781 @override 9773 @override
9782 Object visitBlockFunctionBody(BlockFunctionBody node) { 9774 Object visitBlockFunctionBody(BlockFunctionBody node) {
9783 if (_shouldBeSkipped(node)) { 9775 if (_shouldBeSkipped(node)) {
9784 return null; 9776 return null;
9785 } 9777 }
9786 return super.visitBlockFunctionBody(node); 9778 return super.visitBlockFunctionBody(node);
9787 } 9779 }
9788 9780
9789 @override 9781 @override
9790 Object visitExpressionFunctionBody(ExpressionFunctionBody node) { 9782 Object visitExpressionFunctionBody(ExpressionFunctionBody node) {
9791 if (_shouldBeSkipped(node)) { 9783 if (_shouldBeSkipped(node)) {
9792 return null; 9784 return null;
9793 } 9785 }
9794 return super.visitExpressionFunctionBody(node); 9786 return super.visitExpressionFunctionBody(node);
9795 } 9787 }
9796 9788
9797 @override 9789 @override
9798 Object visitFieldDeclaration(FieldDeclaration node) { 9790 Object visitFieldDeclaration(FieldDeclaration node) {
9799 if (strongMode && node.isStatic) { 9791 if (strongMode && node.isStatic) {
9800 _addVariables(node.fields.variables); 9792 _addVariables(node.fields.variables);
9801 bool wasDiscarding = discardErrorsInInitializer;
9802 discardErrorsInInitializer = true;
9803 try {
9804 return super.visitFieldDeclaration(node);
9805 } finally {
9806 discardErrorsInInitializer = wasDiscarding;
9807 }
9808 } 9793 }
9809 return super.visitFieldDeclaration(node); 9794 return super.visitFieldDeclaration(node);
9810 } 9795 }
9811 9796
9812 @override 9797 @override
9813 Object visitNode(AstNode node) { 9798 Object visitNode(AstNode node) {
9814 if (discardErrorsInInitializer) {
9815 AstNode parent = node.parent;
9816 if (parent is VariableDeclaration && parent.initializer == node) {
9817 DisablableErrorListener listener = errorListener;
9818 return listener.disableWhile(() => super.visitNode(node));
9819 }
9820 }
9821 return super.visitNode(node); 9799 return super.visitNode(node);
9822 } 9800 }
9823 9801
9824 @override 9802 @override
9825 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { 9803 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) {
9826 if (strongMode) { 9804 if (strongMode) {
9827 _addVariables(node.variables.variables); 9805 _addVariables(node.variables.variables);
9828 bool wasDiscarding = discardErrorsInInitializer;
9829 discardErrorsInInitializer = true;
9830 try {
9831 return super.visitTopLevelVariableDeclaration(node);
9832 } finally {
9833 discardErrorsInInitializer = wasDiscarding;
9834 }
9835 } 9806 }
9836 return super.visitTopLevelVariableDeclaration(node); 9807 return super.visitTopLevelVariableDeclaration(node);
9837 } 9808 }
9838 9809
9839 /** 9810 /**
9840 * Add all of the [variables] with initializers to the list of variables whose 9811 * Add all of the [variables] with initializers to the list of variables whose
9841 * type can be inferred. Technically, we only infer the types of variables 9812 * type can be inferred. Technically, we only infer the types of variables
9842 * that do not have a static type, but all variables with initializers 9813 * that do not have a static type, but all variables with initializers
9843 * potentially need to be re-resolved after inference because they might 9814 * potentially need to be re-resolved after inference because they might
9844 * refer to a field whose type was inferred. 9815 * refer to a field whose type was inferred.
(...skipping 6224 matching lines...) Expand 10 before | Expand all | Expand 10 after
16069 nonFields.add(node); 16040 nonFields.add(node);
16070 return null; 16041 return null;
16071 } 16042 }
16072 16043
16073 @override 16044 @override
16074 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); 16045 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this);
16075 16046
16076 @override 16047 @override
16077 Object visitWithClause(WithClause node) => null; 16048 Object visitWithClause(WithClause node) => null;
16078 } 16049 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/error.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698