Skip to content

Commit e62236e

Browse files
scheglovCommit Queue
authored andcommitted
CQ. Pass ErrorReporter to ScopeResolverVisitor.
Change-Id: Iec22d82d42c4ac5c90616bb781bba140a58f71e7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403081 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]>
1 parent 131fe7b commit e62236e

File tree

3 files changed

+12
-21
lines changed

3 files changed

+12
-21
lines changed

pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ class LibraryAnalyzer {
183183
// TODO(scheglov): We don't need to do this for the whole unit.
184184
parsedUnit.accept(
185185
ScopeResolverVisitor(
186-
file.source,
187-
errorListener,
186+
fileAnalysis.errorReporter,
188187
nameScope: unitElement.scope,
189188
unitElement: unitElement,
190189
),
@@ -857,8 +856,7 @@ class LibraryAnalyzer {
857856
fileAnalysis.file.uri, inferenceDataForTesting!);
858857

859858
unit.accept(ScopeResolverVisitor(
860-
source,
861-
errorListener,
859+
fileAnalysis.errorReporter,
862860
nameScope: unitElement.scope,
863861
unitElement: unitElement,
864862
));

pkg/analyzer/lib/src/generated/resolver.dart

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4512,7 +4512,7 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
45124512
class ScopeResolverVisitor extends UnifyingAstVisitor<void> {
45134513
/// The error reporter that will be informed of any errors that are found
45144514
/// during resolution.
4515-
final ErrorReporter _errorReporter;
4515+
final ErrorReporter errorReporter;
45164516

45174517
/// The scope used to resolve identifiers.
45184518
Scope nameScope;
@@ -4537,21 +4537,15 @@ class ScopeResolverVisitor extends UnifyingAstVisitor<void> {
45374537

45384538
/// Initialize a newly created visitor to resolve the nodes in an AST node.
45394539
///
4540-
/// [source] is the source representing the compilation unit containing the
4541-
/// node being visited.
4542-
/// [errorListener] is the error listener that will be informed of any errors
4540+
/// [errorReporter] is the error reporter that will be informed of any errors
45434541
/// that are found during resolution.
45444542
/// [nameScope] is the scope used to resolve identifiers in the node that will
45454543
/// first be visited.
4546-
/// [docImportLibraries] are the `@docImport` imported elements of this node's
4547-
/// library.
45484544
ScopeResolverVisitor(
4549-
Source source,
4550-
AnalysisErrorListener errorListener, {
4545+
this.errorReporter, {
45514546
required this.nameScope,
45524547
required CompilationUnitElementImpl unitElement,
4553-
}) : _errorReporter = ErrorReporter(errorListener, source),
4554-
_docImportScope = DocumentationCommentScope(nameScope, unitElement);
4548+
}) : _docImportScope = DocumentationCommentScope(nameScope, unitElement);
45554549

45564550
/// Return the implicit label scope in which the current node is being
45574551
/// resolved.
@@ -5231,7 +5225,7 @@ class ScopeResolverVisitor extends UnifyingAstVisitor<void> {
52315225
if (node.inSetterContext()) {
52325226
if (element is PatternVariableElementImpl &&
52335227
element.isVisitingWhenClause) {
5234-
_errorReporter.atNode(
5228+
errorReporter.atNode(
52355229
node,
52365230
CompileTimeErrorCode.PATTERN_VARIABLE_ASSIGNMENT_INSIDE_GUARD,
52375231
);
@@ -5364,7 +5358,7 @@ class ScopeResolverVisitor extends UnifyingAstVisitor<void> {
53645358
if (labelScope == null) {
53655359
// There are no labels in scope, so by definition the label is
53665360
// undefined.
5367-
_errorReporter.atNode(
5361+
errorReporter.atNode(
53685362
labelNode,
53695363
CompileTimeErrorCode.LABEL_UNDEFINED,
53705364
arguments: [labelNode.name],
@@ -5375,7 +5369,7 @@ class ScopeResolverVisitor extends UnifyingAstVisitor<void> {
53755369
if (definingScope == null) {
53765370
// No definition of the given label name could be found in any
53775371
// enclosing scope.
5378-
_errorReporter.atNode(
5372+
errorReporter.atNode(
53795373
labelNode,
53805374
CompileTimeErrorCode.LABEL_UNDEFINED,
53815375
arguments: [labelNode.name],
@@ -5388,7 +5382,7 @@ class ScopeResolverVisitor extends UnifyingAstVisitor<void> {
53885382
definingScope.element.thisOrAncestorOfType();
53895383
if (_enclosingClosure != null &&
53905384
!identical(labelContainer, _enclosingClosure)) {
5391-
_errorReporter.atNode(
5385+
errorReporter.atNode(
53925386
labelNode,
53935387
CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE,
53945388
arguments: [labelNode.name],
@@ -5400,7 +5394,7 @@ class ScopeResolverVisitor extends UnifyingAstVisitor<void> {
54005394
node is! ForStatement &&
54015395
node is! SwitchMember &&
54025396
node is! WhileStatement) {
5403-
_errorReporter.atNode(
5397+
errorReporter.atNode(
54045398
parentNode,
54055399
CompileTimeErrorCode.CONTINUE_LABEL_INVALID,
54065400
);

pkg/analyzer/lib/src/summary2/ast_resolver.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ class AstResolver {
3838
dataForTesting: null,
3939
);
4040
late final _scopeResolverVisitor = ScopeResolverVisitor(
41-
_unitElement.source,
42-
_errorListener,
41+
ErrorReporter(_errorListener, _unitElement.source),
4342
nameScope: _nameScope,
4443
unitElement: _unitElement,
4544
);

0 commit comments

Comments
 (0)