Skip to content

Commit

Permalink
Undo change to AbstractFile
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-barnes committed Jan 28, 2020
1 parent f987e97 commit 3091516
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
10 changes: 0 additions & 10 deletions src/reflect/scala/reflect/io/AbstractFile.scala
Expand Up @@ -18,7 +18,6 @@ import java.io.{BufferedOutputStream, ByteArrayOutputStream, IOException, InputS
import java.io.{File => JFile}
import java.net.URL
import java.nio.ByteBuffer
import java.nio.file.Paths

import scala.collection.AbstractIterable

Expand Down Expand Up @@ -266,15 +265,6 @@ abstract class AbstractFile extends AbstractIterable[AbstractFile] {
fileOrSubdirectoryNamed(name, isDir = true)
}

/**
* Check if this file is a child of the given directory string. Can only be used
* on directories that actually exist in the file system.
*/
def isChildOf(dir: String): Boolean = {
val parent = Paths.get(dir).toAbsolutePath().toString
canonicalPath.startsWith(parent)
}

protected def unsupported(): Nothing = unsupported(null)
protected def unsupported(msg: String): Nothing = throw new UnsupportedOperationException(msg)

Expand Down
14 changes: 13 additions & 1 deletion src/scaladoc/scala/tools/nsc/doc/model/MemberLookup.scala
Expand Up @@ -14,7 +14,10 @@ package scala.tools.nsc
package doc
package model

import java.nio.file.Paths

import base._
import scala.tools.nsc.io.AbstractFile

/** This trait extracts all required information for documentation from compilation units */
trait MemberLookup extends base.MemberLookupBase {
Expand Down Expand Up @@ -85,8 +88,17 @@ trait MemberLookup extends base.MemberLookupBase {
}
}

/**
* Check if this file is a child of the given directory string. Can only be used
* on directories that actually exist in the file system.
*/
def isChildOf(f: AbstractFile, dir: String): Boolean = {
val parent = Paths.get(dir).toAbsolutePath().toString
f.canonicalPath.startsWith(parent)
}

private def isJDK(sym: Symbol) =
sym.associatedFile.underlyingSource.map(_.isChildOf(sys.props("java.home"))).getOrElse(false)
sym.associatedFile.underlyingSource.map(f => isChildOf(f, (sys.props("java.home")))).getOrElse(false)

def jdkUrl(path: String): String = {
if (path.endsWith(".jmod")) {
Expand Down

0 comments on commit 3091516

Please sign in to comment.