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

Side by Side Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 1066083002: Report unused function type aliases. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library engine.resolver; 5 library engine.resolver;
6 6
7 import "dart:math" as math; 7 import "dart:math" as math;
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/src/generated/utilities_collection.dart'; 10 import 'package:analyzer/src/generated/utilities_collection.dart';
(...skipping 4550 matching lines...) Expand 10 before | Expand all | Expand 10 after
4561 } 4561 }
4562 if (identical(element, _enclosingExec)) { 4562 if (identical(element, _enclosingExec)) {
4563 return; 4563 return;
4564 } 4564 }
4565 // ignore places where the element is not actually used 4565 // ignore places where the element is not actually used
4566 if (node.parent is TypeName) { 4566 if (node.parent is TypeName) {
4567 AstNode parent2 = node.parent.parent; 4567 AstNode parent2 = node.parent.parent;
4568 if (parent2 is IsExpression) { 4568 if (parent2 is IsExpression) {
4569 return; 4569 return;
4570 } 4570 }
4571 if (parent2 is VariableDeclarationList) { 4571 // We need to instantiate/extend/implement a class to actually use it.
4572 // OTOH, function type aliases are used to define closure structures.
4573 if (parent2 is VariableDeclarationList && element is ClassElement) {
4572 return; 4574 return;
4573 } 4575 }
4574 } 4576 }
4575 // OK 4577 // OK
4576 usedElements.addElement(element); 4578 usedElements.addElement(element);
4577 } 4579 }
4578 4580
4579 static bool _isReadIdentifier(SimpleIdentifier node) { 4581 static bool _isReadIdentifier(SimpleIdentifier node) {
4580 // not reading at all 4582 // not reading at all
4581 if (!node.inGetterContext()) { 4583 if (!node.inGetterContext()) {
(...skipping 10318 matching lines...) Expand 10 before | Expand all | Expand 10 after
14900 if (!_isUsedElement(element)) { 14902 if (!_isUsedElement(element)) {
14901 _reportErrorForElement(HintCode.UNUSED_ELEMENT, element, [ 14903 _reportErrorForElement(HintCode.UNUSED_ELEMENT, element, [
14902 element.kind.displayName, 14904 element.kind.displayName,
14903 element.displayName 14905 element.displayName
14904 ]); 14906 ]);
14905 } 14907 }
14906 super.visitFunctionElement(element); 14908 super.visitFunctionElement(element);
14907 } 14909 }
14908 14910
14909 @override 14911 @override
14912 visitFunctionTypeAliasElement(FunctionTypeAliasElement element) {
14913 if (!_isUsedElement(element)) {
14914 _reportErrorForElement(HintCode.UNUSED_ELEMENT, element, [
14915 element.kind.displayName,
14916 element.displayName
14917 ]);
14918 }
14919 super.visitFunctionTypeAliasElement(element);
14920 }
14921
14922 @override
14910 visitLocalVariableElement(LocalVariableElement element) { 14923 visitLocalVariableElement(LocalVariableElement element) {
14911 if (!_isUsedElement(element) && !_isNamedUnderscore(element)) { 14924 if (!_isUsedElement(element) && !_isNamedUnderscore(element)) {
14912 HintCode errorCode; 14925 HintCode errorCode;
14913 if (_usedElements.isCatchException(element)) { 14926 if (_usedElements.isCatchException(element)) {
14914 errorCode = HintCode.UNUSED_CATCH_CLAUSE; 14927 errorCode = HintCode.UNUSED_CATCH_CLAUSE;
14915 } else if (_usedElements.isCatchStackTrace(element)) { 14928 } else if (_usedElements.isCatchStackTrace(element)) {
14916 errorCode = HintCode.UNUSED_CATCH_STACK; 14929 errorCode = HintCode.UNUSED_CATCH_STACK;
14917 } else { 14930 } else {
14918 errorCode = HintCode.UNUSED_LOCAL_VARIABLE; 14931 errorCode = HintCode.UNUSED_LOCAL_VARIABLE;
14919 } 14932 }
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
15405 nonFields.add(node); 15418 nonFields.add(node);
15406 return null; 15419 return null;
15407 } 15420 }
15408 15421
15409 @override 15422 @override
15410 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); 15423 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this);
15411 15424
15412 @override 15425 @override
15413 Object visitWithClause(WithClause node) => null; 15426 Object visitWithClause(WithClause node) => null;
15414 } 15427 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698