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

Unified Diff: pkg/analyzer/lib/src/task/dart.dart

Issue 2068123003: Skip class method type parameters and formal parameters. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 months 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/src/task/dart_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/task/dart.dart
diff --git a/pkg/analyzer/lib/src/task/dart.dart b/pkg/analyzer/lib/src/task/dart.dart
index bc9139244f2dc4df551f86cd202f28f2e0644130..3e8a868549c5547ea84e1051cc8f254c4eb433ed 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -4664,6 +4664,17 @@ class ReferencedNamesBuilder extends GeneralizingAstVisitor {
}
@override
+ visitMethodDeclaration(MethodDeclaration node) {
+ ReferencedNamesScope outerScope = scope;
+ try {
+ scope = new ReferencedNamesScope.forMethod(scope, node);
+ super.visitMethodDeclaration(node);
+ } finally {
+ scope = outerScope;
+ }
+ }
+
+ @override
visitSimpleIdentifier(SimpleIdentifier node) {
// Ignore all declarations.
if (node.inDeclarationContext()) {
@@ -4714,7 +4725,11 @@ class ReferencedNamesScope {
ReferencedNamesScope scope = new ReferencedNamesScope(enclosing);
scope._addTypeParameters(node.typeParameters);
for (ClassMember member in node.members) {
- if (member is MethodDeclaration) {
+ if (member is FieldDeclaration) {
+ for (VariableDeclaration variable in member.fields.variables) {
+ scope.add(variable.name.name);
+ }
+ } else if (member is MethodDeclaration) {
scope.add(member.name.name);
}
}
@@ -4725,9 +4740,7 @@ class ReferencedNamesScope {
ReferencedNamesScope enclosing, FunctionDeclaration node) {
ReferencedNamesScope scope = new ReferencedNamesScope(enclosing);
scope._addTypeParameters(node.functionExpression.typeParameters);
- node.functionExpression.parameters?.parameters
- ?.map((p) => p is NormalFormalParameter ? p.identifier.name : '')
- ?.forEach(scope.add);
+ scope._addFormalParameters(node.functionExpression.parameters);
return scope;
}
@@ -4738,6 +4751,14 @@ class ReferencedNamesScope {
return scope;
}
+ factory ReferencedNamesScope.forMethod(
+ ReferencedNamesScope enclosing, MethodDeclaration node) {
+ ReferencedNamesScope scope = new ReferencedNamesScope(enclosing);
+ scope._addTypeParameters(node.typeParameters);
+ scope._addFormalParameters(node.parameters);
+ return scope;
+ }
+
void add(String name) {
names ??= new Set<String>();
names.add(name);
@@ -4753,6 +4774,14 @@ class ReferencedNamesScope {
return false;
}
+ void _addFormalParameters(FormalParameterList parameterList) {
+ if (parameterList != null) {
+ parameterList.parameters
+ .map((p) => p is NormalFormalParameter ? p.identifier.name : '')
+ .forEach(add);
+ }
+ }
+
void _addTypeParameters(TypeParameterList typeParameterList) {
typeParameterList?.typeParameters?.map((p) => p.name.name)?.forEach(add);
}
« no previous file with comments | « no previous file | pkg/analyzer/test/src/task/dart_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698