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

Side by Side Diff: pkg/analyzer/test/src/summary/summary_test.dart

Issue 1576663002: Use FlatBuffers for summaries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove IsSet flags and restore toMap() generation. 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
« no previous file with comments | « pkg/analyzer/lib/src/summary/format.dart ('k') | pkg/analyzer/tool/summary/generate.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) 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 analyzer.test.src.summary.summary_test; 5 library analyzer.test.src.summary.summary_test;
6 6
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/src/generated/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/error.dart'; 10 import 'package:analyzer/src/generated/error.dart';
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 91 }
92 92
93 /** 93 /**
94 * Serialize the given [library] element, then deserialize it and store the 94 * Serialize the given [library] element, then deserialize it and store the
95 * resulting summary in [prelinked] and [unlinkedUnits]. 95 * resulting summary in [prelinked] and [unlinkedUnits].
96 */ 96 */
97 void serializeLibraryElement(LibraryElement library) { 97 void serializeLibraryElement(LibraryElement library) {
98 summarize_elements.LibrarySerializationResult serializedLib = 98 summarize_elements.LibrarySerializationResult serializedLib =
99 summarize_elements.serializeLibrary( 99 summarize_elements.serializeLibrary(
100 builderContext, library, typeProvider); 100 builderContext, library, typeProvider);
101 prelinked = 101 {
102 new PrelinkedLibrary.fromBuffer(serializedLib.prelinked.toBuffer()); 102 List<int> buffer = serializedLib.prelinked.toBuffer();
103 unlinkedUnits = serializedLib.unlinkedUnits 103 prelinked = new PrelinkedLibrary.fromBuffer(buffer);
104 .map((UnlinkedUnitBuilder b) => 104 }
105 new UnlinkedUnit.fromBuffer(b.toBuffer())) 105 unlinkedUnits = serializedLib.unlinkedUnits.map((UnlinkedUnitBuilder b) {
106 .toList(); 106 List<int> buffer = b.toBuffer();
107 return new UnlinkedUnit.fromBuffer(buffer);
108 }).toList();
107 unitUris = serializedLib.unitUris; 109 unitUris = serializedLib.unitUris;
108 } 110 }
109 111
110 @override 112 @override
111 void serializeLibraryText(String text, {bool allowErrors: false}) { 113 void serializeLibraryText(String text, {bool allowErrors: false}) {
112 Source source = addSource(text); 114 Source source = addSource(text);
113 LibraryElement library = resolve2(source); 115 LibraryElement library = resolve2(source);
114 if (!allowErrors) { 116 if (!allowErrors) {
115 assertNoErrors(source); 117 assertNoErrors(source);
116 } 118 }
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 593
592 /** 594 /**
593 * Serialize a type declaration using the given [text] as a type name, and 595 * Serialize a type declaration using the given [text] as a type name, and
594 * return a summary of the corresponding [UnlinkedTypeRef]. If the type 596 * return a summary of the corresponding [UnlinkedTypeRef]. If the type
595 * declaration needs to refer to types that are not available in core, those 597 * declaration needs to refer to types that are not available in core, those
596 * types may be declared in [otherDeclarations]. 598 * types may be declared in [otherDeclarations].
597 */ 599 */
598 UnlinkedTypeRef serializeTypeText(String text, 600 UnlinkedTypeRef serializeTypeText(String text,
599 {String otherDeclarations: '', bool allowErrors: false}) { 601 {String otherDeclarations: '', bool allowErrors: false}) {
600 return serializeVariableText('$otherDeclarations\n$text v;', 602 return serializeVariableText('$otherDeclarations\n$text v;',
601 allowErrors: allowErrors).type; 603 allowErrors: allowErrors)
604 .type;
602 } 605 }
603 606
604 /** 607 /**
605 * Serialize the given library [text] and return the summary of the variable 608 * Serialize the given library [text] and return the summary of the variable
606 * with the given [variableName]. 609 * with the given [variableName].
607 */ 610 */
608 UnlinkedVariable serializeVariableText(String text, 611 UnlinkedVariable serializeVariableText(String text,
609 {String variableName: 'v', bool allowErrors: false}) { 612 {String variableName: 'v', bool allowErrors: false}) {
610 serializeLibraryText(text, allowErrors: allowErrors); 613 serializeLibraryText(text, allowErrors: allowErrors);
611 return findVariable(variableName, failIfAbsent: true); 614 return findVariable(variableName, failIfAbsent: true);
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 expect(executable.isConst, false); 1620 expect(executable.isConst, false);
1618 expect(executable.isFactory, false); 1621 expect(executable.isFactory, false);
1619 expect(executable.isStatic, false); 1622 expect(executable.isStatic, false);
1620 expect(executable.parameters, hasLength(1)); 1623 expect(executable.parameters, hasLength(1));
1621 checkTypeRef(executable.returnType, 'dart:core', 'dart:core', 'bool'); 1624 checkTypeRef(executable.returnType, 'dart:core', 'dart:core', 'bool');
1622 expect(executable.typeParameters, isEmpty); 1625 expect(executable.typeParameters, isEmpty);
1623 } 1626 }
1624 1627
1625 test_executable_operator_index_set() { 1628 test_executable_operator_index_set() {
1626 UnlinkedExecutable executable = serializeClassText( 1629 UnlinkedExecutable executable = serializeClassText(
1627 'class C { void operator[]=(int i, bool v) => null; }').executables[0]; 1630 'class C { void operator[]=(int i, bool v) => null; }')
1631 .executables[0];
1628 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); 1632 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod);
1629 expect(executable.name, '[]='); 1633 expect(executable.name, '[]=');
1630 expect(executable.hasImplicitReturnType, false); 1634 expect(executable.hasImplicitReturnType, false);
1631 expect(executable.isAbstract, false); 1635 expect(executable.isAbstract, false);
1632 expect(executable.isConst, false); 1636 expect(executable.isConst, false);
1633 expect(executable.isFactory, false); 1637 expect(executable.isFactory, false);
1634 expect(executable.isStatic, false); 1638 expect(executable.isStatic, false);
1635 expect(executable.parameters, hasLength(2)); 1639 expect(executable.parameters, hasLength(2));
1636 expect(executable.returnType, isNull); 1640 expect(executable.returnType, isNull);
1637 expect(executable.typeParameters, isEmpty); 1641 expect(executable.typeParameters, isEmpty);
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
2655 UnlinkedVariable variable = 2659 UnlinkedVariable variable =
2656 serializeVariableText('int i;', variableName: 'i'); 2660 serializeVariableText('int i;', variableName: 'i');
2657 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int'); 2661 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int');
2658 } 2662 }
2659 2663
2660 test_varible_private() { 2664 test_varible_private() {
2661 serializeVariableText('int _i;', variableName: '_i'); 2665 serializeVariableText('int _i;', variableName: '_i');
2662 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); 2666 expect(unlinkedUnits[0].publicNamespace.names, isEmpty);
2663 } 2667 }
2664 } 2668 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/format.dart ('k') | pkg/analyzer/tool/summary/generate.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698