Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Update scalafmt-core to 3.8.4 #158

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Scala Steward: Reformat with scalafmt 3.8.0
4d568df732c59c023ac08772ec9477692790a5b1

# Scala Steward: Reformat with scalafmt 3.8.4
f193d3ff9e1e59859bda9eb16f86e269020c450b
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.8.3"
version = "3.8.4"
runner.dialect = scala3
maxColumn = 120
align.preset = more
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ package bitlap.rolls.compiler.plugin
sealed trait Schema

final case class ClassSchema(
className: String,
methods: List[MethodSchema]
className: String,
methods: List[MethodSchema]
) extends Schema

final case class MethodSchema(
name: String,
params: List[TypeSchema],
resultType: TypeSchema
name: String,
params: List[TypeSchema],
resultType: TypeSchema
) extends Schema

final case class TypeSchema(
typeName: String,
name: Option[String] = None,
fields: List[TypeSchema] = List.empty,
typeArgs: Option[List[TypeSchema]] = None
typeName: String,
name: Option[String] = None,
fields: List[TypeSchema] = List.empty,
typeArgs: Option[List[TypeSchema]] = None
) extends Schema
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ final class PrettyToStringPhase(setting: RollsSetting) extends PluginPhase with
)

private def mapDefDef(standard: Boolean, classTree: ClassTree, ts: Symbol)(using
ctx: Context,
clazz: ClassSymbol
ctx: Context,
clazz: ClassSymbol
): DefDef =
val paramSyms = classTree.primaryConstructor.paramSymss.flatten.filter(!_.isType).map(_.toFieldTree)
val elements = paramSyms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ package bitlap.rolls.compiler.plugin
* @version 1.0,2023/3/31
*/
final case class RollsConfig(
classSchema: Option[String] = Some("bitlap.rolls.core.annotations.classSchema"),
prettyToString: Option[String] = Some("bitlap.rolls.core.annotations.prettyToString"),
stringMask: String = "bitlap.rolls.core.annotations.stringMask",
validateIdentPrefix: List[String] = List.empty,
rollsRuntimeClass: String = "bitlap.rolls.core.RollsRuntime",
rollsRuntimeToStringMethod: String = "toString_",
classSchemaFolder: String = "/tmp/.compiler",
classSchemaFileName: String = "classSchema_%s.txt",
classSchemaPostUri: Option[String] = None,
validateShouldStartsWith: String = ""
classSchema: Option[String] = Some("bitlap.rolls.core.annotations.classSchema"),
prettyToString: Option[String] = Some("bitlap.rolls.core.annotations.prettyToString"),
stringMask: String = "bitlap.rolls.core.annotations.stringMask",
validateIdentPrefix: List[String] = List.empty,
rollsRuntimeClass: String = "bitlap.rolls.core.RollsRuntime",
rollsRuntimeToStringMethod: String = "toString_",
classSchemaFolder: String = "/tmp/.compiler",
classSchemaFileName: String = "classSchema_%s.txt",
classSchemaPostUri: Option[String] = None,
validateShouldStartsWith: String = ""
)

object RollsConfig:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ object Utils:
)(_.readObject().asInstanceOf[ClassSchema])

private class ObjectInputStreamWithCustomClassLoader(
inputStream: InputStream
inputStream: InputStream
) extends ObjectInputStream(inputStream):

override def resolveClass(desc: java.io.ObjectStreamClass): Class[_] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import dotty.tools.dotc.quoted.reflect.FromSymbol
* @version 1.0,2023/3/31
*/
final case class FieldTree(
name: Name,
thisDot: Select,
tpe: Type,
isPrivate: Boolean,
annotations: List[Tree] // on term
name: Name,
thisDot: Select,
tpe: Type,
isPrivate: Boolean,
annotations: List[Tree] // on term
):

def containsAnnotation(annotation: Name): Context ?=> Boolean =
Expand All @@ -42,27 +42,27 @@ final case class FieldTree(
end FieldTree

final case class SimpleFieldTree(
name: String,
tpe: Type,
typeTree: Tree,
argTypes: List[Tree]
name: String,
tpe: Type,
typeTree: Tree,
argTypes: List[Tree]
)

final case class TpeTree(
typeSymbol: Tree,
argTypes: List[Tree]
typeSymbol: Tree,
argTypes: List[Tree]
)

final case class ClassTree(
name: String,
typeParams: List[Tree],
template: Template,
typeSymbol: Symbol,
annotations: List[untpd.Tree],
classSymbol: ClassSymbol,
contrAnnotations: List[Tree],
primaryConstructor: Symbol,
isCaseClass: Boolean
name: String,
typeParams: List[Tree],
template: Template,
typeSymbol: Symbol,
annotations: List[untpd.Tree],
classSymbol: ClassSymbol,
contrAnnotations: List[Tree],
primaryConstructor: Symbol,
isCaseClass: Boolean
)

extension (s: SingleDenotation)
Expand Down
8 changes: 4 additions & 4 deletions rolls-csv/src/main/scala/bitlap/rolls/csv/CSVMetadata.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ package bitlap.rolls.csv
* @version 1.0,2023/4/16
*/
final case class CSVMetadata(
rawHeaders: List[String],
classFieldNames: List[String],
rowsNum: () => Long,
invalidRowsNum: () => Long
rawHeaders: List[String],
classFieldNames: List[String],
rowsNum: () => Long,
invalidRowsNum: () => Long
)
16 changes: 8 additions & 8 deletions rolls-csv/src/main/scala/bitlap/rolls/csv/CSVUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ object CSVUtils:
def FileName(fileName: String): FileName = fileName

inline def writeCSV[T](fileName: FileName, objs: List[T])(
encodeLine: T => String
encodeLine: T => String
)(using mirror: Mirror.ProductOf[T], format: CSVFormat = DefaultCSVFormat): Boolean =
val fields = mirrors.labels[T](using mirror)
writeCSV(new File(fileName), fields, objs.map(encodeLine))(using format)

inline def writeCSV[T](file: File, objs: List[T])(
encodeLine: T => String
encodeLine: T => String
)(using mirror: Mirror.ProductOf[T], format: CSVFormat): Boolean =
val fields = mirrors.labels[T](using mirror)
writeCSV(file, fields, objs.map(encodeLine))(using format)

private def writeCSV(file: File, fields: List[String], lines: List[String])(using
format: CSVFormat
format: CSVFormat
): Boolean = {
checkFile(file)
// write class fieldName as csv header
Expand Down Expand Up @@ -69,13 +69,13 @@ object CSVUtils:
}

inline def readCSV[T](file: File)(
decodeLine: String => T
decodeLine: String => T
)(using mirror: Mirror.ProductOf[T], format: CSVFormat): CSVData[T] =
CSVUtils.readFromFileWithMetadata[T](file, decodeLine)

inline def readCSV[T](fileName: FileName)(decodeLine: String => T)(using
mirror: Mirror.ProductOf[T],
format: CSVFormat = DefaultCSVFormat
mirror: Mirror.ProductOf[T],
format: CSVFormat = DefaultCSVFormat
): CSVData[T] =
CSVUtils.readFromFileWithMetadata[T](new File(fileName), decodeLine)

Expand All @@ -91,8 +91,8 @@ object CSVUtils:
}

inline private def readFromFileWithMetadata[T](file: File, decodeLine: String => T)(using
mirror: Mirror.ProductOf[T],
format: CSVFormat
mirror: Mirror.ProductOf[T],
format: CSVFormat
): CSVData[T] = {
val lines: Iterator[String] = Source.fromFile(file)(Codec(format.stringCharset.charset)).getLines()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ import bitlap.rolls.csv.internal.*
* @version 1.0,2023/4/5
*/
final class AppliedDecoderBuilder[
To,
ToSubs <: Tuple,
DerivedToSubs <: Tuple
To,
ToSubs <: Tuple,
DerivedToSubs <: Tuple
](
private val appliedTo: String,
private[csv] override val computes: Map[FieldName, String => Any]
private val appliedTo: String,
private[csv] override val computes: Map[FieldName, String => Any]
) extends DecoderBuilder[AppliedDecoderBuilder, To, ToSubs, DerivedToSubs]:

override def construct[DerivedToSubs <: Tuple](
computes: Map[FieldName, String => Any]
computes: Map[FieldName, String => Any]
): AppliedDecoderBuilder[To, ToSubs, DerivedToSubs] =
new AppliedDecoderBuilder[To, ToSubs, DerivedToSubs](this.appliedTo, computes)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ import bitlap.rolls.csv.internal.*
* @version 1.0,2023/4/5
*/
final class AppliedEncoderBuilder[
From,
FromSubs <: Tuple,
DerivedFromSubs <: Tuple
From,
FromSubs <: Tuple,
DerivedFromSubs <: Tuple
](
private val appliedTo: From,
private[csv] val computes: Map[FieldName, Any => String]
private val appliedTo: From,
private[csv] val computes: Map[FieldName, Any => String]
) extends EncoderBuilder[AppliedEncoderBuilder, From, FromSubs, DerivedFromSubs]:

override def construct[DerivedFromSubs <: Tuple](
computes: Map[FieldName, Any => String]
computes: Map[FieldName, Any => String]
): AppliedEncoderBuilder[From, FromSubs, DerivedFromSubs] =
new AppliedEncoderBuilder[From, FromSubs, DerivedFromSubs](this.appliedTo, computes)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ import bitlap.rolls.csv.internal.*
* @version 1.0,2023/4/5
*/
trait DecoderBuilder[
SpecificBuilder[_, _ <: Tuple, _ <: Tuple],
To,
ToSubs <: Tuple,
DerivedToSubs <: Tuple
SpecificBuilder[_, _ <: Tuple, _ <: Tuple],
To,
ToSubs <: Tuple,
DerivedToSubs <: Tuple
]:
private[csv] val computes: Map[FieldName, String => Any]

final transparent inline def withFieldComputed[Field](
inline selector: To => Field,
f: String => Field
inline selector: To => Field,
f: String => Field
) = {
val selectedField = BuilderMacros.selectedField(selector)
val computedField = FieldName(selectedField) -> f.asInstanceOf[String => Field]
Expand All @@ -35,7 +35,7 @@ trait DecoderBuilder[
}

def construct[DerivedToSubs <: Tuple](
computes: Map[FieldName, String => Any] = this.computes
computes: Map[FieldName, String => Any] = this.computes
): SpecificBuilder[To, ToSubs, DerivedToSubs]

end DecoderBuilder
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ import bitlap.rolls.csv.internal.*
* @version 1.0,2023/4/5
*/
trait EncoderBuilder[
SpecificBuilder[_, _ <: Tuple, _ <: Tuple],
From,
FromSubs <: Tuple,
DerivedFromSubs <: Tuple
SpecificBuilder[_, _ <: Tuple, _ <: Tuple],
From,
FromSubs <: Tuple,
DerivedFromSubs <: Tuple
]:
private[csv] val computes: Map[FieldName, Any => String]

final transparent inline def withFieldComputed[Field](
inline selector: From => Field,
f: Field => String
inline selector: From => Field,
f: Field => String
) = {
val selectedField = BuilderMacros.selectedField(selector)
val computedField = FieldName(selectedField) -> f.asInstanceOf[Any => String]
Expand All @@ -35,7 +35,7 @@ trait EncoderBuilder[
}

def construct[DerivedFromSubs <: Tuple](
computes: Map[FieldName, Any => String] = this.computes
computes: Map[FieldName, Any => String] = this.computes
): SpecificBuilder[From, FromSubs, DerivedFromSubs]

end EncoderBuilder
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ private[csv] object BuilderMacros {
private type IsString[S <: String] = S

transparent inline def dropCompletionField[
SpecificBuilder[_, _ <: Tuple, _ <: Tuple],
From,
FromSubs <: Tuple,
DerivedFromSubs <: Tuple,
FieldType
SpecificBuilder[_, _ <: Tuple, _ <: Tuple],
From,
FromSubs <: Tuple,
DerivedFromSubs <: Tuple,
FieldType
](
inline builder: SpecificBuilder[From, FromSubs, DerivedFromSubs],
inline selector: From => FieldType
inline builder: SpecificBuilder[From, FromSubs, DerivedFromSubs],
inline selector: From => FieldType
) = ${ dropCompletionFieldMacro('builder, 'selector) }

inline def selectedField[From, Field](inline selector: From => Field): String =
Expand All @@ -33,14 +33,14 @@ private[csv] object BuilderMacros {
Expr(selectedFieldName(selector))

private def dropCompletionFieldMacro[
SpecificBuilder[_, _ <: Tuple, _ <: Tuple]: Type,
From: Type,
FromSubs <: Tuple: Type,
DerivedFromSubs <: Tuple: Type,
Field: Type
SpecificBuilder[_, _ <: Tuple, _ <: Tuple]: Type,
From: Type,
FromSubs <: Tuple: Type,
DerivedFromSubs <: Tuple: Type,
Field: Type
](
builder: Expr[SpecificBuilder[From, FromSubs, DerivedFromSubs]],
selector: Expr[From => Field]
builder: Expr[SpecificBuilder[From, FromSubs, DerivedFromSubs]],
selector: Expr[From => Field]
)(using Quotes) =
import quotes.reflect.*
val selectedField = selectedFieldName(selector).asConstantType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import bitlap.rolls.csv.*
private[csv] object CodecMacros {

inline def encode[From, DerivedFromSubs <: Tuple](
computes: Map[FieldName, Any => String]
computes: Map[FieldName, Any => String]
)(using CSVFormat): Encoder[From] = { (from: From) =>
val encoders = Derivation.encodersForAllFields[DerivedFromSubs]
Construct.constructCSV(from.asInstanceOf[Product]) { (labelsToValuesOfFrom, label) =>
Expand All @@ -24,8 +24,8 @@ private[csv] object CodecMacros {
}

inline def decode[To, DerivedToSubs <: Tuple](
toMirror: Mirror.ProductOf[To],
computes: Map[FieldName, String => Any]
toMirror: Mirror.ProductOf[To],
computes: Map[FieldName, String => Any]
)(using CSVFormat): Decoder[To] = { (to: String) =>
val strings = StringUtils.splitColumns(to)
val decoders = Derivation.decodersForAllFields[DerivedToSubs]
Expand Down
Loading
Loading