Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't fail for deprecated lazy vals, fixes #85. #113

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions plugin/src/main/scala/com/typesafe/genjavadoc/AST.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,22 @@ trait AST { this: TransformCake ⇒
def maybeSinceDot = if (since.endsWith(".")) " " else ". "
def render = s" * @deprecated ${msg}${maybeDot}Since $since${maybeSinceDot}"

def appendToComment(comment: Seq[String]): Seq[String] = comment match {
case Nil => List("/**", render, "*/")
case c => c.dropRight(1) ++ List(" *", render, "*/")
def fullComment = List("/**", render, "*/")

def appendToComment(comment: Seq[String]): Seq[String] = {
comment match {
case Nil => fullComment
case c :: Nil if c.trim.startsWith("//") =>
// sometimes `comment` is just a single line of `// not preceding`. In that case, we just keep that comment line
// and add the deprecation as the complete thing
c +: fullComment
case cs =>
if (!cs.lastOption.exists(_.trim == "*/"))
(cs :+ "// cannot join comments, what happened here? Report at https://github.com/typesafehub/genjavadoc.") ++
fullComment
else
cs.dropRight(1) ++ List(" *", render, "*/")
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ public class DeprecatedNoComment {
* @deprecated This is replaced by theShinyNewMethod. Since now.
*/
public void oldMethod () { throw new RuntimeException(); }
private void oldLazyVal$lzycompute () { throw new RuntimeException(); }
/**
* @deprecated This is replaced by theShinyNewLazyVal. Since now.
*/
public void oldLazyVal () { throw new RuntimeException(); }
}
3 changes: 3 additions & 0 deletions plugin/src/test/resources/input/basic/test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ private[it] class DontTouchThis {
class DeprecatedNoComment {
@deprecated("This is replaced by theShinyNewMethod", since = "now")
def oldMethod = ()

@deprecated("This is replaced by theShinyNewLazyVal", since = "now")
lazy val oldLazyVal= ()
}


Expand Down