Skip to content

Commit

Permalink
Config: make withDialect a public method
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Feb 28, 2025
1 parent 04c0a87 commit fcac9f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ case class RunnerSettings(
private[scalafmt] def getParser = parser.parse

@inline
private[scalafmt] def withDialect(dialect: NamedDialect) =
copy(dialect = dialect)
def withDialect(nd: NamedDialect): RunnerSettings = copy(dialect = nd)

@inline
private[scalafmt] def withParser(parser: ScalafmtParser) =
copy(parser = parser)
def withParser(parser: ScalafmtParser): RunnerSettings = copy(parser = parser)

private[scalafmt] def forCodeBlock =
copy(debug = false, eventCallback = null, parser = ScalafmtParser.Source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,11 @@ case class ScalafmtConfig(
k -> v.getMatcher
}

private[scalafmt] def withDialect(dialect: NamedDialect): ScalafmtConfig =
copy(runner = runner.withDialect(dialect))
def withDialect(nd: NamedDialect): ScalafmtConfig =
copy(runner = runner.withDialect(nd))

private[scalafmt] def withDialect(
dialect: Option[NamedDialect],
): ScalafmtConfig = dialect.fold(this)(withDialect)
def withDialect(nd: Option[NamedDialect]): ScalafmtConfig = nd
.fold(this)(withDialect)

def withDialect(dialect: Dialect, name: String): ScalafmtConfig =
withDialect(NamedDialect(name, dialect))
Expand Down

0 comments on commit fcac9f9

Please # to comment.