Skip to content

Commit 2c4d35c

Browse files
committed
Review CRs
1 parent ac8531d commit 2c4d35c

File tree

11 files changed

+36
-33
lines changed

11 files changed

+36
-33
lines changed

dist/bin/scaladoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ eval "\"$JAVACMD\"" \
127127
${JAVA_OPTS:-$default_java_opts} \
128128
"${java_args[@]}" \
129129
"${jvm_cp_args-}" \
130+
-Dscala.usejavacp=true \
130131
"dotty.tools.scaladoc.Main" \
131132
"${scala_args[@]}" \
132133
"${residual_args[@]}" \

project/Build.scala

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ object Build {
12431243
libraryDependencies += ("org.scala-js" %%% "scalajs-dom" % "1.1.0").cross(CrossVersion.for3Use2_13)
12441244
)
12451245

1246-
def generateDocumentation(targets: Seq[String], name: String, outDir: String, ref: String, params: Seq[String] = Nil, addBootclasspath: Boolean = false) =
1246+
def generateDocumentation(targets: Seq[String], name: String, outDir: String, ref: String, params: Seq[String] = Nil) =
12471247
Def.taskDyn {
12481248
val distLocation = (dist / pack).value
12491249
val projectVersion = version.value
@@ -1255,13 +1255,6 @@ object Build {
12551255
def srcManaged(v: String, s: String) = s"out/bootstrap/stdlib-bootstrapped/scala-$v/src_managed/main/$s-library-src"
12561256
def scalaSrcLink(v: String, s: String) = s"-source-links:$s=github://scala/scala/v$v#src/library"
12571257
def dottySrcLink(v: String, s: String) = s"-source-links:$s=github://lampepfl/dotty/$v#library/src"
1258-
def bootclasspath: Seq[String] = if(addBootclasspath) Seq(
1259-
"-bootclasspath",
1260-
Seq(
1261-
scalaLib,
1262-
dottyLib
1263-
).mkString(System.getProperty("path.separator"))
1264-
) else Nil
12651258

12661259
val revision = Seq("-revision", ref, "-project-version", projectVersion)
12671260
val cmd = Seq(
@@ -1272,7 +1265,7 @@ object Build {
12721265
scalaSrcLink(stdLibVersion, srcManaged(dottyNonBootstrappedVersion, "scala")),
12731266
dottySrcLink(referenceVersion, srcManaged(dottyNonBootstrappedVersion, "dotty")),
12741267
s"-source-links:github://lampepfl/dotty/$referenceVersion",
1275-
) ++ scalacOptionsDocSettings ++ revision ++ params ++ targets ++ bootclasspath
1268+
) ++ scalacOptionsDocSettings ++ revision ++ params ++ targets
12761269
import _root_.scala.sys.process._
12771270
Def.task((s"$distLocation/bin/scaladoc" +: cmd).!)
12781271
}
@@ -1321,8 +1314,7 @@ object Build {
13211314
generateSelfDocumentation := Def.taskDyn {
13221315
generateDocumentation(
13231316
(Compile / classDirectory).value.getAbsolutePath :: Nil,
1324-
"scaladoc", "scaladoc/output/self", VersionUtil.gitHash,
1325-
addBootclasspath = true
1317+
"scaladoc", "scaladoc/output/self", VersionUtil.gitHash
13261318
)
13271319
}.value,
13281320
generateScalaDocumentation := Def.inputTaskDyn {
@@ -1372,8 +1364,7 @@ object Build {
13721364
(Test / Build.testcasesOutputDir).value,
13731365
"scaladoc testcases",
13741366
"scaladoc/output/testcases",
1375-
"master",
1376-
addBootclasspath = true)
1367+
"master")
13771368
}.value,
13781369

13791370
Test / buildInfoKeys := Seq[BuildInfoKey](

scaladoc/src/dotty/tools/scaladoc/DocContext.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,13 @@ case class DocContext(args: Scaladoc.Args, compilerContext: CompilerContext):
7676

7777
lazy val snippetCompilerArgs = snippets.SnippetCompilerArgs.load(args.snippetCompiler, args.snippetCompilerDebug)(using compilerContext)
7878

79-
lazy val snippetChecker = snippets.SnippetChecker(args.classpath, args.bootclasspath, args.tastyFiles, compilerContext.settings.scalajs.value(using compilerContext))
79+
lazy val snippetChecker = snippets.SnippetChecker(
80+
args.classpath,
81+
args.bootclasspath,
82+
args.tastyFiles,
83+
compilerContext.settings.scalajs.value(using compilerContext),
84+
compilerContext.settings.usejavacp.value(using compilerContext)
85+
)
8086

8187
lazy val staticSiteContext = args.docsRoot.map(path => StaticSiteContext(
8288
File(path).getAbsoluteFile(),

scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class ScaladocSettings extends SettingGroup with AllScalaSettings:
100100
MultiStringSetting("-snippet-compiler", "snippet-compiler", snippets.SnippetCompilerArgs.usage)
101101

102102
val snippetCompilerDebug: Setting[Boolean] =
103-
BooleanSetting("-snippet-compiler-debug", snippets.SnippetCompilerArgs.debugUsage, false)
103+
BooleanSetting("-Ysnippet-compiler-debug", snippets.SnippetCompilerArgs.debugUsage, false)
104104

105105
def scaladocSpecificSettings: Set[Setting[_]] =
106106
Set(sourceLinks, syntax, revision, externalDocumentationMappings, socialLinks, skipById, skipByRegex, deprecatedSkipPackages, docRootContent, snippetCompiler, snippetCompilerDebug)

scaladoc/src/dotty/tools/scaladoc/snippets/SnippetChecker.scala

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,26 @@ import java.io.File
88
import dotty.tools.io.AbstractFile
99
import dotty.tools.dotc.fromtasty.TastyFileUtil
1010

11-
class SnippetChecker(val classpath: String, val bootclasspath: String, val tastyFiles: Seq[File], isScalajs: Boolean):
11+
class SnippetChecker(val classpath: String, val bootclasspath: String, val tastyFiles: Seq[File], isScalajs: Boolean, useJavaCp: Boolean):
1212
private val sep = System.getProperty("path.separator")
13-
private val cp = List(
13+
14+
private val fullClasspath = List(
1415
tastyFiles
1516
.map(_.getAbsolutePath())
1617
.map(AbstractFile.getFile(_))
1718
.flatMap(t => try { TastyFileUtil.getClassPath(t) } catch { case e: AssertionError => Seq() })
1819
.distinct.mkString(sep),
19-
classpath,
20-
bootclasspath
20+
classpath
2121
).mkString(sep)
2222

23+
private val scalacOptions = Seq(
24+
Option.when(!fullClasspath.isEmpty)("-cp " + fullClasspath),
25+
Option.when(!bootclasspath.isEmpty)("-bootclasspath " + bootclasspath),
26+
Option.when(isScalajs)("-scalajs"),
27+
Option.when(useJavaCp)("-usejavacp")
28+
).flatten.mkString(" ")
2329

24-
private val compiler: SnippetCompiler = SnippetCompiler(classpath = cp, scalacOptions = if isScalajs then "-scalajs" else "")
30+
private val compiler: SnippetCompiler = SnippetCompiler(scalacOptions = scalacOptions)
2531

2632
// These constants were found empirically to make snippet compiler
2733
// report errors in the same position as main compiler.

scaladoc/src/dotty/tools/scaladoc/snippets/SnippetCompiler.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ import dotty.tools.dotc.interfaces.Diagnostic._
2121
import scala.util.{ Try, Success, Failure }
2222

2323
class SnippetCompiler(
24-
classpath: String,
25-
val scalacOptions: String = "",
24+
val scalacOptions: String,
2625
target: AbstractFile = new VirtualDirectory("(memory)")
2726
):
2827

@@ -31,7 +30,7 @@ class SnippetCompiler(
3130
List("-color:never", "-unchecked", "-deprecation", "-Ximport-suggestion-timeout", "0")
3231
val options = scalacOptions.split("\\s+").toList
3332
val settings =
34-
options ::: defaultFlags ::: "-classpath" :: classpath :: Nil
33+
options ::: defaultFlags ::: Nil
3534

3635
new InteractiveDriver(settings)
3736
}

scaladoc/src/dotty/tools/scaladoc/tasty/comments/markdown/SnippetRenderer.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ object SnippetRenderer:
1818
case MessageLevel.Error => "snippet-error"
1919
case MessageLevel.Debug => "snippet-debug"
2020

21-
private def cutBetwenSymbols[A](
21+
private def cutBetweenSymbols[A](
2222
startSymbol: String,
2323
endSymbol: String,
2424
snippetLines: Seq[SnippetLine]
@@ -33,7 +33,7 @@ object SnippetRenderer:
3333
} yield f(begin, mid, end)
3434

3535
private def wrapHiddenSymbols(snippetLines: Seq[SnippetLine]): Seq[SnippetLine] =
36-
val mRes = cutBetwenSymbols("//{", "//}", snippetLines) {
36+
val mRes = cutBetweenSymbols("//{", "//}", snippetLines) {
3737
case (begin, mid, end) =>
3838
begin ++ mid.drop(1).dropRight(1).map(_.withClass("hideable")) ++ wrapHiddenSymbols(end)
3939
}
@@ -74,7 +74,7 @@ object SnippetRenderer:
7474
}
7575

7676
private def wrapMultiLineComments(snippetLines: Seq[SnippetLine]): Seq[SnippetLine] =
77-
val mRes = cutBetwenSymbols("/*", "*/", snippetLines) {
77+
val mRes = cutBetweenSymbols("/*", "*/", snippetLines) {
7878
case (begin, mid, end) if mid.size == 1 =>
7979
val midRedacted = mid.map(wrapLineInBetween(Some("/*"), Some("*/"), _))
8080
begin ++ midRedacted ++ end

scaladoc/test/dotty/tools/scaladoc/BaseHtmlTest.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ class BaseHtmlTest:
3434
tastyFiles = pcks.flatMap(tastyFiles(_)),
3535
output = dest.toFile,
3636
docsRoot = docsRoot,
37-
projectVersion = Some(projectVersion),
38-
bootclasspath = dotty.tools.dotc.util.ClasspathFromClassloader(classOf[Predef$].getClassLoader())
37+
projectVersion = Some(projectVersion)
3938
)
4039
Scaladoc.run(args)(using testContext)
4140
op(using ProjectContext(dest))

scaladoc/test/dotty/tools/scaladoc/snippets/SnippetCompilerTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import org.junit.Assert._
66
import dotty.tools.io.{AbstractFile, VirtualDirectory}
77

88
class SnippetCompilerTest {
9-
val compiler = SnippetCompiler(System.getProperty("java.class.path"))
9+
val compiler = SnippetCompiler("-usejavacp")
1010
def wrapFn: String => WrappedSnippet = (str: String) => WrappedSnippet(
1111
str,
1212
Some("test"),

scaladoc/test/dotty/tools/scaladoc/snippets/SnippetsE2eTest.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ abstract class SnippetsE2eTest(testName: String, flag: SCFlags, debug: Boolean)
3838
output = getTempDir().getRoot,
3939
projectVersion = Some("1.0"),
4040
snippetCompiler = List(s"${BuildInfo.test_testcasesSourceRoot}/tests=${flag.flagName}"),
41-
snippetCompilerDebug = debug,
42-
bootclasspath = dotty.tools.dotc.util.ClasspathFromClassloader(classOf[Predef$].getClassLoader())
41+
snippetCompilerDebug = debug
4342
)
4443

4544
override def withModule(op: DocContext ?=> Module => Unit) =

scaladoc/test/dotty/tools/scaladoc/testUtils.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ def testArgs(files: Seq[File] = Nil, dest: File = new File("notUsed")) = Scalado
5555
output = dest,
5656
tastyFiles = files,
5757
docsRoot = Some(""),
58-
bootclasspath = dotty.tools.dotc.util.ClasspathFromClassloader(classOf[Predef$].getClassLoader())
5958
)
6059

61-
def testContext = (new ContextBase).initialCtx.fresh.setReporter(new TestReporter)
60+
def testContext =
61+
val ctx = (new ContextBase).initialCtx.fresh.setReporter(new TestReporter)
62+
ctx.setSetting(ctx.settings.usejavacp, true)
63+
ctx
6264

6365
def testDocContext(files: Seq[File] = Nil) = DocContext(testArgs(files), testContext)
6466

0 commit comments

Comments
 (0)