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

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

Issue 736603005: Rollback r41807. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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';
(...skipping 2381 matching lines...) Expand 10 before | Expand all | Expand 10 after
2392 return type; 2392 return type;
2393 } 2393 }
2394 } 2394 }
2395 return null; 2395 return null;
2396 } 2396 }
2397 2397
2398 @override 2398 @override
2399 void visitChildren(ElementVisitor visitor) { 2399 void visitChildren(ElementVisitor visitor) {
2400 super.visitChildren(visitor); 2400 super.visitChildren(visitor);
2401 safelyVisitChildren(_accessors, visitor); 2401 safelyVisitChildren(_accessors, visitor);
2402 safelyVisitChildren(_enums, visitor);
2403 safelyVisitChildren(_functions, visitor); 2402 safelyVisitChildren(_functions, visitor);
2404 safelyVisitChildren(_typeAliases, visitor); 2403 safelyVisitChildren(_typeAliases, visitor);
2405 safelyVisitChildren(_types, visitor); 2404 safelyVisitChildren(_types, visitor);
2406 safelyVisitChildren(_variables, visitor); 2405 safelyVisitChildren(_variables, visitor);
2407 safelyVisitChildren(_angularViews, visitor); 2406 safelyVisitChildren(_angularViews, visitor);
2408 } 2407 }
2409 2408
2410 /** 2409 /**
2411 * Returns the associated toolkit objects. 2410 * Returns the associated toolkit objects.
2412 * 2411 *
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
2966 * of this class should be accessed through the method [getInstance]. 2965 * of this class should be accessed through the method [getInstance].
2967 */ 2966 */
2968 DynamicElementImpl() : super(Keyword.DYNAMIC.syntax, -1) { 2967 DynamicElementImpl() : super(Keyword.DYNAMIC.syntax, -1) {
2969 setModifier(Modifier.SYNTHETIC, true); 2968 setModifier(Modifier.SYNTHETIC, true);
2970 } 2969 }
2971 2970
2972 @override 2971 @override
2973 ElementKind get kind => ElementKind.DYNAMIC; 2972 ElementKind get kind => ElementKind.DYNAMIC;
2974 2973
2975 @override 2974 @override
2976 ElementLocation get location {
2977 return new DartElementLocation(null, null, nameOffset, kind);
2978 }
2979
2980 @override
2981 accept(ElementVisitor visitor) => null; 2975 accept(ElementVisitor visitor) => null;
2982 } 2976 }
2983 2977
2984 /** 2978 /**
2985 * The unique instance of the class `DynamicTypeImpl` implements the type `dynam ic`. 2979 * The unique instance of the class `DynamicTypeImpl` implements the type `dynam ic`.
2986 */ 2980 */
2987 class DynamicTypeImpl extends TypeImpl { 2981 class DynamicTypeImpl extends TypeImpl {
2988 /** 2982 /**
2989 * The unique instance of this class. 2983 * The unique instance of this class.
2990 */ 2984 */
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
3558 bool get isPublic => !isPrivate; 3552 bool get isPublic => !isPrivate;
3559 3553
3560 @override 3554 @override
3561 bool get isSynthetic => hasModifier(Modifier.SYNTHETIC); 3555 bool get isSynthetic => hasModifier(Modifier.SYNTHETIC);
3562 3556
3563 @override 3557 @override
3564 LibraryElement get library => 3558 LibraryElement get library =>
3565 getAncestor((element) => element is LibraryElement); 3559 getAncestor((element) => element is LibraryElement);
3566 3560
3567 @override 3561 @override
3568 ElementLocation get location { 3562 ElementLocation get location => new ElementLocationImpl.con1(this);
3569 // TODO(scheglov) add separate DartElementImpl
3570 LibraryElement library = this.library;
3571 if (library == null) {
3572 return new DartElementLocation(null, null, nameOffset, kind);
3573 }
3574 String librarySourceEncoding = library.source.encoding;
3575 String unitSourceEncoding = source.encoding;
3576 return new DartElementLocation(
3577 librarySourceEncoding,
3578 unitSourceEncoding,
3579 nameOffset,
3580 kind);
3581 }
3582 3563
3583 @override 3564 @override
3584 String get name => _name; 3565 String get name => _name;
3585 3566
3586 @override 3567 @override
3587 AstNode get node => getNodeMatching((node) => node is AstNode); 3568 AstNode get node => getNodeMatching((node) => node is AstNode);
3588 3569
3589 @override 3570 @override
3590 Source get source { 3571 Source get source {
3591 if (_enclosingElement == null) { 3572 if (_enclosingElement == null) {
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
3925 */ 3906 */
3926 static ElementKind of(Element element) { 3907 static ElementKind of(Element element) {
3927 if (element == null) { 3908 if (element == null) {
3928 return ERROR; 3909 return ERROR;
3929 } 3910 }
3930 return element.kind; 3911 return element.kind;
3931 } 3912 }
3932 } 3913 }
3933 3914
3934 /** 3915 /**
3935 * The interface `ElementLocation` defines the behavior of objects that 3916 * The interface `ElementLocation` defines the behavior of objects that represen t the location
3936 * represent the location of an element within the element model. 3917 * of an element within the element model.
3937 */ 3918 */
3938 abstract class ElementLocation { 3919 abstract class ElementLocation {
3920 /**
3921 * Return the path to the element whose location is represented by this object . Clients must not
3922 * modify the returned array.
3923 *
3924 * @return the path to the element whose location is represented by this objec t
3925 */
3926 List<String> get components;
3927
3928 /**
3929 * Return an encoded representation of this location that can be used to creat e a location that is
3930 * equal to this location.
3931 *
3932 * @return an encoded representation of this location
3933 */
3934 String get encoding;
3939 } 3935 }
3940 3936
3941 /** 3937 /**
3942 * The interface `DartElementLocation` defines the behavior of objects that 3938 * Instances of the class `ElementLocationImpl` implement an [ElementLocation].
3943 * represent the location of a Dart element within the element model.
3944 */ 3939 */
3945 class DartElementLocation implements ElementLocation { 3940 class ElementLocationImpl implements ElementLocation {
3946 /** 3941 /**
3947 * An encoded representation of the library source that contains this element. 3942 * The character used to separate components in the encoded form.
3948 */ 3943 */
3949 final String librarySourceEncoding; 3944 static int _SEPARATOR_CHAR = 0x3B;
3950 3945
3951 /** 3946 /**
3952 * An encoded representation of the unit source that contains this element. 3947 * The path to the element whose location is represented by this object.
3953 */ 3948 */
3954 final String unitSourceEncoding; 3949 List<String> _components;
3955 3950
3956 /** 3951 /**
3957 * The offset of the name of this element in the file that contains 3952 * Initialize a newly created location to represent the given element.
3958 * the declaration of this element, or `-1` if this element is synthetic, 3953 *
3959 * does not have a name, or otherwise does not have an offset. 3954 * @param element the element whose location is being represented
3960 */ 3955 */
3961 final int nameOffset; 3956 ElementLocationImpl.con1(Element element) {
3957 List<String> components = new List<String>();
3958 Element ancestor = element;
3959 while (ancestor != null) {
3960 components.insert(0, (ancestor as ElementImpl).identifier);
3961 ancestor = ancestor.enclosingElement;
3962 }
3963 this._components = components;
3964 }
3962 3965
3963 /** 3966 /**
3964 * The kind of this element. 3967 * Initialize a newly created location from the given encoded form.
3968 *
3969 * @param encoding the encoded form of a location
3965 */ 3970 */
3966 final ElementKind kind; 3971 ElementLocationImpl.con2(String encoding) {
3972 this._components = _decode(encoding);
3973 }
3967 3974
3968 DartElementLocation(this.librarySourceEncoding, this.unitSourceEncoding, 3975 /**
3969 this.nameOffset, this.kind); 3976 * Initialize a newly created location from the given components.
3977 *
3978 * @param components the components of a location
3979 */
3980 ElementLocationImpl.con3(List<String> components) {
3981 this._components = components;
3982 }
3970 3983
3971 @override 3984 @override
3972 bool operator ==(Object other) { 3985 List<String> get components => _components;
3973 if (other is DartElementLocation) { 3986
3974 return other.librarySourceEncoding == librarySourceEncoding && 3987 @override
3975 other.unitSourceEncoding == unitSourceEncoding && 3988 String get encoding {
3976 other.nameOffset == nameOffset && 3989 StringBuffer buffer = new StringBuffer();
3977 other.kind == kind; 3990 int length = _components.length;
3991 for (int i = 0; i < length; i++) {
3992 if (i > 0) {
3993 buffer.writeCharCode(_SEPARATOR_CHAR);
3994 }
3995 _encode(buffer, _components[i]);
3978 } 3996 }
3979 return false; 3997 return buffer.toString();
3998 }
3999
4000 @override
4001 int get hashCode {
4002 int result = 1;
4003 for (int i = 0; i < _components.length; i++) {
4004 String component = _components[i];
4005 result = 31 * result + component.hashCode;
4006 }
4007 return result;
4008 }
4009
4010 @override
4011 bool operator ==(Object object) {
4012 if (identical(this, object)) {
4013 return true;
4014 }
4015 if (object is! ElementLocationImpl) {
4016 return false;
4017 }
4018 ElementLocationImpl location = object as ElementLocationImpl;
4019 List<String> otherComponents = location._components;
4020 int length = _components.length;
4021 if (otherComponents.length != length) {
4022 return false;
4023 }
4024 for (int i = 0; i < length; i++) {
4025 if (_components[i] != otherComponents[i]) {
4026 return false;
4027 }
4028 }
4029 return true;
4030 }
4031
4032 @override
4033 String toString() => encoding;
4034
4035 /**
4036 * Decode the encoded form of a location into an array of components.
4037 *
4038 * @param encoding the encoded form of a location
4039 * @return the components that were encoded
4040 */
4041 List<String> _decode(String encoding) {
4042 List<String> components = new List<String>();
4043 StringBuffer buffer = new StringBuffer();
4044 int index = 0;
4045 int length = encoding.length;
4046 while (index < length) {
4047 int currentChar = encoding.codeUnitAt(index);
4048 if (currentChar == _SEPARATOR_CHAR) {
4049 if (index + 1 < length &&
4050 encoding.codeUnitAt(index + 1) == _SEPARATOR_CHAR) {
4051 buffer.writeCharCode(_SEPARATOR_CHAR);
4052 index += 2;
4053 } else {
4054 components.add(buffer.toString());
4055 buffer = new StringBuffer();
4056 index++;
4057 }
4058 } else {
4059 buffer.writeCharCode(currentChar);
4060 index++;
4061 }
4062 }
4063 components.add(buffer.toString());
4064 return components;
4065 }
4066
4067 /**
4068 * Append an encoded form of the given component to the given builder.
4069 *
4070 * @param builder the builder to which the encoded component is to be appended
4071 * @param component the component to be appended to the builder
4072 */
4073 void _encode(StringBuffer buffer, String component) {
4074 int length = component.length;
4075 for (int i = 0; i < length; i++) {
4076 int currentChar = component.codeUnitAt(i);
4077 if (currentChar == _SEPARATOR_CHAR) {
4078 buffer.writeCharCode(_SEPARATOR_CHAR);
4079 }
4080 buffer.writeCharCode(currentChar);
4081 }
3980 } 4082 }
3981 } 4083 }
3982 4084
3983 /** 4085 /**
3984 * The class `ElementPair` is a pair of [Element]s. [Object.==] and 4086 * The class `ElementPair` is a pair of [Element]s. [Object.==] and
3985 * [Object.hashCode] so this class can be used in hashed data structures. 4087 * [Object.hashCode] so this class can be used in hashed data structures.
3986 */ 4088 */
3987 class ElementPair { 4089 class ElementPair {
3988 /** 4090 /**
3989 * The first [Element] 4091 * The first [Element]
(...skipping 4490 matching lines...) Expand 10 before | Expand all | Expand 10 after
8480 } 8582 }
8481 } 8583 }
8482 for (ExportElement exportElement in _exports) { 8584 for (ExportElement exportElement in _exports) {
8483 if ((exportElement as ExportElementImpl).identifier == identifier) { 8585 if ((exportElement as ExportElementImpl).identifier == identifier) {
8484 return exportElement as ExportElementImpl; 8586 return exportElement as ExportElementImpl;
8485 } 8587 }
8486 } 8588 }
8487 return null; 8589 return null;
8488 } 8590 }
8489 8591
8490 /**
8491 * Returns the child [Element] of this library.
8492 *
8493 * [unitSourceEncoding] - the encoding of the unit.
8494 * [offset] - the name offset of the element.
8495 * [kind] - the kind of the element.
8496 */
8497 ElementImpl getChildElement(String unitSourceEncoding, int offset,
8498 ElementKind kind) {
8499 for (CompilationUnitElement unit in units) {
8500 if (unit.source.encoding == unitSourceEncoding) {
8501 ElementImpl element = _findElementAt(unit, offset, kind);
8502 if (element != null) {
8503 return element;
8504 }
8505 break;
8506 }
8507 }
8508 for (ImportElement importElement in _imports) {
8509 if (importElement.nameOffset == offset) {
8510 return importElement as ImportElementImpl;
8511 }
8512 }
8513 for (ExportElement exportElement in _exports) {
8514 if (exportElement.nameOffset == offset) {
8515 return exportElement as ExportElementImpl;
8516 }
8517 }
8518 return null;
8519 }
8520
8521 ElementImpl _findElementAt(CompilationUnitElement unit, int offset,
8522 ElementKind kind) {
8523 if (offset == -1) {
8524 return unit as ElementImpl;
8525 }
8526 _FindElementAt visitor = new _FindElementAt(offset, kind);
8527 try {
8528 unit.accept(visitor);
8529 } on _FindElementAtDone catch (e) {
8530 return visitor.result;
8531 }
8532 return null;
8533 }
8534
8535 @override 8592 @override
8536 List<ImportElement> getImportsWithPrefix(PrefixElement prefixElement) { 8593 List<ImportElement> getImportsWithPrefix(PrefixElement prefixElement) {
8537 int count = _imports.length; 8594 int count = _imports.length;
8538 List<ImportElement> importList = new List<ImportElement>(); 8595 List<ImportElement> importList = new List<ImportElement>();
8539 for (int i = 0; i < count; i++) { 8596 for (int i = 0; i < count; i++) {
8540 if (identical(_imports[i].prefix, prefixElement)) { 8597 if (identical(_imports[i].prefix, prefixElement)) {
8541 importList.add(_imports[i]); 8598 importList.add(_imports[i]);
8542 } 8599 }
8543 } 8600 }
8544 return importList; 8601 return importList;
(...skipping 3861 matching lines...) Expand 10 before | Expand all | Expand 10 after
12406 // bottom <: void (as bottom is a subtype of all types). 12463 // bottom <: void (as bottom is a subtype of all types).
12407 // void <: dynamic (as dynamic is a supertype of all types) 12464 // void <: dynamic (as dynamic is a supertype of all types)
12408 return identical(type, this) || type.isDynamic; 12465 return identical(type, this) || type.isDynamic;
12409 } 12466 }
12410 12467
12411 @override 12468 @override
12412 VoidTypeImpl substitute2(List<DartType> argumentTypes, 12469 VoidTypeImpl substitute2(List<DartType> argumentTypes,
12413 List<DartType> parameterTypes) => 12470 List<DartType> parameterTypes) =>
12414 this; 12471 this;
12415 } 12472 }
12416
12417
12418 class _FindElementAt extends GeneralizingElementVisitor {
12419 final int offset;
12420 final ElementKind kind;
12421 Element result;
12422
12423 _FindElementAt(this.offset, this.kind);
12424
12425 @override
12426 visitElement(Element element) {
12427 if (element.nameOffset == offset && element.kind == kind) {
12428 result = element;
12429 throw new _FindElementAtDone();
12430 }
12431 super.visitElement(element);
12432 }
12433 }
12434
12435
12436 class _FindElementAtDone {
12437 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/services/index/store/split_store_test.dart ('k') | pkg/analyzer/lib/src/generated/engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698