Browse files

SI-6803: do not use java.net.URI, even more so incorrectly.

  • Loading branch information...
1 parent 14b8045 commit 103a478dfc1b3f918e0643333635e3d8d254a9a0 @vigdorchik vigdorchik committed Dec 18, 2012
View
20 src/compiler/scala/tools/nsc/doc/Settings.scala
@@ -7,8 +7,6 @@ package scala.tools.nsc
package doc
import java.io.File
-import java.net.URI
-import java.lang.System
import scala.language.postfixOps
/** An extended version of compiler settings, with additional Scaladoc-specific options.
@@ -72,10 +70,10 @@ class Settings(error: String => Unit, val printMsg: String => Unit = println(_))
""
)
- val docExternalUris = MultiStringSetting (
- "-doc-external-uris",
+ val docExternalDoc = MultiStringSetting (
+ "-doc-external-doc",
"external-doc",
- "comma-separated list of file://classpath_entry_path#doc_URL URIs for external dependencies"
+ "comma-separated list of classpath_entry_path#doc_URL pairs describing external dependencies."
)
val useStupidTypes = BooleanSetting (
@@ -265,9 +263,15 @@ class Settings(error: String => Unit, val printMsg: String => Unit = println(_))
map ++ (pkgs map (_ -> url))
}
- lazy val extUrlMapping: Map[String, String] = docExternalUris.value map { s =>
- val uri = new URI(s)
- uri.getSchemeSpecificPart -> appendIndex(uri.getFragment)
+ lazy val extUrlMapping: Map[String, String] = docExternalDoc.value flatMap { s =>
+ val idx = s.indexOf("#")
+ if (idx > 0) {
+ val (first, last) = s.splitAt(idx)
+ Some(new File(first).getAbsolutePath -> appendIndex(last.substring(1)))
+ } else {
+ error(s"Illegal -doc-external-doc option; expected a pair with '#' separator, found: '$s'")
+ None
+ }
} toMap
/**
View
4 src/manual/scala/man1/scaladoc.scala
@@ -77,8 +77,8 @@ object scaladoc extends Command {
CmdOption("doc-source-url", Argument("url")),
"Define a URL to be concatenated with source locations for link to source files."),
Definition(
- CmdOption("doc-external-uris", Argument("external-doc")),
- "Define comma-separated list of file://classpath_entry_path#doc_URL URIs for linking to external dependencies."))),
+ CmdOption("doc-external-doc", Argument("external-doc")),
+ "Define a comma-separated list of classpath_entry_path#doc_URL pairs describing external dependencies."))),
Section("Compiler Options",
DefinitionList(
View
8 test/scaladoc/run/SI-191.scala
@@ -33,10 +33,10 @@ object Test extends ScaladocModelTest {
def scalaURL = "http://bog.us"
override def scaladocSettings = {
- val scalaLibUri = getClass.getClassLoader.getResource("scala/Function1.class").toURI.getSchemeSpecificPart.split("!")(0)
- val scalaLib = new File(new URL(scalaLibUri).getPath).getPath
- val extArg = new URI("file", scalaLib, scalaURL).toString
- "-no-link-warnings -doc-external-uris " + extArg
+ val scalaLibUri = getClass.getClassLoader.getResource("scala/Function1.class").getPath.split("!")(0)
+ val scalaLibPath = new URI(scalaLibUri).getPath
+ val externalArg = s"$scalaLibPath#$scalaURL"
+ "-no-link-warnings -doc-external-doc " + externalArg
}
def testModel(rootPackage: Package) {

0 comments on commit 103a478

Please sign in to comment.