Skip to content

Commit

Permalink
Merge branch 'dev' into implementations-for-dependecy-sources
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Dec 27, 2023
2 parents fc5d681 + dc29171 commit 9cd338f
Show file tree
Hide file tree
Showing 99 changed files with 1,342 additions and 886 deletions.
4 changes: 3 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def isScala2(v: Option[(Long, Long)]): Boolean = v.exists(_._1 == 2)
def isScala3(v: Option[(Long, Long)]): Boolean = v.exists(_._1 == 3)
def isScala3WithPresentationCompiler(v: String): Boolean =
(Version.parse(v), Version.parse(V.firstScala3PCVersion)) match {
case (Some(v), _) if V.supportedScalaVersions.contains(v.toString()) =>
false
case (Some(v), Some(firstScala3PCVersion)) => v >= firstScala3PCVersion
case _ => false
}
Expand Down Expand Up @@ -499,7 +501,7 @@ lazy val metals = project
"com.outr" %% "scribe-slf4j" % V.scribe, // needed for flyway database migrations
// for JSON formatted doctor
"com.lihaoyi" %% "ujson" % "3.1.3",
// For remote language server
// For fetching projects' templates
"com.lihaoyi" %% "requests" % "0.8.0",
// for producing SemanticDB from Scala source files, to be sure we want the same version of scalameta
"org.scalameta" %% "scalameta" % V.semanticdb(scalaVersion.value),
Expand Down
169 changes: 0 additions & 169 deletions docs/integrations/remote-language-server.md

This file was deleted.

8 changes: 7 additions & 1 deletion metals-docs/src/main/scala/docs/Snapshot.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,17 @@ object Snapshot {
private implicit val localDateTimeOrdering: Ordering[LocalDateTime] =
Ordering.fromLessThan[LocalDateTime]((a, b) => a.compareTo(b) < 0)

def latest(repo: String, binaryVersion: String): Snapshot = {
def latest(repo: String, binaryVersion: String, retry: Int = 5): Snapshot = {
if (System.getenv("CI") != null) {
try {
fetchLatest(repo, binaryVersion)
} catch {
case NonFatal(e) if retry > 0 =>
scribe.error(
"unexpected error fetching SNAPSHOT version, retrying...",
e,
)
latest(repo, binaryVersion, retry - 1)
case NonFatal(e) =>
scribe.error("unexpected error fetching SNAPSHOT version", e)
current
Expand Down
85 changes: 60 additions & 25 deletions metals/src/main/resources/millw
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION
#
# Project page: https://github.com/lefou/millw
# Script Version: 0.4.7
# Script Version: 0.4.11
#
# If you want to improve this script, please also contribute your changes back!
#
Expand All @@ -14,7 +14,7 @@
set -e

if [ -z "${DEFAULT_MILL_VERSION}" ] ; then
DEFAULT_MILL_VERSION="0.11.0"
DEFAULT_MILL_VERSION="0.11.4"
fi


Expand Down Expand Up @@ -55,12 +55,10 @@ if [ -z "${MILL_VERSION}" ] ; then
fi
fi

MILL_USER_CACHE_DIR="${XDG_CACHE_HOME:-${HOME}/.cache}/mill"

if [ -z "${MILL_DOWNLOAD_PATH}" ] ; then
if [ -n "${XDG_CACHE_HOME}" ] ; then
MILL_DOWNLOAD_PATH="${XDG_CACHE_HOME}/mill/download"
else
MILL_DOWNLOAD_PATH="${HOME}/.cache/mill/download"
fi
MILL_DOWNLOAD_PATH="${MILL_USER_CACHE_DIR}/download"
fi

# If not already set, try to fetch newest from Github
Expand Down Expand Up @@ -106,34 +104,71 @@ fi
MILL="${MILL_DOWNLOAD_PATH}/${MILL_VERSION}"

try_to_use_system_mill() {
if [ "$(uname)" != "Linux" ]; then
return 0
fi

MILL_IN_PATH="$(command -v mill || true)"

if [ -z "${MILL_IN_PATH}" ]; then
return
return 0
fi

UNIVERSAL_SCRIPT_MAGIC="@ 2>/dev/null # 2>nul & echo off & goto BOF"
SYSTEM_MILL_FIRST_TWO_BYTES=$(head --bytes=2 "${MILL_IN_PATH}")
if [ "${SYSTEM_MILL_FIRST_TWO_BYTES}" = "#!" ]; then
# MILL_IN_PATH is (very likely) a shell script and not the mill
# executable, ignore it.
return 0
fi

SYSTEM_MILL_PATH=$(readlink -e "${MILL_IN_PATH}")
SYSTEM_MILL_SIZE=$(stat --format=%s "${SYSTEM_MILL_PATH}")
SYSTEM_MILL_MTIME=$(stat --format=%y "${SYSTEM_MILL_PATH}")

if ! head -c 128 "${MILL_IN_PATH}" | grep -qF "${UNIVERSAL_SCRIPT_MAGIC}"; then
if [ -n "${MILLW_VERBOSE}" ]; then
echo "Could not determine mill version of ${MILL_IN_PATH}, as it does not start with the universal script magic2" 1>&2
if [ ! -d "${MILL_USER_CACHE_DIR}" ]; then
mkdir -p "${MILL_USER_CACHE_DIR}"
fi

SYSTEM_MILL_INFO_FILE="${MILL_USER_CACHE_DIR}/system-mill-info"
if [ -f "${SYSTEM_MILL_INFO_FILE}" ]; then
parseSystemMillInfo() {
LINE_NUMBER="${1}"
# Select the line number of the SYSTEM_MILL_INFO_FILE, cut the
# variable definition in that line in two halves and return
# the value, and finally remove the quotes.
sed -n "${LINE_NUMBER}p" "${SYSTEM_MILL_INFO_FILE}" |\
cut -d= -f2 |\
sed 's/"\(.*\)"/\1/'
}

CACHED_SYSTEM_MILL_PATH=$(parseSystemMillInfo 1)
CACHED_SYSTEM_MILL_VERSION=$(parseSystemMillInfo 2)
CACHED_SYSTEM_MILL_SIZE=$(parseSystemMillInfo 3)
CACHED_SYSTEM_MILL_MTIME=$(parseSystemMillInfo 4)

if [ "${SYSTEM_MILL_PATH}" = "${CACHED_SYSTEM_MILL_PATH}" ] \
&& [ "${SYSTEM_MILL_SIZE}" = "${CACHED_SYSTEM_MILL_SIZE}" ] \
&& [ "${SYSTEM_MILL_MTIME}" = "${CACHED_SYSTEM_MILL_MTIME}" ]; then
if [ "${CACHED_SYSTEM_MILL_VERSION}" = "${MILL_VERSION}" ]; then
MILL="${SYSTEM_MILL_PATH}"
return 0
else
return 0
fi
fi
return
fi

# Roughly the size of the universal script.
MILL_VERSION_SEARCH_RANGE="2403"
MILL_IN_PATH_VERSION=$(head -c "${MILL_VERSION_SEARCH_RANGE}" "${MILL_IN_PATH}" |\
sed -n 's/^.*-DMILL_VERSION=\([^\s]*\) .*$/\1/p' |\
head -n 1)
SYSTEM_MILL_VERSION=$(${SYSTEM_MILL_PATH} --version | head -n1 | sed -n 's/^Mill.*version \(.*\)/\1/p')

if [ -z "${MILL_IN_PATH_VERSION}" ]; then
echo "Could not determine mill version, even though ${MILL_IN_PATH} has the universal script magic" 1>&2
return
fi
cat <<EOF > "${SYSTEM_MILL_INFO_FILE}"
CACHED_SYSTEM_MILL_PATH="${SYSTEM_MILL_PATH}"
CACHED_SYSTEM_MILL_VERSION="${SYSTEM_MILL_VERSION}"
CACHED_SYSTEM_MILL_SIZE="${SYSTEM_MILL_SIZE}"
CACHED_SYSTEM_MILL_MTIME="${SYSTEM_MILL_MTIME}"
EOF

if [ "${MILL_IN_PATH_VERSION}" = "${MILL_VERSION}" ]; then
MILL="${MILL_IN_PATH}"
if [ "${SYSTEM_MILL_VERSION}" = "${MILL_VERSION}" ]; then
MILL="${SYSTEM_MILL_PATH}"
fi
}
try_to_use_system_mill
Expand Down Expand Up @@ -167,7 +202,7 @@ if [ ! -s "${MILL}" ] ; then
if [ "$DOWNLOAD_FROM_MAVEN" = "1" ] ; then
DOWNLOAD_URL="https://repo1.maven.org/maven2/com/lihaoyi/mill-dist/${MILL_VERSION}/mill-dist-${MILL_VERSION}.jar"
else
MILL_VERSION_TAG=$(echo $MILL_VERSION | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/')
MILL_VERSION_TAG=$(echo "$MILL_VERSION" | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/')
DOWNLOAD_URL="${GITHUB_RELEASE_CDN}${MILL_REPO_URL}/releases/download/${MILL_VERSION_TAG}/${MILL_VERSION}${DOWNLOAD_SUFFIX}"
unset MILL_VERSION_TAG
fi
Expand Down
14 changes: 7 additions & 7 deletions metals/src/main/resources/millw.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ rem You can give the required mill version with --mill-version parameter
rem If no version is given, it falls back to the value of DEFAULT_MILL_VERSION
rem
rem Project page: https://github.com/lefou/millw
rem Script Version: 0.4.7
rem Script Version: 0.4.11
rem
rem If you want to improve this script, please also contribute your changes back!
rem
Expand All @@ -16,13 +16,17 @@ rem but I don't think we need to support them in 2019
setlocal enabledelayedexpansion

if [!DEFAULT_MILL_VERSION!]==[] (
set "DEFAULT_MILL_VERSION=0.11.0"
set "DEFAULT_MILL_VERSION=0.11.4"
)

if [!GITHUB_RELEASE_CDN!]==[] (
set "GITHUB_RELEASE_CDN="
)

if [!MILL_MAIN_CLI!]==[] (
set "MILL_MAIN_CLI=%~f0"
)

set "MILL_REPO_URL=https://github.com/com-lihaoyi/mill"

rem %~1% removes surrounding quotes
Expand Down Expand Up @@ -129,7 +133,7 @@ if not exist "%MILL%" (
rem there seems to be no way to generate a unique temporary file path (on native Windows)
set DOWNLOAD_FILE=%MILL%.tmp

if [!DOWNLOAD_FROM_MAVEN]==[1] (
if [!DOWNLOAD_FROM_MAVEN!]==[1] (
set DOWNLOAD_URL=https://repo1.maven.org/maven2/com/lihaoyi/mill-dist/!MILL_VERSION!/mill-dist-!MILL_VERSION!.jar
) else (
set DOWNLOAD_URL=!GITHUB_RELEASE_CDN!%MILL_REPO_URL%/releases/download/!MILL_VERSION_TAG!/!MILL_VERSION!!DOWNLOAD_SUFFIX!
Expand Down Expand Up @@ -164,10 +168,6 @@ set MILL_DOWNLOAD_PATH=
set MILL_VERSION=
set MILL_REPO_URL=

if [!MILL_MAIN_CLI!]==[] (
set "MILL_MAIN_CLI=%0"
)

rem Need to preserve the first position of those listed options
set MILL_FIRST_ARG=
if [%~1%]==[--bsp] (
Expand Down
Loading

0 comments on commit 9cd338f

Please sign in to comment.