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

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

Issue 1922563003: @deprecated should work on 'called' objects (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/dart.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 analyzer.src.generated.resolver; 5 library analyzer.src.generated.resolver;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 * to have a bare "return;" in an async method. 70 * to have a bare "return;" in an async method.
71 */ 71 */
72 final InterfaceType _futureNullType; 72 final InterfaceType _futureNullType;
73 73
74 /** 74 /**
75 * The type system primitives 75 * The type system primitives
76 */ 76 */
77 TypeSystem _typeSystem; 77 TypeSystem _typeSystem;
78 78
79 /** 79 /**
80 * The current library
81 */
82 LibraryElement _currentLibrary;
83
84 /**
80 * Create a new instance of the [BestPracticesVerifier]. 85 * Create a new instance of the [BestPracticesVerifier].
81 * 86 *
82 * @param errorReporter the error reporter 87 * @param errorReporter the error reporter
83 */ 88 */
84 BestPracticesVerifier(this._errorReporter, TypeProvider typeProvider, 89 BestPracticesVerifier(
90 this._errorReporter, TypeProvider typeProvider, this._currentLibrary,
85 {TypeSystem typeSystem}) 91 {TypeSystem typeSystem})
86 : _futureNullType = typeProvider.futureNullType, 92 : _futureNullType = typeProvider.futureNullType,
87 _typeSystem = (typeSystem != null) ? typeSystem : new TypeSystemImpl(); 93 _typeSystem = (typeSystem != null) ? typeSystem : new TypeSystemImpl();
88 94
89 @override 95 @override
90 Object visitArgumentList(ArgumentList node) { 96 Object visitArgumentList(ArgumentList node) {
91 _checkForArgumentTypesNotAssignableInList(node); 97 _checkForArgumentTypesNotAssignableInList(node);
92 return super.visitArgumentList(node); 98 return super.visitArgumentList(node);
93 } 99 }
94 100
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 return super.visitMethodDeclaration(node); 238 return super.visitMethodDeclaration(node);
233 } finally { 239 } finally {
234 inDeprecatedMember = wasInDeprecatedMember; 240 inDeprecatedMember = wasInDeprecatedMember;
235 } 241 }
236 } 242 }
237 243
238 @override 244 @override
239 Object visitMethodInvocation(MethodInvocation node) { 245 Object visitMethodInvocation(MethodInvocation node) {
240 _checkForCanBeNullAfterNullAware(node.realTarget, node.operator); 246 _checkForCanBeNullAfterNullAware(node.realTarget, node.operator);
241 _checkForInvalidProtectedMethodCalls(node); 247 _checkForInvalidProtectedMethodCalls(node);
248 DartType staticInvokeType = node.staticInvokeType;
249 if (staticInvokeType is InterfaceType) {
250 MethodElement methodElement = staticInvokeType.lookUpMethod(
251 FunctionElement.CALL_METHOD_NAME, _currentLibrary);
scheglov 2016/04/26 15:54:19 I'm concerned that we perform method lookup multip
srawlins 2016/04/26 18:55:59 Maybe... element_resolver.dart is where INVOCATION
scheglov 2016/04/27 16:12:19 Yes, that's where I thought we could put the check
srawlins 2016/04/27 19:53:49 Acknowledged.
252 _checkForDeprecatedMemberUse(methodElement, node);
253 }
242 return super.visitMethodInvocation(node); 254 return super.visitMethodInvocation(node);
243 } 255 }
244 256
245 @override 257 @override
246 Object visitPostfixExpression(PostfixExpression node) { 258 Object visitPostfixExpression(PostfixExpression node) {
247 _checkForDeprecatedMemberUse(node.bestElement, node); 259 _checkForDeprecatedMemberUse(node.bestElement, node);
248 return super.visitPostfixExpression(node); 260 return super.visitPostfixExpression(node);
249 } 261 }
250 262
251 @override 263 @override
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 String displayName = element.displayName; 544 String displayName = element.displayName;
533 if (element is ConstructorElement) { 545 if (element is ConstructorElement) {
534 // TODO(jwren) We should modify ConstructorElement.getDisplayName(), 546 // TODO(jwren) We should modify ConstructorElement.getDisplayName(),
535 // or have the logic centralized elsewhere, instead of doing this logic 547 // or have the logic centralized elsewhere, instead of doing this logic
536 // here. 548 // here.
537 ConstructorElement constructorElement = element; 549 ConstructorElement constructorElement = element;
538 displayName = constructorElement.enclosingElement.displayName; 550 displayName = constructorElement.enclosingElement.displayName;
539 if (!constructorElement.displayName.isEmpty) { 551 if (!constructorElement.displayName.isEmpty) {
540 displayName = "$displayName.${constructorElement.displayName}"; 552 displayName = "$displayName.${constructorElement.displayName}";
541 } 553 }
554 } else if (element.displayName == FunctionElement.CALL_METHOD_NAME &&
Brian Wilkerson 2016/04/26 15:25:28 "element.displayName" --> "displayName"
srawlins 2016/04/27 19:53:49 Done.
555 node is MethodInvocation &&
556 node.staticInvokeType is InterfaceType) {
557 displayName = "${node.staticInvokeType.displayName}.${element.displayNam e}";
542 } 558 }
543 _errorReporter.reportErrorForNode( 559 _errorReporter.reportErrorForNode(
544 HintCode.DEPRECATED_MEMBER_USE, node, [displayName]); 560 HintCode.DEPRECATED_MEMBER_USE, node, [displayName]);
545 } 561 }
546 } 562 }
547 563
548 /** 564 /**
549 * For [SimpleIdentifier]s, only call [checkForDeprecatedMemberUse] 565 * For [SimpleIdentifier]s, only call [checkForDeprecatedMemberUse]
550 * if the node is not in a declaration context. 566 * if the node is not in a declaration context.
551 * 567 *
(...skipping 3691 matching lines...) Expand 10 before | Expand all | Expand 10 after
4243 unit.accept(_usedImportedElementsVisitor); 4259 unit.accept(_usedImportedElementsVisitor);
4244 // dead code analysis 4260 // dead code analysis
4245 unit.accept( 4261 unit.accept(
4246 new DeadCodeVerifier(errorReporter, typeSystem: _context.typeSystem)); 4262 new DeadCodeVerifier(errorReporter, typeSystem: _context.typeSystem));
4247 unit.accept(_usedLocalElementsVisitor); 4263 unit.accept(_usedLocalElementsVisitor);
4248 // dart2js analysis 4264 // dart2js analysis
4249 if (_enableDart2JSHints) { 4265 if (_enableDart2JSHints) {
4250 unit.accept(new Dart2JSVerifier(errorReporter)); 4266 unit.accept(new Dart2JSVerifier(errorReporter));
4251 } 4267 }
4252 // Dart best practices 4268 // Dart best practices
4253 unit.accept(new BestPracticesVerifier(errorReporter, _context.typeProvider, 4269 unit.accept(new BestPracticesVerifier(
4270 errorReporter, _context.typeProvider, _library,
4254 typeSystem: _context.typeSystem)); 4271 typeSystem: _context.typeSystem));
4255 unit.accept(new OverrideVerifier(errorReporter, _manager)); 4272 unit.accept(new OverrideVerifier(errorReporter, _manager));
4256 // Find to-do comments 4273 // Find to-do comments
4257 new ToDoFinder(errorReporter).findIn(unit); 4274 new ToDoFinder(errorReporter).findIn(unit);
4258 // pub analysis 4275 // pub analysis
4259 // TODO(danrubel/jwren) Commented out until bugs in the pub verifier are 4276 // TODO(danrubel/jwren) Commented out until bugs in the pub verifier are
4260 // fixed 4277 // fixed
4261 // unit.accept(new PubVerifier(context, errorReporter)); 4278 // unit.accept(new PubVerifier(context, errorReporter));
4262 } 4279 }
4263 } 4280 }
(...skipping 6512 matching lines...) Expand 10 before | Expand all | Expand 10 after
10776 return null; 10793 return null;
10777 } 10794 }
10778 if (identical(node.staticElement, variable)) { 10795 if (identical(node.staticElement, variable)) {
10779 if (node.inSetterContext()) { 10796 if (node.inSetterContext()) {
10780 result = true; 10797 result = true;
10781 } 10798 }
10782 } 10799 }
10783 return null; 10800 return null;
10784 } 10801 }
10785 } 10802 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/dart.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698