|
1 | 1 | // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. |
2 | 2 | // See LICENSE in the project root for license information. |
3 | 3 |
|
4 | | -import { DocDeclarationReference } from '@microsoft/tsdoc'; |
| 4 | +import { DocDeclarationReference, SelectorKind } from '@microsoft/tsdoc'; |
5 | 5 | import { ApiItem } from '../items/ApiItem'; |
6 | 6 | import { ApiModel } from './ApiModel'; |
7 | 7 | import { ApiPackage } from './ApiPackage'; |
8 | 8 | import { ApiEntryPoint } from './ApiEntryPoint'; |
9 | 9 | import { ApiItemContainerMixin } from '../mixins/ApiItemContainerMixin'; |
| 10 | +import { ApiParameterListMixin } from '../mixins/ApiParameterListMixin'; |
10 | 11 |
|
11 | 12 | /** |
12 | 13 | * Result object for {@link ApiModel.resolveDeclarationReference}. |
@@ -108,7 +109,31 @@ export class ModelReferenceResolver { |
108 | 109 | return result; |
109 | 110 | } |
110 | 111 | if (foundMembers.length > 1) { |
111 | | - // TODO: Support TSDoc selectors |
| 112 | + if (memberReference.selector && memberReference.selector.selectorKind === SelectorKind.Index) { |
| 113 | + const selectedMembers: ApiItem[] = []; |
| 114 | + |
| 115 | + const selectorOverloadIndex: number = parseInt(memberReference.selector.selector); |
| 116 | + for (const foundMember of foundMembers) { |
| 117 | + if (ApiParameterListMixin.isBaseClassOf(foundMember)) { |
| 118 | + if (foundMember.overloadIndex === selectorOverloadIndex) { |
| 119 | + selectedMembers.push(foundMember); |
| 120 | + } |
| 121 | + } |
| 122 | + } |
| 123 | + |
| 124 | + if (selectedMembers.length === 0) { |
| 125 | + result.errorMessage = `An overload for ${JSON.stringify(identifier)} was not found that matches` |
| 126 | + + ` the TSDoc selector ":${selectorOverloadIndex}"`; |
| 127 | + return result; |
| 128 | + } |
| 129 | + |
| 130 | + if (selectedMembers.length === 1) { |
| 131 | + result.resolvedApiItem = selectedMembers[0]; |
| 132 | + return result; |
| 133 | + } |
| 134 | + } |
| 135 | + |
| 136 | + // TODO: Support other TSDoc selectors |
112 | 137 | result.errorMessage = `The member reference ${JSON.stringify(identifier)} was ambiguous` ; |
113 | 138 | return result; |
114 | 139 | } |
|
0 commit comments