|
1 | 1 | import handlers from './handlers/index.js'; |
2 | 2 |
|
3 | | -import type { ParserOptions } from 'prettier'; |
4 | | -import type { AstNode, Comment } from '../slang-nodes/types.d.ts'; |
| 3 | +import type { Comment } from '../slang-nodes/types.d.ts'; |
5 | 4 |
|
6 | | -function ownLine( |
| 5 | +function handler( |
7 | 6 | comment: Comment, |
8 | | - text: string, |
9 | | - options: ParserOptions<AstNode>, |
10 | | - ast: AstNode, |
11 | | - isLastComment: boolean |
| 7 | + text: string |
| 8 | + // options: ParserOptions<AstNode>, |
| 9 | + // ast: AstNode, |
| 10 | + // isLastComment: boolean |
12 | 11 | ): boolean { |
13 | 12 | const { precedingNode, enclosingNode, followingNode } = comment; |
14 | 13 | const handlerArguments = { |
15 | 14 | text, |
16 | 15 | precedingNode, |
17 | 16 | enclosingNode, |
18 | 17 | followingNode, |
19 | | - comment, |
20 | | - ast, |
21 | | - isLastComment |
| 18 | + comment |
22 | 19 | }; |
23 | 20 |
|
24 | 21 | return handlers.some((handler) => handler(handlerArguments)); |
25 | 22 | } |
26 | 23 |
|
27 | | -function endOfLine( |
28 | | - comment: Comment, |
29 | | - text: string, |
30 | | - options: ParserOptions<AstNode>, |
31 | | - ast: AstNode, |
32 | | - isLastComment: boolean |
33 | | -): boolean { |
34 | | - const { precedingNode, enclosingNode, followingNode } = comment; |
35 | | - const handlerArguments = { |
36 | | - text, |
37 | | - precedingNode, |
38 | | - enclosingNode, |
39 | | - followingNode, |
40 | | - comment, |
41 | | - ast, |
42 | | - isLastComment |
43 | | - }; |
44 | | - |
45 | | - return handlers.some((handler) => handler(handlerArguments)); |
46 | | -} |
47 | | - |
48 | | -function remaining( |
49 | | - comment: Comment, |
50 | | - text: string, |
51 | | - options: ParserOptions<AstNode>, |
52 | | - ast: AstNode, |
53 | | - isLastComment: boolean |
54 | | -): boolean { |
55 | | - const { precedingNode, enclosingNode, followingNode } = comment; |
56 | | - const handlerArguments = { |
57 | | - text, |
58 | | - precedingNode, |
59 | | - enclosingNode, |
60 | | - followingNode, |
61 | | - comment, |
62 | | - ast, |
63 | | - isLastComment |
64 | | - }; |
65 | | - |
66 | | - return handlers.some((handler) => handler(handlerArguments)); |
67 | | -} |
68 | | - |
69 | | -export const handleComments = { ownLine, endOfLine, remaining }; |
| 24 | +export const handleComments = { |
| 25 | + ownLine: handler, |
| 26 | + endOfLine: handler, |
| 27 | + remaining: handler |
| 28 | +}; |
0 commit comments