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

Unified Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 1526973005: Replace using '_commentBeforeFunction' with visitXyzInScope(). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/non_error_resolver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 43b81e984cd71037817c59855ed580c028517f9d..fbe93600bfe6dcc9c8fc1c03cb9d8aaddec08fb1 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -7956,12 +7956,6 @@ class ResolverVisitor extends ScopedVisitor {
*/
ExecutableElement _enclosingFunction = null;
- /**
- * The [Comment] before a [FunctionDeclaration] or a [MethodDeclaration] that
- * cannot be resolved where we visited it, because it should be resolved in the scope of the body.
- */
- Comment _commentBeforeFunction = null;
-
InferenceContext inferenceContext = null;
/**
@@ -8122,7 +8116,6 @@ class ResolverVisitor extends ScopedVisitor {
if (element is ExecutableElement) {
_enclosingFunction = element;
}
- _commentBeforeFunction = declaration.documentationComment;
}
_overrideManager.enterScope();
}
@@ -8417,7 +8410,6 @@ class ResolverVisitor extends ScopedVisitor {
@override
Object visitBlockFunctionBody(BlockFunctionBody node) {
- safelyVisit(_commentBeforeFunction);
_overrideManager.enterScope();
try {
inferenceContext.pushReturnContext(InferenceContext.getType(node));
@@ -8502,13 +8494,9 @@ class ResolverVisitor extends ScopedVisitor {
parent is FunctionTypeAlias ||
parent is ConstructorDeclaration ||
parent is MethodDeclaration) {
- if (!identical(node, _commentBeforeFunction)) {
- _commentBeforeFunction = node;
- return null;
- }
+ return null;
}
super.visitComment(node);
- _commentBeforeFunction = null;
return null;
}
@@ -8633,6 +8621,14 @@ class ResolverVisitor extends ScopedVisitor {
}
@override
+ void visitConstructorDeclarationInScope(ConstructorDeclaration node) {
+ super.visitConstructorDeclarationInScope(node);
+ if (node.documentationComment != null) {
Brian Wilkerson 2015/12/17 14:54:21 These three lines occur often enough that it might
scheglov 2015/12/17 18:52:04 Done.
+ super.visitComment(node.documentationComment);
+ }
+ }
+
+ @override
Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) {
//
// We visit the expression, but do not visit the field name because it needs
@@ -8706,7 +8702,6 @@ class ResolverVisitor extends ScopedVisitor {
@override
Object visitEmptyFunctionBody(EmptyFunctionBody node) {
- safelyVisit(_commentBeforeFunction);
if (resolveOnlyCommentInFunctionBody) {
return null;
}
@@ -8744,7 +8739,6 @@ class ResolverVisitor extends ScopedVisitor {
@override
Object visitExpressionFunctionBody(ExpressionFunctionBody node) {
- safelyVisit(_commentBeforeFunction);
if (resolveOnlyCommentInFunctionBody) {
return null;
}
@@ -8882,6 +8876,14 @@ class ResolverVisitor extends ScopedVisitor {
}
@override
+ void visitFunctionDeclarationInScope(FunctionDeclaration node) {
+ super.visitFunctionDeclarationInScope(node);
+ if (node.documentationComment != null) {
+ super.visitComment(node.documentationComment);
+ }
+ }
+
+ @override
Object visitFunctionExpression(FunctionExpression node) {
ExecutableElement outerFunction = _enclosingFunction;
try {
@@ -8931,13 +8933,11 @@ class ResolverVisitor extends ScopedVisitor {
}
@override
- Object visitFormalParameterList(FormalParameterList node) {
- super.visitFormalParameterList(node);
- if (_commentBeforeFunction != null) {
- safelyVisit(_commentBeforeFunction);
- _commentBeforeFunction = null;
+ void visitFunctionTypeAliasInScope(FunctionTypeAlias node) {
+ super.visitFunctionTypeAliasInScope(node);
+ if (node.documentationComment != null) {
+ super.visitComment(node.documentationComment);
}
- return null;
}
@override
@@ -9109,6 +9109,14 @@ class ResolverVisitor extends ScopedVisitor {
}
@override
+ void visitMethodDeclarationInScope(MethodDeclaration node) {
+ super.visitMethodDeclarationInScope(node);
+ if (node.documentationComment != null) {
+ super.visitComment(node.documentationComment);
+ }
+ }
+
+ @override
Object visitMethodInvocation(MethodInvocation node) {
//
// We visit the target and argument list, but do not visit the method name
@@ -10207,13 +10215,17 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<Object> {
} else {
nameScope = new FunctionScope(nameScope, constructorElement);
}
- super.visitConstructorDeclaration(node);
+ visitConstructorDeclarationInScope(node);
} finally {
nameScope = outerScope;
}
return null;
}
+ void visitConstructorDeclarationInScope(ConstructorDeclaration node) {
+ super.visitConstructorDeclaration(node);
+ }
+
@override
Object visitDeclaredIdentifier(DeclaredIdentifier node) {
VariableElement element = node.element;
@@ -10365,13 +10377,17 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<Object> {
} else {
nameScope = new FunctionScope(nameScope, functionElement);
}
- super.visitFunctionDeclaration(node);
+ visitFunctionDeclarationInScope(node);
} finally {
nameScope = outerScope;
}
return null;
}
+ void visitFunctionDeclarationInScope(FunctionDeclaration node) {
+ super.visitFunctionDeclaration(node);
+ }
+
@override
Object visitFunctionExpression(FunctionExpression node) {
if (node.parent is FunctionDeclaration) {
@@ -10414,13 +10430,17 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<Object> {
Scope outerScope = nameScope;
try {
nameScope = new FunctionTypeScope(nameScope, node.element);
- super.visitFunctionTypeAlias(node);
+ visitFunctionTypeAliasInScope(node);
} finally {
nameScope = outerScope;
}
return null;
}
+ void visitFunctionTypeAliasInScope(FunctionTypeAlias node) {
+ super.visitFunctionTypeAlias(node);
+ }
+
@override
Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
Scope outerScope = nameScope;
@@ -10475,13 +10495,17 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<Object> {
} else {
nameScope = new FunctionScope(nameScope, methodElement);
}
- super.visitMethodDeclaration(node);
+ visitMethodDeclarationInScope(node);
} finally {
nameScope = outerScope;
}
return null;
}
+ void visitMethodDeclarationInScope(MethodDeclaration node) {
+ super.visitMethodDeclaration(node);
+ }
+
/**
* Visit the given statement after it's scope has been created. This is used by ResolverVisitor to
* correctly visit the 'then' and 'else' statements of an 'if' statement.
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/non_error_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698