| 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 engine.element; | 5 library engine.element; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/utilities_general.dart'; | 9 import 'package:analyzer/src/generated/utilities_general.dart'; |
| 10 import 'package:analyzer/src/task/dart.dart'; | 10 import 'package:analyzer/src/task/dart.dart'; |
| (...skipping 2444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2455 * Return the display name of this element, or `null` if this element does not | 2455 * Return the display name of this element, or `null` if this element does not |
| 2456 * have a name. | 2456 * have a name. |
| 2457 * | 2457 * |
| 2458 * In most cases the name and the display name are the same. Differences | 2458 * In most cases the name and the display name are the same. Differences |
| 2459 * though are cases such as setters where the name of some setter `set f(x)` | 2459 * though are cases such as setters where the name of some setter `set f(x)` |
| 2460 * is `f=`, instead of `f`. | 2460 * is `f=`, instead of `f`. |
| 2461 */ | 2461 */ |
| 2462 String get displayName; | 2462 String get displayName; |
| 2463 | 2463 |
| 2464 /** | 2464 /** |
| 2465 * Return the source range of the documentation comment for this element, |
| 2466 * or `null` if this element does not or cannot have a documentation. |
| 2467 */ |
| 2468 SourceRange get docRange; |
| 2469 |
| 2470 /** |
| 2465 * Return the element that either physically or logically encloses this | 2471 * Return the element that either physically or logically encloses this |
| 2466 * element. This will be `null` if this element is a library because libraries | 2472 * element. This will be `null` if this element is a library because libraries |
| 2467 * are the top-level elements in the model. | 2473 * are the top-level elements in the model. |
| 2468 */ | 2474 */ |
| 2469 Element get enclosingElement; | 2475 Element get enclosingElement; |
| 2470 | 2476 |
| 2471 /** | 2477 /** |
| 2472 * The unique integer identifier of this element. | 2478 * The unique integer identifier of this element. |
| 2473 */ | 2479 */ |
| 2474 int get id; | 2480 int get id; |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2821 * A cached copy of the calculated hashCode for this element. | 2827 * A cached copy of the calculated hashCode for this element. |
| 2822 */ | 2828 */ |
| 2823 int _cachedHashCode; | 2829 int _cachedHashCode; |
| 2824 | 2830 |
| 2825 /** | 2831 /** |
| 2826 * A cached copy of the calculated location for this element. | 2832 * A cached copy of the calculated location for this element. |
| 2827 */ | 2833 */ |
| 2828 ElementLocation _cachedLocation; | 2834 ElementLocation _cachedLocation; |
| 2829 | 2835 |
| 2830 /** | 2836 /** |
| 2837 * The offset to the beginning of the documentation comment, |
| 2838 * or `null` if this element does not have a documentation comment. |
| 2839 */ |
| 2840 int _docRangeOffset; |
| 2841 |
| 2842 /** |
| 2843 * The length of the documentation comment range for this element. |
| 2844 */ |
| 2845 int _docRangeLength; |
| 2846 |
| 2847 /** |
| 2831 * Initialize a newly created element to have the given [name] at the given | 2848 * Initialize a newly created element to have the given [name] at the given |
| 2832 * [_nameOffset]. | 2849 * [_nameOffset]. |
| 2833 */ | 2850 */ |
| 2834 ElementImpl(String name, this._nameOffset) { | 2851 ElementImpl(String name, this._nameOffset) { |
| 2835 this._name = StringUtilities.intern(name); | 2852 this._name = StringUtilities.intern(name); |
| 2836 } | 2853 } |
| 2837 | 2854 |
| 2838 /** | 2855 /** |
| 2839 * Initialize a newly created element to have the given [name]. | 2856 * Initialize a newly created element to have the given [name]. |
| 2840 */ | 2857 */ |
| 2841 ElementImpl.forNode(Identifier name) | 2858 ElementImpl.forNode(Identifier name) |
| 2842 : this(name == null ? "" : name.name, name == null ? -1 : name.offset); | 2859 : this(name == null ? "" : name.name, name == null ? -1 : name.offset); |
| 2843 | 2860 |
| 2844 @override | 2861 @override |
| 2845 AnalysisContext get context { | 2862 AnalysisContext get context { |
| 2846 if (_enclosingElement == null) { | 2863 if (_enclosingElement == null) { |
| 2847 return null; | 2864 return null; |
| 2848 } | 2865 } |
| 2849 return _enclosingElement.context; | 2866 return _enclosingElement.context; |
| 2850 } | 2867 } |
| 2851 | 2868 |
| 2852 @override | 2869 @override |
| 2853 String get displayName => _name; | 2870 String get displayName => _name; |
| 2854 | 2871 |
| 2855 @override | 2872 @override |
| 2873 SourceRange get docRange { |
| 2874 if (_docRangeOffset != null && _docRangeLength != null) { |
| 2875 return new SourceRange(_docRangeOffset, _docRangeLength); |
| 2876 } |
| 2877 return null; |
| 2878 } |
| 2879 |
| 2880 @override |
| 2856 Element get enclosingElement => _enclosingElement; | 2881 Element get enclosingElement => _enclosingElement; |
| 2857 | 2882 |
| 2858 /** | 2883 /** |
| 2859 * Set the enclosing element of this element to the given [element]. | 2884 * Set the enclosing element of this element to the given [element]. |
| 2860 */ | 2885 */ |
| 2861 void set enclosingElement(Element element) { | 2886 void set enclosingElement(Element element) { |
| 2862 _enclosingElement = element as ElementImpl; | 2887 _enclosingElement = element as ElementImpl; |
| 2863 _cachedLocation = null; | 2888 _cachedLocation = null; |
| 2864 _cachedHashCode = null; | 2889 _cachedHashCode = null; |
| 2865 } | 2890 } |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3095 */ | 3120 */ |
| 3096 void safelyVisitChildren(List<Element> children, ElementVisitor visitor) { | 3121 void safelyVisitChildren(List<Element> children, ElementVisitor visitor) { |
| 3097 if (children != null) { | 3122 if (children != null) { |
| 3098 for (Element child in children) { | 3123 for (Element child in children) { |
| 3099 child.accept(visitor); | 3124 child.accept(visitor); |
| 3100 } | 3125 } |
| 3101 } | 3126 } |
| 3102 } | 3127 } |
| 3103 | 3128 |
| 3104 /** | 3129 /** |
| 3130 * Set the documentation comment source range for this element. |
| 3131 */ |
| 3132 void setDocRange(int offset, int length) { |
| 3133 _docRangeOffset = offset; |
| 3134 _docRangeLength = length; |
| 3135 } |
| 3136 |
| 3137 /** |
| 3105 * Set whether the given [modifier] is associated with this element to | 3138 * Set whether the given [modifier] is associated with this element to |
| 3106 * correspond to the given [value]. | 3139 * correspond to the given [value]. |
| 3107 */ | 3140 */ |
| 3108 void setModifier(Modifier modifier, bool value) { | 3141 void setModifier(Modifier modifier, bool value) { |
| 3109 _modifiers = BooleanArray.setEnum(_modifiers, modifier, value); | 3142 _modifiers = BooleanArray.setEnum(_modifiers, modifier, value); |
| 3110 } | 3143 } |
| 3111 | 3144 |
| 3112 @override | 3145 @override |
| 3113 String toString() { | 3146 String toString() { |
| 3114 StringBuffer buffer = new StringBuffer(); | 3147 StringBuffer buffer = new StringBuffer(); |
| (...skipping 4795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7910 AnalysisContext get context => _baseElement.context; | 7943 AnalysisContext get context => _baseElement.context; |
| 7911 | 7944 |
| 7912 /** | 7945 /** |
| 7913 * Return the type in which the element is defined. | 7946 * Return the type in which the element is defined. |
| 7914 */ | 7947 */ |
| 7915 ParameterizedType get definingType => _definingType; | 7948 ParameterizedType get definingType => _definingType; |
| 7916 | 7949 |
| 7917 @override | 7950 @override |
| 7918 String get displayName => _baseElement.displayName; | 7951 String get displayName => _baseElement.displayName; |
| 7919 | 7952 |
| 7953 @override |
| 7954 SourceRange get docRange => _baseElement.docRange; |
| 7955 |
| 7920 int get id => _baseElement.id; | 7956 int get id => _baseElement.id; |
| 7921 | 7957 |
| 7922 @override | 7958 @override |
| 7923 bool get isDeprecated => _baseElement.isDeprecated; | 7959 bool get isDeprecated => _baseElement.isDeprecated; |
| 7924 | 7960 |
| 7925 @override | 7961 @override |
| 7926 bool get isOverride => _baseElement.isOverride; | 7962 bool get isOverride => _baseElement.isOverride; |
| 7927 | 7963 |
| 7928 @override | 7964 @override |
| 7929 bool get isPrivate => _baseElement.isPrivate; | 7965 bool get isPrivate => _baseElement.isPrivate; |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8420 * list of [conflictingElements]. | 8456 * list of [conflictingElements]. |
| 8421 */ | 8457 */ |
| 8422 MultiplyDefinedElementImpl(this.context, this.conflictingElements) { | 8458 MultiplyDefinedElementImpl(this.context, this.conflictingElements) { |
| 8423 _name = conflictingElements[0].name; | 8459 _name = conflictingElements[0].name; |
| 8424 } | 8460 } |
| 8425 | 8461 |
| 8426 @override | 8462 @override |
| 8427 String get displayName => _name; | 8463 String get displayName => _name; |
| 8428 | 8464 |
| 8429 @override | 8465 @override |
| 8466 SourceRange get docRange => null; |
| 8467 |
| 8468 @override |
| 8430 Element get enclosingElement => null; | 8469 Element get enclosingElement => null; |
| 8431 | 8470 |
| 8432 @override | 8471 @override |
| 8433 bool get isDeprecated => false; | 8472 bool get isDeprecated => false; |
| 8434 | 8473 |
| 8435 @override | 8474 @override |
| 8436 bool get isOverride => false; | 8475 bool get isOverride => false; |
| 8437 | 8476 |
| 8438 @override | 8477 @override |
| 8439 bool get isPrivate { | 8478 bool get isPrivate { |
| (...skipping 2365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10805 | 10844 |
| 10806 @override | 10845 @override |
| 10807 void visitElement(Element element) { | 10846 void visitElement(Element element) { |
| 10808 int offset = element.nameOffset; | 10847 int offset = element.nameOffset; |
| 10809 if (offset != -1) { | 10848 if (offset != -1) { |
| 10810 map[offset] = element; | 10849 map[offset] = element; |
| 10811 } | 10850 } |
| 10812 super.visitElement(element); | 10851 super.visitElement(element); |
| 10813 } | 10852 } |
| 10814 } | 10853 } |
| OLD | NEW |