Skip to content

Commit

Permalink
feat: update function name
Browse files Browse the repository at this point in the history
  • Loading branch information
lit26 committed Feb 13, 2024
1 parent e3eed25 commit 746ee88
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions lib/plugin/utils/ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,24 +228,25 @@ export function getTsDocTagsOfNode(node: Node, typeChecker: TypeChecker) {
return tagResults;
}

export function getTsDocReturnsOrErrorOfNode(node: Node) {
export function getTsDocErrorsOfNode(node: Node) {
const tsdocParser: TSDocParser = new TSDocParser();
const parserContext: ParserContext = tsdocParser.parseString(
node.getFullText()
);
const docComment: DocComment = parserContext.docComment;

const tagResults = [];
const errorParsingRegex = /{(\d+)} (.*)/;

const introspectTsDocTags = (docComment: DocComment) => {
const blocks = docComment.customBlocks.filter((block) =>
['@throws', '@returns'].includes(block.blockTag.tagName)
const blocks = docComment.customBlocks.filter(
(block) => block.blockTag.tagName === '@throws'
);

blocks.forEach((block) => {
try {
const docValue = renderDocNode(block.content).split('\n')[0].trim();
const regex = /{(\d+)} (.*)/;
const match = docValue.match(regex);
const match = docValue.match(errorParsingRegex);
tagResults.push({
status: match[1],
description: `"${match[2]}"`
Expand Down
4 changes: 2 additions & 2 deletions lib/plugin/visitors/controller-class.visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
getDecoratorArguments,
getDecoratorName,
getMainCommentOfNode,
getTsDocReturnsOrErrorOfNode,
getTsDocErrorsOfNode,
getTsDocTagsOfNode
} from '../utils/ast-utils';
import {
Expand Down Expand Up @@ -353,7 +353,7 @@ export class ControllerClassVisitor extends AbstractFileVisitor {
}
}

const tags = getTsDocReturnsOrErrorOfNode(node);
const tags = getTsDocErrorsOfNode(node);
if (!tags.length) {
return [];
}
Expand Down

0 comments on commit 746ee88

Please sign in to comment.