diff options
author | Martin Odersky <odersky@gmail.com> | 2015-06-08 13:27:48 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-06-08 13:29:47 +0200 |
commit | 291aecabf400df4a85af498d1045b9ec618dda13 (patch) | |
tree | f32418cd98f829e2d50dfda889a73707ba1234a9 /src/dotty/tools/dotc/core/SymDenotations.scala | |
parent | 8191c86cba985e9edb596fbd1a2190c02cf45e0b (diff) | |
download | dotty-291aecabf400df4a85af498d1045b9ec618dda13.tar.gz dotty-291aecabf400df4a85af498d1045b9ec618dda13.tar.bz2 dotty-291aecabf400df4a85af498d1045b9ec618dda13.zip |
Methods for filtering annotations carrying meta information.
Diffstat (limited to 'src/dotty/tools/dotc/core/SymDenotations.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index f24c41ee2..9c6dde798 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -215,6 +215,10 @@ object SymDenotations { final def transformAnnotations(f: Annotation => Annotation)(implicit ctx: Context): Unit = annotations = annotations.mapConserve(f) + /** Keep only those annotations that satisfy `p` */ + final def filterAnnotations(p: Annotation => Boolean)(implicit ctx: Context): Unit = + annotations = annotations.filterConserve(p) + /** Optionally, the annotation matching the given class symbol */ final def getAnnotation(cls: Symbol)(implicit ctx: Context): Option[Annotation] = dropOtherAnnotations(annotations, cls) match { @@ -230,9 +234,9 @@ object SymDenotations { final def removeAnnotation(cls: Symbol)(implicit ctx: Context): Unit = annotations = myAnnotations.filterNot(_ matches cls) - /** Copy all annotations from given symbol by adding them to this symbol */ - final def addAnnotations(from: Symbol)(implicit ctx: Context): Unit = - from.annotations.foreach(addAnnotation) + /** Add all given annotations to this symbol */ + final def addAnnotations(annots: TraversableOnce[Annotation])(implicit ctx: Context): Unit = + annots.foreach(addAnnotation) @tailrec private def dropOtherAnnotations(anns: List[Annotation], cls: Symbol)(implicit ctx: Context): List[Annotation] = anns match { |