Skip to content

Commit

Permalink
feat: Detect deprecated function overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomByte committed Sep 5, 2024
1 parent 4da7aa4 commit b11fc72
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/linter/ui5Types/SourceFileLinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ export default class SourceFileLinter {
return deprecatedTag.text?.reduce((acc, text) => acc + text.text, "").split("\n\n")[0] ?? "";
}

getDeprecationInfo(symbol: ts.Symbol | undefined): DeprecationInfo | null {
getDeprecationInfo(symbol: ts.Symbol | undefined, signature?: ts.Signature): DeprecationInfo | null {
if (symbol && this.isSymbolOfUi5Type(symbol)) {
const jsdocTags = symbol.getJsDocTags(this.#checker);
const jsdocTags = (signature ?? symbol).getJsDocTags(this.#checker);
const deprecatedTag = jsdocTags.find((tag) => tag.name === "deprecated");
if (deprecatedTag) {
const deprecationInfo: DeprecationInfo = {
Expand Down Expand Up @@ -286,7 +286,9 @@ export default class SourceFileLinter {
throw new Error(`Unhandled CallExpression expression syntax: ${ts.SyntaxKind[exprNode.kind]}`);
}

const deprecationInfo = this.getDeprecationInfo(exprType.symbol);
const signature = this.#checker.getResolvedSignature(node);
const deprecationInfo = this.getDeprecationInfo(exprType.symbol, signature);

if (!deprecationInfo) {
return;
}
Expand Down Expand Up @@ -454,6 +456,20 @@ export default class SourceFileLinter {
return; // Already analyzed in context of call expression
}

const nodeType = this.#checker.getTypeAtLocation(node);
const signatures = nodeType.getCallSignatures();
if (signatures) {
const allSignaturesDeprecated = signatures.every((signature) => {
signature.getJsDocTags().some((tag) => {
return tag.name === "deprecated";
});
});

if (!allSignaturesDeprecated) {
return;
}
}

const deprecationInfo = this.getDeprecationInfoForAccess(node);
if (deprecationInfo) {
if (this.isSymbolOfJquerySapType(deprecationInfo.symbol)) {
Expand Down

0 comments on commit b11fc72

Please sign in to comment.