Skip to content

Commit

Permalink
Add error message - Comments.scala:128
Browse files Browse the repository at this point in the history
This commit adds the semantic object for the ```definition not found``` error.
It is part of the (scala#1589
  • Loading branch information
Thiago Pereira authored and Thiago Pereira committed Oct 24, 2016
1 parent cdb83f9 commit 96284b9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/dotty/tools/dotc/core/Comments.scala
Expand Up @@ -9,6 +9,7 @@ import util.Positions._
import util.CommentParsing._
import util.Property.Key
import parsing.Parsers.Parser
import reporting.diagnostic.messages.ProperDefinitionNotFound

object Comments {
val ContextDoc = new Key[ContextDocstrings]
Expand Down Expand Up @@ -125,7 +126,7 @@ object Comments {
val newName = (tree.name.show + "$" + codePos + "$doc").toTermName
untpd.DefDef(newName, tree.tparams, tree.vparamss, tree.tpt, tree.rhs)
case _ =>
ctx.error("proper definition was not found in `@usecase`", codePos)
ctx.error(ProperDefinitionNotFound(), codePos)
tree
}
}
Expand Down
21 changes: 21 additions & 0 deletions src/dotty/tools/dotc/reporting/diagnostic/messages.scala
Expand Up @@ -500,4 +500,25 @@ object messages {
|which cannot start with ${Red(illegalToken)}.""".stripMargin
}
}

case class ProperDefinitionNotFound()(implicit ctx: Context) extends Message(18) {
val kind = "Definition Not Found"
val msg = hl"""|Proper definition was not found in ${"@usecase"}"""
val explanation = {
hl"""|You should use ${"def"} when overriding the method signature on ${"@usecase"}.
|
|Example:
|
|${"def map[B, That](f: A => B)(implicit bf: CanBuildFrom[List[A], B, That] : That"}
|
|Could be written using ${"@usecase"} as follow:
|
|${"@usecase def map[B](f: A => B): List[B]"}
|
|This way you can hide the ugly definition by providing an easy readable version.
|
|""".stripMargin
}
}

}

0 comments on commit 96284b9

Please sign in to comment.