Skip to content

Commit

Permalink
Merge branch 'main' into update/cask-0.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lefou authored Mar 7, 2024
2 parents e646bd6 + 7b5c395 commit c43af34
Show file tree
Hide file tree
Showing 171 changed files with 4,476 additions and 4,233 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Reformatted scala code
78d98a149f2a4d7ad81f398edc72475a4fe8c5bf
21 changes: 18 additions & 3 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ jobs:
distribution: temurin
- run: ./mill -i -k integrationTest ${{ matrix.scala-version }}

site:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
java-version: 8
distribution: temurin
- run: echo "Hello World" && ./mill -i publishDocs --skipDeploy true
shell: 'script -q -e -c "bash {0}"'
env:
TERM: xterm-256color

publishLocal:
strategy:
fail-fast: false
Expand All @@ -65,20 +80,20 @@ jobs:

release:
if: github.repository == 'com-lihaoyi/Ammonite' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/2.x')
needs: [ test, itest, publishLocal ]
needs: [ test, itest, site, publishLocal ]
uses: ./.github/workflows/release.yml
secrets: inherit

publishDosc:
if: github.repository == 'com-lihaoyi/Ammonite' && github.ref == 'refs/heads/main'
needs: [ test, itest ]
needs: [ test, itest, site ]
uses: ./.github/workflows/publishDocs.yml
secrets:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}

publishExecutable:
if: github.repository == 'com-lihaoyi/Ammonite' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/2.x')
needs: [ test, itest ]
needs: [ test, itest, site ]
uses: ./.github/workflows/publishExecutable.yml
secrets:
AMMONITE_BOT_AUTH_TOKEN: ${{ secrets.AMMONITE_BOT_AUTH_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
release:
strategy:
matrix:
shard: [ 1, 2, 3, 4, 5 ]
shard: [ 1, 2, 3, 4, 5, 6]
fail-fast: false
runs-on: ubuntu-latest
env:
Expand All @@ -39,4 +39,4 @@ jobs:
java-version: '8'
distribution: temurin
- run: test -z "$SONATYPE_PGP_SECRET" || echo "$SONATYPE_PGP_SECRET" | base64 --decode | gpg --import --no-tty --batch --yes
- run: GPG_TTY=$(tty) ./mill -i publishSonatype __.publishArtifacts --shard ${{ matrix.shard }} --divisionCount 5
- run: GPG_TTY=$(tty) ./mill -i publishSonatype __.publishArtifacts --shard ${{ matrix.shard }} --divisionCount 6
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)
}
Loading

0 comments on commit c43af34

Please sign in to comment.