Skip to content

Instantly share code, notes, and snippets.

@Daxten
Created February 14, 2017 21:33
Show Gist options
  • Save Daxten/7b1396eff91d4ba937f2d73e29c1d6ad to your computer and use it in GitHub Desktop.
Save Daxten/7b1396eff91d4ba937f2d73e29c1d6ad to your computer and use it in GitHub Desktop.
def isCaseClass(tree: Tree): Boolean = {
tree.is[Defn.Class] && tree.children.exists(_.is[Mod.Case]) ||
tree.parent.exists(_.is[Defn.Class]) && tree.parent.exists(_.children.exists(_.is[Mod.Case]))
}
def isCaseObject(tree: Tree): Boolean = {
tree.is[Defn.Object] && tree.children.exists(_.is[Mod.Case]) ||
tree.parent.exists(_.is[Defn.Object]) && tree.parent.exists(_.children.exists(_.is[Mod.Case]))
}
def isFinalClass(tree: Tree): Boolean = {
tree.is[Defn.Class] && tree.children.exists(_.is[Mod.Final]) ||
tree.parent.exists(_.is[Defn.Class]) && tree.parent.exists(_.children.exists(_.is[Mod.Final]))
}
def isBasicClass(tree: Tree): Boolean = {
tree.is[Defn.Class] && !tree.children.exists(e => e.is[Mod.Final] || e.is[Mod.Case]) ||
tree.parent.exists(_.is[Defn.Class]) && !tree.parent.exists(_.children.exists(e => e.is[Mod.Final] || e.is[Mod.Case]))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment