Chromium Code Reviews| 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 1ca9d3b0047fca7278ee141244164d68cb56a8cf..173c83963c4064486689ce8fea8458b1f11efb69 100644 |
| --- a/pkg/analyzer/lib/src/generated/resolver.dart |
| +++ b/pkg/analyzer/lib/src/generated/resolver.dart |
| @@ -15583,6 +15583,25 @@ class _GatherUsedElementsVisitor extends RecursiveAstVisitor { |
| } |
| @override |
| + visitFunctionDeclaration(FunctionDeclaration node) { |
| + ExecutableElement enclosingExecOld = _enclosingExec; |
| + try { |
| + _enclosingExec = node.element; |
| + super.visitFunctionDeclaration(node); |
| + } finally { |
| + _enclosingExec = enclosingExecOld; |
| + } |
| + } |
| + |
| + @override |
| + visitFunctionExpression(FunctionExpression node) { |
| + if (node.parent is! FunctionDeclaration) { |
| + _useElement(node.element); |
| + } |
| + super.visitFunctionExpression(node); |
| + } |
| + |
| + @override |
| visitMethodDeclaration(MethodDeclaration node) { |
| ExecutableElement enclosingExecOld = _enclosingExec; |
| try { |
| @@ -15739,7 +15758,7 @@ class _UnusedElementsVerifier extends RecursiveElementVisitor { |
| @override |
| visitFieldElement(FieldElement element) { |
| - if (!element.isSynthetic && !_isReadMember(element)) { |
| + if (!_isReadMember(element)) { |
| _reportErrorForElement( |
| HintCode.UNUSED_FIELD, |
| element, |
| @@ -15749,6 +15768,17 @@ class _UnusedElementsVerifier extends RecursiveElementVisitor { |
| } |
| @override |
| + visitFunctionElement(FunctionElement element) { |
| + if (!_isUsedElement(element)) { |
| + _reportErrorForElement( |
| + HintCode.UNUSED_ELEMENT, |
| + element, |
| + [element.kind.displayName, element.displayName]); |
| + } |
| + super.visitFunctionElement(element); |
| + } |
| + |
| + @override |
| visitLocalVariableElement(LocalVariableElement element) { |
| if (!_isUsedElement(element)) { |
| _reportErrorForElement( |
| @@ -15771,7 +15801,7 @@ class _UnusedElementsVerifier extends RecursiveElementVisitor { |
| @override |
| visitPropertyAccessorElement(PropertyAccessorElement element) { |
| - if (!element.isSynthetic && !_isUsedMember(element)) { |
| + if (!_isUsedMember(element)) { |
| _reportErrorForElement( |
| HintCode.UNUSED_ELEMENT, |
| element, |
| @@ -15781,11 +15811,21 @@ class _UnusedElementsVerifier extends RecursiveElementVisitor { |
| } |
| bool _isUsedElement(Element element) { |
| - if (element is! LocalVariableElement) { |
| + if (element.isSynthetic) { |
| + return true; |
| + } |
| + if (element is LocalVariableElement || |
| + element is FunctionElement && !element.isStatic) { |
|
Brian Wilkerson
2014/11/14 18:52:57
It always looks weird to me to have an empty then
scheglov
2014/11/14 19:08:09
I agree in general, but in this case there are two
|
| + } else { |
| if (element.isPublic) { |
| return true; |
| } |
| } |
| +// if (element is! LocalVariableElement) { |
| +// if (element.isPublic) { |
| +// return true; |
| +// } |
| +// } |
| return _usedElements.elements.contains(element); |
| } |
| @@ -15793,6 +15833,9 @@ class _UnusedElementsVerifier extends RecursiveElementVisitor { |
| if (element.isPublic) { |
| return true; |
| } |
| + if (element.isSynthetic) { |
| + return true; |
| + } |
| return _usedElements.readMembers.contains(element.displayName); |
| } |
| @@ -15800,6 +15843,9 @@ class _UnusedElementsVerifier extends RecursiveElementVisitor { |
| if (element.isPublic) { |
| return true; |
| } |
| + if (element.isSynthetic) { |
| + return true; |
| + } |
| if (_usedElements.members.contains(element.displayName)) { |
| return true; |
| } |