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

Side by Side Diff: pkg/analyzer/lib/src/summary/resynthesize.dart

Issue 1625543002: Use the explicit string 'void' to refer to void in summaries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 summary_resynthesizer; 5 library summary_resynthesizer;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/dart/element/type.dart'; 10 import 'package:analyzer/dart/element/type.dart';
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 int oldTypeParametersLength = currentTypeParameters.length; 561 int oldTypeParametersLength = currentTypeParameters.length;
562 if (serializedExecutable.typeParameters.isNotEmpty) { 562 if (serializedExecutable.typeParameters.isNotEmpty) {
563 executableElement.typeParameters = 563 executableElement.typeParameters =
564 serializedExecutable.typeParameters.map(buildTypeParameter).toList(); 564 serializedExecutable.typeParameters.map(buildTypeParameter).toList();
565 currentTypeParameters.addAll(executableElement.typeParameters); 565 currentTypeParameters.addAll(executableElement.typeParameters);
566 } 566 }
567 executableElement.parameters = 567 executableElement.parameters =
568 serializedExecutable.parameters.map(buildParameter).toList(); 568 serializedExecutable.parameters.map(buildParameter).toList();
569 if (serializedExecutable.returnType != null) { 569 if (serializedExecutable.returnType != null) {
570 executableElement.returnType = buildType(serializedExecutable.returnType); 570 executableElement.returnType = buildType(serializedExecutable.returnType);
571 } else if (serializedExecutable.kind ==
572 UnlinkedExecutableKind.constructor) {
573 // Return type was set by the caller.
574 } else { 571 } else {
575 executableElement.returnType = VoidTypeImpl.instance; 572 // Null return type should only be used for constructors. Caller will
573 // handle setting the return type.
574 assert(serializedExecutable.kind == UnlinkedExecutableKind.constructor);
576 } 575 }
577 executableElement.type = new FunctionTypeImpl.elementWithNameAndArgs( 576 executableElement.type = new FunctionTypeImpl.elementWithNameAndArgs(
578 executableElement, null, oldTypeArguments, false); 577 executableElement, null, oldTypeArguments, false);
579 executableElement.hasImplicitReturnType = 578 executableElement.hasImplicitReturnType =
580 serializedExecutable.hasImplicitReturnType; 579 serializedExecutable.hasImplicitReturnType;
581 executableElement.external = serializedExecutable.isExternal; 580 executableElement.external = serializedExecutable.isExternal;
582 currentTypeParameters.removeRange( 581 currentTypeParameters.removeRange(
583 oldTypeParametersLength, currentTypeParameters.length); 582 oldTypeParametersLength, currentTypeParameters.length);
584 buildDocumentation( 583 buildDocumentation(
585 executableElement, serializedExecutable.documentationComment); 584 executableElement, serializedExecutable.documentationComment);
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 serializedParameter.name, serializedParameter.nameOffset); 896 serializedParameter.name, serializedParameter.nameOffset);
898 } 897 }
899 if (serializedParameter.isFunctionTyped) { 898 if (serializedParameter.isFunctionTyped) {
900 FunctionElementImpl parameterTypeElement = 899 FunctionElementImpl parameterTypeElement =
901 new FunctionElementImpl('', -1); 900 new FunctionElementImpl('', -1);
902 parameterTypeElement.synthetic = true; 901 parameterTypeElement.synthetic = true;
903 parameterElement.parameters = 902 parameterElement.parameters =
904 serializedParameter.parameters.map(buildParameter).toList(); 903 serializedParameter.parameters.map(buildParameter).toList();
905 parameterTypeElement.enclosingElement = parameterElement; 904 parameterTypeElement.enclosingElement = parameterElement;
906 parameterTypeElement.shareParameters(parameterElement.parameters); 905 parameterTypeElement.shareParameters(parameterElement.parameters);
907 if (serializedParameter.type != null) { 906 parameterTypeElement.returnType = buildType(serializedParameter.type);
908 parameterTypeElement.returnType = buildType(serializedParameter.type);
909 } else {
910 parameterTypeElement.returnType = VoidTypeImpl.instance;
911 }
912 parameterElement.type = new FunctionTypeImpl.elementWithNameAndArgs( 907 parameterElement.type = new FunctionTypeImpl.elementWithNameAndArgs(
913 parameterTypeElement, null, currentTypeArguments, false); 908 parameterTypeElement, null, currentTypeArguments, false);
914 } else { 909 } else {
915 if (serializedParameter.isInitializingFormal && 910 if (serializedParameter.isInitializingFormal &&
916 serializedParameter.hasImplicitType) { 911 serializedParameter.hasImplicitType) {
917 // The type is inherited from the matching field. 912 // The type is inherited from the matching field.
918 parameterElement.type = fields[serializedParameter.name]?.type ?? 913 parameterElement.type = fields[serializedParameter.name]?.type ??
919 summaryResynthesizer.typeProvider.dynamicType; 914 summaryResynthesizer.typeProvider.dynamicType;
920 } else { 915 } else {
921 parameterElement.type = buildType(serializedParameter.type); 916 parameterElement.type = buildType(serializedParameter.type);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 ElementLocationImpl location; 977 ElementLocationImpl location;
983 if (referenceResolution.dependency != 0) { 978 if (referenceResolution.dependency != 0) {
984 location = getReferencedLocation( 979 location = getReferencedLocation(
985 linkedLibrary.dependencies[referenceResolution.dependency], 980 linkedLibrary.dependencies[referenceResolution.dependency],
986 referenceResolution.unit, 981 referenceResolution.unit,
987 name); 982 name);
988 } else if (referenceResolution.kind == ReferenceKind.unresolved) { 983 } else if (referenceResolution.kind == ReferenceKind.unresolved) {
989 return summaryResynthesizer.typeProvider.undefinedType; 984 return summaryResynthesizer.typeProvider.undefinedType;
990 } else if (name == 'dynamic') { 985 } else if (name == 'dynamic') {
991 return summaryResynthesizer.typeProvider.dynamicType; 986 return summaryResynthesizer.typeProvider.dynamicType;
987 } else if (name == 'void') {
988 return VoidTypeImpl.instance;
992 } else { 989 } else {
993 String referencedLibraryUri = librarySource.uri.toString(); 990 String referencedLibraryUri = librarySource.uri.toString();
994 String partUri; 991 String partUri;
995 if (referenceResolution.unit != 0) { 992 if (referenceResolution.unit != 0) {
996 String uri = unlinkedUnits[0].publicNamespace.parts[ 993 String uri = unlinkedUnits[0].publicNamespace.parts[
997 referenceResolution.unit - 1]; 994 referenceResolution.unit - 1];
998 Source partSource = 995 Source partSource =
999 summaryResynthesizer.sourceFactory.resolveUri(librarySource, uri); 996 summaryResynthesizer.sourceFactory.resolveUri(librarySource, uri);
1000 partUri = partSource.uri.toString(); 997 partUri = partSource.uri.toString();
1001 } else { 998 } else {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 serializedTypedef.typeParameters.map(buildTypeParameter).toList(); 1043 serializedTypedef.typeParameters.map(buildTypeParameter).toList();
1047 for (int i = 0; i < serializedTypedef.typeParameters.length; i++) { 1044 for (int i = 0; i < serializedTypedef.typeParameters.length; i++) {
1048 finishTypeParameter( 1045 finishTypeParameter(
1049 serializedTypedef.typeParameters[i], currentTypeParameters[i]); 1046 serializedTypedef.typeParameters[i], currentTypeParameters[i]);
1050 } 1047 }
1051 FunctionTypeAliasElementImpl functionTypeAliasElement = 1048 FunctionTypeAliasElementImpl functionTypeAliasElement =
1052 new FunctionTypeAliasElementImpl( 1049 new FunctionTypeAliasElementImpl(
1053 serializedTypedef.name, serializedTypedef.nameOffset); 1050 serializedTypedef.name, serializedTypedef.nameOffset);
1054 functionTypeAliasElement.parameters = 1051 functionTypeAliasElement.parameters =
1055 serializedTypedef.parameters.map(buildParameter).toList(); 1052 serializedTypedef.parameters.map(buildParameter).toList();
1056 if (serializedTypedef.returnType != null) { 1053 functionTypeAliasElement.returnType =
1057 functionTypeAliasElement.returnType = 1054 buildType(serializedTypedef.returnType);
1058 buildType(serializedTypedef.returnType);
1059 } else {
1060 functionTypeAliasElement.returnType = VoidTypeImpl.instance;
1061 }
1062 functionTypeAliasElement.type = 1055 functionTypeAliasElement.type =
1063 new FunctionTypeImpl.forTypedef(functionTypeAliasElement); 1056 new FunctionTypeImpl.forTypedef(functionTypeAliasElement);
1064 functionTypeAliasElement.typeParameters = currentTypeParameters; 1057 functionTypeAliasElement.typeParameters = currentTypeParameters;
1065 buildDocumentation( 1058 buildDocumentation(
1066 functionTypeAliasElement, serializedTypedef.documentationComment); 1059 functionTypeAliasElement, serializedTypedef.documentationComment);
1067 unitHolder.addTypeAlias(functionTypeAliasElement); 1060 unitHolder.addTypeAlias(functionTypeAliasElement);
1068 } finally { 1061 } finally {
1069 currentTypeParameters = <TypeParameterElement>[]; 1062 currentTypeParameters = <TypeParameterElement>[];
1070 } 1063 }
1071 } 1064 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 for (PropertyAccessorElementImpl accessor in unit.accessors) { 1200 for (PropertyAccessorElementImpl accessor in unit.accessors) {
1208 elementMap[accessor.identifier] = accessor; 1201 elementMap[accessor.identifier] = accessor;
1209 } 1202 }
1210 resummarizedElements[absoluteUri] = elementMap; 1203 resummarizedElements[absoluteUri] = elementMap;
1211 unitHolder = null; 1204 unitHolder = null;
1212 linkedUnit = null; 1205 linkedUnit = null;
1213 unlinkedUnit = null; 1206 unlinkedUnit = null;
1214 linkedTypeMap = null; 1207 linkedTypeMap = null;
1215 } 1208 }
1216 } 1209 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/prelink.dart ('k') | pkg/analyzer/lib/src/summary/summarize_ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698