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

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

Issue 2353433002: Use configurations and declared variables to select import/export URIs during prelinking. (Closed)
Patch Set: Cache selected URI. Created 4 years, 3 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 /** 5 /**
6 * This library is capable of producing linked summaries from unlinked 6 * This library is capable of producing linked summaries from unlinked
7 * ones (or prelinked ones). It functions by building a miniature 7 * ones (or prelinked ones). It functions by building a miniature
8 * element model to represent the contents of the summaries, and then 8 * element model to represent the contents of the summaries, and then
9 * scanning the element model to gather linked information and adding 9 * scanning the element model to gather linked information and adding
10 * it to the summary data structures. 10 * it to the summary data structures.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 * 93 *
94 * The [strong] flag controls whether type inference is performed in strong 94 * The [strong] flag controls whether type inference is performed in strong
95 * mode or spec mode. Note that in spec mode, the only types that are inferred 95 * mode or spec mode. Note that in spec mode, the only types that are inferred
96 * are the types of initializing formals, which are inferred from the types of 96 * are the types of initializing formals, which are inferred from the types of
97 * the corresponding fields. 97 * the corresponding fields.
98 * 98 *
99 * A map is returned whose keys are the URIs of the libraries in this 99 * A map is returned whose keys are the URIs of the libraries in this
100 * build unit, and whose values are the corresponding 100 * build unit, and whose values are the corresponding
101 * [LinkedLibraryBuilder]s. 101 * [LinkedLibraryBuilder]s.
102 */ 102 */
103 Map<String, LinkedLibraryBuilder> link(Set<String> libraryUris, 103 Map<String, LinkedLibraryBuilder> link(
104 GetDependencyCallback getDependency, GetUnitCallback getUnit, bool strong) { 104 Set<String> libraryUris,
105 GetDependencyCallback getDependency,
106 GetUnitCallback getUnit,
107 GetDeclaredVariable getDeclaredVariable,
108 bool strong) {
105 Map<String, LinkedLibraryBuilder> linkedLibraries = 109 Map<String, LinkedLibraryBuilder> linkedLibraries =
106 setupForLink(libraryUris, getUnit); 110 setupForLink(libraryUris, getUnit, getDeclaredVariable);
107 relink(linkedLibraries, getDependency, getUnit, strong); 111 relink(linkedLibraries, getDependency, getUnit, strong);
108 return linkedLibraries; 112 return linkedLibraries;
109 } 113 }
110 114
111 /** 115 /**
112 * Given [libraries] (a map from URI to [LinkedLibraryBuilder] 116 * Given [libraries] (a map from URI to [LinkedLibraryBuilder]
113 * containing correct prelinked information), rebuild linked 117 * containing correct prelinked information), rebuild linked
114 * information, using [getDependency] to fetch the [LinkedLibrary] 118 * information, using [getDependency] to fetch the [LinkedLibrary]
115 * objects from other build units, and [getUnit] to fetch the 119 * objects from other build units, and [getUnit] to fetch the
116 * [UnlinkedUnit] objects from both this build unit and other build 120 * [UnlinkedUnit] objects from both this build unit and other build
(...skipping 11 matching lines...) Expand all
128 132
129 /** 133 /**
130 * Prepare to link together the build unit consisting of [libraryUris], using 134 * Prepare to link together the build unit consisting of [libraryUris], using
131 * [getUnit] to fetch the [UnlinkedUnit] objects from both this build unit and 135 * [getUnit] to fetch the [UnlinkedUnit] objects from both this build unit and
132 * other build units. 136 * other build units.
133 * 137 *
134 * The libraries are prelinked, and a map is returned whose keys are the URIs of 138 * The libraries are prelinked, and a map is returned whose keys are the URIs of
135 * the libraries in this build unit, and whose values are the corresponding 139 * the libraries in this build unit, and whose values are the corresponding
136 * [LinkedLibraryBuilder]s. 140 * [LinkedLibraryBuilder]s.
137 */ 141 */
138 Map<String, LinkedLibraryBuilder> setupForLink( 142 Map<String, LinkedLibraryBuilder> setupForLink(Set<String> libraryUris,
139 Set<String> libraryUris, GetUnitCallback getUnit) { 143 GetUnitCallback getUnit, GetDeclaredVariable getDeclaredVariable) {
140 Map<String, LinkedLibraryBuilder> linkedLibraries = 144 Map<String, LinkedLibraryBuilder> linkedLibraries =
141 <String, LinkedLibraryBuilder>{}; 145 <String, LinkedLibraryBuilder>{};
142 for (String absoluteUri in libraryUris) { 146 for (String absoluteUri in libraryUris) {
143 Uri uri = Uri.parse(absoluteUri); 147 Uri uri = Uri.parse(absoluteUri);
144 UnlinkedUnit getRelativeUnit(String relativeUri) => 148 UnlinkedUnit getRelativeUnit(String relativeUri) =>
145 getUnit(resolveRelativeUri(uri, Uri.parse(relativeUri)).toString()); 149 getUnit(resolveRelativeUri(uri, Uri.parse(relativeUri)).toString());
146 linkedLibraries[absoluteUri] = prelink( 150 linkedLibraries[absoluteUri] = prelink(
147 getUnit(absoluteUri), 151 getUnit(absoluteUri),
148 getRelativeUnit, 152 getRelativeUnit,
149 (String relativeUri) => getRelativeUnit(relativeUri)?.publicNamespace); 153 (String relativeUri) => getRelativeUnit(relativeUri)?.publicNamespace,
154 getDeclaredVariable);
150 } 155 }
151 return linkedLibraries; 156 return linkedLibraries;
152 } 157 }
153 158
154 /** 159 /**
155 * Create an [EntityRefBuilder] representing the given [type], in a form 160 * Create an [EntityRefBuilder] representing the given [type], in a form
156 * suitable for inclusion in [LinkedUnit.types]. [compilationUnit] is the 161 * suitable for inclusion in [LinkedUnit.types]. [compilationUnit] is the
157 * compilation unit in which the type will be used. If [slot] is provided, it 162 * compilation unit in which the type will be used. If [slot] is provided, it
158 * is stored in [EntityRefBuilder.slot]. 163 * is stored in [EntityRefBuilder.slot].
159 */ 164 */
(...skipping 4810 matching lines...) Expand 10 before | Expand all | Expand 10 after
4970 * there are no type parameters in scope. 4975 * there are no type parameters in scope.
4971 */ 4976 */
4972 TypeParameterizedElementMixin get _typeParameterContext; 4977 TypeParameterizedElementMixin get _typeParameterContext;
4973 4978
4974 @override 4979 @override
4975 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 4980 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
4976 4981
4977 @override 4982 @override
4978 String toString() => '$enclosingElement.$name'; 4983 String toString() => '$enclosingElement.$name';
4979 } 4984 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | pkg/analyzer/lib/src/summary/prelink.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698