Skip to content

Commit

Permalink
ScalafmtDynamic: inline ignore check
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Nov 22, 2021
1 parent 4da84d3 commit 04c3280
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ final case class ScalafmtDynamic(
} else {
config
}
if (isIgnoredFile(filename, configWithDialect)) {
if (
respectExcludeFilters && !configWithDialect.isIncludedInProject(file)
) {
reporter.excluded(file)
code
} else {
Expand All @@ -202,13 +204,6 @@ final case class ScalafmtDynamic(
}
}

private def isIgnoredFile(
filename: String,
config: ScalafmtReflectConfig
): Boolean = {
respectExcludeFilters && !config.isIncludedInProject(filename)
}

private def readVersion(config: Path): FormatEval[ScalafmtVersion] = {
Try {
ConfigFactory.parseFile(config.toFile).getString("version")
Expand Down Expand Up @@ -240,7 +235,7 @@ final case class ScalafmtDynamic(
formatted => formatted
)
override def matchesProjectFilters(file: Path): Boolean =
cfg.isIncludedInProject(file.toString)
cfg.isIncludedInProject(file)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class ScalafmtReflectConfig private[dynamic] (val fmtReflect: ScalafmtReflect)(

@inline def getVersion = fmtReflect.version

@inline def isIncludedInProject(path: Path): Boolean =
isIncludedInProject(path.toString)

def isIncludedInProject(filename: String): Boolean =
projectMatcherField.invokeAs[Boolean]("matches", filename.asParam)

Expand Down

0 comments on commit 04c3280

Please sign in to comment.