| OLD | NEW | 
|     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 12 matching lines...) Expand all  Loading... | 
|    23 import 'package:analyzer/src/generated/java_engine.dart'; |    23 import 'package:analyzer/src/generated/java_engine.dart'; | 
|    24 import 'package:analyzer/src/generated/resolver.dart'; |    24 import 'package:analyzer/src/generated/resolver.dart'; | 
|    25 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; |    25 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; | 
|    26 import 'package:analyzer/src/generated/source.dart'; |    26 import 'package:analyzer/src/generated/source.dart'; | 
|    27 import 'package:analyzer/src/generated/testing/ast_test_factory.dart'; |    27 import 'package:analyzer/src/generated/testing/ast_test_factory.dart'; | 
|    28 import 'package:analyzer/src/generated/utilities_collection.dart'; |    28 import 'package:analyzer/src/generated/utilities_collection.dart'; | 
|    29 import 'package:analyzer/src/generated/utilities_dart.dart'; |    29 import 'package:analyzer/src/generated/utilities_dart.dart'; | 
|    30 import 'package:analyzer/src/generated/utilities_general.dart'; |    30 import 'package:analyzer/src/generated/utilities_general.dart'; | 
|    31 import 'package:analyzer/src/summary/idl.dart'; |    31 import 'package:analyzer/src/summary/idl.dart'; | 
|    32 import 'package:analyzer/src/task/dart.dart'; |    32 import 'package:analyzer/src/task/dart.dart'; | 
 |    33 import 'package:kernel/kernel.dart' as kernel; | 
|    33  |    34  | 
|    34 /** |    35 /** | 
|    35  * Assert that the given [object] is null, which in the places where this |    36  * Assert that the given [object] is null, which in the places where this | 
|    36  * function is called means that the element is not resynthesized. |    37  * function is called means that the element is not resynthesized. | 
|    37  */ |    38  */ | 
|    38 void _assertNotResynthesized(Object object) { |    39 void _assertNotResynthesized(Object object) { | 
|    39   // TODO(scheglov) I comment this check for now. |    40   // TODO(scheglov) I comment this check for now. | 
|    40   // When we make a decision about switch to the new analysis driver, |    41   // When we make a decision about switch to the new analysis driver, | 
|    41   // we will need to rework the analysis code to don't call the setters |    42   // we will need to rework the analysis code to don't call the setters | 
|    42   // or restore / inline it. |    43   // or restore / inline it. | 
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   404  * An [AbstractClassElementImpl] which is a class. |   405  * An [AbstractClassElementImpl] which is a class. | 
|   405  */ |   406  */ | 
|   406 class ClassElementImpl extends AbstractClassElementImpl |   407 class ClassElementImpl extends AbstractClassElementImpl | 
|   407     with TypeParameterizedElementMixin { |   408     with TypeParameterizedElementMixin { | 
|   408   /** |   409   /** | 
|   409    * The unlinked representation of the class in the summary. |   410    * The unlinked representation of the class in the summary. | 
|   410    */ |   411    */ | 
|   411   final UnlinkedClass _unlinkedClass; |   412   final UnlinkedClass _unlinkedClass; | 
|   412  |   413  | 
|   413   /** |   414   /** | 
 |   415    * The kernel of the element. | 
 |   416    */ | 
 |   417   final kernel.Class _kernel; | 
 |   418  | 
 |   419   /** | 
|   414    * The superclass of the class, or `null` for [Object]. |   420    * The superclass of the class, or `null` for [Object]. | 
|   415    */ |   421    */ | 
|   416   InterfaceType _supertype; |   422   InterfaceType _supertype; | 
|   417  |   423  | 
|   418   /** |   424   /** | 
|   419    * The type defined by the class. |   425    * The type defined by the class. | 
|   420    */ |   426    */ | 
|   421   InterfaceType _type; |   427   InterfaceType _type; | 
|   422  |   428  | 
|   423   /** |   429   /** | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   459    * methods might be different. |   465    * methods might be different. | 
|   460    */ |   466    */ | 
|   461   int version = 0; |   467   int version = 0; | 
|   462  |   468  | 
|   463   /** |   469   /** | 
|   464    * Initialize a newly created class element to have the given [name] at the |   470    * Initialize a newly created class element to have the given [name] at the | 
|   465    * given [offset] in the file that contains the declaration of this element. |   471    * given [offset] in the file that contains the declaration of this element. | 
|   466    */ |   472    */ | 
|   467   ClassElementImpl(String name, int offset) |   473   ClassElementImpl(String name, int offset) | 
|   468       : _unlinkedClass = null, |   474       : _unlinkedClass = null, | 
 |   475         _kernel = null, | 
|   469         super(name, offset); |   476         super(name, offset); | 
|   470  |   477  | 
|   471   /** |   478   /** | 
|   472    * Initialize a newly created class element to have the given [name]. |   479    * Initialize a newly created class element to have the given [name]. | 
|   473    */ |   480    */ | 
|   474   ClassElementImpl.forNode(Identifier name) |   481   ClassElementImpl.forNode(Identifier name) | 
|   475       : _unlinkedClass = null, |   482       : _unlinkedClass = null, | 
 |   483         _kernel = null, | 
|   476         super.forNode(name); |   484         super.forNode(name); | 
|   477  |   485  | 
|   478   /** |   486   /** | 
|   479    * Initialize using the given serialized information. |   487    * Initialize using the given serialized information. | 
|   480    */ |   488    */ | 
|   481   ClassElementImpl.forSerialized( |   489   ClassElementImpl.forSerialized( | 
|   482       this._unlinkedClass, CompilationUnitElementImpl enclosingUnit) |   490       this._unlinkedClass, CompilationUnitElementImpl enclosingUnit) | 
|   483       : super.forSerialized(enclosingUnit); |   491       : _kernel = null, | 
 |   492         super.forSerialized(enclosingUnit); | 
 |   493  | 
 |   494   /** | 
 |   495    * Initialize using the given kernel. | 
 |   496    */ | 
 |   497   ClassElementImpl.forKernel( | 
 |   498       CompilationUnitElementImpl enclosingUnit, this._kernel) | 
 |   499       : _unlinkedClass = null, | 
 |   500         super.forSerialized(enclosingUnit); | 
|   484  |   501  | 
|   485   /** |   502   /** | 
|   486    * Set whether this class is abstract. |   503    * Set whether this class is abstract. | 
|   487    */ |   504    */ | 
|   488   void set abstract(bool isAbstract) { |   505   void set abstract(bool isAbstract) { | 
|   489     _assertNotResynthesized(_unlinkedClass); |   506     _assertNotResynthesized(_unlinkedClass); | 
|   490     setModifier(Modifier.ABSTRACT, isAbstract); |   507     setModifier(Modifier.ABSTRACT, isAbstract); | 
|   491   } |   508   } | 
|   492  |   509  | 
|   493   @override |   510   @override | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   525       return _unlinkedClass.codeRange?.offset; |   542       return _unlinkedClass.codeRange?.offset; | 
|   526     } |   543     } | 
|   527     return super.codeOffset; |   544     return super.codeOffset; | 
|   528   } |   545   } | 
|   529  |   546  | 
|   530   @override |   547   @override | 
|   531   List<ConstructorElement> get constructors { |   548   List<ConstructorElement> get constructors { | 
|   532     if (isMixinApplication) { |   549     if (isMixinApplication) { | 
|   533       return _computeMixinAppConstructors(); |   550       return _computeMixinAppConstructors(); | 
|   534     } |   551     } | 
 |   552     if (_kernel != null && _constructors == null) { | 
 |   553       _constructors = _kernel.constructors | 
 |   554           .map((k) => new ConstructorElementImpl.forKernel(this, k)) | 
 |   555           .toList(growable: false); | 
 |   556     } | 
|   535     if (_unlinkedClass != null && _constructors == null) { |   557     if (_unlinkedClass != null && _constructors == null) { | 
|   536       _constructors = _unlinkedClass.executables |   558       _constructors = _unlinkedClass.executables | 
|   537           .where((e) => e.kind == UnlinkedExecutableKind.constructor) |   559           .where((e) => e.kind == UnlinkedExecutableKind.constructor) | 
|   538           .map((e) => new ConstructorElementImpl.forSerialized(e, this)) |   560           .map((e) => new ConstructorElementImpl.forSerialized(e, this)) | 
|   539           .toList(growable: false); |   561           .toList(growable: false); | 
|   540       // Ensure at least implicit default constructor. |   562       // Ensure at least implicit default constructor. | 
|   541       if (_constructors.isEmpty) { |   563       if (_constructors.isEmpty) { | 
|   542         ConstructorElementImpl constructor = new ConstructorElementImpl('', -1); |   564         ConstructorElementImpl constructor = new ConstructorElementImpl('', -1); | 
|   543         constructor.isSynthetic = true; |   565         constructor.isSynthetic = true; | 
|   544         constructor.enclosingElement = this; |   566         constructor.enclosingElement = this; | 
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   729     return _interfaces ?? const <InterfaceType>[]; |   751     return _interfaces ?? const <InterfaceType>[]; | 
|   730   } |   752   } | 
|   731  |   753  | 
|   732   void set interfaces(List<InterfaceType> interfaces) { |   754   void set interfaces(List<InterfaceType> interfaces) { | 
|   733     _assertNotResynthesized(_unlinkedClass); |   755     _assertNotResynthesized(_unlinkedClass); | 
|   734     _interfaces = interfaces; |   756     _interfaces = interfaces; | 
|   735   } |   757   } | 
|   736  |   758  | 
|   737   @override |   759   @override | 
|   738   bool get isAbstract { |   760   bool get isAbstract { | 
 |   761     if (_kernel != null) { | 
 |   762       return _kernel.isAbstract; | 
 |   763     } | 
|   739     if (_unlinkedClass != null) { |   764     if (_unlinkedClass != null) { | 
|   740       return _unlinkedClass.isAbstract; |   765       return _unlinkedClass.isAbstract; | 
|   741     } |   766     } | 
|   742     return hasModifier(Modifier.ABSTRACT); |   767     return hasModifier(Modifier.ABSTRACT); | 
|   743   } |   768   } | 
|   744  |   769  | 
|   745   @override |   770   @override | 
|   746   bool get isEnum => false; |   771   bool get isEnum => false; | 
|   747  |   772  | 
|   748   @override |   773   @override | 
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   836     return _mixins ?? const <InterfaceType>[]; |   861     return _mixins ?? const <InterfaceType>[]; | 
|   837   } |   862   } | 
|   838  |   863  | 
|   839   void set mixins(List<InterfaceType> mixins) { |   864   void set mixins(List<InterfaceType> mixins) { | 
|   840     _assertNotResynthesized(_unlinkedClass); |   865     _assertNotResynthesized(_unlinkedClass); | 
|   841     _mixins = mixins; |   866     _mixins = mixins; | 
|   842   } |   867   } | 
|   843  |   868  | 
|   844   @override |   869   @override | 
|   845   String get name { |   870   String get name { | 
 |   871     if (_kernel != null) { | 
 |   872       return _kernel.name; | 
 |   873     } | 
|   846     if (_unlinkedClass != null) { |   874     if (_unlinkedClass != null) { | 
|   847       return _unlinkedClass.name; |   875       return _unlinkedClass.name; | 
|   848     } |   876     } | 
|   849     return super.name; |   877     return super.name; | 
|   850   } |   878   } | 
|   851  |   879  | 
|   852   @override |   880   @override | 
|   853   int get nameOffset { |   881   int get nameOffset { | 
|   854     int offset = super.nameOffset; |   882     int offset = super.nameOffset; | 
|   855     if (offset == 0 && _unlinkedClass != null) { |   883     if (offset == 0 && _unlinkedClass != null) { | 
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1270    * The unlinked representation of the unit in the summary. |  1298    * The unlinked representation of the unit in the summary. | 
|  1271    */ |  1299    */ | 
|  1272   final UnlinkedUnit _unlinkedUnit; |  1300   final UnlinkedUnit _unlinkedUnit; | 
|  1273  |  1301  | 
|  1274   /** |  1302   /** | 
|  1275    * The unlinked representation of the part in the summary. |  1303    * The unlinked representation of the part in the summary. | 
|  1276    */ |  1304    */ | 
|  1277   final UnlinkedPart _unlinkedPart; |  1305   final UnlinkedPart _unlinkedPart; | 
|  1278  |  1306  | 
|  1279   /** |  1307   /** | 
 |  1308    * The kernel context in which the library is resynthesized. | 
 |  1309    */ | 
 |  1310   final KernelLibraryResynthesizerContext _kernelContext; | 
 |  1311  | 
 |  1312   /** | 
|  1280    * The source that corresponds to this compilation unit. |  1313    * The source that corresponds to this compilation unit. | 
|  1281    */ |  1314    */ | 
|  1282   @override |  1315   @override | 
|  1283   Source source; |  1316   Source source; | 
|  1284  |  1317  | 
|  1285   @override |  1318   @override | 
|  1286   LineInfo lineInfo; |  1319   LineInfo lineInfo; | 
|  1287  |  1320  | 
|  1288   /** |  1321   /** | 
|  1289    * The source of the library containing this compilation unit. |  1322    * The source of the library containing this compilation unit. | 
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1353       _topLevelVariableReplaceMap; |  1386       _topLevelVariableReplaceMap; | 
|  1354  |  1387  | 
|  1355   /** |  1388   /** | 
|  1356    * Initialize a newly created compilation unit element to have the given |  1389    * Initialize a newly created compilation unit element to have the given | 
|  1357    * [name]. |  1390    * [name]. | 
|  1358    */ |  1391    */ | 
|  1359   CompilationUnitElementImpl(String name) |  1392   CompilationUnitElementImpl(String name) | 
|  1360       : resynthesizerContext = null, |  1393       : resynthesizerContext = null, | 
|  1361         _unlinkedUnit = null, |  1394         _unlinkedUnit = null, | 
|  1362         _unlinkedPart = null, |  1395         _unlinkedPart = null, | 
 |  1396         _kernelContext = null, | 
|  1363         super(name, -1); |  1397         super(name, -1); | 
|  1364  |  1398  | 
|  1365   /** |  1399   /** | 
|  1366    * Initialize using the given serialized information. |  1400    * Initialize using the given serialized information. | 
|  1367    */ |  1401    */ | 
|  1368   CompilationUnitElementImpl.forSerialized( |  1402   CompilationUnitElementImpl.forSerialized( | 
|  1369       LibraryElementImpl enclosingLibrary, |  1403       LibraryElementImpl enclosingLibrary, | 
|  1370       this.resynthesizerContext, |  1404       this.resynthesizerContext, | 
|  1371       this._unlinkedUnit, |  1405       this._unlinkedUnit, | 
|  1372       this._unlinkedPart, |  1406       this._unlinkedPart, | 
|  1373       String name) |  1407       String name) | 
|  1374       : super.forSerialized(null) { |  1408       : _kernelContext = null, | 
 |  1409         super.forSerialized(null) { | 
|  1375     _enclosingElement = enclosingLibrary; |  1410     _enclosingElement = enclosingLibrary; | 
|  1376     _name = name; |  1411     _name = name; | 
|  1377     _nameOffset = -1; |  1412     _nameOffset = -1; | 
 |  1413   } | 
 |  1414  | 
 |  1415   /** | 
 |  1416    * Initialize using the given kernel information. | 
 |  1417    */ | 
 |  1418   CompilationUnitElementImpl.forKernel( | 
 |  1419       LibraryElementImpl enclosingLibrary, this._kernelContext, String name) | 
 |  1420       : resynthesizerContext = null, | 
 |  1421         _unlinkedUnit = null, | 
 |  1422         _unlinkedPart = null, | 
 |  1423         super.forSerialized(null) { | 
 |  1424     _enclosingElement = enclosingLibrary; | 
 |  1425     _name = name; | 
 |  1426     _nameOffset = -1; | 
|  1378   } |  1427   } | 
|  1379  |  1428  | 
|  1380   @override |  1429   @override | 
|  1381   List<PropertyAccessorElement> get accessors { |  1430   List<PropertyAccessorElement> get accessors { | 
|  1382     if (_unlinkedUnit != null) { |  1431     if (_unlinkedUnit != null) { | 
|  1383       if (_accessors == null) { |  1432       if (_accessors == null) { | 
|  1384         _explicitTopLevelAccessors ??= |  1433         _explicitTopLevelAccessors ??= | 
|  1385             resynthesizerContext.buildTopLevelAccessors(); |  1434             resynthesizerContext.buildTopLevelAccessors(); | 
|  1386         _explicitTopLevelVariables ??= |  1435         _explicitTopLevelVariables ??= | 
|  1387             resynthesizerContext.buildTopLevelVariables(); |  1436             resynthesizerContext.buildTopLevelVariables(); | 
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1568       (typeAlias as ElementImpl).enclosingElement = this; |  1617       (typeAlias as ElementImpl).enclosingElement = this; | 
|  1569     } |  1618     } | 
|  1570     this._typeAliases = typeAliases; |  1619     this._typeAliases = typeAliases; | 
|  1571   } |  1620   } | 
|  1572  |  1621  | 
|  1573   @override |  1622   @override | 
|  1574   TypeParameterizedElementMixin get typeParameterContext => null; |  1623   TypeParameterizedElementMixin get typeParameterContext => null; | 
|  1575  |  1624  | 
|  1576   @override |  1625   @override | 
|  1577   List<ClassElement> get types { |  1626   List<ClassElement> get types { | 
 |  1627     if (_kernelContext != null) { | 
 |  1628       _types ??= _kernelContext.library.classes | 
 |  1629           .map((k) => new ClassElementImpl.forKernel(this, k)) | 
 |  1630           .toList(growable: false); | 
 |  1631     } | 
|  1578     if (_unlinkedUnit != null) { |  1632     if (_unlinkedUnit != null) { | 
|  1579       _types ??= _unlinkedUnit.classes |  1633       _types ??= _unlinkedUnit.classes | 
|  1580           .map((c) => new ClassElementImpl.forSerialized(c, this)) |  1634           .map((c) => new ClassElementImpl.forSerialized(c, this)) | 
|  1581           .toList(growable: false); |  1635           .toList(growable: false); | 
|  1582     } |  1636     } | 
|  1583     return _types ?? const <ClassElement>[]; |  1637     return _types ?? const <ClassElement>[]; | 
|  1584   } |  1638   } | 
|  1585  |  1639  | 
|  1586   /** |  1640   /** | 
|  1587    * Set the types contained in this compilation unit to the given [types]. |  1641    * Set the types contained in this compilation unit to the given [types]. | 
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1927    */ |  1981    */ | 
|  1928   ConstructorElement _redirectedConstructor; |  1982   ConstructorElement _redirectedConstructor; | 
|  1929  |  1983  | 
|  1930   /** |  1984   /** | 
|  1931    * The initializers for this constructor (used for evaluating constant |  1985    * The initializers for this constructor (used for evaluating constant | 
|  1932    * instance creation expressions). |  1986    * instance creation expressions). | 
|  1933    */ |  1987    */ | 
|  1934   List<ConstructorInitializer> _constantInitializers; |  1988   List<ConstructorInitializer> _constantInitializers; | 
|  1935  |  1989  | 
|  1936   /** |  1990   /** | 
 |  1991    * The kernel of the element. | 
 |  1992    */ | 
 |  1993   final kernel.Constructor _kernel; | 
 |  1994  | 
 |  1995   /** | 
|  1937    * The offset of the `.` before this constructor name or `null` if not named. |  1996    * The offset of the `.` before this constructor name or `null` if not named. | 
|  1938    */ |  1997    */ | 
|  1939   int _periodOffset; |  1998   int _periodOffset; | 
|  1940  |  1999  | 
|  1941   /** |  2000   /** | 
|  1942    * Return the offset of the character immediately following the last character |  2001    * Return the offset of the character immediately following the last character | 
|  1943    * of this constructor's name, or `null` if not named. |  2002    * of this constructor's name, or `null` if not named. | 
|  1944    */ |  2003    */ | 
|  1945   int _nameEnd; |  2004   int _nameEnd; | 
|  1946  |  2005  | 
|  1947   /** |  2006   /** | 
|  1948    * True if this constructor has been found by constant evaluation to be free |  2007    * True if this constructor has been found by constant evaluation to be free | 
|  1949    * of redirect cycles, and is thus safe to evaluate. |  2008    * of redirect cycles, and is thus safe to evaluate. | 
|  1950    */ |  2009    */ | 
|  1951   bool _isCycleFree = false; |  2010   bool _isCycleFree = false; | 
|  1952  |  2011  | 
|  1953   /** |  2012   /** | 
|  1954    * Initialize a newly created constructor element to have the given [name] and |  2013    * Initialize a newly created constructor element to have the given [name] and | 
|  1955    * [offset]. |  2014    * [offset]. | 
|  1956    */ |  2015    */ | 
|  1957   ConstructorElementImpl(String name, int offset) : super(name, offset); |  2016   ConstructorElementImpl(String name, int offset) | 
 |  2017       : _kernel = null, | 
 |  2018         super(name, offset); | 
|  1958  |  2019  | 
|  1959   /** |  2020   /** | 
|  1960    * Initialize a newly created constructor element to have the given [name]. |  2021    * Initialize a newly created constructor element to have the given [name]. | 
|  1961    */ |  2022    */ | 
|  1962   ConstructorElementImpl.forNode(Identifier name) : super.forNode(name); |  2023   ConstructorElementImpl.forNode(Identifier name) | 
 |  2024       : _kernel = null, | 
 |  2025         super.forNode(name); | 
|  1963  |  2026  | 
|  1964   /** |  2027   /** | 
|  1965    * Initialize using the given serialized information. |  2028    * Initialize using the given serialized information. | 
|  1966    */ |  2029    */ | 
|  1967   ConstructorElementImpl.forSerialized( |  2030   ConstructorElementImpl.forSerialized( | 
|  1968       UnlinkedExecutable serializedExecutable, ClassElementImpl enclosingClass) |  2031       UnlinkedExecutable serializedExecutable, ClassElementImpl enclosingClass) | 
|  1969       : super.forSerialized(serializedExecutable, enclosingClass); |  2032       : _kernel = null, | 
 |  2033         super.forSerialized(serializedExecutable, enclosingClass); | 
 |  2034  | 
 |  2035   /** | 
 |  2036    * Initialize using the given serialized information. | 
 |  2037    */ | 
 |  2038   ConstructorElementImpl.forKernel( | 
 |  2039       ClassElementImpl enclosingClass, this._kernel) | 
 |  2040       : super.forSerialized(null, enclosingClass) { | 
 |  2041     isSynthetic = _kernel.isSyntheticDefault; | 
 |  2042   } | 
|  1970  |  2043  | 
|  1971   /** |  2044   /** | 
|  1972    * Return the constant initializers for this element, which will be empty if |  2045    * Return the constant initializers for this element, which will be empty if | 
|  1973    * there are no initializers, or `null` if there was an error in the source. |  2046    * there are no initializers, or `null` if there was an error in the source. | 
|  1974    */ |  2047    */ | 
|  1975   List<ConstructorInitializer> get constantInitializers { |  2048   List<ConstructorInitializer> get constantInitializers { | 
|  1976     if (serializedExecutable != null && _constantInitializers == null) { |  2049     if (serializedExecutable != null && _constantInitializers == null) { | 
|  1977       _constantInitializers ??= serializedExecutable.constantInitializers |  2050       _constantInitializers ??= serializedExecutable.constantInitializers | 
|  1978           .map((i) => _buildConstructorInitializer(i)) |  2051           .map((i) => _buildConstructorInitializer(i)) | 
|  1979           .toList(growable: false); |  2052           .toList(growable: false); | 
| (...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  3542  */ |  3615  */ | 
|  3543 abstract class ExecutableElementImpl extends ElementImpl |  3616 abstract class ExecutableElementImpl extends ElementImpl | 
|  3544     with TypeParameterizedElementMixin |  3617     with TypeParameterizedElementMixin | 
|  3545     implements ExecutableElement { |  3618     implements ExecutableElement { | 
|  3546   /** |  3619   /** | 
|  3547    * The unlinked representation of the executable in the summary. |  3620    * The unlinked representation of the executable in the summary. | 
|  3548    */ |  3621    */ | 
|  3549   final UnlinkedExecutable serializedExecutable; |  3622   final UnlinkedExecutable serializedExecutable; | 
|  3550  |  3623  | 
|  3551   /** |  3624   /** | 
 |  3625    * The kernel of the element. | 
 |  3626    */ | 
 |  3627   final kernel.Member _kernel; | 
 |  3628  | 
 |  3629   /** | 
|  3552    * A list containing all of the functions defined within this executable |  3630    * A list containing all of the functions defined within this executable | 
|  3553    * element. |  3631    * element. | 
|  3554    */ |  3632    */ | 
|  3555   List<FunctionElement> _functions; |  3633   List<FunctionElement> _functions; | 
|  3556  |  3634  | 
|  3557   /** |  3635   /** | 
|  3558    * A list containing all of the parameters defined by this executable element. |  3636    * A list containing all of the parameters defined by this executable element. | 
|  3559    */ |  3637    */ | 
|  3560   List<ParameterElement> _parameters; |  3638   List<ParameterElement> _parameters; | 
|  3561  |  3639  | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
|  3573    * The type of function defined by this executable element. |  3651    * The type of function defined by this executable element. | 
|  3574    */ |  3652    */ | 
|  3575   FunctionType _type; |  3653   FunctionType _type; | 
|  3576  |  3654  | 
|  3577   /** |  3655   /** | 
|  3578    * Initialize a newly created executable element to have the given [name] and |  3656    * Initialize a newly created executable element to have the given [name] and | 
|  3579    * [offset]. |  3657    * [offset]. | 
|  3580    */ |  3658    */ | 
|  3581   ExecutableElementImpl(String name, int offset) |  3659   ExecutableElementImpl(String name, int offset) | 
|  3582       : serializedExecutable = null, |  3660       : serializedExecutable = null, | 
 |  3661         _kernel = null, | 
|  3583         super(name, offset); |  3662         super(name, offset); | 
|  3584  |  3663  | 
|  3585   /** |  3664   /** | 
|  3586    * Initialize a newly created executable element to have the given [name]. |  3665    * Initialize a newly created executable element to have the given [name]. | 
|  3587    */ |  3666    */ | 
|  3588   ExecutableElementImpl.forNode(Identifier name) |  3667   ExecutableElementImpl.forNode(Identifier name) | 
|  3589       : serializedExecutable = null, |  3668       : serializedExecutable = null, | 
 |  3669         _kernel = null, | 
|  3590         super.forNode(name); |  3670         super.forNode(name); | 
|  3591  |  3671  | 
|  3592   /** |  3672   /** | 
|  3593    * Initialize using the given serialized information. |  3673    * Initialize using the given serialized information. | 
|  3594    */ |  3674    */ | 
|  3595   ExecutableElementImpl.forSerialized( |  3675   ExecutableElementImpl.forSerialized( | 
|  3596       this.serializedExecutable, ElementImpl enclosingElement) |  3676       this.serializedExecutable, ElementImpl enclosingElement) | 
|  3597       : super.forSerialized(enclosingElement); |  3677       : _kernel = null, | 
 |  3678         super.forSerialized(enclosingElement); | 
 |  3679  | 
 |  3680   /** | 
 |  3681    * Initialize using the given kernel. | 
 |  3682    */ | 
 |  3683   ExecutableElementImpl.forKernel(ElementImpl enclosingElement, this._kernel) | 
 |  3684       : serializedExecutable = null, | 
 |  3685         super.forSerialized(enclosingElement); | 
|  3598  |  3686  | 
|  3599   /** |  3687   /** | 
|  3600    * Set whether this executable element's body is asynchronous. |  3688    * Set whether this executable element's body is asynchronous. | 
|  3601    */ |  3689    */ | 
|  3602   void set asynchronous(bool isAsynchronous) { |  3690   void set asynchronous(bool isAsynchronous) { | 
|  3603     _assertNotResynthesized(serializedExecutable); |  3691     _assertNotResynthesized(serializedExecutable); | 
|  3604     setModifier(Modifier.ASYNCHRONOUS, isAsynchronous); |  3692     setModifier(Modifier.ASYNCHRONOUS, isAsynchronous); | 
|  3605   } |  3693   } | 
|  3606  |  3694  | 
|  3607   @override |  3695   @override | 
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  3737   List<ElementAnnotation> get metadata { |  3825   List<ElementAnnotation> get metadata { | 
|  3738     if (serializedExecutable != null) { |  3826     if (serializedExecutable != null) { | 
|  3739       return _metadata ??= |  3827       return _metadata ??= | 
|  3740           _buildAnnotations(enclosingUnit, serializedExecutable.annotations); |  3828           _buildAnnotations(enclosingUnit, serializedExecutable.annotations); | 
|  3741     } |  3829     } | 
|  3742     return super.metadata; |  3830     return super.metadata; | 
|  3743   } |  3831   } | 
|  3744  |  3832  | 
|  3745   @override |  3833   @override | 
|  3746   String get name { |  3834   String get name { | 
 |  3835     if (_kernel != null) { | 
 |  3836       return _kernel.name.name; | 
 |  3837     } | 
|  3747     if (serializedExecutable != null) { |  3838     if (serializedExecutable != null) { | 
|  3748       return serializedExecutable.name; |  3839       return serializedExecutable.name; | 
|  3749     } |  3840     } | 
|  3750     return super.name; |  3841     return super.name; | 
|  3751   } |  3842   } | 
|  3752  |  3843  | 
|  3753   @override |  3844   @override | 
|  3754   int get nameOffset { |  3845   int get nameOffset { | 
|  3755     int offset = super.nameOffset; |  3846     int offset = super.nameOffset; | 
|  3756     if (offset == 0 && serializedExecutable != null) { |  3847     if (offset == 0 && serializedExecutable != null) { | 
| (...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  5525  * A concrete implementation of a [LibraryElement]. |  5616  * A concrete implementation of a [LibraryElement]. | 
|  5526  */ |  5617  */ | 
|  5527 class LibraryElementImpl extends ElementImpl implements LibraryElement { |  5618 class LibraryElementImpl extends ElementImpl implements LibraryElement { | 
|  5528   /** |  5619   /** | 
|  5529    * The analysis context in which this library is defined. |  5620    * The analysis context in which this library is defined. | 
|  5530    */ |  5621    */ | 
|  5531   final AnalysisContext context; |  5622   final AnalysisContext context; | 
|  5532  |  5623  | 
|  5533   final LibraryResynthesizerContext resynthesizerContext; |  5624   final LibraryResynthesizerContext resynthesizerContext; | 
|  5534  |  5625  | 
 |  5626   /** | 
 |  5627    * The kernel context in which the library is resynthesized. | 
 |  5628    */ | 
 |  5629   final KernelLibraryResynthesizerContext _kernelContext; | 
 |  5630  | 
|  5535   final UnlinkedUnit _unlinkedDefiningUnit; |  5631   final UnlinkedUnit _unlinkedDefiningUnit; | 
|  5536  |  5632  | 
|  5537   /** |  5633   /** | 
|  5538    * The compilation unit that defines this library. |  5634    * The compilation unit that defines this library. | 
|  5539    */ |  5635    */ | 
|  5540   CompilationUnitElement _definingCompilationUnit; |  5636   CompilationUnitElement _definingCompilationUnit; | 
|  5541  |  5637  | 
|  5542   /** |  5638   /** | 
|  5543    * The entry point for this library, or `null` if this library does not have |  5639    * The entry point for this library, or `null` if this library does not have | 
|  5544    * an entry point. |  5640    * an entry point. | 
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  5602    * The cached list of prefixes. |  5698    * The cached list of prefixes. | 
|  5603    */ |  5699    */ | 
|  5604   List<PrefixElement> _prefixes; |  5700   List<PrefixElement> _prefixes; | 
|  5605  |  5701  | 
|  5606   /** |  5702   /** | 
|  5607    * Initialize a newly created library element in the given [context] to have |  5703    * Initialize a newly created library element in the given [context] to have | 
|  5608    * the given [name] and [offset]. |  5704    * the given [name] and [offset]. | 
|  5609    */ |  5705    */ | 
|  5610   LibraryElementImpl(this.context, String name, int offset, this.nameLength) |  5706   LibraryElementImpl(this.context, String name, int offset, this.nameLength) | 
|  5611       : resynthesizerContext = null, |  5707       : resynthesizerContext = null, | 
 |  5708         _kernelContext = null, | 
|  5612         _unlinkedDefiningUnit = null, |  5709         _unlinkedDefiningUnit = null, | 
|  5613         super(name, offset); |  5710         super(name, offset); | 
|  5614  |  5711  | 
|  5615   /** |  5712   /** | 
|  5616    * Initialize a newly created library element in the given [context] to have |  5713    * Initialize a newly created library element in the given [context] to have | 
|  5617    * the given [name]. |  5714    * the given [name]. | 
|  5618    */ |  5715    */ | 
|  5619   LibraryElementImpl.forNode(this.context, LibraryIdentifier name) |  5716   LibraryElementImpl.forNode(this.context, LibraryIdentifier name) | 
|  5620       : nameLength = name != null ? name.length : 0, |  5717       : nameLength = name != null ? name.length : 0, | 
|  5621         resynthesizerContext = null, |  5718         resynthesizerContext = null, | 
 |  5719         _kernelContext = null, | 
|  5622         _unlinkedDefiningUnit = null, |  5720         _unlinkedDefiningUnit = null, | 
|  5623         super.forNode(name); |  5721         super.forNode(name); | 
|  5624  |  5722  | 
|  5625   /** |  5723   /** | 
|  5626    * Initialize using the given serialized information. |  5724    * Initialize using the given serialized information. | 
|  5627    */ |  5725    */ | 
|  5628   LibraryElementImpl.forSerialized(this.context, String name, int offset, |  5726   LibraryElementImpl.forSerialized(this.context, String name, int offset, | 
|  5629       this.nameLength, this.resynthesizerContext, this._unlinkedDefiningUnit) |  5727       this.nameLength, this.resynthesizerContext, this._unlinkedDefiningUnit) | 
|  5630       : super.forSerialized(null) { |  5728       : _kernelContext = null, | 
 |  5729         super.forSerialized(null) { | 
|  5631     _name = name; |  5730     _name = name; | 
|  5632     _nameOffset = offset; |  5731     _nameOffset = offset; | 
|  5633     setResolutionCapability( |  5732     setResolutionCapability( | 
|  5634         LibraryResolutionCapability.resolvedTypeNames, true); |  5733         LibraryResolutionCapability.resolvedTypeNames, true); | 
|  5635     setResolutionCapability( |  5734     setResolutionCapability( | 
|  5636         LibraryResolutionCapability.constantExpressions, true); |  5735         LibraryResolutionCapability.constantExpressions, true); | 
|  5637   } |  5736   } | 
|  5638  |  5737  | 
 |  5738   /** | 
 |  5739    * Initialize using the given kernel information. | 
 |  5740    */ | 
 |  5741   LibraryElementImpl.forKernel(this.context, this._kernelContext) | 
 |  5742       : resynthesizerContext = null, | 
 |  5743         _unlinkedDefiningUnit = null, | 
 |  5744         nameLength = _kernelContext.library.name?.length ?? 0, | 
 |  5745         super.forSerialized(null) { | 
 |  5746     _name = _kernelContext.library.name ?? ''; | 
 |  5747     _nameOffset = _kernelContext.library.fileOffset; | 
 |  5748     setResolutionCapability( | 
 |  5749         LibraryResolutionCapability.resolvedTypeNames, true); | 
 |  5750     setResolutionCapability( | 
 |  5751         LibraryResolutionCapability.constantExpressions, true); | 
 |  5752  | 
 |  5753     definingCompilationUnit = new CompilationUnitElementImpl.forKernel( | 
 |  5754         this, _kernelContext, '<no-name>'); | 
 |  5755  | 
 |  5756     // TODO(scheglov) how to support parts? | 
 |  5757   } | 
 |  5758  | 
|  5639   @override |  5759   @override | 
|  5640   int get codeLength { |  5760   int get codeLength { | 
|  5641     CompilationUnitElement unit = _definingCompilationUnit; |  5761     CompilationUnitElement unit = _definingCompilationUnit; | 
|  5642     if (unit is CompilationUnitElementImpl) { |  5762     if (unit is CompilationUnitElementImpl) { | 
|  5643       return unit.codeLength; |  5763       return unit.codeLength; | 
|  5644     } |  5764     } | 
|  5645     return null; |  5765     return null; | 
|  5646   } |  5766   } | 
|  5647  |  5767  | 
|  5648   @override |  5768   @override | 
| (...skipping 3215 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  8864  |  8984  | 
|  8865   @override |  8985   @override | 
|  8866   DartObject computeConstantValue() => null; |  8986   DartObject computeConstantValue() => null; | 
|  8867  |  8987  | 
|  8868   @override |  8988   @override | 
|  8869   void visitChildren(ElementVisitor visitor) { |  8989   void visitChildren(ElementVisitor visitor) { | 
|  8870     super.visitChildren(visitor); |  8990     super.visitChildren(visitor); | 
|  8871     _initializer?.accept(visitor); |  8991     _initializer?.accept(visitor); | 
|  8872   } |  8992   } | 
|  8873 } |  8993 } | 
 |  8994  | 
 |  8995 /** | 
 |  8996  * The kernel context in which a library is resynthesized. | 
 |  8997  */ | 
 |  8998 abstract class KernelLibraryResynthesizerContext { | 
 |  8999   kernel.Library get library; | 
 |  9000 } | 
| OLD | NEW |