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

Update scalafmt-core to 2.7.5 #340

Open
wants to merge 4 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
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "2.7.4"
version = "2.7.5"
project.git=true
align = none
danglingParentheses = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ object FingerprintOps {
val hexChars = new Array[Char](bytes.length * 2)
var j = 0
while (j < bytes.length) {
val v: Int = bytes(j) & 0xFF
val v: Int = bytes(j) & 0xff
hexChars(j * 2) = hexArray(v >>> 4)
hexChars(j * 2 + 1) = hexArray(v & 0x0F)
hexChars(j * 2 + 1) = hexArray(v & 0x0f)
j += 1
}
new String(hexChars)
Expand Down
60 changes: 30 additions & 30 deletions metabrowse-cli/src/main/scala/metabrowse/cli/MetabrowseCli.scala
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,10 @@ class CliRunner(classpath: Seq[AbsolutePath], options: MetabrowseOptions) {
attrs: BasicFileAttributes
): FileVisitResult = {
val filename = file.getFileName.toString
if (filename.endsWith(".semanticdb") ||
filename.endsWith(".semanticdb.json")) {
if (
filename.endsWith(".semanticdb") ||
filename.endsWith(".semanticdb.json")
) {
files += AbsolutePath(file)
}
FileVisitResult.CONTINUE
Expand Down Expand Up @@ -246,15 +248,15 @@ class CliRunner(classpath: Seq[AbsolutePath], options: MetabrowseOptions) {
if !sym.endsWith(".") && !sym.endsWith("#") =>
// Do nothing, local symbol.
case s.SymbolOccurrence(
Some(r),
sym,
s.SymbolOccurrence.Role.DEFINITION
Some(r),
sym,
s.SymbolOccurrence.Role.DEFINITION
) =>
addDefinition(sym, r.toPosition(document.uri))
case s.SymbolOccurrence(
Some(r),
sym,
s.SymbolOccurrence.Role.REFERENCE
Some(r),
sym,
s.SymbolOccurrence.Role.REFERENCE
) =>
addReference(document.uri, r.toDocRange, sym)
case _ =>
Expand Down Expand Up @@ -282,11 +284,10 @@ class CliRunner(classpath: Seq[AbsolutePath], options: MetabrowseOptions) {

def symbolIndexByTopLevelSymbol: util.Map[String, List[d.SymbolIndex]] = {
val byToplevel = new util.HashMap[String, List[d.SymbolIndex]]()
symbols.asScala.foreach {
case (sym, ref) =>
val toplevel = sym.toplevelPackage
val old = byToplevel.getOrDefault(toplevel, Nil)
byToplevel.put(toplevel, ref.get() :: old)
symbols.asScala.foreach { case (sym, ref) =>
val toplevel = sym.toplevelPackage
val old = byToplevel.getOrDefault(toplevel, Nil)
byToplevel.put(toplevel, ref.get() :: old)
}
byToplevel
}
Expand All @@ -296,24 +297,23 @@ class CliRunner(classpath: Seq[AbsolutePath], options: MetabrowseOptions) {
Files.createDirectory(symbolRoot.toNIO)
val symbolsMap = symbols.asScala
val byToplevel = symbolIndexByTopLevelSymbol.asScala
byToplevel.foreach {
case (sym, indexes) =>
tick()
val actualIndexes = indexes.map { symbolIndex =>
val actualIndex = symbolIndex.definition match {
case Some(_) => updateReferencesForType(symbolsMap, symbolIndex)
case None => updateDefinitionsForTerm(symbolsMap, symbolIndex)
}
actualIndex
}
val symbolIndexes =
d.SymbolIndexes(actualIndexes.filter(_.definition.isDefined))
if (symbolIndexes.indexes.nonEmpty) {
val filename = sym.symbolIndexPath.stripSuffix(".gz")
val out = symbolRoot.resolve(filename)
Files.createDirectories(out.toNIO.getParent)
overwrite(out.toNIO, symbolIndexes.toByteArray)
byToplevel.foreach { case (sym, indexes) =>
tick()
val actualIndexes = indexes.map { symbolIndex =>
val actualIndex = symbolIndex.definition match {
case Some(_) => updateReferencesForType(symbolsMap, symbolIndex)
case None => updateDefinitionsForTerm(symbolsMap, symbolIndex)
}
actualIndex
}
val symbolIndexes =
d.SymbolIndexes(actualIndexes.filter(_.definition.isDefined))
if (symbolIndexes.indexes.nonEmpty) {
val filename = sym.symbolIndexPath.stripSuffix(".gz")
val out = symbolRoot.resolve(filename)
Files.createDirectories(out.toNIO.getParent)
overwrite(out.toNIO, symbolIndexes.toByteArray)
}
}
}

Expand Down
31 changes: 14 additions & 17 deletions metabrowse-cli/src/main/scala/metabrowse/cli/TermDisplay.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/**
* This code is copy/pasted from (Apache 2 licence)
/** This code is copy/pasted from (Apache 2 licence)
* https://github.com/alexarchambault/coursier/blob/51fefe5c29d95752ce487f60d333b1f8a91dd1b0/cache/src/main/scala/coursier/TermDisplay.scala
*
* which in turn was copy/pasted from (MIT licence)
Expand Down Expand Up @@ -40,23 +39,19 @@ object Terminal {
implicit class Ansi(val output: Writer) extends AnyVal {
private def control(n: Int, c: Char) = output.write("\u001b[" + n + c)

/**
* Move up `n` squares
/** Move up `n` squares
*/
def up(n: Int): Unit = if (n > 0) control(n, 'A')

/**
* Move down `n` squares
/** Move down `n` squares
*/
def down(n: Int): Unit = if (n > 0) control(n, 'B')

/**
* Move left `n` squares
/** Move left `n` squares
*/
def left(n: Int): Unit = if (n > 0) control(n, 'D')

/**
* Clear the current line
/** Clear the current line
*
* n=0: clear from cursor to end of line
* n=1: clear from cursor to start of line
Expand Down Expand Up @@ -151,7 +146,8 @@ object TermDisplay {
s"Last update: ${formatTimestamp(remote)}"
case (None, None) =>
"" // ???
} else
}
else
currentTimeOpt match {
case Some(current) =>
s"Checking for updates since ${formatTimestamp(current)}"
Expand Down Expand Up @@ -269,7 +265,9 @@ object TermDisplay {

val extra0 =
if (extra.length > baseExtraWidth)
extra.take((baseExtraWidth max (extra.length - overflow)) - 1) + "…"
extra.take(
(baseExtraWidth max (extra.length - overflow)) - 1
) + "…"
else
extra

Expand Down Expand Up @@ -310,9 +308,8 @@ object TermDisplay {
case Some(Message.Update) =>
val (done0, downloads0) = downloads.synchronized {
val q = doneQueue.toVector
.filter {
case (url, _) =>
!url.endsWith(".sha1") && !url.endsWith(".md5")
.filter { case (url, _) =>
!url.endsWith(".sha1") && !url.endsWith(".md5")
}
.sortBy { case (url, _) => url }

Expand Down Expand Up @@ -396,8 +393,8 @@ object TermDisplay {

out.flush()
Thread.sleep(fallbackRefreshInterval)
fallbackDisplayLoop(previous ++ downloads0.map {
case (url, _) => url
fallbackDisplayLoop(previous ++ downloads0.map { case (url, _) =>
url
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ trait MetabrowseSemanticdbIndex {
def definition(symbol: String): Option[d.Position] =
document.occurrences.collectFirst {
case s.SymbolOccurrence(
Some(r),
`symbol`,
s.SymbolOccurrence.Role.DEFINITION
Some(r),
`symbol`,
s.SymbolOccurrence.Role.DEFINITION
) =>
r.toPosition(document.uri)
}
Expand Down Expand Up @@ -50,19 +50,19 @@ trait MetabrowseSemanticdbIndex {
val names = document.occurrences.filter(_.symbol == sym)
val definition = names.collectFirst {
case s.SymbolOccurrence(
Some(r),
_,
s.SymbolOccurrence.Role.DEFINITION
Some(r),
_,
s.SymbolOccurrence.Role.DEFINITION
) =>
r.toPosition(document.uri)
}
val references = Map(
document.uri -> d.Ranges(
names.collect {
case s.SymbolOccurrence(
Some(r),
_,
s.SymbolOccurrence.Role.REFERENCE
Some(r),
_,
s.SymbolOccurrence.Role.REFERENCE
) =>
r.toDocRange
}
Expand Down
6 changes: 2 additions & 4 deletions metabrowse-js/src/main/scala/mdc/MDCSimpleMenu.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import scala.scalajs.js
import scala.scalajs.js.annotation._
import org.scalajs.dom

/**
* The MDC Simple Menu component is a spec-aligned drawer component.
/** The MDC Simple Menu component is a spec-aligned drawer component.
*
* @see https://material.io/components/web/catalog/menus/
*/
Expand All @@ -14,8 +13,7 @@ import org.scalajs.dom
class MDCSimpleMenu extends js.Object {
def this(element: dom.Element) = this()

/**
* Puts the component in the open state.
/** Puts the component in the open state.
*/
var open: Boolean = js.native
}
25 changes: 15 additions & 10 deletions metabrowse-js/src/main/scala/metabrowse/MetabrowseApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ object MetabrowseApp {
dom.document.querySelector("#editor-theme-menu");
val editorThemeMenu = new mdc.MDCSimpleMenu(editorThemeMenuElement);
val editorThemeIcon = dom.document.querySelector(".editor-theme");
editorThemeIcon.addEventListener("click", { (event: dom.Event) =>
event.preventDefault()
editorThemeMenu.open = !editorThemeMenu.open
})
editorThemeIcon.addEventListener(
"click",
{ (event: dom.Event) =>
event.preventDefault()
editorThemeMenu.open = !editorThemeMenu.open
}
)

for (theme <- Seq("vs", "vs-dark", "hc-black")) {
val themeControl = dom.document
Expand Down Expand Up @@ -205,8 +208,7 @@ object MetabrowseApp {
}
}

/**
* Load the Monaco Editor AMD bundle using `require`.
/** Load the Monaco Editor AMD bundle using `require`.
*
* The AMD bundle is not compatible with Webpack and must be loaded
* dynamically at runtime to avoid errors:
Expand All @@ -216,10 +218,13 @@ object MetabrowseApp {
val promise = Promise[Unit]()
val mod = "vs/editor/editor.main"
// call require via eval, so that webpack doesn't pick it during linking
js.Dynamic.global.eval("require")(js.Array(mod), { ctx: js.Dynamic =>
println("Monaco Editor loaded")
promise.success(())
}: js.ThisFunction)
js.Dynamic.global.eval("require")(
js.Array(mod),
{ ctx: js.Dynamic =>
println("Monaco Editor loaded")
promise.success(())
}: js.ThisFunction
)
promise.future
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ class ScalaReferenceProvider(index: MetabrowseSemanticdbIndex)
sym <- index.fetchSymbol(offset)
} yield {
val references = sym.map(_.references).getOrElse(Map.empty)
val locations = references.flatMap {
case (filename, ranges) =>
ranges.ranges.map(_.toPosition(filename)).map(resolveLocation)
val locations = references.flatMap { case (filename, ranges) =>
ranges.ranges.map(_.toPosition(filename)).map(resolveLocation)
}
js.Array[Location](locations.toSeq: _*)
}
Expand Down
3 changes: 1 addition & 2 deletions metabrowse-js/src/main/scala/metabrowse/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import monaco.services.ITextEditorOptions

package object metabrowse {

/**
* Instantiate a JavaScript object conforming to a
/** Instantiate a JavaScript object conforming to a
* given facade. Main usage is to create an empty
* object and update its mutable fields.
*
Expand Down
Loading