• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Portions Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /*
18  * Copyright (c) Tor Norbye.
19  *
20  * Licensed under the Apache License, Version 2.0 (the "License");
21  * you may not use this file except in compliance with the License.
22  * You may obtain a copy of the License at
23  *
24  *     http://www.apache.org/licenses/LICENSE-2.0
25  *
26  * Unless required by applicable law or agreed to in writing, software
27  * distributed under the License is distributed on an "AS IS" BASIS,
28  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29  * See the License for the specific language governing permissions and
30  * limitations under the License.
31  */
32 
33 package com.facebook.ktfmt.kdoc
34 
35 class FormattingTask(
36     /** Options to format with */
37     var options: KDocFormattingOptions,
38 
39     /** The original comment to be formatted */
40     var comment: String,
41 
42     /**
43      * The initial indentation on the first line of the KDoc. The reformatted comment will prefix
44      * each subsequent line with this string.
45      */
46     var initialIndent: String,
47 
48     /**
49      * Indent to use after the first line.
50      *
51      * This is useful when the comment starts the end of an existing code line. For example,
52      * something like this:
53      * ```
54      *     if (foo.bar.baz()) { // This comment started at column 25
55      *         // but the second and subsequent lines are indented 8 spaces
56      *         // ...
57      * ```
58      *
59      * (This doesn't matter much for KDoc comments, since the formatter will always push these into
60      * their own lines so the indents will match, but for line and block comments it can matter.)
61      */
62     var secondaryIndent: String = initialIndent,
63 
64     /**
65      * Optional list of parameters associated with this doc; if set, and if
66      * [KDocFormattingOptions.orderDocTags] is set, parameter doc tags will be sorted to match this
67      * order. (The intent is for the tool invoking KDocFormatter to pass in the parameter names in
68      * signature order here.)
69      */
70     var orderedParameterNames: List<String> = emptyList(),
71 
72     /** The type of comment being formatted. */
73     val type: CommentType = comment.commentType()
74 )
75