@@ -4510,18 +4510,9 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
45104510// TODO(paulberry): migrate the responsibility for all scope resolution into
45114511// this visitor.
45124512class ScopeResolverVisitor extends UnifyingAstVisitor <void > {
4513- /// The element for the library containing the compilation unit being visited.
4514- final LibraryElementImpl definingLibrary;
4515-
4516- /// The source representing the compilation unit being visited.
4517- final Source source;
4518-
4519- /// The object used to access the types from the core library.
4520- final TypeProviderImpl typeProvider;
4521-
45224513 /// The error reporter that will be informed of any errors that are found
45234514 /// during resolution.
4524- final ErrorReporter errorReporter ;
4515+ final ErrorReporter _errorReporter ;
45254516
45264517 /// The scope used to resolve identifiers.
45274518 Scope nameScope;
@@ -4534,7 +4525,7 @@ class ScopeResolverVisitor extends UnifyingAstVisitor<void> {
45344525
45354526 /// The scope used to resolve labels for `break` and `continue` statements, or
45364527 /// `null` if no labels have been defined in the current context.
4537- LabelScope ? labelScope ;
4528+ LabelScope ? _labelScope ;
45384529
45394530 /// The container with information about local variables.
45404531 final LocalVariableInfo _localVariableInfo = LocalVariableInfo ();
@@ -4546,26 +4537,20 @@ class ScopeResolverVisitor extends UnifyingAstVisitor<void> {
45464537
45474538 /// Initialize a newly created visitor to resolve the nodes in an AST node.
45484539 ///
4549- /// [definingLibrary] is the element for the library containing the node being
4550- /// visited.
45514540 /// [source] is the source representing the compilation unit containing the
45524541 /// node being visited.
4553- /// [typeProvider] is the object used to access the types from the core
4554- /// library.
45554542 /// [errorListener] is the error listener that will be informed of any errors
45564543 /// that are found during resolution.
45574544 /// [nameScope] is the scope used to resolve identifiers in the node that will
45584545 /// first be visited.
45594546 /// [docImportLibraries] are the `@docImport` imported elements of this node's
45604547 /// library.
45614548 ScopeResolverVisitor (
4562- this .definingLibrary,
4563- this .source,
4564- this .typeProvider,
4549+ Source source,
45654550 AnalysisErrorListener errorListener, {
45664551 required this .nameScope,
45674552 required CompilationUnitElementImpl unitElement,
4568- }) : errorReporter = ErrorReporter (errorListener, source),
4553+ }) : _errorReporter = ErrorReporter (errorListener, source),
45694554 _docImportScope = DocumentationCommentScope (nameScope, unitElement);
45704555
45714556 /// Return the implicit label scope in which the current node is being
@@ -5090,7 +5075,7 @@ class ScopeResolverVisitor extends UnifyingAstVisitor<void> {
50905075 try {
50915076 super .visitLabeledStatement (node);
50925077 } finally {
5093- labelScope = outerScope;
5078+ _labelScope = outerScope;
50945079 }
50955080 }
50965081
@@ -5246,7 +5231,7 @@ class ScopeResolverVisitor extends UnifyingAstVisitor<void> {
52465231 if (node.inSetterContext ()) {
52475232 if (element is PatternVariableElementImpl &&
52485233 element.isVisitingWhenClause) {
5249- errorReporter .atNode (
5234+ _errorReporter .atNode (
52505235 node,
52515236 CompileTimeErrorCode .PATTERN_VARIABLE_ASSIGNMENT_INSIDE_GUARD ,
52525237 );
@@ -5278,16 +5263,16 @@ class ScopeResolverVisitor extends UnifyingAstVisitor<void> {
52785263
52795264 @override
52805265 void visitSwitchStatement (covariant SwitchStatementImpl node) {
5281- var outerScope = labelScope ;
5282- ImplicitLabelScope outerImplicitScope = _implicitLabelScope;
5266+ var outerScope = _labelScope ;
5267+ var outerImplicitScope = _implicitLabelScope;
52835268 try {
52845269 _implicitLabelScope = _implicitLabelScope.nest (node);
5285- for (SwitchMember member in node.members) {
5286- for (Label label in member.labels) {
5287- SimpleIdentifier labelName = label.label;
5288- LabelElement labelElement = labelName.staticElement as LabelElement ;
5289- labelScope =
5290- LabelScope (labelScope , labelName.name, member, labelElement);
5270+ for (var member in node.members) {
5271+ for (var label in member.labels) {
5272+ var labelName = label.label;
5273+ var labelElement = labelName.staticElement as LabelElement ;
5274+ _labelScope =
5275+ LabelScope (_labelScope , labelName.name, member, labelElement);
52915276 }
52925277 }
52935278 node.expression.accept (this );
@@ -5313,7 +5298,7 @@ class ScopeResolverVisitor extends UnifyingAstVisitor<void> {
53135298 });
53145299 }
53155300 } finally {
5316- labelScope = outerScope;
5301+ _labelScope = outerScope;
53175302 _implicitLabelScope = outerImplicitScope;
53185303 }
53195304 }
@@ -5351,12 +5336,12 @@ class ScopeResolverVisitor extends UnifyingAstVisitor<void> {
53515336 ///
53525337 /// Returns the scope that was in effect before the new scopes were added.
53535338 LabelScope ? _addScopesFor (NodeList <Label > labels, AstNode node) {
5354- var outerScope = labelScope ;
5355- for (Label label in labels) {
5356- SimpleIdentifier labelNameNode = label.label;
5357- String labelName = labelNameNode.name;
5358- LabelElement labelElement = labelNameNode.staticElement as LabelElement ;
5359- labelScope = LabelScope (labelScope , labelName, node, labelElement);
5339+ var outerScope = _labelScope ;
5340+ for (var label in labels) {
5341+ var labelNameNode = label.label;
5342+ var labelName = labelNameNode.name;
5343+ var labelElement = labelNameNode.staticElement as LabelElement ;
5344+ _labelScope = LabelScope (_labelScope , labelName, node, labelElement);
53605345 }
53615346 return outerScope;
53625347 }
@@ -5375,11 +5360,11 @@ class ScopeResolverVisitor extends UnifyingAstVisitor<void> {
53755360 if (labelNode == null ) {
53765361 return implicitLabelScope.getTarget (isContinue);
53775362 } else {
5378- var labelScope = this .labelScope ;
5363+ var labelScope = _labelScope ;
53795364 if (labelScope == null ) {
53805365 // There are no labels in scope, so by definition the label is
53815366 // undefined.
5382- errorReporter .atNode (
5367+ _errorReporter .atNode (
53835368 labelNode,
53845369 CompileTimeErrorCode .LABEL_UNDEFINED ,
53855370 arguments: [labelNode.name],
@@ -5390,7 +5375,7 @@ class ScopeResolverVisitor extends UnifyingAstVisitor<void> {
53905375 if (definingScope == null ) {
53915376 // No definition of the given label name could be found in any
53925377 // enclosing scope.
5393- errorReporter .atNode (
5378+ _errorReporter .atNode (
53945379 labelNode,
53955380 CompileTimeErrorCode .LABEL_UNDEFINED ,
53965381 arguments: [labelNode.name],
@@ -5403,7 +5388,7 @@ class ScopeResolverVisitor extends UnifyingAstVisitor<void> {
54035388 definingScope.element.thisOrAncestorOfType ();
54045389 if (_enclosingClosure != null &&
54055390 ! identical (labelContainer, _enclosingClosure)) {
5406- errorReporter .atNode (
5391+ _errorReporter .atNode (
54075392 labelNode,
54085393 CompileTimeErrorCode .LABEL_IN_OUTER_SCOPE ,
54095394 arguments: [labelNode.name],
@@ -5415,7 +5400,7 @@ class ScopeResolverVisitor extends UnifyingAstVisitor<void> {
54155400 node is ! ForStatement &&
54165401 node is ! SwitchMember &&
54175402 node is ! WhileStatement ) {
5418- errorReporter .atNode (
5403+ _errorReporter .atNode (
54195404 parentNode,
54205405 CompileTimeErrorCode .CONTINUE_LABEL_INVALID ,
54215406 );
0 commit comments