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

Update scalafmt-core to 3.7.17 #1437

Closed
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
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Scala Steward: Reformat with scalafmt 3.7.17
691602e1123f04f1da079b4cd5217963e7b8005e
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Newer versions won't work with Java 8!
version = "3.7.15"
version = "3.7.17"

align.openParenCallSite = false
align.preset = none
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,31 @@ import ammonite.util.Util.CodeSource
abstract class CodeWrapper {
def wrapperPath: Seq[Name] = Nil
def apply(
code: String,
source: CodeSource,
imports: Imports,
printCode: String,
indexedWrapper: Name,
extraCode: String
code: String,
source: CodeSource,
imports: Imports,
printCode: String,
indexedWrapper: Name,
extraCode: String
): (String, String, Int)

def wrapCode(codeSource: CodeSource,
indexedWrapperName: Name,
code: String,
printCode: String,
imports: Imports,
extraCode: String,
markScript: Boolean) = {
def wrapCode(
codeSource: CodeSource,
indexedWrapperName: Name,
code: String,
printCode: String,
imports: Imports,
extraCode: String,
markScript: Boolean
) = {

//we need to normalize topWrapper and bottomWrapper in order to ensure
//the snippets always use the platform-specific newLine
// we need to normalize topWrapper and bottomWrapper in order to ensure
// the snippets always use the platform-specific newLine
val extraCode0 =
if (markScript) extraCode + "/*</generated>*/"
else extraCode
val (topWrapper, bottomWrapper, userCodeNestingLevel) =
apply(code, codeSource, imports, printCode, indexedWrapperName, extraCode0)
apply(code, codeSource, imports, printCode, indexedWrapperName, extraCode0)
val (topWrapper0, bottomWrapper0) =
if (markScript) (topWrapper + "/*<script>*/", "/*</script>*/ /*<generated>*/" + bottomWrapper)
else (topWrapper, bottomWrapper)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import ammonite.util.{Imports, Printer}
abstract class Compiler {

def compile(
src: Array[Byte],
printer: Printer,
importsLen: Int,
userCodeNestingLevel: Int,
fileName: String
src: Array[Byte],
printer: Printer,
importsLen: Int,
userCodeNestingLevel: Int,
fileName: String
): Option[Compiler.Output]

def preprocessor(fileName: String, markGeneratedSections: Boolean = false): Preprocessor
Expand All @@ -19,10 +19,9 @@ abstract class Compiler {
object Compiler {

case class Output(
classFiles: Vector[(String, Array[Byte])],
imports: Imports,
usedEarlierDefinitions: Option[Seq[String]]
classFiles: Vector[(String, Array[Byte])],
imports: Imports,
usedEarlierDefinitions: Option[Seq[String]]
)

}

Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ import ammonite.util.Frame
abstract class CompilerBuilder {

def newManager(
rtCacheDir: Option[Path],
headFrame: => Frame,
dependencyCompleter: => Option[String => (Int, Seq[String])],
whiteList: Set[Seq[String]],
initialClassLoader: ClassLoader,
settings: Seq[String]
rtCacheDir: Option[Path],
headFrame: => Frame,
dependencyCompleter: => Option[String => (Int, Seq[String])],
whiteList: Set[Seq[String]],
initialClassLoader: ClassLoader,
settings: Seq[String]
): CompilerLifecycleManager

def create(
initialClassPath: Seq[URL],
classPath: Seq[URL],
dynamicClassPath: Seq[(String, Array[Byte])],
evalClassLoader: ClassLoader,
pluginClassLoader: ClassLoader,
reporter: Option[CompilerBuilder.Message => Unit],
settings: Seq[String],
classPathWhiteList: Set[Seq[String]],
lineNumberModifier: Boolean
initialClassPath: Seq[URL],
classPath: Seq[URL],
dynamicClassPath: Seq[(String, Array[Byte])],
evalClassLoader: ClassLoader,
pluginClassLoader: ClassLoader,
reporter: Option[CompilerBuilder.Message => Unit],
settings: Seq[String],
classPathWhiteList: Set[Seq[String]],
lineNumberModifier: Boolean
): Compiler

def scalaVersion: String
Expand All @@ -34,10 +34,10 @@ abstract class CompilerBuilder {
object CompilerBuilder {

case class Message(
severity: String,
start: Int,
end: Int,
message: String
severity: String,
start: Int,
end: Int,
message: String
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ abstract class CompilerLifecycleManager {
def init(force: Boolean = false): Unit

def complete(
offset: Int,
previousImports: String,
snippet: String
offset: Int,
previousImports: String,
snippet: String
): (Int, Seq[String], Seq[String])

def compileClass(
processed: Preprocessor.Output,
printer: Printer,
fileName: String
processed: Preprocessor.Output,
printer: Printer,
fileName: String
): Option[Compiler.Output]

def addToClasspath(classFiles: ClassFiles): Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,72 +6,74 @@ import ammonite.util.Util.CodeSource
abstract class Parser {

def split(
code: String,
ignoreIncomplete: Boolean = true,
fileName: String = "(console)"
code: String,
ignoreIncomplete: Boolean = true,
fileName: String = "(console)"
): Option[Either[String, Seq[String]]]

final def parseImportHooks(
source: CodeSource,
stmts: Seq[String]
source: CodeSource,
stmts: Seq[String]
): (Seq[String], Seq[ImportTree]) =
parseImportHooksWithIndices(source, stmts.map((0, _)))
def parseImportHooksWithIndices(
source: CodeSource,
stmts: Seq[(Int, String)]
source: CodeSource,
stmts: Seq[(Int, String)]
): (Seq[String], Seq[ImportTree])

/**
* Splits up a script file into its constituent blocks, each of which
* is a tuple of (leading-whitespace, statements). Leading whitespace
* is returned separately so we can later manipulate the statements e.g.
* by adding `val res2 = ` without the whitespace getting in the way
*/
* Splits up a script file into its constituent blocks, each of which
* is a tuple of (leading-whitespace, statements). Leading whitespace
* is returned separately so we can later manipulate the statements e.g.
* by adding `val res2 = ` without the whitespace getting in the way
*/
def splitScript(
rawCode: String,
fileName: String
rawCode: String,
fileName: String
): Either[String, IndexedSeq[(String, Seq[String])]]

def scriptBlocksWithStartIndices(
rawCode: String,
fileName: String
rawCode: String,
fileName: String
): Either[Parser.ScriptSplittingError, Seq[Parser.ScriptBlock]]

def defaultHighlight(buffer: Vector[Char],
comment: fansi.Attrs,
`type`: fansi.Attrs,
literal: fansi.Attrs,
keyword: fansi.Attrs,
reset: fansi.Attrs,
notImplemented: fansi.Attrs): Vector[Char]
def defaultHighlight(
buffer: Vector[Char],
comment: fansi.Attrs,
`type`: fansi.Attrs,
literal: fansi.Attrs,
keyword: fansi.Attrs,
reset: fansi.Attrs,
notImplemented: fansi.Attrs
): Vector[Char]

def isObjDef(code: String): Boolean
}

object Parser {

case class ParsedImportHooks(
hookStatements: Seq[String],
importTrees: Seq[ImportTree]
hookStatements: Seq[String],
importTrees: Seq[ImportTree]
)

case class ScriptBlock(
startIndex: Int,
ncomment: String,
codeWithStartIndices: Seq[(Int, String)]
startIndex: Int,
ncomment: String,
codeWithStartIndices: Seq[(Int, String)]
)

object ScriptBlock {
def apply(
ncomment: String,
codeWithStartIndices: Seq[(Int, String)]
ncomment: String,
codeWithStartIndices: Seq[(Int, String)]
): ScriptBlock =
ScriptBlock(0, ncomment, codeWithStartIndices)
}

class ScriptSplittingError(
message: String,
val index: Int = -1,
val expected: String = ""
message: String,
val index: Int = -1,
val expected: String = ""
) extends Exception(message)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,47 @@ import ammonite.util.{Imports, Name, Res}
import ammonite.util.Util.CodeSource

/**
* Responsible for all scala-source-code-munging that happens within the
* Ammonite REPL.
*
* Performs several tasks:
*
* - Takes top-level Scala expressions and assigns them to `res{1, 2, 3, ...}`
* values so they can be accessed later in the REPL
*
* - Wraps the code snippet with an wrapper `object` since Scala doesn't allow
* top-level expressions
*
* - Mangles imports from our [[ammonite.util.ImportData]] data structure into a source
* String
*
* - Combines all of these into a complete compilation unit ready to feed into
* the Scala compiler
*/
* Responsible for all scala-source-code-munging that happens within the
* Ammonite REPL.
*
* Performs several tasks:
*
* - Takes top-level Scala expressions and assigns them to `res{1, 2, 3, ...}`
* values so they can be accessed later in the REPL
*
* - Wraps the code snippet with an wrapper `object` since Scala doesn't allow
* top-level expressions
*
* - Mangles imports from our [[ammonite.util.ImportData]] data structure into a source
* String
*
* - Combines all of these into a complete compilation unit ready to feed into
* the Scala compiler
*/
abstract class Preprocessor {

def transform(
stmts: Seq[String],
resultIndex: String,
leadingSpaces: String,
codeSource: CodeSource,
indexedWrapperName: Name,
imports: Imports,
printerTemplate: String => String,
extraCode: String,
skipEmpty: Boolean,
markScript: Boolean,
codeWrapper: CodeWrapper
stmts: Seq[String],
resultIndex: String,
leadingSpaces: String,
codeSource: CodeSource,
indexedWrapperName: Name,
imports: Imports,
printerTemplate: String => String,
extraCode: String,
skipEmpty: Boolean,
markScript: Boolean,
codeWrapper: CodeWrapper
): Res[Preprocessor.Output]

}

object Preprocessor {

case class Output(
code: String,
prefixCharLength: Int,
userCodeNestingLevel: Int
code: String,
prefixCharLength: Int,
userCodeNestingLevel: Int
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,24 @@ object CompilerCompatibility extends ExtraCompilerCompatibility {
}
}

def interactiveAnalyzer(g: InteractiveGlobal,
cl: ClassLoader): InteractiveAnalyzer { val global: g.type } = {
def interactiveAnalyzer(
g: InteractiveGlobal,
cl: ClassLoader
): InteractiveAnalyzer { val global: g.type } = {
new { val global: g.type = g } with InteractiveAnalyzer {
override def findMacroClassLoader() = cl
}
}
def importInfo(g: Global)(t: g.Import) =
new g.analyzer.ImportInfo(t, 0)



def initGlobal(settings: Settings,
reporter: AbstractReporter,
jcp: AggregateClassPath,
evalClassloader: ClassLoader,
createPlugins: Global => List[Plugin]): Global = {
def initGlobal(
settings: Settings,
reporter: AbstractReporter,
jcp: AggregateClassPath,
evalClassloader: ClassLoader,
createPlugins: Global => List[Plugin]
): Global = {

new nsc.Global(settings, reporter) { g =>
override lazy val plugins = createPlugins(g)
Expand Down
Loading
Loading