-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into to/#93-battery-storag…
…e-conversion # Conflicts: # src/main/scala/edu/ie3/powerFactory2psdm/util/Formatter.scala
- Loading branch information
Showing
3 changed files
with
36 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,2 @@ | ||
# | ||
# https://help.github.com/articles/dealing-with-line-endings/ | ||
# | ||
# These are explicitly windows files and should use crlf | ||
*.bat text eol=crlf | ||
|
||
# use LF line endings within the project | ||
* text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 31 additions & 32 deletions
63
src/main/scala/edu/ie3/powerFactory2psdm/util/Formatter.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,31 @@ | ||
/* | ||
* © 2021. TU Dortmund University, | ||
* Institute of Energy Systems, Energy Efficiency and Energy Economics, | ||
* Research group Distribution grid planning and operation | ||
*/ | ||
|
||
package edu.ie3.powerFactory2psdm.util | ||
|
||
import java.nio.file.{Files, Paths} | ||
import org.scalafmt.interfaces.Scalafmt | ||
|
||
import java.io.File | ||
|
||
object Formatter { | ||
|
||
def format(str: String, fmtPath: Option[String]): String = { | ||
val classLoader = this.getClass.getClassLoader | ||
val scalafmt = Scalafmt.create(classLoader) | ||
val configFile = new File(classLoader.getResource(".scalafmt.conf").getFile) | ||
val defaultConfigPath = | ||
Paths.get(configFile.getPath) | ||
val defaultConfig = | ||
if (Files.exists(defaultConfigPath)) defaultConfigPath else Paths.get("") | ||
val config = fmtPath.fold(defaultConfig)(Paths.get(_)) | ||
val result = scalafmt | ||
.withRespectVersion(false) | ||
.format(config, Paths.get("Nil.scala"), str) | ||
scalafmt.clear() | ||
result | ||
} | ||
|
||
} | ||
/* | ||
* © 2021. TU Dortmund University, | ||
* Institute of Energy Systems, Energy Efficiency and Energy Economics, | ||
* Research group Distribution grid planning and operation | ||
*/ | ||
|
||
package edu.ie3.powerFactory2psdm.util | ||
|
||
import java.nio.file.{Files, Paths} | ||
import org.scalafmt.interfaces.Scalafmt | ||
import java.io.File | ||
|
||
object Formatter { | ||
|
||
def format(str: String, fmtPath: Option[String]): String = { | ||
val classLoader = this.getClass.getClassLoader | ||
val scalafmt = Scalafmt.create(classLoader) | ||
val configFile = new File(classLoader.getResource(".scalafmt.conf").getFile) | ||
val defaultConfigPath = | ||
Paths.get(configFile.getPath) | ||
val defaultConfig = | ||
if (Files.exists(defaultConfigPath)) defaultConfigPath else Paths.get("") | ||
val config = fmtPath.fold(defaultConfig)(Paths.get(_)) | ||
val result = scalafmt | ||
.withRespectVersion(false) | ||
.format(config, Paths.get("Nil.scala"), str) | ||
scalafmt.clear() | ||
result | ||
} | ||
|
||
} |