OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 serialization.summarize_ast; | 5 library serialization.summarize_ast; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
9 import 'package:analyzer/dart/ast/visitor.dart'; | 9 import 'package:analyzer/dart/ast/visitor.dart'; |
10 import 'package:analyzer/src/generated/utilities_dart.dart'; | 10 import 'package:analyzer/src/generated/utilities_dart.dart'; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 'Unexpected identifier type: ${identifier.runtimeType}'); | 86 'Unexpected identifier type: ${identifier.runtimeType}'); |
87 } | 87 } |
88 return b; | 88 return b; |
89 } | 89 } |
90 | 90 |
91 @override | 91 @override |
92 EntityRefBuilder serializePropertyAccess(PropertyAccess access) { | 92 EntityRefBuilder serializePropertyAccess(PropertyAccess access) { |
93 Expression target = access.target; | 93 Expression target = access.target; |
94 if (target is Identifier) { | 94 if (target is Identifier) { |
95 EntityRefBuilder targetRef = serializeIdentifier(target); | 95 EntityRefBuilder targetRef = serializeIdentifier(target); |
96 return new EntityRefBuilder( | 96 return new EntityRefBuilder(reference: visitor.serializeReference( |
97 reference: visitor.serializeReference( | 97 targetRef.reference, access.propertyName.name)); |
98 targetRef.reference, access.propertyName.name)); | |
99 } else { | 98 } else { |
100 // TODO(scheglov) should we handle other targets in malformed constants? | 99 // TODO(scheglov) should we handle other targets in malformed constants? |
101 throw new StateError('Unexpected target type: ${target.runtimeType}'); | 100 throw new StateError('Unexpected target type: ${target.runtimeType}'); |
102 } | 101 } |
103 } | 102 } |
104 | 103 |
105 @override | 104 @override |
106 EntityRefBuilder serializeType(TypeName node) { | 105 EntityRefBuilder serializeType(TypeName node) { |
107 return visitor.serializeTypeName(node); | 106 return visitor.serializeTypeName(node); |
108 } | 107 } |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 serializer.serializeAnnotation(a); | 341 serializer.serializeAnnotation(a); |
343 return serializer.toBuilder(); | 342 return serializer.toBuilder(); |
344 }).toList(); | 343 }).toList(); |
345 } | 344 } |
346 | 345 |
347 /** | 346 /** |
348 * Serialize a [ClassDeclaration] or [ClassTypeAlias] into an [UnlinkedClass] | 347 * Serialize a [ClassDeclaration] or [ClassTypeAlias] into an [UnlinkedClass] |
349 * and store the result in [classes]. | 348 * and store the result in [classes]. |
350 */ | 349 */ |
351 void serializeClass( | 350 void serializeClass( |
| 351 AstNode node, |
352 Token abstractKeyword, | 352 Token abstractKeyword, |
353 String name, | 353 String name, |
354 int nameOffset, | 354 int nameOffset, |
355 TypeParameterList typeParameters, | 355 TypeParameterList typeParameters, |
356 TypeName superclass, | 356 TypeName superclass, |
357 WithClause withClause, | 357 WithClause withClause, |
358 ImplementsClause implementsClause, | 358 ImplementsClause implementsClause, |
359 NodeList<ClassMember> members, | 359 NodeList<ClassMember> members, |
360 bool isMixinApplication, | 360 bool isMixinApplication, |
361 Comment documentationComment, | 361 Comment documentationComment, |
(...skipping 26 matching lines...) Expand all Loading... |
388 for (ClassMember member in members) { | 388 for (ClassMember member in members) { |
389 member.accept(this); | 389 member.accept(this); |
390 } | 390 } |
391 scopes.removeLast(); | 391 scopes.removeLast(); |
392 } | 392 } |
393 b.executables = executables; | 393 b.executables = executables; |
394 b.fields = variables; | 394 b.fields = variables; |
395 b.isAbstract = abstractKeyword != null; | 395 b.isAbstract = abstractKeyword != null; |
396 b.documentationComment = serializeDocumentation(documentationComment); | 396 b.documentationComment = serializeDocumentation(documentationComment); |
397 b.annotations = serializeAnnotations(annotations); | 397 b.annotations = serializeAnnotations(annotations); |
| 398 b.codeRange = serializeCodeRange(node); |
398 classes.add(b); | 399 classes.add(b); |
399 scopes.removeLast(); | 400 scopes.removeLast(); |
400 assert(scopes.length == oldScopesLength); | 401 assert(scopes.length == oldScopesLength); |
401 executables = oldExecutables; | 402 executables = oldExecutables; |
402 variables = oldVariables; | 403 variables = oldVariables; |
403 } | 404 } |
404 | 405 |
405 /** | 406 /** |
| 407 * Create a [CodeRangeBuilder] for the given [node]. |
| 408 */ |
| 409 CodeRangeBuilder serializeCodeRange(AstNode node) { |
| 410 return new CodeRangeBuilder(offset: node.offset, length: node.length); |
| 411 } |
| 412 |
| 413 /** |
406 * Serialize a [Combinator] into an [UnlinkedCombinator]. | 414 * Serialize a [Combinator] into an [UnlinkedCombinator]. |
407 */ | 415 */ |
408 UnlinkedCombinatorBuilder serializeCombinator(Combinator combinator) { | 416 UnlinkedCombinatorBuilder serializeCombinator(Combinator combinator) { |
409 UnlinkedCombinatorBuilder b = new UnlinkedCombinatorBuilder(); | 417 UnlinkedCombinatorBuilder b = new UnlinkedCombinatorBuilder(); |
410 if (combinator is ShowCombinator) { | 418 if (combinator is ShowCombinator) { |
411 b.shows = | 419 b.shows = |
412 combinator.shownNames.map((SimpleIdentifier id) => id.name).toList(); | 420 combinator.shownNames.map((SimpleIdentifier id) => id.name).toList(); |
413 b.offset = combinator.offset; | 421 b.offset = combinator.offset; |
414 b.end = combinator.end; | 422 b.end = combinator.end; |
415 } else if (combinator is HideCombinator) { | 423 } else if (combinator is HideCombinator) { |
(...skipping 15 matching lines...) Expand all Loading... |
431 if (!hasCoreBeenImported) { | 439 if (!hasCoreBeenImported) { |
432 unlinkedImports.add(new UnlinkedImportBuilder(isImplicit: true)); | 440 unlinkedImports.add(new UnlinkedImportBuilder(isImplicit: true)); |
433 } | 441 } |
434 compilationUnit.declarations.accept(this); | 442 compilationUnit.declarations.accept(this); |
435 UnlinkedUnitBuilder b = new UnlinkedUnitBuilder(); | 443 UnlinkedUnitBuilder b = new UnlinkedUnitBuilder(); |
436 b.libraryName = libraryName; | 444 b.libraryName = libraryName; |
437 b.libraryNameOffset = libraryNameOffset; | 445 b.libraryNameOffset = libraryNameOffset; |
438 b.libraryNameLength = libraryNameLength; | 446 b.libraryNameLength = libraryNameLength; |
439 b.libraryDocumentationComment = libraryDocumentationComment; | 447 b.libraryDocumentationComment = libraryDocumentationComment; |
440 b.libraryAnnotations = libraryAnnotations; | 448 b.libraryAnnotations = libraryAnnotations; |
| 449 b.codeRange = serializeCodeRange(compilationUnit); |
441 b.classes = classes; | 450 b.classes = classes; |
442 b.enums = enums; | 451 b.enums = enums; |
443 b.executables = executables; | 452 b.executables = executables; |
444 b.exports = exports; | 453 b.exports = exports; |
445 b.imports = unlinkedImports; | 454 b.imports = unlinkedImports; |
446 b.parts = parts; | 455 b.parts = parts; |
447 b.references = unlinkedReferences; | 456 b.references = unlinkedReferences; |
448 b.typedefs = typedefs; | 457 b.typedefs = typedefs; |
449 b.variables = variables; | 458 b.variables = variables; |
450 b.publicNamespace = computePublicNamespace(compilationUnit); | 459 b.publicNamespace = computePublicNamespace(compilationUnit); |
(...skipping 27 matching lines...) Expand all Loading... |
478 text: text, | 487 text: text, |
479 offset: documentationComment.offset, | 488 offset: documentationComment.offset, |
480 length: documentationComment.length); | 489 length: documentationComment.length); |
481 } | 490 } |
482 | 491 |
483 /** | 492 /** |
484 * Serialize a [FunctionDeclaration] or [MethodDeclaration] into an | 493 * Serialize a [FunctionDeclaration] or [MethodDeclaration] into an |
485 * [UnlinkedExecutable]. | 494 * [UnlinkedExecutable]. |
486 */ | 495 */ |
487 UnlinkedExecutableBuilder serializeExecutable( | 496 UnlinkedExecutableBuilder serializeExecutable( |
| 497 AstNode node, |
488 String name, | 498 String name, |
489 int nameOffset, | 499 int nameOffset, |
490 bool isGetter, | 500 bool isGetter, |
491 bool isSetter, | 501 bool isSetter, |
492 TypeName returnType, | 502 TypeName returnType, |
493 FormalParameterList formalParameters, | 503 FormalParameterList formalParameters, |
494 FunctionBody body, | 504 FunctionBody body, |
495 bool isTopLevel, | 505 bool isTopLevel, |
496 bool isDeclaredStatic, | 506 bool isDeclaredStatic, |
497 Comment documentationComment, | 507 Comment documentationComment, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 for (int i = 0; i < formalParameters.parameters.length; i++) { | 540 for (int i = 0; i < formalParameters.parameters.length; i++) { |
531 if (!b.parameters[i].isFunctionTyped && | 541 if (!b.parameters[i].isFunctionTyped && |
532 b.parameters[i].type == null) { | 542 b.parameters[i].type == null) { |
533 b.parameters[i].inferredTypeSlot = assignSlot(); | 543 b.parameters[i].inferredTypeSlot = assignSlot(); |
534 } | 544 } |
535 } | 545 } |
536 } | 546 } |
537 } | 547 } |
538 b.documentationComment = serializeDocumentation(documentationComment); | 548 b.documentationComment = serializeDocumentation(documentationComment); |
539 b.annotations = serializeAnnotations(annotations); | 549 b.annotations = serializeAnnotations(annotations); |
| 550 b.codeRange = serializeCodeRange(node); |
540 if (returnType == null && !isSemanticallyStatic) { | 551 if (returnType == null && !isSemanticallyStatic) { |
541 b.inferredReturnTypeSlot = assignSlot(); | 552 b.inferredReturnTypeSlot = assignSlot(); |
542 } | 553 } |
543 b.visibleOffset = enclosingBlock?.offset; | 554 b.visibleOffset = enclosingBlock?.offset; |
544 b.visibleLength = enclosingBlock?.length; | 555 b.visibleLength = enclosingBlock?.length; |
545 serializeFunctionBody(b, body); | 556 serializeFunctionBody(b, body); |
546 scopes.removeLast(); | 557 scopes.removeLast(); |
547 assert(scopes.length == oldScopesLength); | 558 assert(scopes.length == oldScopesLength); |
548 return b; | 559 return b; |
549 } | 560 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 | 619 |
609 /** | 620 /** |
610 * Serialize a [FieldFormalParameter], [FunctionTypedFormalParameter], or | 621 * Serialize a [FieldFormalParameter], [FunctionTypedFormalParameter], or |
611 * [SimpleFormalParameter] into an [UnlinkedParam]. | 622 * [SimpleFormalParameter] into an [UnlinkedParam]. |
612 */ | 623 */ |
613 UnlinkedParamBuilder serializeParameter(NormalFormalParameter node) { | 624 UnlinkedParamBuilder serializeParameter(NormalFormalParameter node) { |
614 UnlinkedParamBuilder b = new UnlinkedParamBuilder(); | 625 UnlinkedParamBuilder b = new UnlinkedParamBuilder(); |
615 b.name = node.identifier.name; | 626 b.name = node.identifier.name; |
616 b.nameOffset = node.identifier.offset; | 627 b.nameOffset = node.identifier.offset; |
617 b.annotations = serializeAnnotations(node.metadata); | 628 b.annotations = serializeAnnotations(node.metadata); |
| 629 b.codeRange = serializeCodeRange(node); |
618 switch (node.kind) { | 630 switch (node.kind) { |
619 case ParameterKind.REQUIRED: | 631 case ParameterKind.REQUIRED: |
620 b.kind = UnlinkedParamKind.required; | 632 b.kind = UnlinkedParamKind.required; |
621 break; | 633 break; |
622 case ParameterKind.POSITIONAL: | 634 case ParameterKind.POSITIONAL: |
623 b.kind = UnlinkedParamKind.positional; | 635 b.kind = UnlinkedParamKind.positional; |
624 break; | 636 break; |
625 case ParameterKind.NAMED: | 637 case ParameterKind.NAMED: |
626 b.kind = UnlinkedParamKind.named; | 638 b.kind = UnlinkedParamKind.named; |
627 break; | 639 break; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 for (VariableDeclaration variable in variables.variables) { | 777 for (VariableDeclaration variable in variables.variables) { |
766 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder(); | 778 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder(); |
767 b.isFinal = variables.isFinal; | 779 b.isFinal = variables.isFinal; |
768 b.isConst = variables.isConst; | 780 b.isConst = variables.isConst; |
769 b.isStatic = isDeclaredStatic; | 781 b.isStatic = isDeclaredStatic; |
770 b.name = variable.name.name; | 782 b.name = variable.name.name; |
771 b.nameOffset = variable.name.offset; | 783 b.nameOffset = variable.name.offset; |
772 b.type = serializeTypeName(variables.type); | 784 b.type = serializeTypeName(variables.type); |
773 b.documentationComment = serializeDocumentation(documentationComment); | 785 b.documentationComment = serializeDocumentation(documentationComment); |
774 b.annotations = serializeAnnotations(annotations); | 786 b.annotations = serializeAnnotations(annotations); |
| 787 b.codeRange = serializeCodeRange(variables.parent); |
775 if (variable.isConst || | 788 if (variable.isConst || |
776 variable.isFinal && isField && !isDeclaredStatic) { | 789 variable.isFinal && isField && !isDeclaredStatic) { |
777 Expression initializer = variable.initializer; | 790 Expression initializer = variable.initializer; |
778 if (initializer != null) { | 791 if (initializer != null) { |
779 b.constExpr = serializeConstExpr(initializer); | 792 b.constExpr = serializeConstExpr(initializer); |
780 } | 793 } |
781 } | 794 } |
782 if (variable.initializer != null && | 795 if (variable.initializer != null && |
783 (variables.isFinal || variables.isConst)) { | 796 (variables.isFinal || variables.isConst)) { |
784 b.propagatedTypeSlot = assignSlot(); | 797 b.propagatedTypeSlot = assignSlot(); |
(...skipping 16 matching lines...) Expand all Loading... |
801 enclosingBlock = node; | 814 enclosingBlock = node; |
802 super.visitBlock(node); | 815 super.visitBlock(node); |
803 enclosingBlock = oldBlock; | 816 enclosingBlock = oldBlock; |
804 } | 817 } |
805 | 818 |
806 @override | 819 @override |
807 void visitClassDeclaration(ClassDeclaration node) { | 820 void visitClassDeclaration(ClassDeclaration node) { |
808 TypeName superclass = | 821 TypeName superclass = |
809 node.extendsClause == null ? null : node.extendsClause.superclass; | 822 node.extendsClause == null ? null : node.extendsClause.superclass; |
810 serializeClass( | 823 serializeClass( |
| 824 node, |
811 node.abstractKeyword, | 825 node.abstractKeyword, |
812 node.name.name, | 826 node.name.name, |
813 node.name.offset, | 827 node.name.offset, |
814 node.typeParameters, | 828 node.typeParameters, |
815 superclass, | 829 superclass, |
816 node.withClause, | 830 node.withClause, |
817 node.implementsClause, | 831 node.implementsClause, |
818 node.members, | 832 node.members, |
819 false, | 833 false, |
820 node.documentationComment, | 834 node.documentationComment, |
821 node.metadata); | 835 node.metadata); |
822 } | 836 } |
823 | 837 |
824 @override | 838 @override |
825 void visitClassTypeAlias(ClassTypeAlias node) { | 839 void visitClassTypeAlias(ClassTypeAlias node) { |
826 serializeClass( | 840 serializeClass( |
| 841 node, |
827 node.abstractKeyword, | 842 node.abstractKeyword, |
828 node.name.name, | 843 node.name.name, |
829 node.name.offset, | 844 node.name.offset, |
830 node.typeParameters, | 845 node.typeParameters, |
831 node.superclass, | 846 node.superclass, |
832 node.withClause, | 847 node.withClause, |
833 node.implementsClause, | 848 node.implementsClause, |
834 null, | 849 null, |
835 true, | 850 true, |
836 node.documentationComment, | 851 node.documentationComment, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 b.nameOffset = node.name.offset; | 923 b.nameOffset = node.name.offset; |
909 b.values = node.constants | 924 b.values = node.constants |
910 .map((EnumConstantDeclaration value) => new UnlinkedEnumValueBuilder( | 925 .map((EnumConstantDeclaration value) => new UnlinkedEnumValueBuilder( |
911 documentationComment: | 926 documentationComment: |
912 serializeDocumentation(value.documentationComment), | 927 serializeDocumentation(value.documentationComment), |
913 name: value.name.name, | 928 name: value.name.name, |
914 nameOffset: value.name.offset)) | 929 nameOffset: value.name.offset)) |
915 .toList(); | 930 .toList(); |
916 b.documentationComment = serializeDocumentation(node.documentationComment); | 931 b.documentationComment = serializeDocumentation(node.documentationComment); |
917 b.annotations = serializeAnnotations(node.metadata); | 932 b.annotations = serializeAnnotations(node.metadata); |
| 933 b.codeRange = serializeCodeRange(node); |
918 enums.add(b); | 934 enums.add(b); |
919 } | 935 } |
920 | 936 |
921 @override | 937 @override |
922 void visitExportDirective(ExportDirective node) { | 938 void visitExportDirective(ExportDirective node) { |
923 UnlinkedExportNonPublicBuilder b = new UnlinkedExportNonPublicBuilder( | 939 UnlinkedExportNonPublicBuilder b = new UnlinkedExportNonPublicBuilder( |
924 uriOffset: node.uri.offset, uriEnd: node.uri.end, offset: node.offset); | 940 uriOffset: node.uri.offset, uriEnd: node.uri.end, offset: node.offset); |
925 b.annotations = serializeAnnotations(node.metadata); | 941 b.annotations = serializeAnnotations(node.metadata); |
926 exports.add(b); | 942 exports.add(b); |
927 } | 943 } |
(...skipping 15 matching lines...) Expand all Loading... |
943 } else { | 959 } else { |
944 b.type = serializeTypeName(node.type); | 960 b.type = serializeTypeName(node.type); |
945 } | 961 } |
946 } | 962 } |
947 return b; | 963 return b; |
948 } | 964 } |
949 | 965 |
950 @override | 966 @override |
951 void visitFunctionDeclaration(FunctionDeclaration node) { | 967 void visitFunctionDeclaration(FunctionDeclaration node) { |
952 executables.add(serializeExecutable( | 968 executables.add(serializeExecutable( |
| 969 node, |
953 node.name.name, | 970 node.name.name, |
954 node.name.offset, | 971 node.name.offset, |
955 node.isGetter, | 972 node.isGetter, |
956 node.isSetter, | 973 node.isSetter, |
957 node.returnType, | 974 node.returnType, |
958 node.functionExpression.parameters, | 975 node.functionExpression.parameters, |
959 node.functionExpression.body, | 976 node.functionExpression.body, |
960 true, | 977 true, |
961 false, | 978 false, |
962 node.documentationComment, | 979 node.documentationComment, |
963 node.metadata, | 980 node.metadata, |
964 node.functionExpression.typeParameters, | 981 node.functionExpression.typeParameters, |
965 node.externalKeyword != null)); | 982 node.externalKeyword != null)); |
966 } | 983 } |
967 | 984 |
968 @override | 985 @override |
969 void visitFunctionExpression(FunctionExpression node) { | 986 void visitFunctionExpression(FunctionExpression node) { |
970 if (node.parent is! FunctionDeclaration) { | 987 if (node.parent is! FunctionDeclaration) { |
971 executables.add(serializeExecutable( | 988 executables.add(serializeExecutable( |
| 989 node, |
972 null, | 990 null, |
973 node.offset, | 991 node.offset, |
974 false, | 992 false, |
975 false, | 993 false, |
976 null, | 994 null, |
977 node.parameters, | 995 node.parameters, |
978 node.body, | 996 node.body, |
979 false, | 997 false, |
980 false, | 998 false, |
981 null, | 999 null, |
(...skipping 15 matching lines...) Expand all Loading... |
997 serializeTypeParameters(node.typeParameters, typeParameterScope); | 1015 serializeTypeParameters(node.typeParameters, typeParameterScope); |
998 EntityRefBuilder serializedReturnType = serializeTypeName(node.returnType); | 1016 EntityRefBuilder serializedReturnType = serializeTypeName(node.returnType); |
999 if (serializedReturnType != null) { | 1017 if (serializedReturnType != null) { |
1000 b.returnType = serializedReturnType; | 1018 b.returnType = serializedReturnType; |
1001 } | 1019 } |
1002 b.parameters = node.parameters.parameters | 1020 b.parameters = node.parameters.parameters |
1003 .map((FormalParameter p) => p.accept(this)) | 1021 .map((FormalParameter p) => p.accept(this)) |
1004 .toList(); | 1022 .toList(); |
1005 b.documentationComment = serializeDocumentation(node.documentationComment); | 1023 b.documentationComment = serializeDocumentation(node.documentationComment); |
1006 b.annotations = serializeAnnotations(node.metadata); | 1024 b.annotations = serializeAnnotations(node.metadata); |
| 1025 b.codeRange = serializeCodeRange(node); |
1007 typedefs.add(b); | 1026 typedefs.add(b); |
1008 scopes.removeLast(); | 1027 scopes.removeLast(); |
1009 assert(scopes.length == oldScopesLength); | 1028 assert(scopes.length == oldScopesLength); |
1010 } | 1029 } |
1011 | 1030 |
1012 @override | 1031 @override |
1013 UnlinkedParamBuilder visitFunctionTypedFormalParameter( | 1032 UnlinkedParamBuilder visitFunctionTypedFormalParameter( |
1014 FunctionTypedFormalParameter node) { | 1033 FunctionTypedFormalParameter node) { |
1015 UnlinkedParamBuilder b = serializeParameter(node); | 1034 UnlinkedParamBuilder b = serializeParameter(node); |
1016 b.isFunctionTyped = true; | 1035 b.isFunctionTyped = true; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 libraryNameOffset = node.name.offset; | 1075 libraryNameOffset = node.name.offset; |
1057 libraryNameLength = node.name.length; | 1076 libraryNameLength = node.name.length; |
1058 libraryDocumentationComment = | 1077 libraryDocumentationComment = |
1059 serializeDocumentation(node.documentationComment); | 1078 serializeDocumentation(node.documentationComment); |
1060 libraryAnnotations = serializeAnnotations(node.metadata); | 1079 libraryAnnotations = serializeAnnotations(node.metadata); |
1061 } | 1080 } |
1062 | 1081 |
1063 @override | 1082 @override |
1064 void visitMethodDeclaration(MethodDeclaration node) { | 1083 void visitMethodDeclaration(MethodDeclaration node) { |
1065 executables.add(serializeExecutable( | 1084 executables.add(serializeExecutable( |
| 1085 node, |
1066 node.name.name, | 1086 node.name.name, |
1067 node.name.offset, | 1087 node.name.offset, |
1068 node.isGetter, | 1088 node.isGetter, |
1069 node.isSetter, | 1089 node.isSetter, |
1070 node.returnType, | 1090 node.returnType, |
1071 node.parameters, | 1091 node.parameters, |
1072 node.body, | 1092 node.body, |
1073 false, | 1093 false, |
1074 node.isStatic, | 1094 node.isStatic, |
1075 node.documentationComment, | 1095 node.documentationComment, |
(...skipping 28 matching lines...) Expand all Loading... |
1104 | 1124 |
1105 @override | 1125 @override |
1106 UnlinkedTypeParamBuilder visitTypeParameter(TypeParameter node) { | 1126 UnlinkedTypeParamBuilder visitTypeParameter(TypeParameter node) { |
1107 UnlinkedTypeParamBuilder b = new UnlinkedTypeParamBuilder(); | 1127 UnlinkedTypeParamBuilder b = new UnlinkedTypeParamBuilder(); |
1108 b.name = node.name.name; | 1128 b.name = node.name.name; |
1109 b.nameOffset = node.name.offset; | 1129 b.nameOffset = node.name.offset; |
1110 if (node.bound != null) { | 1130 if (node.bound != null) { |
1111 b.bound = serializeTypeName(node.bound); | 1131 b.bound = serializeTypeName(node.bound); |
1112 } | 1132 } |
1113 b.annotations = serializeAnnotations(node.metadata); | 1133 b.annotations = serializeAnnotations(node.metadata); |
| 1134 b.codeRange = serializeCodeRange(node); |
1114 return b; | 1135 return b; |
1115 } | 1136 } |
1116 | 1137 |
1117 @override | 1138 @override |
1118 void visitVariableDeclarationStatement(VariableDeclarationStatement node) { | 1139 void visitVariableDeclarationStatement(VariableDeclarationStatement node) { |
1119 serializeVariables(node.variables, false, null, null, false); | 1140 serializeVariables(node.variables, false, null, null, false); |
1120 } | 1141 } |
1121 | 1142 |
1122 /** | 1143 /** |
1123 * Helper method to determine if a given [typeName] refers to `dynamic`. | 1144 * Helper method to determine if a given [typeName] refers to `dynamic`. |
1124 */ | 1145 */ |
1125 static bool isDynamic(TypeName typeName) { | 1146 static bool isDynamic(TypeName typeName) { |
1126 Identifier name = typeName.name; | 1147 Identifier name = typeName.name; |
1127 return name is SimpleIdentifier && name.name == 'dynamic'; | 1148 return name is SimpleIdentifier && name.name == 'dynamic'; |
1128 } | 1149 } |
1129 } | 1150 } |
1130 | 1151 |
1131 /** | 1152 /** |
1132 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. | 1153 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. |
1133 */ | 1154 */ |
1134 class _TypeParameterScope extends _Scope { | 1155 class _TypeParameterScope extends _Scope { |
1135 /** | 1156 /** |
1136 * Get the number of [_ScopedTypeParameter]s defined in this | 1157 * Get the number of [_ScopedTypeParameter]s defined in this |
1137 * [_TypeParameterScope]. | 1158 * [_TypeParameterScope]. |
1138 */ | 1159 */ |
1139 int get length => _definedNames.length; | 1160 int get length => _definedNames.length; |
1140 } | 1161 } |
OLD | NEW |