Skip to content

Instantly share code, notes, and snippets.

@ignatov
Created June 18, 2011 09:03
Show Gist options
  • Save ignatov/1032939 to your computer and use it in GitHub Desktop.
Save ignatov/1032939 to your computer and use it in GitHub Desktop.
Colladoc: Model rebuild
Index: src/main/scala/scala/tools/colladoc/model/mapper/User.scala
===================================================================
--- src/main/scala/scala/tools/colladoc/model/mapper/User.scala (revision 0b95b1d340a4c9660fd027a0e3c6ccf7143c2596)
+++ src/main/scala/scala/tools/colladoc/model/mapper/User.scala (revision )
@@ -32,6 +32,7 @@
import js.JE.ValById
import net.liftweb.util.Helpers._
import xml.Text
+import lib.DependencyFactory
import lib.js.JqUI.ReloadTable
/**
@@ -259,7 +260,7 @@
<h4>Work with source code:</h4>
{SHtml.ajaxButton("Reload from source",
() => {
- Model.rebuild
+ DependencyFactory.rebuild
S.notice("Model successfully reloaded from source")
Noop },
("class", "ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only admin-button"))}
@@ -369,4 +370,4 @@
}
}
-}
\ No newline at end of file
+}
Index: src/main/scala/scala/tools/colladoc/model/Model.scala
===================================================================
--- src/main/scala/scala/tools/colladoc/model/Model.scala (revision 0b95b1d340a4c9660fd027a0e3c6ccf7143c2596)
+++ src/main/scala/scala/tools/colladoc/model/Model.scala (revision )
@@ -101,19 +101,14 @@
val factory = new Factory()
- var model = factory construct (getSources)
+ def build = new Factory().construct(getSources)
- /** Rebuild model. */
- def rebuild {
- model = new Factory() construct (getSources)
- }
-
/** Update model path.
* @param path new model path
*/
def updatePath(path: String) {
settings.sourcepath.value = path
- rebuild
+ DependencyFactory.rebuild
}
/**
@@ -133,8 +128,7 @@
/** Initialize model. */
def init() {
- List(model)
-
+ List(build)
}
}
Index: src/main/scala/scala/tools/colladoc/api/ExportService.scala
===================================================================
--- src/main/scala/scala/tools/colladoc/api/ExportService.scala (revision 0b95b1d340a4c9660fd027a0e3c6ccf7143c2596)
+++ src/main/scala/scala/tools/colladoc/api/ExportService.scala (revision )
@@ -38,6 +38,7 @@
import collection.mutable.HashSet
import tools.nsc.doc.model._
import xml.{Node, NodeSeq}
+import lib.DependencyFactory.model
object ExportService extends RestHelper {
@@ -55,7 +56,7 @@
case _ => Long.MaxValue
}
<scaladoc>
- { new Traversal(rec, rev) construct(Model.model.rootPackage, path) }
+ { new Traversal(rec, rev) construct(model.vend.rootPackage, path) }
</scaladoc>
}
Index: src/main/scala/scala/tools/colladoc/lib/DependencyFactory.scala
===================================================================
--- src/main/scala/scala/tools/colladoc/lib/DependencyFactory.scala (revision 0b95b1d340a4c9660fd027a0e3c6ccf7143c2596)
+++ src/main/scala/scala/tools/colladoc/lib/DependencyFactory.scala (revision )
@@ -54,11 +54,17 @@
// Make sure that we index the model when it is created.
getIndex
- Model.model
+ Model.build
}
private lazy val getIndex =
- new SearchIndex(Model.model.rootPackage, getComment)
+ new SearchIndex(Model.build.rootPackage, getComment)
+
+ private def rebuildModel = model.default.set(Model.build)
+
+ private def rebuildIndex = index.default.set(new SearchIndex(Model.build.rootPackage, getComment))
+
+ def rebuild = {rebuildIndex; rebuildModel}
}
}
Index: src/main/scala/scala/tools/colladoc/page/History.scala
===================================================================
--- src/main/scala/scala/tools/colladoc/page/History.scala (revision 0b95b1d340a4c9660fd027a0e3c6ccf7143c2596)
+++ src/main/scala/scala/tools/colladoc/page/History.scala (revision )
@@ -34,6 +34,7 @@
import collection.mutable.HashMap
import tools.nsc.doc.model._
import xml.NodeSeq
+import lib.DependencyFactory.model
/**
* Page with history of all comment changes displayed in the form of timeline.
@@ -154,7 +155,7 @@
* @return member entity if found, none otherwise
*/
def commentToMember(cmt: Comment) = {
- nameToMember(Model.model.rootPackage, cmt.qualifiedName.is) match {
+ nameToMember(model.vend.rootPackage, cmt.qualifiedName.is) match {
case Some(m) =>
val c = Model.factory.parse(m, cmt.comment.is)
Some(Model.factory.copyMember(m, c)(cmt))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment