Skip to content

Enable scalafmt for Scala 3 #419

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

Closed
wants to merge 2 commits into from
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
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.6.1
aa7db3a42121f78a5b3bed3658786c1cef83efe8

# Enable scalafmt for Scala 3
96cf83dc668207737b7a955b8a501da20fcc2f13
5 changes: 5 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ rewrite.neverInfix.excludeFilters = [until
theSameElementsAs]

runner.dialect = scala213
fileOverride {
"glob:**/scala-3/**" {
runner.dialect = scala3
}
}
353 changes: 183 additions & 170 deletions core/shared/src/main/scala-3/org/threeten/bp/DayOfWeek.scala

Large diffs are not rendered by default.

408 changes: 214 additions & 194 deletions core/shared/src/main/scala-3/org/threeten/bp/Month.scala

Large diffs are not rendered by default.

42 changes: 24 additions & 18 deletions core/shared/src/main/scala-3/org/threeten/bp/chrono/HijrahEra.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ object HijrahEra {
/**
* Obtains an instance of {@code HijrahEra} from a value.
*
* The current era (from ISO date 622-06-19 onwards) has the value 1
* The previous era has the value 0.
* The current era (from ISO date 622-06-19 onwards) has the value 1 The previous era has the
* value 0.
*
* @param hijrahEra the era to represent, from 0 to 1
* @return the HijrahEra singleton, never null
* @throws DateTimeException if the era is invalid
* @param hijrahEra
* the era to represent, from 0 to 1
* @return
* the HijrahEra singleton, never null
* @throws DateTimeException
* if the era is invalid
*/
def of(hijrahEra: Int): HijrahEra =
hijrahEra match {
Expand All @@ -62,19 +65,19 @@ object HijrahEra {
/**
* An era in the Hijrah calendar system.
*
* The Hijrah calendar system has two eras.
* The date {@code 0001-01-01 (Hijrah)} is {@code 622-06-19 (ISO)}.
* The Hijrah calendar system has two eras. The date {@code 0001-01-01 (Hijrah)} is {@code 622-06-19
* (ISO)}.
*
* <b>Do not use {@code ordinal()} to obtain the numeric representation of {@code HijrahEra}.
* Use {@code getValue()} instead.</b>
* <b>Do not use {@code ordinal()} to obtain the numeric representation of {@code HijrahEra}. Use
* {@code getValue()} instead.</b>
*
* <h3>Specification for implementors</h3>
* This is an immutable and thread-safe enum.
* <h3>Specification for implementors</h3> This is an immutable and thread-safe enum.
*/
enum HijrahEra(name: String, ordinal: Int) extends java.lang.Enum[HijrahEra] with Era {

/**
* The singleton instance for the era before the current one, 'Before Anno Hegirae',
* which has the value 0.
* The singleton instance for the era before the current one, 'Before Anno Hegirae', which has the
* value 0.
*/
case BEFORE_AH extends HijrahEra("BEFORE_AH", 0)

Expand All @@ -84,10 +87,11 @@ enum HijrahEra(name: String, ordinal: Int) extends java.lang.Enum[HijrahEra] wit
/**
* Gets the era numeric value.
*
* The current era (from ISO date 622-06-19 onwards) has the value 1.
* The previous era has the value 0.
* The current era (from ISO date 622-06-19 onwards) has the value 1. The previous era has the
* value 0.
*
* @return the era value, from 0 (BEFORE_AH) to 1 (AH)
* @return
* the era value, from 0 (BEFORE_AH) to 1 (AH)
*/
def getValue: Int = ordinal

Expand All @@ -100,8 +104,10 @@ enum HijrahEra(name: String, ordinal: Int) extends java.lang.Enum[HijrahEra] wit
/**
* Returns the proleptic year from this era and year of era.
*
* @param yearOfEra the year of Era
* @return the computed prolepticYear
* @param yearOfEra
* the year of Era
* @return
* the computed prolepticYear
*/
private[chrono] def prolepticYear(yearOfEra: Int): Int =
if (this eq HijrahEra.AH) yearOfEra else 1 - yearOfEra
Expand Down
44 changes: 23 additions & 21 deletions core/shared/src/main/scala-3/org/threeten/bp/chrono/IsoEra.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@ object IsoEra {
/**
* Obtains an instance of {@code IsoEra} from an {@code int} value.
*
* {@code IsoEra} is an enum representing the ISO eras of BCE/CE.
* This factory allows the enum to be obtained from the {@code int} value.
* {@code IsoEra} is an enum representing the ISO eras of BCE/CE. This factory allows the enum to
* be obtained from the {@code int} value.
*
* @param era the BCE/CE value to represent, from 0 (BCE) to 1 (CE)
* @return the era singleton, not null
* @throws DateTimeException if the value is invalid
* @param era
* the BCE/CE value to represent, from 0 (BCE) to 1 (CE)
* @return
* the era singleton, not null
* @throws DateTimeException
* if the value is invalid
*/
def of(era: Int): IsoEra =
era match {
Expand All @@ -56,30 +59,28 @@ object IsoEra {
/**
* An era in the ISO calendar system.
*
* The ISO-8601 standard does not define eras.
* A definition has therefore been created with two eras - 'Current era' (CE) for
* years from 0001-01-01 (ISO) and 'Before current era' (BCE) for years before that.
* The ISO-8601 standard does not define eras. A definition has therefore been created with two eras
* \- 'Current era' (CE) for years from 0001-01-01 (ISO) and 'Before current era' (BCE) for years
* before that.
*
* <b>Do not use {@code ordinal()} to obtain the numeric representation of {@code IsoEra}.
* Use {@code getValue()} instead.</b>
* <b>Do not use {@code ordinal()} to obtain the numeric representation of {@code IsoEra}. Use
* {@code getValue()} instead.</b>
*
* <h3>Specification for implementors</h3>
* This is an immutable and thread-safe enum.
* <h3>Specification for implementors</h3> This is an immutable and thread-safe enum.
*/
enum IsoEra(name: String, ordinal: Int) extends java.lang.Enum[IsoEra] with Era {

/**
* The singleton instance for the era BCE, 'Before Current Era'.
* The 'ISO' part of the name emphasizes that this differs from the BCE
* era in the Gregorian calendar system.
* This has the numeric value of {@code 0}.
* The singleton instance for the era BCE, 'Before Current Era'. The 'ISO' part of the name
* emphasizes that this differs from the BCE era in the Gregorian calendar system. This has the
* numeric value of {@code 0}.
*/
case BCE extends IsoEra("BCE", 0)

/**
* The singleton instance for the era CE, 'Current Era'.
* The 'ISO' part of the name emphasizes that this differs from the CE
* era in the Gregorian calendar system.
* This has the numeric value of {@code 1}.
* The singleton instance for the era CE, 'Current Era'. The 'ISO' part of the name emphasizes
* that this differs from the CE era in the Gregorian calendar system. This has the numeric value
* of {@code 1}.
*/
case CE extends IsoEra("CE", 1)

Expand All @@ -88,7 +89,8 @@ enum IsoEra(name: String, ordinal: Int) extends java.lang.Enum[IsoEra] with Era
*
* The era BCE has the value 0, while the era CE has the value 1.
*
* @return the era value, from 0 (BCE) to 1 (CE)
* @return
* the era value, from 0 (BCE) to 1 (CE)
*/
def getValue: Int = ordinal
}
35 changes: 19 additions & 16 deletions core/shared/src/main/scala-3/org/threeten/bp/chrono/MinguoEra.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@ object MinguoEra {
/**
* Obtains an instance of {@code MinguoEra} from an {@code int} value.
*
* {@code MinguoEra} is an enum representing the Minguo eras of BEFORE_ROC/ROC.
* This factory allows the enum to be obtained from the {@code int} value.
* {@code MinguoEra} is an enum representing the Minguo eras of BEFORE_ROC/ROC. This factory
* allows the enum to be obtained from the {@code int} value.
*
* @param era the BEFORE_ROC/ROC value to represent, from 0 (BEFORE_ROC) to 1 (ROC)
* @return the era singleton, not null
* @throws DateTimeException if the value is invalid
* @param era
* the BEFORE_ROC/ROC value to represent, from 0 (BEFORE_ROC) to 1 (ROC)
* @return
* the era singleton, not null
* @throws DateTimeException
* if the value is invalid
*/
def of(era: Int): MinguoEra =
era match {
Expand All @@ -57,26 +60,25 @@ object MinguoEra {
/**
* An era in the Minguo calendar system.
*
* The Minguo calendar system has two eras.
* The date {@code 0001-01-01 (Minguo)} is equal to {@code 1912-01-01 (ISO)}.
* The Minguo calendar system has two eras. The date {@code 0001-01-01 (Minguo)} is equal to {@code
* 1912-01-01 (ISO)}.
*
* <b>Do not use {@code ordinal()} to obtain the numeric representation of {@code MinguoEra}.
* Use {@code getValue()} instead.</b>
* <b>Do not use {@code ordinal()} to obtain the numeric representation of {@code MinguoEra}. Use
* {@code getValue()} instead.</b>
*
* <h3>Specification for implementors</h3>
* This is an immutable and thread-safe enum.
* <h3>Specification for implementors</h3> This is an immutable and thread-safe enum.
*/
enum MinguoEra(name: String, ordinal: Int) extends java.lang.Enum[MinguoEra] with Era {

/**
* The singleton instance for the era BEFORE_ROC, 'Before Republic of China'.
* This has the numeric value of {@code 0}.
* The singleton instance for the era BEFORE_ROC, 'Before Republic of China'. This has the numeric
* value of {@code 0}.
*/
case BEFORE_ROC extends MinguoEra("BEFORE_ROC", 0)

/**
* The singleton instance for the era ROC, 'Republic of China'.
* This has the numeric value of {@code 1}.
* The singleton instance for the era ROC, 'Republic of China'. This has the numeric value of
* {@code 1}.
*/
case ROC extends MinguoEra("ROC", 1)

Expand All @@ -85,7 +87,8 @@ enum MinguoEra(name: String, ordinal: Int) extends java.lang.Enum[MinguoEra] wit
*
* The era BEFORE_ROC has the value 0, while the era ROC has the value 1.
*
* @return the era value, from 0 (BEFORE_ROC) to 1 (ROC)
* @return
* the era value, from 0 (BEFORE_ROC) to 1 (ROC)
*/
def getValue: Int = ordinal

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ object ThaiBuddhistEra {
/**
* Obtains an instance of {@code ThaiBuddhistEra} from a value.
*
* The current era (from ISO year -543 onwards) has the value 1
* The previous era has the value 0.
* The current era (from ISO year -543 onwards) has the value 1 The previous era has the value 0.
*
* @param thaiBuddhistEra the era to represent, from 0 to 1
* @return the BuddhistEra singleton, never null
* @throws DateTimeException if the era is invalid
* @param thaiBuddhistEra
* the era to represent, from 0 to 1
* @return
* the BuddhistEra singleton, never null
* @throws DateTimeException
* if the era is invalid
*/
def of(thaiBuddhistEra: Int): ThaiBuddhistEra =
thaiBuddhistEra match {
Expand All @@ -59,18 +61,16 @@ object ThaiBuddhistEra {
*
* The Thai Buddhist calendar system has two eras.
*
* <b>Do not use ordinal() to obtain the numeric representation of a ThaiBuddhistEra
* instance. Use getValue() instead.</b>
* <b>Do not use ordinal() to obtain the numeric representation of a ThaiBuddhistEra instance. Use
* getValue() instead.</b>
*
* <h3>Specification for implementors</h3>
* This is an immutable and thread-safe enum.
* <h3>Specification for implementors</h3> This is an immutable and thread-safe enum.
*/
enum ThaiBuddhistEra(name: String, ordinal: Int)
extends java.lang.Enum[ThaiBuddhistEra]
with Era {
enum ThaiBuddhistEra(name: String, ordinal: Int) extends java.lang.Enum[ThaiBuddhistEra] with Era {

/**
* The singleton instance for the era before the current one, 'Before Buddhist Era',
* which has the value 0.
* The singleton instance for the era before the current one, 'Before Buddhist Era', which has the
* value 0.
*/
case BEFORE_BE extends ThaiBuddhistEra("BEFORE_BE", 0)

Expand All @@ -80,10 +80,10 @@ enum ThaiBuddhistEra(name: String, ordinal: Int)
/**
* Gets the era numeric value.
*
* The current era (from ISO year -543 onwards) has the value 1
* The previous era has the value 0.
* The current era (from ISO year -543 onwards) has the value 1 The previous era has the value 0.
*
* @return the era value, from 0 (BEFORE_BE) to 1 (BE)
* @return
* the era value, from 0 (BEFORE_BE) to 1 (BE)
*/
def getValue: Int = ordinal

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,31 @@ package org.threeten.bp.format
/**
* Enumeration of the style of a localized date, time or date-time formatter.
*
* These styles are used when obtaining a date-time style from configuration.
* See {@link DateTimeFormatter} and {@link DateTimeFormatterBuilder} for usage.
* These styles are used when obtaining a date-time style from configuration. See {@link
* DateTimeFormatter} and {@link DateTimeFormatterBuilder} for usage.
*
* <h3>Specification for implementors</h3>
* This is an immutable and thread-safe enum.
* <h3>Specification for implementors</h3> This is an immutable and thread-safe enum.
*/
enum FormatStyle private (name: String, ordinal: Int)
extends java.lang.Enum[FormatStyle] {
enum FormatStyle private (name: String, ordinal: Int) extends java.lang.Enum[FormatStyle] {

/**
* Full text style, with the most detail.
* For example, the format might be 'Tuesday, April 12, 1952 AD' or '3:30:42pm PST'.
* Full text style, with the most detail. For example, the format might be 'Tuesday, April 12,
* 1952 AD' or '3:30:42pm PST'.
*/
case FULL extends FormatStyle("FULL", 0)

/**
* Long text style, with lots of detail.
* For example, the format might be 'January 12, 1952'.
* Long text style, with lots of detail. For example, the format might be 'January 12, 1952'.
*/
case LONG extends FormatStyle("LONG", 1)

/**
* Medium text style, with some detail.
* For example, the format might be 'Jan 12, 1952'.
* Medium text style, with some detail. For example, the format might be 'Jan 12, 1952'.
*/
case MEDIUM extends FormatStyle("MEDIUM", 2)

/**
* Short text style, typically numeric.
* For example, the format might be '12.13.52' or '3:30pm'.
* Short text style, typically numeric. For example, the format might be '12.13.52' or '3:30pm'.
*/
case SHORT extends FormatStyle("SHORT", 3)
}
Loading