Skip to content

Commit

Permalink
Clean code.
Browse files Browse the repository at this point in the history
  • Loading branch information
jushi committed Jul 2, 2012
1 parent 1feea08 commit 262fc80
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/scala/com/github/zhongl/housemd/command/Loaded.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,20 @@ class Loaded(val inst: Instrumentation, out: PrintOut)
val k = classSimpleName()
val matched = inst.getAllLoadedClasses filter {simpleNameOf(_) == k}
if (matched.isEmpty) println("No matched class")
else matched foreach { c => println(c.getName + originOf(c)); if (hierarchyable()) layout(c.getClassLoader) }
else matched foreach { c =>
println(c.getName + originOf(c))
if (hierarchyable()) layout(Option(c.getClassLoader))
}
}

@tailrec
private def layout(cl: ClassLoader, lastIndents: String = "- ") {
private def layout(cl: Option[ClassLoader], lastIndents: String = "- ") {
cl match {
case null => Unit
case _ =>
case Some(loader) =>
val indents = tab + lastIndents
println(indents + getOrForceToNativeString(cl))
layout(cl.getParent, indents)
layout(Option(loader.getParent), indents)
case None =>
}
}

Expand Down

0 comments on commit 262fc80

Please sign in to comment.