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

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: Addressing feedback 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);
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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 if (!inDeprecatedMember && isDeprecated(element)) { 545 if (!inDeprecatedMember && isDeprecated(element)) {
534 String displayName = element.displayName; 546 String displayName = element.displayName;
535 if (element is ConstructorElement) { 547 if (element is ConstructorElement) {
536 // TODO(jwren) We should modify ConstructorElement.getDisplayName(), 548 // TODO(jwren) We should modify ConstructorElement.getDisplayName(),
537 // or have the logic centralized elsewhere, instead of doing this logic 549 // or have the logic centralized elsewhere, instead of doing this logic
538 // here. 550 // here.
539 displayName = element.enclosingElement.displayName; 551 displayName = element.enclosingElement.displayName;
540 if (!element.displayName.isEmpty) { 552 if (!element.displayName.isEmpty) {
541 displayName = "$displayName.${element.displayName}"; 553 displayName = "$displayName.${element.displayName}";
542 } 554 }
555 } else if (displayName == FunctionElement.CALL_METHOD_NAME &&
556 node is MethodInvocation &&
557 node.staticInvokeType is InterfaceType) {
558 displayName = "${node.staticInvokeType.displayName}.${element.displayNam e}";
543 } 559 }
544 _errorReporter.reportErrorForNode( 560 _errorReporter.reportErrorForNode(
545 HintCode.DEPRECATED_MEMBER_USE, node, [displayName]); 561 HintCode.DEPRECATED_MEMBER_USE, node, [displayName]);
546 } 562 }
547 } 563 }
548 564
549 /** 565 /**
550 * For [SimpleIdentifier]s, only call [checkForDeprecatedMemberUse] 566 * For [SimpleIdentifier]s, only call [checkForDeprecatedMemberUse]
551 * if the node is not in a declaration context. 567 * if the node is not in a declaration context.
552 * 568 *
(...skipping 3662 matching lines...) Expand 10 before | Expand all | Expand 10 after
4215 unit.accept(_usedImportedElementsVisitor); 4231 unit.accept(_usedImportedElementsVisitor);
4216 // dead code analysis 4232 // dead code analysis
4217 unit.accept( 4233 unit.accept(
4218 new DeadCodeVerifier(errorReporter, typeSystem: _context.typeSystem)); 4234 new DeadCodeVerifier(errorReporter, typeSystem: _context.typeSystem));
4219 unit.accept(_usedLocalElementsVisitor); 4235 unit.accept(_usedLocalElementsVisitor);
4220 // dart2js analysis 4236 // dart2js analysis
4221 if (_enableDart2JSHints) { 4237 if (_enableDart2JSHints) {
4222 unit.accept(new Dart2JSVerifier(errorReporter)); 4238 unit.accept(new Dart2JSVerifier(errorReporter));
4223 } 4239 }
4224 // Dart best practices 4240 // Dart best practices
4225 unit.accept(new BestPracticesVerifier(errorReporter, _context.typeProvider, 4241 unit.accept(new BestPracticesVerifier(
4242 errorReporter, _context.typeProvider, _library,
4226 typeSystem: _context.typeSystem)); 4243 typeSystem: _context.typeSystem));
4227 unit.accept(new OverrideVerifier(errorReporter, _manager)); 4244 unit.accept(new OverrideVerifier(errorReporter, _manager));
4228 // Find to-do comments 4245 // Find to-do comments
4229 new ToDoFinder(errorReporter).findIn(unit); 4246 new ToDoFinder(errorReporter).findIn(unit);
4230 // pub analysis 4247 // pub analysis
4231 // TODO(danrubel/jwren) Commented out until bugs in the pub verifier are 4248 // TODO(danrubel/jwren) Commented out until bugs in the pub verifier are
4232 // fixed 4249 // fixed
4233 // unit.accept(new PubVerifier(context, errorReporter)); 4250 // unit.accept(new PubVerifier(context, errorReporter));
4234 } 4251 }
4235 } 4252 }
(...skipping 6575 matching lines...) Expand 10 before | Expand all | Expand 10 after
10811 return null; 10828 return null;
10812 } 10829 }
10813 if (identical(node.staticElement, variable)) { 10830 if (identical(node.staticElement, variable)) {
10814 if (node.inSetterContext()) { 10831 if (node.inSetterContext()) {
10815 result = true; 10832 result = true;
10816 } 10833 }
10817 } 10834 }
10818 return null; 10835 return null;
10819 } 10836 }
10820 } 10837 }
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