Re: Compiler plugin for warning suppression
Roman Janusz <[email protected]>
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <[email protected]> |
1) treeRangePos simply computes range position based on all positions "seen" in the tree. This could potentially not catch some warnings issued for positions of trees which are already not present after typer. This should be easily fixable, though. 2) You're right, it probably doesn't work in presentation compiler. It would be nice to be able to declare that a PluginComponent which runs just after typer could be also invoked by the presentation compiler. 3) I assume you are referring to the fact that the plugin delays reporting of warnings until the typer phase is done. This is because it needs fully typechecked tree so that it can properly detect the @silent annotations. I was aware that this could *potentially* break something, but it seemed strange to me that some compiler code would rely on warnings like that. I did a quick search for hasWarnings in the compiler code and did not find anything. Anyway, this is one thing that I definitely wanted to ask here about, so thank you for bringing this up. I didn't know that AnalyzerPlugin and MacroPlugin exist. The solution to both 2) and 3) would be to move the annotation detection before the typer, but I'm not sure how to do it at a phase where my annotations are not yet typechecked. I could do some hairy stuff like trying to resolve imports to @silent manually, but this is always going to be limited and incorrect in general case (although it would still be useful to me). 4) You mean to add a possibility to suppress warnings e.g. by using some magic import which would suppress warnings in entire file? Seems a little out of scope of what I needed and it can't be done with annotations, so currently I'd prefer to leave it as it is, i.e. fully annotation-based. W dniu środa, 15 kwietnia 2015 08:23:55 UTC+2 użytkownik Eugene Burmako napisał: > > Some questions: > 1) treeRangePos says "approximate". Is it possible to make it > non-approximate? > 2) Will this work with Scala IDE? Iirc it only runs up until typer and > then stops compilation. > 3) In general, what about extensibility? If an AnalyzerPlugin and/or > MacroPlugin plugin wants to check whether there are warnings reported, how > does it do that? > 4) What do you think of per-file and per-project suppressions? > > On Tuesday, April 14, 2015 at 11:46:01 PM UTC+2, Roman Janusz wrote: >> >> Hello, >> >> Recently, inspired by the Towards a Safer Scala >> <http://confreaks.tv/videos/pnws2014-towards-a-safer-scala> talk from >> this year's ScalaDays, I wanted to try out the set of scalac options >> recommended by the speaker: >> >> scalacOptions ++= Seq( >> "-Xlint", >> "-Xdeprecation", >> "-Xfatal-warnings" >> ) >> >> Unfortunately, almost immediately I ran into a show-stopper: Scala has no >> warning suppression similar to Java's @SuppressWarnings. I googled >> around and unpleasantly found out that requests for this feature have been >> rejected. See for example SI-1781 >> <https://issues.scala-lang.org/browse/SI-1781>. >> >> But I realized that writing a compiler plugin which could fill that gap >> would not be that hard. >> >> So here it is: >> >> *silencer <https://github.com/ghik/silencer>*It would be nice to have >> some feedback from you, Scala users, to see if there is any interest in >> maintaining such plugin. The current proof-of-concept implementation is >> really simple and small, but uses internal scalac API, so I guess there's >> no guarantee that it won't break with some new Scala version. That is also >> why I think some community support would help a lot. >> >> Cheers, >> Roman >> > -- You received this message because you are subscribed to the Google Groups "scala-language" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.