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

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

Issue 1933763002: Use null-aware operators to clean up the code (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Additional clean-up 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
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.element_resolver; 5 library analyzer.src.generated.element_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 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 if (constructor != null) { 792 if (constructor != null) {
793 _recordUndefinedNode( 793 _recordUndefinedNode(
794 typeReference, 794 typeReference,
795 StaticTypeWarningCode.UNDEFINED_METHOD_WITH_CONSTRUCTOR, 795 StaticTypeWarningCode.UNDEFINED_METHOD_WITH_CONSTRUCTOR,
796 methodName, 796 methodName,
797 [methodName.name, typeReference.name]); 797 [methodName.name, typeReference.name]);
798 return null; 798 return null;
799 } 799 }
800 } 800 }
801 } 801 }
802 targetTypeName = targetType == null ? null : targetType.displayName; 802 targetTypeName = targetType?.displayName;
803 ErrorCode proxyErrorCode = (generatedWithTypePropagation 803 ErrorCode proxyErrorCode = (generatedWithTypePropagation
804 ? HintCode.UNDEFINED_METHOD 804 ? HintCode.UNDEFINED_METHOD
805 : StaticTypeWarningCode.UNDEFINED_METHOD); 805 : StaticTypeWarningCode.UNDEFINED_METHOD);
806 _recordUndefinedNode(targetType.element, proxyErrorCode, methodName, 806 _recordUndefinedNode(targetType.element, proxyErrorCode, methodName,
807 [methodName.name, targetTypeName]); 807 [methodName.name, targetTypeName]);
808 } 808 }
809 } else if (identical( 809 } else if (identical(
810 errorCode, StaticTypeWarningCode.UNDEFINED_SUPER_METHOD)) { 810 errorCode, StaticTypeWarningCode.UNDEFINED_SUPER_METHOD)) {
811 // Generate the type name. 811 // Generate the type name.
812 // The error code will never be generated via type propagation 812 // The error code will never be generated via type propagation
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 if (enclosingClass == null) { 1137 if (enclosingClass == null) {
1138 // TODO(brianwilkerson) Report this error. 1138 // TODO(brianwilkerson) Report this error.
1139 return null; 1139 return null;
1140 } 1140 }
1141 InterfaceType superType = enclosingClass.supertype; 1141 InterfaceType superType = enclosingClass.supertype;
1142 if (superType == null) { 1142 if (superType == null) {
1143 // TODO(brianwilkerson) Report this error. 1143 // TODO(brianwilkerson) Report this error.
1144 return null; 1144 return null;
1145 } 1145 }
1146 SimpleIdentifier name = node.constructorName; 1146 SimpleIdentifier name = node.constructorName;
1147 String superName = name != null ? name.name : null; 1147 String superName = name?.name;
1148 ConstructorElement element = 1148 ConstructorElement element =
1149 superType.lookUpConstructor(superName, _definingLibrary); 1149 superType.lookUpConstructor(superName, _definingLibrary);
1150 if (element == null || 1150 if (element == null ||
1151 (!enclosingClass.doesMixinLackConstructors && 1151 (!enclosingClass.doesMixinLackConstructors &&
1152 !enclosingClass.isSuperConstructorAccessible(element))) { 1152 !enclosingClass.isSuperConstructorAccessible(element))) {
1153 if (name != null) { 1153 if (name != null) {
1154 _resolver.errorReporter.reportErrorForNode( 1154 _resolver.errorReporter.reportErrorForNode(
1155 CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER, 1155 CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER,
1156 node, 1156 node,
1157 [superType.displayName, name]); 1157 [superType.displayName, name]);
(...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after
2291 _enableHints && 2291 _enableHints &&
2292 _shouldReportMissingMember(propagatedType, propagatedElement) && 2292 _shouldReportMissingMember(propagatedType, propagatedElement) &&
2293 !_memberFoundInSubclass( 2293 !_memberFoundInSubclass(
2294 propagatedType.element, propertyName.name, false, true); 2294 propagatedType.element, propertyName.name, false, true);
2295 if (shouldReportMissingMember_static || 2295 if (shouldReportMissingMember_static ||
2296 shouldReportMissingMember_propagated) { 2296 shouldReportMissingMember_propagated) {
2297 DartType staticOrPropagatedType = 2297 DartType staticOrPropagatedType =
2298 shouldReportMissingMember_static ? staticType : propagatedType; 2298 shouldReportMissingMember_static ? staticType : propagatedType;
2299 Element staticOrPropagatedEnclosingElt = staticOrPropagatedType.element; 2299 Element staticOrPropagatedEnclosingElt = staticOrPropagatedType.element;
2300 bool isStaticProperty = _isStatic(staticOrPropagatedEnclosingElt); 2300 bool isStaticProperty = _isStatic(staticOrPropagatedEnclosingElt);
2301 DartType displayType = staticOrPropagatedType != null 2301 DartType displayType =
2302 ? staticOrPropagatedType 2302 staticOrPropagatedType ?? propagatedType ?? staticType;
2303 : propagatedType != null ? propagatedType : staticType;
2304 // Special getter cases. 2303 // Special getter cases.
2305 if (propertyName.inGetterContext()) { 2304 if (propertyName.inGetterContext()) {
2306 if (!isStaticProperty && 2305 if (!isStaticProperty &&
2307 staticOrPropagatedEnclosingElt is ClassElement) { 2306 staticOrPropagatedEnclosingElt is ClassElement) {
2308 InterfaceType targetType = staticOrPropagatedEnclosingElt.type; 2307 InterfaceType targetType = staticOrPropagatedEnclosingElt.type;
2309 if (!_enableStrictCallChecks && 2308 if (!_enableStrictCallChecks &&
2310 targetType != null && 2309 targetType != null &&
2311 targetType.isDartCoreFunction && 2310 targetType.isDartCoreFunction &&
2312 propertyName.name == FunctionElement.CALL_METHOD_NAME) { 2311 propertyName.name == FunctionElement.CALL_METHOD_NAME) {
2313 // TODO(brianwilkerson) Can we ever resolve the function being 2312 // TODO(brianwilkerson) Can we ever resolve the function being
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
2588 2587
2589 @override 2588 @override
2590 Element get staticElement => null; 2589 Element get staticElement => null;
2591 2590
2592 @override 2591 @override
2593 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) => null; 2592 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) => null;
2594 2593
2595 @override 2594 @override
2596 void visitChildren(AstVisitor visitor) {} 2595 void visitChildren(AstVisitor visitor) {}
2597 } 2596 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/constant.dart ('k') | pkg/analyzer/lib/src/generated/engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698