SHARE
TWEET

Untitled

a guest Sep 16th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package warts
  2.  
  3. import org.wartremover.{WartTraverser, WartUniverse}
  4.  
  5. object LayerControl extends WartTraverser {
  6.   def apply(u: WartUniverse): u.Traverser = {
  7.     import u.universe._
  8.  
  9.     val layerName = "services"
  10.  
  11.     new Traverser {
  12.       override def traverse(tree: Tree) {
  13.         tree match {
  14.           // Ignore trees marked by SuppressWarnings
  15.           case t if hasWartAnnotation(u)(t) =>
  16.  
  17.           case ValDef(_, _, ref, _) if tree.pos.toString.contains(layerName) &&
  18.             layerName.r.findPrefixMatchOf(ref.toString()).nonEmpty =>
  19.             u.error(tree.pos, s"Calling $layerName from $layerName is not allowed.")
  20.  
  21.           case _ =>
  22.             super.traverse(tree)
  23.         }
  24.       }
  25.     }
  26.   }
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top