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

Side by Side Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 2353433002: Use configurations and declared variables to select import/export URIs during prelinking. (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/link.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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.src.dart.element.element; 5 library analyzer.src.dart.element.element;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:math' show min; 8 import 'dart:math' show min;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 4017 matching lines...) Expand 10 before | Expand all | Expand 10 after
4028 4028
4029 void set combinators(List<NamespaceCombinator> combinators) { 4029 void set combinators(List<NamespaceCombinator> combinators) {
4030 assert(_unlinkedExportPublic == null); 4030 assert(_unlinkedExportPublic == null);
4031 _combinators = combinators; 4031 _combinators = combinators;
4032 } 4032 }
4033 4033
4034 @override 4034 @override
4035 LibraryElement get exportedLibrary { 4035 LibraryElement get exportedLibrary {
4036 if (_unlinkedExportNonPublic != null && _exportedLibrary == null) { 4036 if (_unlinkedExportNonPublic != null && _exportedLibrary == null) {
4037 LibraryElementImpl library = enclosingElement as LibraryElementImpl; 4037 LibraryElementImpl library = enclosingElement as LibraryElementImpl;
4038 _exportedLibrary = library.resynthesizerContext 4038 _exportedLibrary = library.resynthesizerContext.buildExportedLibrary(uri);
4039 .buildExportedLibrary(_unlinkedExportPublic.uri);
4040 } 4039 }
4041 return _exportedLibrary; 4040 return _exportedLibrary;
4042 } 4041 }
4043 4042
4044 void set exportedLibrary(LibraryElement exportedLibrary) { 4043 void set exportedLibrary(LibraryElement exportedLibrary) {
4045 assert(_unlinkedExportNonPublic == null); 4044 assert(_unlinkedExportNonPublic == null);
4046 _exportedLibrary = exportedLibrary; 4045 _exportedLibrary = exportedLibrary;
4047 } 4046 }
4048 4047
4049 @override 4048 @override
(...skipping 21 matching lines...) Expand all
4071 int get nameOffset { 4070 int get nameOffset {
4072 if (_unlinkedExportNonPublic != null) { 4071 if (_unlinkedExportNonPublic != null) {
4073 return _unlinkedExportNonPublic.offset; 4072 return _unlinkedExportNonPublic.offset;
4074 } 4073 }
4075 return super.nameOffset; 4074 return super.nameOffset;
4076 } 4075 }
4077 4076
4078 @override 4077 @override
4079 String get uri { 4078 String get uri {
4080 if (_unlinkedExportPublic != null) { 4079 if (_unlinkedExportPublic != null) {
4081 return _unlinkedExportPublic.uri; 4080 return _selectUri(
Paul Berry 2016/09/18 13:46:49 For efficiency we should cache this result in a lo
scheglov 2016/09/18 21:03:48 Done.
4081 _unlinkedExportPublic.uri, _unlinkedExportPublic.configurations);
4082 } 4082 }
4083 return super.uri; 4083 return super.uri;
4084 } 4084 }
4085 4085
4086 @override 4086 @override
4087 void set uri(String uri) { 4087 void set uri(String uri) {
4088 assert(_unlinkedExportPublic == null); 4088 assert(_unlinkedExportPublic == null);
4089 super.uri = uri; 4089 super.uri = uri;
4090 } 4090 }
4091 4091
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
4999 assert(_unlinkedImport == null); 4999 assert(_unlinkedImport == null);
5000 _prefixOffset = prefixOffset; 5000 _prefixOffset = prefixOffset;
5001 } 5001 }
5002 5002
5003 @override 5003 @override
5004 String get uri { 5004 String get uri {
5005 if (_unlinkedImport != null) { 5005 if (_unlinkedImport != null) {
5006 if (_unlinkedImport.isImplicit) { 5006 if (_unlinkedImport.isImplicit) {
5007 return null; 5007 return null;
5008 } 5008 }
5009 return _unlinkedImport.uri; 5009 return _selectUri(_unlinkedImport.uri, _unlinkedImport.configurations);
Paul Berry 2016/09/18 13:46:49 Same here.
scheglov 2016/09/18 21:03:48 Done.
5010 } 5010 }
5011 return super.uri; 5011 return super.uri;
5012 } 5012 }
5013 5013
5014 @override 5014 @override
5015 void set uri(String uri) { 5015 void set uri(String uri) {
5016 assert(_unlinkedImport == null); 5016 assert(_unlinkedImport == null);
5017 super.uri = uri; 5017 super.uri = uri;
5018 } 5018 }
5019 5019
(...skipping 3175 matching lines...) Expand 10 before | Expand all | Expand 10 after
8195 * Return the offset of the URI in the file, or `-1` if this node is synthetic . 8195 * Return the offset of the URI in the file, or `-1` if this node is synthetic .
8196 */ 8196 */
8197 int get uriOffset => _uriOffset; 8197 int get uriOffset => _uriOffset;
8198 8198
8199 /** 8199 /**
8200 * Set the offset of the URI in the file to the given [offset]. 8200 * Set the offset of the URI in the file to the given [offset].
8201 */ 8201 */
8202 void set uriOffset(int offset) { 8202 void set uriOffset(int offset) {
8203 _uriOffset = offset; 8203 _uriOffset = offset;
8204 } 8204 }
8205
8206 String _selectUri(
8207 String defaultUri, List<UnlinkedConfiguration> configurations) {
8208 for (UnlinkedConfiguration configuration in configurations) {
8209 if (context.declaredVariables.get(configuration.name) ==
8210 configuration.value) {
8211 return configuration.uri;
8212 }
8213 }
8214 return defaultUri;
8215 }
8205 } 8216 }
8206 8217
8207 /** 8218 /**
8208 * A concrete implementation of a [VariableElement]. 8219 * A concrete implementation of a [VariableElement].
8209 */ 8220 */
8210 abstract class VariableElementImpl extends ElementImpl 8221 abstract class VariableElementImpl extends ElementImpl
8211 implements VariableElement { 8222 implements VariableElement {
8212 /** 8223 /**
8213 * The declared type of this variable. 8224 * The declared type of this variable.
8214 */ 8225 */
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
8364 8375
8365 @override 8376 @override
8366 void visitElement(Element element) { 8377 void visitElement(Element element) {
8367 int offset = element.nameOffset; 8378 int offset = element.nameOffset;
8368 if (offset != -1) { 8379 if (offset != -1) {
8369 map[offset] = element; 8380 map[offset] = element;
8370 } 8381 }
8371 super.visitElement(element); 8382 super.visitElement(element);
8372 } 8383 }
8373 } 8384 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/link.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698