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

Apply scalafmt #2246

Merged
merged 3 commits into from
Jan 11, 2022
Merged
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 .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ jobs:
java-version: ${{ matrix.jvm }}
- name: Cache Scala
uses: coursier/cache-action@v5
- name: Check Formatting (Scala 2.12 only)
if: startsWith(matrix.scala, '2.12')
run: sbt ++${{ matrix.scala }} scalafmtCheckAll
- name: Documentation (Scala 2.12 only)
if: startsWith(matrix.scala, '2.12')
run: sbt ++${{ matrix.scala }} docs/mdoc unidoc
Expand Down
26 changes: 26 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version = 2.6.4

maxColumn = 120
align = most
continuationIndent.defnSite = 2
assumeStandardLibraryStripMargin = true
docstrings = ScalaDoc
lineEndings = preserve
includeCurlyBraceInSelectChains = false
danglingParentheses = true

align.tokens.add = [
{
code = ":"
}
]

newlines.alwaysBeforeCurlyBraceLambdaParams = false
newlines.alwaysBeforeMultilineDef = false
newlines.implicitParamListModifierForce = [before]

verticalMultiline.atDefnSite = true

optIn.annotationNewlines = true

rewrite.rules = [SortImports, PreferCurlyFors, AvoidInfix]
3 changes: 2 additions & 1 deletion build.sc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import mill._
import mill.scalalib._
import mill.scalalib.publish._
import mill.scalalib.scalafmt._
import coursier.maven.MavenRepository
import $ivy.`com.lihaoyi::mill-contrib-buildinfo:$MILL_VERSION`
import mill.contrib.buildinfo.BuildInfo
Expand Down Expand Up @@ -29,7 +30,7 @@ def getTestVersion(dep: String, org: String = "edu.berkeley.cs") = {
}

// Since chisel contains submodule core and macros, a CommonModule is needed
trait CommonModule extends CrossSbtModule with PublishModule {
trait CommonModule extends CrossSbtModule with PublishModule with ScalafmtModule {
def firrtlModule: Option[PublishModule] = None

def firrtlIvyDeps = if (firrtlModule.isEmpty) Agg(
Expand Down
667 changes: 396 additions & 271 deletions core/src/main/scala/chisel3/Aggregate.scala

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions core/src/main/scala/chisel3/Annotation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import firrtl.transforms.{DontTouchAnnotation, NoDedupAnnotation}
* Defines a conversion to a corresponding FIRRTL Annotation
*/
trait ChiselAnnotation {

/** Conversion to FIRRTL Annotation */
def toFirrtl: Annotation
}
Expand Down Expand Up @@ -54,7 +55,7 @@ object annotate {
* m.io.out
* }
*
*class AdderTester extends Module
* class AdderTester extends Module
* with ConstantPropagationTest {
* val io = IO(new Bundle {
* val a = Input(UInt(32.W))
Expand All @@ -73,12 +74,13 @@ object annotate {
*/

object doNotDedup {

/** Marks a module to be ignored in Dedup Transform in Firrtl
*
* @param module The module to be marked
* @return Unmodified signal `module`
*/
def apply[T <: RawModule](module: T)(implicit compileOptions: CompileOptions): Unit = {
def apply[T <: RawModule](module: T)(implicit compileOptions: CompileOptions): Unit = {
annotate(new ChiselAnnotation { def toFirrtl = NoDedupAnnotation(module.toNamed) })
}
}
1 change: 0 additions & 1 deletion core/src/main/scala/chisel3/Attach.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ object attach {
}
}
}

Loading