| 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 /** | 5 /** |
| 6 * Data structures representing an API definition, and visitor base classes | 6 * Data structures representing an API definition, and visitor base classes |
| 7 * for visiting those data structures. | 7 * for visiting those data structures. |
| 8 */ | 8 */ |
| 9 library api; | 9 library api; |
| 10 | 10 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 112 |
| 113 void visitTypeObjectField(TypeObjectField typeObjectField) { | 113 void visitTypeObjectField(TypeObjectField typeObjectField) { |
| 114 visitTypeDecl(typeObjectField.type); | 114 visitTypeDecl(typeObjectField.type); |
| 115 } | 115 } |
| 116 | 116 |
| 117 @override | 117 @override |
| 118 void visitTypeReference(TypeReference typeReference) { | 118 void visitTypeReference(TypeReference typeReference) { |
| 119 } | 119 } |
| 120 | 120 |
| 121 /** | 121 /** |
| 122 * If [type] is a [TypeReference] which points to another [TypeReference], | 122 * If [type] is a [TypeReference] that is defined in the API, follow the |
| 123 * follow the chain until the last [TypeReference] is reached. | 123 * chain until a non-[TypeReference] is found, if possible. |
| 124 * |
| 125 * If it is not possible (because the chain ends with a [TypeReference] that |
| 126 * is not defined in the API), then that final [TypeReference] is returned. |
| 124 */ | 127 */ |
| 125 TypeReference resolveTypeReferenceChain(TypeReference type) { | 128 TypeDecl resolveTypeReferenceChain(TypeDecl type) { |
| 126 while (api.types.containsKey(type.typeName)) { | 129 while (type is TypeReference && api.types.containsKey(type.typeName)) { |
| 127 TypeDecl referredType = api.types[type.typeName].type; | 130 type = api.types[(type as TypeReference).typeName].type; |
| 128 if (referredType is TypeReference) { | |
| 129 type = referredType; | |
| 130 continue; | |
| 131 } | |
| 132 break; | |
| 133 } | 131 } |
| 134 return type; | 132 return type; |
| 135 } | 133 } |
| 136 } | 134 } |
| 137 | 135 |
| 138 /** | 136 /** |
| 139 * Base class for objects in the API model. | 137 * Base class for objects in the API model. |
| 140 */ | 138 */ |
| 141 class ApiNode { | 139 class ApiNode { |
| 142 /** | 140 /** |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 } | 438 } |
| 441 | 439 |
| 442 /** | 440 /** |
| 443 * Description of a single allowed value for an enum. | 441 * Description of a single allowed value for an enum. |
| 444 */ | 442 */ |
| 445 class TypeEnumValue extends ApiNode { | 443 class TypeEnumValue extends ApiNode { |
| 446 final String value; | 444 final String value; |
| 447 | 445 |
| 448 TypeEnumValue(this.value, dom.Element html) : super(html); | 446 TypeEnumValue(this.value, dom.Element html) : super(html); |
| 449 } | 447 } |
| OLD | NEW |