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

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

Issue 1624853002: Store the result of type inference 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) 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 analyzer.test.src.summary.summarize_elements_test; 5 library analyzer.test.src.summary.summarize_elements_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/engine.dart'; 8 import 'package:analyzer/src/generated/engine.dart';
9 import 'package:analyzer/src/generated/source.dart'; 9 import 'package:analyzer/src/generated/source.dart';
10 import 'package:analyzer/src/generated/source_io.dart'; 10 import 'package:analyzer/src/generated/source_io.dart';
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 /** 56 /**
57 * Determine the analysis options that should be used for this test. 57 * Determine the analysis options that should be used for this test.
58 */ 58 */
59 AnalysisOptionsImpl get options => 59 AnalysisOptionsImpl get options =>
60 new AnalysisOptionsImpl()..enableGenericMethods = true; 60 new AnalysisOptionsImpl()..enableGenericMethods = true;
61 61
62 @override 62 @override
63 bool get skipFullyLinkedData => false; 63 bool get skipFullyLinkedData => false;
64 64
65 @override 65 @override
66 bool get strongMode => false;
67
68 @override
66 Source addNamedSource(String filePath, String contents) { 69 Source addNamedSource(String filePath, String contents) {
67 Source source = super.addNamedSource(filePath, contents); 70 Source source = super.addNamedSource(filePath, contents);
68 _fileContents[source] = contents; 71 _fileContents[source] = contents;
69 return source; 72 return source;
70 } 73 }
71 74
72 /** 75 /**
73 * Serialize the library containing the given class [element], then 76 * Serialize the library containing the given class [element], then
74 * deserialize it and return the summary of the class. 77 * deserialize it and return the summary of the class.
75 */ 78 */
76 UnlinkedClass serializeClassElement(ClassElement element) { 79 UnlinkedClass serializeClassElement(ClassElement element) {
77 serializeLibraryElement(element.library); 80 serializeLibraryElement(element.library);
78 return findClass(element.name, failIfAbsent: true); 81 return findClass(element.name, failIfAbsent: true);
79 } 82 }
80 83
81 /** 84 /**
82 * Serialize the given [library] element, then deserialize it and store the 85 * Serialize the given [library] element, then deserialize it and store the
83 * resulting summary in [linked] and [unlinkedUnits]. 86 * resulting summary in [linked] and [unlinkedUnits].
84 */ 87 */
85 void serializeLibraryElement(LibraryElement library) { 88 void serializeLibraryElement(LibraryElement library) {
86 summarize_elements.LibrarySerializationResult serializedLib = 89 summarize_elements.LibrarySerializationResult serializedLib =
87 summarize_elements.serializeLibrary(library, typeProvider); 90 summarize_elements.serializeLibrary(
91 library, typeProvider, analysisContext.analysisOptions.strongMode);
88 { 92 {
89 List<int> buffer = serializedLib.linked.toBuffer(); 93 List<int> buffer = serializedLib.linked.toBuffer();
90 linked = new LinkedLibrary.fromBuffer(buffer); 94 linked = new LinkedLibrary.fromBuffer(buffer);
91 } 95 }
92 unlinkedUnits = serializedLib.unlinkedUnits.map((UnlinkedUnitBuilder b) { 96 unlinkedUnits = serializedLib.unlinkedUnits.map((UnlinkedUnitBuilder b) {
93 List<int> buffer = b.toBuffer(); 97 List<int> buffer = b.toBuffer();
94 return new UnlinkedUnit.fromBuffer(buffer); 98 return new UnlinkedUnit.fromBuffer(buffer);
95 }).toList(); 99 }).toList();
96 unitUris = serializedLib.unitUris; 100 unitUris = serializedLib.unitUris;
97 } 101 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } else { 146 } else {
143 UnlinkedPublicNamespace namespace = 147 UnlinkedPublicNamespace namespace =
144 computePublicNamespaceFromText(text, source); 148 computePublicNamespaceFromText(text, source);
145 expect(canonicalize(namespace), 149 expect(canonicalize(namespace),
146 canonicalize(unlinkedUnits[i].publicNamespace), 150 canonicalize(unlinkedUnits[i].publicNamespace),
147 reason: 'publicNamespace(${unitUris[i]})'); 151 reason: 'publicNamespace(${unitUris[i]})');
148 } 152 }
149 } 153 }
150 } 154 }
151 } 155 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698