@microsoft/api-extractor-model
Advanced tools
Comparing version 7.8.22 to 7.9.0
@@ -5,2 +5,14 @@ { | ||
{ | ||
"version": "7.9.0", | ||
"tag": "@microsoft/api-extractor-model_v7.9.0", | ||
"date": "Sun, 13 Sep 2020 01:53:20 GMT", | ||
"comments": { | ||
"minor": [ | ||
{ | ||
"comment": "Add support for system selectors in declaration references" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"version": "7.8.22", | ||
@@ -7,0 +19,0 @@ "tag": "@microsoft/api-extractor-model_v7.8.22", |
# Change Log - @microsoft/api-extractor-model | ||
This log was last generated on Fri, 11 Sep 2020 02:13:35 GMT and should not be manually modified. | ||
This log was last generated on Sun, 13 Sep 2020 01:53:20 GMT and should not be manually modified. | ||
## 7.9.0 | ||
Sun, 13 Sep 2020 01:53:20 GMT | ||
### Minor changes | ||
- Add support for system selectors in declaration references | ||
## 7.8.22 | ||
@@ -6,0 +13,0 @@ Fri, 11 Sep 2020 02:13:35 GMT |
@@ -32,3 +32,5 @@ import { DocDeclarationReference } from '@microsoft/tsdoc'; | ||
resolve(declarationReference: DocDeclarationReference, contextApiItem: ApiItem | undefined): IResolveDeclarationReferenceResult; | ||
private _selectUsingSystemSelector; | ||
private _selectUsingIndexSelector; | ||
} | ||
//# sourceMappingURL=ModelReferenceResolver.d.ts.map |
@@ -73,29 +73,28 @@ "use strict"; | ||
} | ||
if (foundMembers.length > 1) { | ||
if (memberReference.selector && memberReference.selector.selectorKind === "index" /* Index */) { | ||
const selectedMembers = []; | ||
const selectorOverloadIndex = parseInt(memberReference.selector.selector); | ||
for (const foundMember of foundMembers) { | ||
if (ApiParameterListMixin_1.ApiParameterListMixin.isBaseClassOf(foundMember)) { | ||
if (foundMember.overloadIndex === selectorOverloadIndex) { | ||
selectedMembers.push(foundMember); | ||
} | ||
} | ||
} | ||
if (selectedMembers.length === 0) { | ||
result.errorMessage = | ||
`An overload for ${JSON.stringify(identifier)} was not found that matches` + | ||
` the TSDoc selector ":${selectorOverloadIndex}"`; | ||
const memberSelector = memberReference.selector; | ||
if (memberSelector === undefined) { | ||
if (foundMembers.length > 1) { | ||
result.errorMessage = `The member reference ${JSON.stringify(identifier)} was ambiguous`; | ||
return result; | ||
} | ||
currentItem = foundMembers[0]; | ||
} | ||
else { | ||
let memberSelectorResult; | ||
switch (memberSelector.selectorKind) { | ||
case "system" /* System */: | ||
memberSelectorResult = this._selectUsingSystemSelector(foundMembers, memberSelector, identifier); | ||
break; | ||
case "index" /* Index */: | ||
memberSelectorResult = this._selectUsingIndexSelector(foundMembers, memberSelector, identifier); | ||
break; | ||
default: | ||
result.errorMessage = `The selector "${memberSelector.selector}" is not a supported selector type`; | ||
return result; | ||
} | ||
if (selectedMembers.length === 1) { | ||
result.resolvedApiItem = selectedMembers[0]; | ||
return result; | ||
} | ||
} | ||
// TODO: Support other TSDoc selectors | ||
result.errorMessage = `The member reference ${JSON.stringify(identifier)} was ambiguous`; | ||
return result; | ||
if (memberSelectorResult.resolvedApiItem === undefined) { | ||
return memberSelectorResult; | ||
} | ||
currentItem = memberSelectorResult.resolvedApiItem; | ||
} | ||
currentItem = foundMembers[0]; | ||
} | ||
@@ -105,4 +104,77 @@ result.resolvedApiItem = currentItem; | ||
} | ||
_selectUsingSystemSelector(foundMembers, memberSelector, identifier) { | ||
const result = { | ||
resolvedApiItem: undefined, | ||
errorMessage: undefined | ||
}; | ||
const selectorName = memberSelector.selector; | ||
let selectorItemKind; | ||
switch (selectorName) { | ||
case 'class': | ||
selectorItemKind = "Class" /* Class */; | ||
break; | ||
case 'enum': | ||
selectorItemKind = "Enum" /* Enum */; | ||
break; | ||
case 'function': | ||
selectorItemKind = "Function" /* Function */; | ||
break; | ||
case 'interface': | ||
selectorItemKind = "Interface" /* Interface */; | ||
break; | ||
case 'namespace': | ||
selectorItemKind = "Namespace" /* Namespace */; | ||
break; | ||
case 'type': | ||
selectorItemKind = "TypeAlias" /* TypeAlias */; | ||
break; | ||
case 'variable': | ||
selectorItemKind = "Variable" /* Variable */; | ||
break; | ||
default: | ||
result.errorMessage = `Unsupported system selector "${selectorName}"`; | ||
return result; | ||
} | ||
const matches = foundMembers.filter((x) => x.kind === selectorItemKind); | ||
if (matches.length === 0) { | ||
result.errorMessage = | ||
`A declaration for "${identifier}" was not found that matches the` + | ||
` TSDoc selector "${selectorName}"`; | ||
return result; | ||
} | ||
if (matches.length > 1) { | ||
result.errorMessage = `More than one declaration "${identifier}" matches the TSDoc selector "${selectorName}"`; | ||
} | ||
result.resolvedApiItem = matches[0]; | ||
return result; | ||
} | ||
_selectUsingIndexSelector(foundMembers, memberSelector, identifier) { | ||
const result = { | ||
resolvedApiItem: undefined, | ||
errorMessage: undefined | ||
}; | ||
const selectedMembers = []; | ||
const selectorOverloadIndex = parseInt(memberSelector.selector); | ||
for (const foundMember of foundMembers) { | ||
if (ApiParameterListMixin_1.ApiParameterListMixin.isBaseClassOf(foundMember)) { | ||
if (foundMember.overloadIndex === selectorOverloadIndex) { | ||
selectedMembers.push(foundMember); | ||
} | ||
} | ||
} | ||
if (selectedMembers.length === 0) { | ||
result.errorMessage = | ||
`An overload for ${JSON.stringify(identifier)} was not found that matches` + | ||
` the TSDoc selector ":${selectorOverloadIndex}"`; | ||
return result; | ||
} | ||
if (selectedMembers.length === 1) { | ||
result.resolvedApiItem = selectedMembers[0]; | ||
return result; | ||
} | ||
result.errorMessage = `The member reference ${JSON.stringify(identifier)} was ambiguous`; | ||
return result; | ||
} | ||
} | ||
exports.ModelReferenceResolver = ModelReferenceResolver; | ||
//# sourceMappingURL=ModelReferenceResolver.js.map |
{ | ||
"name": "@microsoft/api-extractor-model", | ||
"version": "7.8.22", | ||
"version": "7.9.0", | ||
"description": "A helper library for loading and saving the .api.json files created by API Extractor", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
626130
8543