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

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

Issue 946023003: Fix for searching constructor references. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 | Annotate | Revision Log
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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.element; 8 library engine.element;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
11 11
12 import 'package:analyzer/src/generated/utilities_general.dart';
13
12 import 'ast.dart'; 14 import 'ast.dart';
13 import 'constant.dart' show EvaluationResultImpl; 15 import 'constant.dart' show EvaluationResultImpl;
14 import 'engine.dart' show AnalysisContext, AnalysisEngine, AnalysisException; 16 import 'engine.dart' show AnalysisContext, AnalysisEngine, AnalysisException;
15 import 'html.dart' show XmlAttributeNode, XmlTagNode; 17 import 'html.dart' show XmlAttributeNode, XmlTagNode;
16 import 'java_core.dart'; 18 import 'java_core.dart';
17 import 'java_engine.dart'; 19 import 'java_engine.dart';
18 import 'resolver.dart'; 20 import 'resolver.dart';
19 import 'scanner.dart' show Keyword; 21 import 'scanner.dart' show Keyword;
20 import 'sdk.dart' show DartSdk; 22 import 'sdk.dart' show DartSdk;
21 import 'source.dart'; 23 import 'source.dart';
22 import 'utilities_collection.dart'; 24 import 'utilities_collection.dart';
23 import 'utilities_dart.dart'; 25 import 'utilities_dart.dart';
24 import 'package:analyzer/src/generated/utilities_general.dart';
25 26
26 27
27 /** 28 /**
28 * For AST nodes that could be in both the getter and setter contexts ([IndexExp ression]s and 29 * For AST nodes that could be in both the getter and setter contexts ([IndexExp ression]s and
29 * [SimpleIdentifier]s), the additional resolved elements are stored in the AST node, in an 30 * [SimpleIdentifier]s), the additional resolved elements are stored in the AST node, in an
30 * [AuxiliaryElements]. Since resolved elements are either statically resolved o r resolved 31 * [AuxiliaryElements]. Since resolved elements are either statically resolved o r resolved
31 * using propagated type information, this class is a wrapper for a pair of 32 * using propagated type information, this class is a wrapper for a pair of
32 * [ExecutableElement]s, not just a single [ExecutableElement]. 33 * [ExecutableElement]s, not just a single [ExecutableElement].
33 */ 34 */
34 class AuxiliaryElements { 35 class AuxiliaryElements {
(...skipping 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after
1669 bool get isDefaultConstructor; 1670 bool get isDefaultConstructor;
1670 1671
1671 /** 1672 /**
1672 * Return `true` if this constructor represents a factory constructor. 1673 * Return `true` if this constructor represents a factory constructor.
1673 * 1674 *
1674 * @return `true` if this constructor represents a factory constructor 1675 * @return `true` if this constructor represents a factory constructor
1675 */ 1676 */
1676 bool get isFactory; 1677 bool get isFactory;
1677 1678
1678 /** 1679 /**
1680 * Return the offset of the character immediately following the last character
1681 * of this constructor's name, or `null` if not named.
1682 */
1683 int get nameEnd;
1684
1685 /**
1679 * Return the resolved [ConstructorDeclaration] node that declares this 1686 * Return the resolved [ConstructorDeclaration] node that declares this
1680 * [ConstructorElement] . 1687 * [ConstructorElement] .
1681 * 1688 *
1682 * This method is expensive, because resolved AST might be evicted from cache, so parsing and 1689 * This method is expensive, because resolved AST might be evicted from cache, so parsing and
1683 * resolving will be performed. 1690 * resolving will be performed.
1684 * 1691 *
1685 * @return the resolved [ConstructorDeclaration], not `null`. 1692 * @return the resolved [ConstructorDeclaration], not `null`.
1686 */ 1693 */
1687 @override 1694 @override
1688 ConstructorDeclaration get node; 1695 ConstructorDeclaration get node;
1689 1696
1690 /** 1697 /**
1698 * Return the offset of the `.` before this constructor name, or `null` if
1699 * not named.
1700 */
1701 int get periodOffset;
1702
1703 /**
1691 * Return the constructor to which this constructor is redirecting, or `null` if this 1704 * Return the constructor to which this constructor is redirecting, or `null` if this
1692 * constructor does not redirect to another constructor or if the library cont aining this 1705 * constructor does not redirect to another constructor or if the library cont aining this
1693 * constructor has not yet been resolved. 1706 * constructor has not yet been resolved.
1694 * 1707 *
1695 * @return the constructor to which this constructor is redirecting 1708 * @return the constructor to which this constructor is redirecting
1696 */ 1709 */
1697 ConstructorElement get redirectedConstructor; 1710 ConstructorElement get redirectedConstructor;
1698 } 1711 }
1699 1712
1700 /** 1713 /**
(...skipping 13 matching lines...) Expand all
1714 */ 1727 */
1715 ConstructorElement redirectedConstructor; 1728 ConstructorElement redirectedConstructor;
1716 1729
1717 /** 1730 /**
1718 * The initializers for this constructor (used for evaluating constant instanc e creation 1731 * The initializers for this constructor (used for evaluating constant instanc e creation
1719 * expressions). 1732 * expressions).
1720 */ 1733 */
1721 List<ConstructorInitializer> constantInitializers; 1734 List<ConstructorInitializer> constantInitializers;
1722 1735
1723 /** 1736 /**
1737 * The offset of the `.` before this constructor name or `null` if not named.
1738 */
1739 int periodOffset;
1740
1741 /**
1742 * Return the offset of the character immediately following the last character
1743 * of this constructor's name, or `null` if not named.
1744 */
1745 int nameEnd;
1746
1747 /**
1724 * Initialize a newly created constructor element to have the given name. 1748 * Initialize a newly created constructor element to have the given name.
1725 * 1749 *
1726 * @param name the name of this element 1750 * @param name the name of this element
1727 * @param nameOffset the offset of the name of this element in the file that c ontains the 1751 * @param nameOffset the offset of the name of this element in the file that c ontains the
1728 * declaration of this element 1752 * declaration of this element
1729 */ 1753 */
1730 ConstructorElementImpl(String name, int nameOffset) : super(name, nameOffset); 1754 ConstructorElementImpl(String name, int nameOffset) : super(name, nameOffset);
1731 1755
1732 /** 1756 /**
1733 * Initialize a newly created constructor element to have the given name. 1757 * Initialize a newly created constructor element to have the given name.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 @override 1868 @override
1845 bool get isConst => baseElement.isConst; 1869 bool get isConst => baseElement.isConst;
1846 1870
1847 @override 1871 @override
1848 bool get isDefaultConstructor => baseElement.isDefaultConstructor; 1872 bool get isDefaultConstructor => baseElement.isDefaultConstructor;
1849 1873
1850 @override 1874 @override
1851 bool get isFactory => baseElement.isFactory; 1875 bool get isFactory => baseElement.isFactory;
1852 1876
1853 @override 1877 @override
1878 int get nameEnd => baseElement.nameEnd;
1879
1880 @override
1854 ConstructorDeclaration get node => baseElement.node; 1881 ConstructorDeclaration get node => baseElement.node;
1855 1882
1856 @override 1883 @override
1884 int get periodOffset => baseElement.periodOffset;
1885
1886 @override
1857 ConstructorElement get redirectedConstructor => 1887 ConstructorElement get redirectedConstructor =>
1858 from(baseElement.redirectedConstructor, definingType); 1888 from(baseElement.redirectedConstructor, definingType);
1859 1889
1860 @override 1890 @override
1861 accept(ElementVisitor visitor) => visitor.visitConstructorElement(this); 1891 accept(ElementVisitor visitor) => visitor.visitConstructorElement(this);
1862 1892
1863 @override 1893 @override
1864 String toString() { 1894 String toString() {
1865 ConstructorElement baseElement = this.baseElement; 1895 ConstructorElement baseElement = this.baseElement;
1866 List<ParameterElement> parameters = this.parameters; 1896 List<ParameterElement> parameters = this.parameters;
(...skipping 2931 matching lines...) Expand 10 before | Expand all | Expand 10 after
4798 } 4828 }
4799 name = buffer.toString(); 4829 name = buffer.toString();
4800 } 4830 }
4801 return name; 4831 return name;
4802 } 4832 }
4803 4833
4804 @override 4834 @override
4805 int get hashCode => internalHashCode(<DartType>[]); 4835 int get hashCode => internalHashCode(<DartType>[]);
4806 4836
4807 @override 4837 @override
4808 int internalHashCode(List<DartType> visitedTypes) {
4809 if (element == null) {
4810 return 0;
4811 } else if (visitedTypes.contains(this)) {
4812 return 3;
4813 }
4814 visitedTypes.add(this);
4815 // Reference the arrays of parameters
4816 List<DartType> normalParameterTypes = this.normalParameterTypes;
4817 List<DartType> optionalParameterTypes = this.optionalParameterTypes;
4818 Iterable<DartType> namedParameterTypes = this.namedParameterTypes.values;
4819 // Generate the hashCode
4820 int code = (returnType as TypeImpl).internalHashCode(visitedTypes);
4821 for (int i = 0; i < normalParameterTypes.length; i++) {
4822 code = (code << 1) +
4823 (normalParameterTypes[i] as TypeImpl).internalHashCode(visitedTypes);
4824 }
4825 for (int i = 0; i < optionalParameterTypes.length; i++) {
4826 code = (code << 1) +
4827 (optionalParameterTypes[i] as TypeImpl).internalHashCode(visitedTypes) ;
4828 }
4829 for (DartType type in namedParameterTypes) {
4830 code = (code << 1) + (type as TypeImpl).internalHashCode(visitedTypes);
4831 }
4832 return code;
4833 }
4834
4835 @override
4836 Map<String, DartType> get namedParameterTypes { 4838 Map<String, DartType> get namedParameterTypes {
4837 LinkedHashMap<String, DartType> namedParameterTypes = 4839 LinkedHashMap<String, DartType> namedParameterTypes =
4838 new LinkedHashMap<String, DartType>(); 4840 new LinkedHashMap<String, DartType>();
4839 List<ParameterElement> parameters = baseParameters; 4841 List<ParameterElement> parameters = baseParameters;
4840 if (parameters.length == 0) { 4842 if (parameters.length == 0) {
4841 return namedParameterTypes; 4843 return namedParameterTypes;
4842 } 4844 }
4843 List<DartType> typeParameters = 4845 List<DartType> typeParameters =
4844 TypeParameterTypeImpl.getTypes(this.typeParameters); 4846 TypeParameterTypeImpl.getTypes(this.typeParameters);
4845 for (ParameterElement parameter in parameters) { 4847 for (ParameterElement parameter in parameters) {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
5049 (returnType as TypeImpl).internalEquals( 5051 (returnType as TypeImpl).internalEquals(
5050 otherType.returnType, 5052 otherType.returnType,
5051 visitedElementPairs); 5053 visitedElementPairs);
5052 // Remove the pair from our visited pairs list 5054 // Remove the pair from our visited pairs list
5053 visitedElementPairs.remove(elementPair); 5055 visitedElementPairs.remove(elementPair);
5054 // Return the result 5056 // Return the result
5055 return result; 5057 return result;
5056 } 5058 }
5057 5059
5058 @override 5060 @override
5061 int internalHashCode(List<DartType> visitedTypes) {
5062 if (element == null) {
5063 return 0;
5064 } else if (visitedTypes.contains(this)) {
5065 return 3;
5066 }
5067 visitedTypes.add(this);
5068 // Reference the arrays of parameters
5069 List<DartType> normalParameterTypes = this.normalParameterTypes;
5070 List<DartType> optionalParameterTypes = this.optionalParameterTypes;
5071 Iterable<DartType> namedParameterTypes = this.namedParameterTypes.values;
5072 // Generate the hashCode
5073 int code = (returnType as TypeImpl).internalHashCode(visitedTypes);
5074 for (int i = 0; i < normalParameterTypes.length; i++) {
5075 code = (code << 1) +
5076 (normalParameterTypes[i] as TypeImpl).internalHashCode(visitedTypes);
5077 }
5078 for (int i = 0; i < optionalParameterTypes.length; i++) {
5079 code = (code << 1) +
5080 (optionalParameterTypes[i] as TypeImpl).internalHashCode(visitedTypes) ;
5081 }
5082 for (DartType type in namedParameterTypes) {
5083 code = (code << 1) + (type as TypeImpl).internalHashCode(visitedTypes);
5084 }
5085 return code;
5086 }
5087
5088 @override
5059 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, 5089 bool internalIsMoreSpecificThan(DartType type, bool withDynamic,
5060 Set<TypeImpl_TypePair> visitedTypePairs) { 5090 Set<TypeImpl_TypePair> visitedTypePairs) {
5061 // trivial base cases 5091 // trivial base cases
5062 if (type == null) { 5092 if (type == null) {
5063 return false; 5093 return false;
5064 } else if (identical(this, type) || 5094 } else if (identical(this, type) ||
5065 type.isDynamic || 5095 type.isDynamic ||
5066 type.isDartCoreFunction || 5096 type.isDartCoreFunction ||
5067 type.isObject) { 5097 type.isObject) {
5068 return true; 5098 return true;
(...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after
6268 @override 6298 @override
6269 int get hashCode { 6299 int get hashCode {
6270 ClassElement element = this.element; 6300 ClassElement element = this.element;
6271 if (element == null) { 6301 if (element == null) {
6272 return 0; 6302 return 0;
6273 } 6303 }
6274 return element.hashCode; 6304 return element.hashCode;
6275 } 6305 }
6276 6306
6277 @override 6307 @override
6278 int internalHashCode(List<DartType> visitedTypes) => hashCode;
6279
6280 @override
6281 List<InterfaceType> get interfaces { 6308 List<InterfaceType> get interfaces {
6282 ClassElement classElement = element; 6309 ClassElement classElement = element;
6283 List<InterfaceType> interfaces = classElement.interfaces; 6310 List<InterfaceType> interfaces = classElement.interfaces;
6284 List<TypeParameterElement> typeParameters = classElement.typeParameters; 6311 List<TypeParameterElement> typeParameters = classElement.typeParameters;
6285 List<DartType> parameterTypes = classElement.type.typeArguments; 6312 List<DartType> parameterTypes = classElement.type.typeArguments;
6286 if (typeParameters.length == 0) { 6313 if (typeParameters.length == 0) {
6287 return interfaces; 6314 return interfaces;
6288 } 6315 }
6289 int count = interfaces.length; 6316 int count = interfaces.length;
6290 List<InterfaceType> typedInterfaces = new List<InterfaceType>(count); 6317 List<InterfaceType> typedInterfaces = new List<InterfaceType>(count);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
6456 } 6483 }
6457 InterfaceTypeImpl otherType = object as InterfaceTypeImpl; 6484 InterfaceTypeImpl otherType = object as InterfaceTypeImpl;
6458 return (element == otherType.element) && 6485 return (element == otherType.element) &&
6459 TypeImpl.equalArrays( 6486 TypeImpl.equalArrays(
6460 typeArguments, 6487 typeArguments,
6461 otherType.typeArguments, 6488 otherType.typeArguments,
6462 visitedElementPairs); 6489 visitedElementPairs);
6463 } 6490 }
6464 6491
6465 @override 6492 @override
6493 int internalHashCode(List<DartType> visitedTypes) => hashCode;
6494
6495 @override
6466 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, 6496 bool internalIsMoreSpecificThan(DartType type, bool withDynamic,
6467 Set<TypeImpl_TypePair> visitedTypePairs) { 6497 Set<TypeImpl_TypePair> visitedTypePairs) {
6468 // 6498 //
6469 // S is dynamic. 6499 // S is dynamic.
6470 // The test to determine whether S is dynamic is done here because dynamic 6500 // The test to determine whether S is dynamic is done here because dynamic
6471 // is not an instance of InterfaceType. 6501 // is not an instance of InterfaceType.
6472 // 6502 //
6473 if (type.isDynamic) { 6503 if (type.isDynamic) {
6474 return true; 6504 return true;
6475 } else if (type is UnionType) { 6505 } else if (type is UnionType) {
(...skipping 4136 matching lines...) Expand 10 before | Expand all | Expand 10 after
10612 return buffer.toString(); 10642 return buffer.toString();
10613 } 10643 }
10614 10644
10615 @override 10645 @override
10616 Set<DartType> get elements => _types; 10646 Set<DartType> get elements => _types;
10617 10647
10618 @override 10648 @override
10619 int get hashCode => _types.hashCode; 10649 int get hashCode => _types.hashCode;
10620 10650
10621 @override 10651 @override
10622 int internalHashCode(List<DartType> visitedTypes) => hashCode;
10623
10624 @override
10625 bool operator ==(Object other) { 10652 bool operator ==(Object other) {
10626 if (other == null || other is! UnionType) { 10653 if (other == null || other is! UnionType) {
10627 return false; 10654 return false;
10628 } else if (identical(this, other)) { 10655 } else if (identical(this, other)) {
10629 return true; 10656 return true;
10630 } else { 10657 } else {
10631 return javaSetEquals(_types, (other as UnionType).elements); 10658 return javaSetEquals(_types, (other as UnionType).elements);
10632 } 10659 }
10633 } 10660 }
10634 10661
(...skipping 10 matching lines...) Expand all
10645 prefix = ","; 10672 prefix = ",";
10646 } 10673 }
10647 buffer.write("}"); 10674 buffer.write("}");
10648 } 10675 }
10649 10676
10650 @override 10677 @override
10651 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => 10678 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) =>
10652 this == object; 10679 this == object;
10653 10680
10654 @override 10681 @override
10682 int internalHashCode(List<DartType> visitedTypes) => hashCode;
10683
10684 @override
10655 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, 10685 bool internalIsMoreSpecificThan(DartType type, bool withDynamic,
10656 Set<TypeImpl_TypePair> visitedTypePairs) { 10686 Set<TypeImpl_TypePair> visitedTypePairs) {
10657 // What version of subtyping do we want? See discussion below in 10687 // What version of subtyping do we want? See discussion below in
10658 // [internalIsSubtypeOf]. 10688 // [internalIsSubtypeOf].
10659 if (AnalysisEngine.instance.strictUnionTypes) { 10689 if (AnalysisEngine.instance.strictUnionTypes) {
10660 // The less unsound version: all. 10690 // The less unsound version: all.
10661 for (DartType t in _types) { 10691 for (DartType t in _types) {
10662 if (!(t as TypeImpl).internalIsMoreSpecificThan( 10692 if (!(t as TypeImpl).internalIsMoreSpecificThan(
10663 type, 10693 type,
10664 withDynamic, 10694 withDynamic,
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
11123 11153
11124 /** 11154 /**
11125 * Prevent the creation of instances of this class. 11155 * Prevent the creation of instances of this class.
11126 */ 11156 */
11127 VoidTypeImpl() : super(null, Keyword.VOID.syntax); 11157 VoidTypeImpl() : super(null, Keyword.VOID.syntax);
11128 11158
11129 @override 11159 @override
11130 int get hashCode => 2; 11160 int get hashCode => 2;
11131 11161
11132 @override 11162 @override
11133 int internalHashCode(List<DartType> visitedTypes) => hashCode;
11134
11135 @override
11136 bool get isVoid => true; 11163 bool get isVoid => true;
11137 11164
11138 @override 11165 @override
11139 bool operator ==(Object object) => identical(object, this); 11166 bool operator ==(Object object) => identical(object, this);
11140 11167
11141 @override 11168 @override
11142 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => 11169 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) =>
11143 identical(object, this); 11170 identical(object, this);
11144 11171
11145 @override 11172 @override
11173 int internalHashCode(List<DartType> visitedTypes) => hashCode;
11174
11175 @override
11146 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, 11176 bool internalIsMoreSpecificThan(DartType type, bool withDynamic,
11147 Set<TypeImpl_TypePair> visitedTypePairs) => 11177 Set<TypeImpl_TypePair> visitedTypePairs) =>
11148 isSubtypeOf(type); 11178 isSubtypeOf(type);
11149 11179
11150 @override 11180 @override
11151 bool internalIsSubtypeOf(DartType type, 11181 bool internalIsSubtypeOf(DartType type,
11152 Set<TypeImpl_TypePair> visitedTypePairs) { 11182 Set<TypeImpl_TypePair> visitedTypePairs) {
11153 if (type is UnionType) { 11183 if (type is UnionType) {
11154 return (type as UnionTypeImpl).internalUnionTypeIsSuperTypeOf( 11184 return (type as UnionTypeImpl).internalUnionTypeIsSuperTypeOf(
11155 this, 11185 this,
11156 visitedTypePairs); 11186 visitedTypePairs);
11157 } 11187 }
11158 // The only subtype relations that pertain to void are therefore: 11188 // The only subtype relations that pertain to void are therefore:
11159 // void <: void (by reflexivity) 11189 // void <: void (by reflexivity)
11160 // bottom <: void (as bottom is a subtype of all types). 11190 // bottom <: void (as bottom is a subtype of all types).
11161 // void <: dynamic (as dynamic is a supertype of all types) 11191 // void <: dynamic (as dynamic is a supertype of all types)
11162 return identical(type, this) || type.isDynamic; 11192 return identical(type, this) || type.isDynamic;
11163 } 11193 }
11164 11194
11165 @override 11195 @override
11166 VoidTypeImpl substitute2(List<DartType> argumentTypes, 11196 VoidTypeImpl substitute2(List<DartType> argumentTypes,
11167 List<DartType> parameterTypes) => 11197 List<DartType> parameterTypes) =>
11168 this; 11198 this;
11169 } 11199 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/services/search/search_engine_test.dart ('k') | pkg/analyzer/lib/src/generated/element_handle.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698