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

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

Issue 2983423003: Resynthesize import prefixes from Kernel. (Closed)
Patch Set: Created 3 years, 4 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_kernel_test.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 5747 matching lines...) Expand 10 before | Expand all | Expand 10 after
5758 if (offset == 0 && _unlinkedImport != null) { 5758 if (offset == 0 && _unlinkedImport != null) {
5759 if (_unlinkedImport.isImplicit) { 5759 if (_unlinkedImport.isImplicit) {
5760 return -1; 5760 return -1;
5761 } 5761 }
5762 return _unlinkedImport.offset; 5762 return _unlinkedImport.offset;
5763 } 5763 }
5764 return offset; 5764 return offset;
5765 } 5765 }
5766 5766
5767 PrefixElement get prefix { 5767 PrefixElement get prefix {
5768 if (_unlinkedImport != null) { 5768 if (_prefix == null) {
5769 if (_unlinkedImport.prefixReference != 0 && _prefix == null) { 5769 if (_kernel != null && _kernel.name != null) {
5770 LibraryElementImpl library = enclosingElement as LibraryElementImpl;
5771 _prefix = new PrefixElementImpl.forKernel(library, _kernel);
5772 }
5773 if (_unlinkedImport != null && _unlinkedImport.prefixReference != 0) {
5770 LibraryElementImpl library = enclosingElement as LibraryElementImpl; 5774 LibraryElementImpl library = enclosingElement as LibraryElementImpl;
5771 _prefix = new PrefixElementImpl.forSerialized(_unlinkedImport, library); 5775 _prefix = new PrefixElementImpl.forSerialized(_unlinkedImport, library);
5772 } 5776 }
5773 } 5777 }
5774 return _prefix; 5778 return _prefix;
5775 } 5779 }
5776 5780
5777 void set prefix(PrefixElement prefix) { 5781 void set prefix(PrefixElement prefix) {
5778 _assertNotResynthesized(_unlinkedImport); 5782 _assertNotResynthesized(_unlinkedImport);
5779 _prefix = prefix; 5783 _prefix = prefix;
(...skipping 2532 matching lines...) Expand 10 before | Expand all | Expand 10 after
8312 /** 8316 /**
8313 * A concrete implementation of a [PrefixElement]. 8317 * A concrete implementation of a [PrefixElement].
8314 */ 8318 */
8315 class PrefixElementImpl extends ElementImpl implements PrefixElement { 8319 class PrefixElementImpl extends ElementImpl implements PrefixElement {
8316 /** 8320 /**
8317 * The unlinked representation of the import in the summary. 8321 * The unlinked representation of the import in the summary.
8318 */ 8322 */
8319 final UnlinkedImport _unlinkedImport; 8323 final UnlinkedImport _unlinkedImport;
8320 8324
8321 /** 8325 /**
8326 * The kernel of the element.
8327 */
8328 final kernel.LibraryDependency _kernel;
8329
8330 /**
8322 * Initialize a newly created method element to have the given [name] and 8331 * Initialize a newly created method element to have the given [name] and
8323 * [nameOffset]. 8332 * [nameOffset].
8324 */ 8333 */
8325 PrefixElementImpl(String name, int nameOffset) 8334 PrefixElementImpl(String name, int nameOffset)
8326 : _unlinkedImport = null, 8335 : _unlinkedImport = null,
8336 _kernel = null,
8327 super(name, nameOffset); 8337 super(name, nameOffset);
8328 8338
8329 /** 8339 /**
8330 * Initialize a newly created prefix element to have the given [name]. 8340 * Initialize a newly created prefix element to have the given [name].
8331 */ 8341 */
8332 PrefixElementImpl.forNode(Identifier name) 8342 PrefixElementImpl.forNode(Identifier name)
8333 : _unlinkedImport = null, 8343 : _unlinkedImport = null,
8344 _kernel = null,
8334 super.forNode(name); 8345 super.forNode(name);
8335 8346
8336 /** 8347 /**
8337 * Initialize using the given serialized information. 8348 * Initialize using the given serialized information.
8338 */ 8349 */
8339 PrefixElementImpl.forSerialized( 8350 PrefixElementImpl.forSerialized(
8340 this._unlinkedImport, LibraryElementImpl enclosingLibrary) 8351 this._unlinkedImport, LibraryElementImpl enclosingLibrary)
8341 : super.forSerialized(enclosingLibrary); 8352 : _kernel = null,
8353 super.forSerialized(enclosingLibrary);
8354
8355 /**
8356 * Initialize using the given kernel.
8357 */
8358 PrefixElementImpl.forKernel(LibraryElementImpl enclosingLibrary, this._kernel)
8359 : _unlinkedImport = null,
8360 super.forSerialized(enclosingLibrary);
8342 8361
8343 @override 8362 @override
8344 String get displayName => name; 8363 String get displayName => name;
8345 8364
8346 @override 8365 @override
8347 LibraryElement get enclosingElement => 8366 LibraryElement get enclosingElement =>
8348 super.enclosingElement as LibraryElement; 8367 super.enclosingElement as LibraryElement;
8349 8368
8350 @override 8369 @override
8351 String get identifier => "_${super.identifier}"; 8370 String get identifier => "_${super.identifier}";
8352 8371
8353 @override 8372 @override
8354 List<LibraryElement> get importedLibraries => LibraryElement.EMPTY_LIST; 8373 List<LibraryElement> get importedLibraries => LibraryElement.EMPTY_LIST;
8355 8374
8356 @override 8375 @override
8357 ElementKind get kind => ElementKind.PREFIX; 8376 ElementKind get kind => ElementKind.PREFIX;
8358 8377
8359 @override 8378 @override
8360 String get name { 8379 String get name {
8380 if (_kernel != null) {
8381 return _kernel.name;
8382 }
8361 if (_unlinkedImport != null) { 8383 if (_unlinkedImport != null) {
8362 if (_name == null) { 8384 if (_name == null) {
8363 LibraryElementImpl library = enclosingElement as LibraryElementImpl; 8385 LibraryElementImpl library = enclosingElement as LibraryElementImpl;
8364 int prefixId = _unlinkedImport.prefixReference; 8386 int prefixId = _unlinkedImport.prefixReference;
8365 return _name = library._unlinkedDefiningUnit.references[prefixId].name; 8387 return _name = library._unlinkedDefiningUnit.references[prefixId].name;
8366 } 8388 }
8367 } 8389 }
8368 return super.name; 8390 return super.name;
8369 } 8391 }
8370 8392
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after
9586 9608
9587 @override 9609 @override
9588 DartObject computeConstantValue() => null; 9610 DartObject computeConstantValue() => null;
9589 9611
9590 @override 9612 @override
9591 void visitChildren(ElementVisitor visitor) { 9613 void visitChildren(ElementVisitor visitor) {
9592 super.visitChildren(visitor); 9614 super.visitChildren(visitor);
9593 _initializer?.accept(visitor); 9615 _initializer?.accept(visitor);
9594 } 9616 }
9595 } 9617 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_kernel_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698