Skip to content

Commit 7edeff1

Browse files
Nivaldo Bondançafacebook-github-bot
Nivaldo Bondança
authored andcommitted
Delete FormattingOptions.Style enum
Summary: This is not really necessary with `FormattingOptions` being a data class. Reviewed By: cortinico Differential Revision: D58394978 fbshipit-source-id: 00c877a8db3b166c0d6ba834c4079d7fa0897af9
1 parent f9d4d25 commit 7edeff1

File tree

5 files changed

+35
-15
lines changed

5 files changed

+35
-15
lines changed

CHANGELOG.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Changelog
2+
3+
All notable changes to the ktfmt project (starting on v0.51) should be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/).
6+
7+
## [Unreleased]
8+
9+
### Added
10+
- Created CHANGELOG.md
11+
12+
### Changed
13+
- Preserves blank spaces between when clauses (https://github.com/facebook/ktfmt/issues/342)
14+
15+
### Fixed
16+
- Compilation issues with online formatter (https://github.com/facebook/ktfmt/commit/8605080cb0aadb7eaba20f3b469d6ddafe32c941)
17+
18+
### Removed
19+
- Deleted `FormattingOptions.Style` enum

CONTRIBUTING.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ We actively welcome your pull requests.
1313
4. Ensure the test suite passes.
1414
5. Make sure your code lints.
1515
6. If you haven't already, complete the Contributor License Agreement ("CLA").
16+
7. If applicable add relevant change information to the changelog
1617

1718
Note that pull requests are imported into Facebook's internal repository and code is
1819
formatted as part of that process (using ktfmt!). It's not necessary for PRs to stick

core/src/main/java/com/facebook/ktfmt/format/Formatter.kt

+14-5
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
package com.facebook.ktfmt.format
1818

1919
import com.facebook.ktfmt.debughelpers.printOps
20-
import com.facebook.ktfmt.format.FormattingOptions.Style.DROPBOX
21-
import com.facebook.ktfmt.format.FormattingOptions.Style.GOOGLE
2220
import com.facebook.ktfmt.format.RedundantElementManager.addRedundantElements
2321
import com.facebook.ktfmt.format.RedundantElementManager.dropRedundantElements
2422
import com.facebook.ktfmt.format.WhitespaceTombstones.indexOfWhitespaceTombstone
@@ -47,14 +45,25 @@ object Formatter {
4745
@JvmField
4846
val GOOGLE_FORMAT =
4947
FormattingOptions(
50-
style = GOOGLE, blockIndent = 2, continuationIndent = 2, manageTrailingCommas = true)
48+
blockIndent = 2,
49+
continuationIndent = 2,
50+
manageTrailingCommas = true,
51+
)
5152

5253
/** A format that attempts to reflect https://kotlinlang.org/docs/coding-conventions.html. */
5354
@JvmField
54-
val KOTLINLANG_FORMAT = FormattingOptions(style = GOOGLE, blockIndent = 4, continuationIndent = 4)
55+
val KOTLINLANG_FORMAT =
56+
FormattingOptions(
57+
blockIndent = 4,
58+
continuationIndent = 4,
59+
)
5560

5661
@JvmField
57-
val DROPBOX_FORMAT = FormattingOptions(style = DROPBOX, blockIndent = 4, continuationIndent = 4)
62+
val DROPBOX_FORMAT =
63+
FormattingOptions(
64+
blockIndent = 4,
65+
continuationIndent = 4,
66+
)
5867

5968
private val MINIMUM_KOTLIN_VERSION = KotlinVersion(1, 4)
6069

core/src/main/java/com/facebook/ktfmt/format/FormattingOptions.kt

-9
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
package com.facebook.ktfmt.format
1818

1919
data class FormattingOptions(
20-
val style: Style = Style.FACEBOOK,
21-
2220
/** ktfmt breaks lines longer than maxWidth. */
2321
val maxWidth: Int = DEFAULT_MAX_WIDTH,
2422

@@ -64,14 +62,7 @@ data class FormattingOptions(
6462
*/
6563
val manageTrailingCommas: Boolean = false,
6664
) {
67-
6865
companion object {
6966
const val DEFAULT_MAX_WIDTH: Int = 100
7067
}
71-
72-
enum class Style {
73-
FACEBOOK,
74-
DROPBOX,
75-
GOOGLE
76-
}
7768
}

core/src/main/java/com/facebook/ktfmt/format/KotlinInputAstVisitor.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class KotlinInputAstVisitor(
135135
private val builder: OpsBuilder
136136
) : KtTreeVisitorVoid() {
137137

138-
private val isGoogleStyle = options.style == FormattingOptions.Style.GOOGLE
138+
private val isGoogleStyle = options.manageTrailingCommas
139139

140140
/** Standard indentation for a block */
141141
private val blockIndent: Indent.Const = Indent.Const.make(options.blockIndent, 1)

0 commit comments

Comments
 (0)