diff options
author | Paul Phillips <paulp@improving.org> | 2013-09-27 14:38:38 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-09-27 14:42:24 -0700 |
commit | 7d62df035cd4393c73e7530e1cad1130e79d90c6 (patch) | |
tree | 8a643ea65861b7bceb8d22397d991401b8716079 /src/reflect/scala/reflect/internal/util/Position.scala | |
parent | 5a8cd09819f58adcb866722f48b00066d23e7a82 (diff) | |
download | scala-7d62df035cd4393c73e7530e1cad1130e79d90c6.tar.gz scala-7d62df035cd4393c73e7530e1cad1130e79d90c6.tar.bz2 scala-7d62df035cd4393c73e7530e1cad1130e79d90c6.zip |
Updating Position call sites.
Calling position factories rather than instantiating these
particular classes. Not calling deprecated methods. Added a few
position combinator methods.
Diffstat (limited to 'src/reflect/scala/reflect/internal/util/Position.scala')
-rw-r--r-- | src/reflect/scala/reflect/internal/util/Position.scala | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/reflect/scala/reflect/internal/util/Position.scala b/src/reflect/scala/reflect/internal/util/Position.scala index 8e7df28167..15cfda26b5 100644 --- a/src/reflect/scala/reflect/internal/util/Position.scala +++ b/src/reflect/scala/reflect/internal/util/Position.scala @@ -169,6 +169,20 @@ private[util] trait InternalPositionImpl { def focus: Position = if (this.isRange) asOffset(point) else this def focusEnd: Position = if (this.isRange) asOffset(end) else this + /** If you have it in for punctuation you might not like these methods. + * However I think they're aptly named. + * + * | means union + * ^ means "the point" (look, it's a caret) + * |^ means union, taking the point of the rhs + * ^| means union, taking the point of the lhs + */ + def |(that: Position, poses: Position*): Position = poses.foldLeft(this | that)(_ | _) + def |(that: Position): Position = this union that + def ^(point: Int): Position = this withPoint point + def |^(that: Position): Position = (this | that) ^ that.point + def ^|(that: Position): Position = (this | that) ^ this.point + def union(pos: Position): Position = ( if (!pos.isRange) this else if (this.isRange) copyRange(start = start min pos.start, end = end max pos.end) @@ -246,9 +260,9 @@ private[util] trait DeprecatedPosition { @deprecated("Use `withSource(source)` and `withShift`", "2.11.0") def withSource(source: SourceFile, shift: Int): Position = this withSource source withShift shift - @deprecated("Use `start`", "2.11.0") + @deprecated("Use `start` instead", "2.11.0") def startOrPoint: Int = if (isRange) start else point - @deprecated("Use `end`", "2.11.0") + @deprecated("Use `end` instead", "2.11.0") def endOrPoint: Int = if (isRange) end else point } |