Skip to content

Commit

Permalink
feat: function declaration expose position
Browse files Browse the repository at this point in the history
  • Loading branch information
plantain-00 committed Jan 22, 2022
1 parent 899ccac commit 214adad
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
20 changes: 20 additions & 0 deletions demo/debug.json
Original file line number Diff line number Diff line change
Expand Up @@ -3992,6 +3992,11 @@
"comment": "pet"
}
],
"position": {
"file": "demo/cases.ts",
"line": 428,
"character": 0
},
"method": "get",
"path": "/pet/{id}",
"summary": "get pet by id.",
Expand Down Expand Up @@ -4669,6 +4674,11 @@
"comment": "/download"
}
],
"position": {
"file": "demo/cases.ts",
"line": 546,
"character": 0
},
"method": "get",
"path": "/download"
},
Expand Down Expand Up @@ -4698,6 +4708,11 @@
"comment": "/empty"
}
],
"position": {
"file": "demo/cases.ts",
"line": 552,
"character": 0
},
"method": "get",
"path": "/empty"
},
Expand Down Expand Up @@ -4750,6 +4765,11 @@
"comment": "/upload"
}
],
"position": {
"file": "demo/cases.ts",
"line": 558,
"character": 1
},
"method": "post",
"path": "/upload"
},
Expand Down
1 change: 1 addition & 0 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export class Parser {
parameters: declaration.parameters.map((parameter) => this.handleFunctionParameter(parameter, sourceFile)),
comments,
jsDocs,
position: this.getPosition(declaration, sourceFile),
}
for (const jsDoc of jsDocs || []) {
if (jsDoc.comment) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export type ReferenceDeclaration = ReferenceType & {
newName: string;
}

export interface FunctionDeclaration extends JsDocAndComment {
export interface FunctionDeclaration extends Position, JsDocAndComment {
kind: 'function';
name: string;
type: Type;
Expand Down

0 comments on commit 214adad

Please sign in to comment.