1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.getFunctionHeadLoc = void 0;
|
4 | const utils_1 = require("@typescript-eslint/utils");
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | function getFunctionHeadLoc(node, sourceCode) {
|
23 | function getLocStart() {
|
24 | if (node.parent && node.parent.type === utils_1.AST_NODE_TYPES.MethodDefinition) {
|
25 |
|
26 | if (node.parent.decorators && node.parent.decorators.length > 0) {
|
27 |
|
28 | return sourceCode.getTokenAfter(node.parent.decorators[node.parent.decorators.length - 1]).loc.start;
|
29 | }
|
30 | return node.parent.loc.start;
|
31 | }
|
32 | if (node.parent &&
|
33 | node.parent.type === utils_1.AST_NODE_TYPES.Property &&
|
34 | node.parent.method) {
|
35 |
|
36 | return node.parent.loc.start;
|
37 | }
|
38 |
|
39 | return node.loc.start;
|
40 | }
|
41 | function getLocEnd() {
|
42 | if (node.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression) {
|
43 |
|
44 | return sourceCode.getTokenBefore(node.body, token => token.type === utils_1.AST_TOKEN_TYPES.Punctuator && token.value === '=>').loc.end;
|
45 | }
|
46 |
|
47 | return sourceCode.getTokenBefore(node.body).loc.end;
|
48 | }
|
49 | return {
|
50 | start: getLocStart(),
|
51 | end: getLocEnd(),
|
52 | };
|
53 | }
|
54 | exports.getFunctionHeadLoc = getFunctionHeadLoc;
|
55 |
|
\ | No newline at end of file |