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

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

Issue 2689573002: Fix export + local when the library is also exported. (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | pkg/analyzer/test/src/summary/resynthesize_common.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) 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 import 'package:analyzer/src/generated/utilities_dart.dart'; 5 import 'package:analyzer/src/generated/utilities_dart.dart';
6 import 'package:analyzer/src/summary/format.dart'; 6 import 'package:analyzer/src/summary/format.dart';
7 import 'package:analyzer/src/summary/idl.dart'; 7 import 'package:analyzer/src/summary/idl.dart';
8 import 'package:analyzer/src/summary/name_filter.dart'; 8 import 'package:analyzer/src/summary/name_filter.dart';
9 9
10 /** 10 /**
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 292
293 /** 293 /**
294 * Compute the export namespace for the library whose URI is reachable from 294 * Compute the export namespace for the library whose URI is reachable from
295 * [definingUnit] via [relativeUri], by aggregating together public namespace 295 * [definingUnit] via [relativeUri], by aggregating together public namespace
296 * information from the library and the transitive closure of its exports. 296 * information from the library and the transitive closure of its exports.
297 * 297 *
298 * If [relativeUri] is `null` (meaning the export namespace of [definingUnit] 298 * If [relativeUri] is `null` (meaning the export namespace of [definingUnit]
299 * should be computed), then names defined in [definingUnit] are ignored. 299 * should be computed), then names defined in [definingUnit] are ignored.
300 */ 300 */
301 _Namespace computeExportNamespace(String relativeUri) { 301 _Namespace computeExportNamespace(String relativeUri) {
302 _Namespace exportNamespace = relativeUri == null 302 Set<String> seenUris = new Set<String>();
303 ? new _Namespace() 303 _Namespace chaseExports(String relativeUri, NameFilter filter) {
304 : aggregatePublicNamespace(relativeUri); 304 _Namespace exportedNamespace = relativeUri == null
305 void chaseExports( 305 ? new _Namespace()
306 NameFilter filter, String relativeUri, Set<String> seenUris) { 306 : aggregatePublicNamespace(relativeUri);
307 if (seenUris.add(relativeUri)) { 307 if (seenUris.add(relativeUri)) {
308 UnlinkedPublicNamespace exportedNamespace = 308 UnlinkedPublicNamespace publicNamespace = getImportCached(relativeUri);
309 getImportCached(relativeUri); 309 if (publicNamespace != null) {
310 if (exportedNamespace != null) { 310 for (UnlinkedExportPublic export in publicNamespace.exports) {
311 for (UnlinkedExportPublic export in exportedNamespace.exports) {
312 String relativeExportUri = 311 String relativeExportUri =
313 _selectUri(export.uri, export.configurations); 312 _selectUri(export.uri, export.configurations);
314 String exportUri = resolveUri(relativeUri, relativeExportUri); 313 String exportUri = resolveUri(relativeUri, relativeExportUri);
315 NameFilter newFilter = filter.merge( 314 NameFilter newFilter = filter.merge(
316 new NameFilter.forUnlinkedCombinators(export.combinators)); 315 new NameFilter.forUnlinkedCombinators(export.combinators));
317 aggregatePublicNamespace(exportUri) 316 _Namespace exportNamespace = chaseExports(exportUri, newFilter);
318 .forEach((String name, _Meaning meaning) { 317 exportNamespace.forEach((String name, _Meaning meaning) {
319 if (newFilter.accepts(name) && 318 if (newFilter.accepts(name) &&
320 !exportNamespace.definesLibraryName(name)) { 319 !exportedNamespace.definesLibraryName(name)) {
321 exportNamespace.add(name, meaning); 320 exportedNamespace.add(name, meaning);
322 } 321 }
323 }); 322 });
324 chaseExports(newFilter, exportUri, seenUris);
325 } 323 }
326 } 324 }
327 seenUris.remove(relativeUri); 325 seenUris.remove(relativeUri);
328 } 326 }
327 return exportedNamespace;
329 } 328 }
330 329
331 chaseExports(NameFilter.identity, relativeUri, new Set<String>()); 330 return chaseExports(relativeUri, NameFilter.identity);
332 return exportNamespace;
333 } 331 }
334 332
335 /** 333 /**
336 * Extract all the names defined in [unit] (which is the [unitNum]th unit in 334 * Extract all the names defined in [unit] (which is the [unitNum]th unit in
337 * the library being prelinked) and store them in [privateNamespace]. 335 * the library being prelinked) and store them in [privateNamespace].
338 * Excludes names introduced by `import` statements. 336 * Excludes names introduced by `import` statements.
339 */ 337 */
340 void extractPrivateNames(UnlinkedUnit unit, int unitNum) { 338 void extractPrivateNames(UnlinkedUnit unit, int unitNum) {
341 for (UnlinkedClass cls in unit.classes) { 339 for (UnlinkedClass cls in unit.classes) {
342 _Namespace namespace = new _Namespace(); 340 _Namespace namespace = new _Namespace();
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 String _selectUri( 605 String _selectUri(
608 String defaultUri, List<UnlinkedConfiguration> configurations) { 606 String defaultUri, List<UnlinkedConfiguration> configurations) {
609 for (UnlinkedConfiguration configuration in configurations) { 607 for (UnlinkedConfiguration configuration in configurations) {
610 if (getDeclaredVariable(configuration.name) == configuration.value) { 608 if (getDeclaredVariable(configuration.name) == configuration.value) {
611 return configuration.uri; 609 return configuration.uri;
612 } 610 }
613 } 611 }
614 return defaultUri; 612 return defaultUri;
615 } 613 }
616 } 614 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698