Skip to content

Commit

Permalink
Link now keeps a reference to the stable id (if it exists).
Browse files Browse the repository at this point in the history
  • Loading branch information
olim7t authored and harrah committed Jun 4, 2010
1 parent 851a979 commit 97acddd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/main/scala/Browse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -372,14 +372,14 @@ abstract class Browse extends Plugin
private def makeLink(from: File, to: File, id: Int): Some[Link] =
{
val base = if(to == from) "" else FileUtil.relativePath(relativeSource(from), relativeSource(to))
Some(new Link(base, id))
Some(new Link(base, id, None))
}
private def externalLinkTo(from: File, sym: Symbol, links: LinkMap): Option[Link] =
{
if(publicSymbol(sym))
{
val name = stableID(sym)
links(name) map { case (src, id) => new Link(src, id) }
links(name) map { case (src, id) => new Link(src, id, Some(name)) }
}
else
None
Expand Down Expand Up @@ -412,4 +412,4 @@ abstract class Browse extends Plugin
// for compatibility with 2.8
package forScope {
class Sequence
}
}
7 changes: 4 additions & 3 deletions src/main/scala/Token.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
package sxr

/** Represents a link to a definition. The path is the relative path to the file in the source
* directory, and target is the symbol ID targeted.
* directory, target is the symbol ID targeted. stableID is an identifier that will survive
* successive sxr runs (only used for public symbols).
* Specific writers need to construct the actual path from these informations (e.g in
* HtmlWriter, add '.html' to get the relative path of the target HTML file, and append the
* ID separated by a '#'. */
private class Link(val path: String, val target: Int) extends NotNull
private class Link(val path: String, val target: Int, val stableID: Option[String]) extends NotNull
{
// This can still be useful for debugging, but must not be used directly by a writer.
override def toString = path + "#" + target
def retarget(newTarget: Int) = new Link(path, newTarget)
def retarget(newTarget: Int) = new Link(path, newTarget, stableID)
}
/** Represents a token at the lexer level with associated type information.
* 'start' is the offset of the token in the original source file.
Expand Down

0 comments on commit 97acddd

Please sign in to comment.