Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndentOperator: rename include to includeRegex #2841

Merged
merged 1 commit into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -539,23 +539,28 @@ function {
}
```

#### `indentOperator.exclude`
#### `indentOperator.excludeRegex`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although should we mention since when it's available? And the previous name?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!


Defines a regular expression for excluded infix operators. If an eligible
operator matches, it will not be indented.

In v3.1.0, this parameter was renamed from `indentOperator.exclude`.

```scala mdoc:defaults
indentOperator.exclude
indentOperator.excludeRegex
```

#### `indentOperator.include`
#### `indentOperator.includeRegex`

Defines a regular expression for included infix operators. If an eligible
operator matches and is not excluded explicitly by
[indentOperator.exclude](#indentoperatorexclude), it be will indented.
[indentOperator.excludeRegex](#indentoperatorexcluderegex), it be will indented.

In v3.1.0, due to conflict with built-in HOCON keyword, this parameter was
renamed from `indentOperator.include`.

```scala mdoc:defaults
indentOperator.include
indentOperator.includeRegex
```

#### `indentOperator.preset`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,21 @@ import metaconfig._
*/
case class IndentOperator(
topLevelOnly: Boolean = true,
include: String = ".*",
exclude: String = "^(&&|\\|\\|)$"
@annotation.ExtraName("include")
includeRegex: String = ".*",
@annotation.ExtraName("exclude")
excludeRegex: String = "^(&&|\\|\\|)$"
) {
private val includeRegexp = include.r.pattern
private val excludeRegexp = exclude.r.pattern
private val includeRegexp = includeRegex.r.pattern
private val excludeRegexp = excludeRegex.r.pattern

def noindent(op: String): Boolean =
excludeRegexp.matcher(op).find() || !includeRegexp.matcher(op).find()
}

object IndentOperator {
private val default = IndentOperator()
private val akka = IndentOperator(include = "^.*=$", exclude = "^$")
private val akka = IndentOperator(includeRegex = "^.*=$", excludeRegex = "^$")

implicit lazy val surface: generic.Surface[IndentOperator] =
generic.deriveSurface
Expand Down