Skip to content
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
5 changes: 5 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Commits listed here are skipped by `git blame` (bulk reformats, etc.).
# Enable locally with: git config blame.ignoreRevsFile .git-blame-ignore-revs

# Reformat with scalafmt 3.11.1
2e0458a04993c5d35625ad52fec79604df5db32f
105 changes: 105 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
//description of properties: https://scalameta.org/scalafmt/docs/configuration.html
version = "3.11.1"
runner.dialect = scala213
maxColumn = 120

continuationIndent {
defnSite = 2
ctorSite = 2
extendSite = 2
withSiteRelativeToExtends = 2
}

align.preset = none

binPack {
parentConstructors = OnelineIfPrimaryOneline
literalsSingleLine = false
}

newlines {
alwaysBeforeMultilineDef = false
afterCurlyLambda = preserve
implicitParamListModifierPrefer = after
penalizeSingleSelectMultiArgList = false
avoidForSimpleOverflow = [punct, tooLong]
afterInfix = some
}

# RedundantParens is omitted (vs. the shared AVSystem config): scex is an existential-type-heavy
# codebase and the rule strips parens that are syntactically required around `T forSome { ... }`
# types in lambda-parameter ascriptions, producing code that no longer parses.
rewrite.rules = [AvoidInfix, SortModifiers, SortImports, PreferCurlyFors, RedundantBraces]
rewrite.sortModifiers.order = ["override", "private", "protected", "implicit", "final", "sealed", "abstract", "lazy"]
rewrite.redundantBraces {
stringInterpolation = true
generalExpressions = false
methodBodies = true
includeUnitMethods = false
parensForOneLineApply = true
}

trailingCommas = multiple
importSelectors = singleLine

optIn {
breakChainOnFirstMethodDot = false
# - if newlines.source is missing or keep:
# - if true, will keep existing line breaks around annotations
# - if newlines.source is fold:
# - if true, will break before the entity being annotatated
# - will not force break between consecutive annotations
# - if newlines.source is unfold:
# - if true, will break between consecutive annotations
# - will always break before the entity being annotatated
annotationNewlines = false
}

rewrite.neverInfix.excludeFilters = [
until
to
by
eq
ne
"should.*"
"contain.*"
"must.*"
in
ignore
be
taggedAs
thrownBy
synchronized
have
when
size
only
noneOf
oneElementOf
noElementsOf
atLeastOneElementOf
atMostOneElementOf
allElementsOf
inOrderElementsOf
theSameElementsAs
//below extends default
theSameElementsInOrderAs
like
zip
orElse
getOrElse
matchOpt
map
flatMap
]

xmlLiterals.assumeFormatted = true
project.git = true
danglingParentheses.exclude = [
// "class", //with that, trailling comma don't work in class definition
"trait"
]
verticalMultiline {
atDefnSite = true
newlineAfterOpenParen = true
}
83 changes: 46 additions & 37 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
name := "scex"

inThisBuild(Seq(
organization := "com.avsystem.scex",
scalaVersion := "2.13.18",
githubWorkflowTargetTags ++= Seq("v*"),
githubWorkflowJavaVersions := Seq(JavaSpec.temurin("17"), JavaSpec.temurin("21"), JavaSpec.temurin("25")),
githubWorkflowPublishTargetBranches := Seq(RefPredicate.StartsWith(Ref.Tag("v"))),

githubWorkflowPublish := Seq(WorkflowStep.Sbt(
List("ci-release"),
env = Map(
"PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}",
"PGP_SECRET" -> "${{ secrets.PGP_SECRET }}",
"SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}",
"SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}"
)
)),
))
inThisBuild(
Seq(
organization := "com.avsystem.scex",
scalaVersion := "2.13.18",
githubWorkflowTargetTags ++= Seq("v*"),
githubWorkflowJavaVersions := Seq(JavaSpec.temurin("17"), JavaSpec.temurin("21"), JavaSpec.temurin("25")),
githubWorkflowPublishTargetBranches := Seq(RefPredicate.StartsWith(Ref.Tag("v"))),

githubWorkflowPublish := Seq(
WorkflowStep.Sbt(
List("ci-release"),
env = Map(
"PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}",
"PGP_SECRET" -> "${{ secrets.PGP_SECRET }}",
"SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}",
"SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}",
),
)
),
)
)

val CompileAndTest = "compile->compile;test->test"

Expand All @@ -38,8 +42,9 @@ lazy val subprojectSettings = Seq(
crossVersion := CrossVersion.full,

javacOptions ++= Seq(
"--release", "17",
"-parameters"
"--release",
"17",
"-parameters",
),

scalacOptions ++= Seq(
Expand All @@ -51,12 +56,12 @@ lazy val subprojectSettings = Seq(
"-language:dynamics",
"-language:experimental.macros",
"-Xfatal-warnings",
"-Xlint:-missing-interpolator,-adapted-args,-unused,_"
"-Xlint:-missing-interpolator,-adapted-args,-unused,_",
),

scalacOptions ++= Seq(
"-Xnon-strict-patmat-analysis",
"-Xlint:-strict-unsealed-patmat"
"-Xlint:-strict-unsealed-patmat",
),

projectInfo := ModuleInfo(
Expand All @@ -66,14 +71,16 @@ lazy val subprojectSettings = Seq(
startYear = Some(2015),
organizationName = "AVSystem",
organizationHomepage = Some(url("http://www.avsystem.com/")),
scmInfo = Some(ScmInfo(
browseUrl = url("https://github.com/AVSystem/scex.git"),
connection = "scm:git:git@github.com:AVSystem/scex.git",
devConnection = Some("scm:git:git@github.com:AVSystem/scex.git")
)),
scmInfo = Some(
ScmInfo(
browseUrl = url("https://github.com/AVSystem/scex.git"),
connection = "scm:git:git@github.com:AVSystem/scex.git",
devConnection = Some("scm:git:git@github.com:AVSystem/scex.git"),
)
),
licenses = Vector(License.MIT),
developers = Vector(
Developer("ddworak", "Dawid Dworak", "d.dworak@avsystem.com", url("https://github.com/ddworak")),
Developer("ddworak", "Dawid Dworak", "d.dworak@avsystem.com", url("https://github.com/ddworak"))
),
),

Expand All @@ -91,23 +98,23 @@ lazy val subprojectSettings = Seq(
})),
libraryDependencies ++= Seq(
compilerPlugin("com.avsystem.commons" %% "commons-analyzer" % avsCommonsVersion),
"org.scalatest" %% "scalatest" % scalatestVersion % Test
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
),
Compile / doc / sources := Seq.empty
Compile / doc / sources := Seq.empty,
)

lazy val scex = project.in(file("."))
.aggregate(`scex-macros`, `scex-core`, `scex-util`, `scex-test`)
.settings(noPublishSettings: _*)
lazy val scex =
project.in(file(".")).aggregate(`scex-macros`, `scex-core`, `scex-util`, `scex-test`).settings(noPublishSettings: _*)

lazy val `scex-macros` = project
.settings(subprojectSettings: _*)
.settings(
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value,
libraryDependencies += "com.avsystem.commons" %% "commons-macros" % avsCommonsVersion
libraryDependencies += "com.avsystem.commons" %% "commons-macros" % avsCommonsVersion,
)

lazy val `scex-core` = project.dependsOn(`scex-macros` % CompileAndTest)
lazy val `scex-core` = project
.dependsOn(`scex-macros` % CompileAndTest)
.settings(subprojectSettings: _*)
.settings(
libraryDependencies ++= Seq(
Expand All @@ -122,7 +129,8 @@ lazy val `scex-core` = project.dependsOn(`scex-macros` % CompileAndTest)
)
)

lazy val `scex-util` = project.dependsOn(`scex-core` % CompileAndTest)
lazy val `scex-util` = project
.dependsOn(`scex-core` % CompileAndTest)
.settings(subprojectSettings: _*)
.settings(
libraryDependencies ++= Seq(
Expand All @@ -131,6 +139,7 @@ lazy val `scex-util` = project.dependsOn(`scex-core` % CompileAndTest)
)
)

lazy val `scex-test` = project.dependsOn(`scex-core` % CompileAndTest, `scex-util`)
lazy val `scex-test` = project
.dependsOn(`scex-core` % CompileAndTest, `scex-util`)
.settings(subprojectSettings: _*)
.settings(noPublishSettings: _*)
.settings(noPublishSettings: _*)
1 change: 1 addition & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ logLevel := Level.Warn
addSbtPlugin("org.jetbrains.scala" % "sbt-ide-settings" % "1.1.4")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.11.2")
addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.30.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.6.1")
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package com.avsystem.scex

import scala.util.control.NoStackTrace

/**
* Created: 16-06-2014
* Author: ghik
/** Created: 16-06-2014 Author: ghik
*/
final case class EvaluationException(cause: Throwable) extends RuntimeException(cause) with NoStackTrace
3 changes: 2 additions & 1 deletion scex-core/src/main/scala/com/avsystem/scex/Expression.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ abstract class AbstractExpression[-C <: ExpressionContext[_, _], +T]

def eval(context: C): T

final def apply(context: C): T = try eval(context) catch {
final def apply(context: C): T = try eval(context)
catch {
case NonFatal(cause) => throw new EvaluationException(cause)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import com.avsystem.scex.compiler.annotation.NotValidated

import scala.language.higherKinds

/**
* Created: 23-09-2013
* Author: ghik
/** Created: 23-09-2013 Author: ghik
*/
trait ExpressionContext[R, V] {
type Root = R
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ package com.avsystem.scex

import com.avsystem.scex.compiler.ExpressionDef

/**
* Created: 16-06-2014
* Author: ghik
*/
/** Created: 16-06-2014 Author: ghik
*/
class ExpressionDebugInfo(
val definition: ExpressionDef) {
val definition: ExpressionDef
) {

lazy val originalLines = {
val mapping = definition.positionMapping.reverse
val lineLengths = definition.expression.split('\n').iterator.map(l => l.length + 1)
val originalLineStarts = lineLengths.scanLeft(0)(_ + _).map(mapping.apply)

originalLineStarts.sliding(2).map {
case Seq(start, end) => definition.originalExpression.substring(start, end - 1)
}.toVector
originalLineStarts
.sliding(2)
.map { case Seq(start, end) =>
definition.originalExpression.substring(start, end - 1)
}
.toVector
}
}
15 changes: 12 additions & 3 deletions scex-core/src/main/scala/com/avsystem/scex/ExpressionProfile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class ExpressionProfile(
val symbolAttributes: SymbolAttributes,
val expressionHeader: String,
val expressionUtils: NamedSource,
val dynamicVariablesEnabled: Boolean) {
val dynamicVariablesEnabled: Boolean,
) {

@bincompat
def this(
Expand All @@ -20,8 +21,16 @@ class ExpressionProfile(
symbolValidator: SymbolValidator,
symbolAttributes: SymbolAttributes,
expressionHeader: String,
expressionUtils: NamedSource
) = this(name, syntaxValidator, symbolValidator, symbolAttributes, expressionHeader, expressionUtils, dynamicVariablesEnabled = true)
expressionUtils: NamedSource,
) = this(
name,
syntaxValidator,
symbolValidator,
symbolAttributes,
expressionHeader,
expressionUtils,
dynamicVariablesEnabled = true,
)

override def toString = s"ExpressionProfile[$name]"
}
10 changes: 4 additions & 6 deletions scex-core/src/main/scala/com/avsystem/scex/NamedSource.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.avsystem.scex

/**
* Represents named source "file". Used to pass around compilable code fragments in runtime.
*
* Created: 29-10-2014
* Author: ghik
*/
/** Represents named source "file". Used to pass around compilable code fragments in runtime.
*
* Created: 29-10-2014 Author: ghik
*/
final case class NamedSource(name: String, code: String)
4 changes: 1 addition & 3 deletions scex-core/src/main/scala/com/avsystem/scex/Setter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package com.avsystem.scex

import scala.annotation.implicitNotFound

/**
* Created: 28-11-2013
* Author: ghik
/** Created: 28-11-2013 Author: ghik
*/
trait Setter[-T] extends (T => Unit) {
def acceptedType: Type
Expand Down
6 changes: 2 additions & 4 deletions scex-core/src/main/scala/com/avsystem/scex/Type.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.avsystem.scex

/**
* Author: ghik
* Created: 12/10/14.
*/
/** Author: ghik Created: 12/10/14.
*/
final case class Type(fullRepr: String, erasure: Class[_]) {
override def toString: String = fullRepr
}
Expand Down
Loading