~ubuntu-branches/debian/sid/scala/sid

« back to all changes in this revision

Viewing changes to src/library/scala/util/parsing/input/Position.scala

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg, Mehdi Dogguy, Lucas Satabin, Frank S. Thomas, Emmanuel Bourg
  • Date: 2015-06-05 23:52:59 UTC
  • mfrom: (1.2.11)
  • Revision ID: package-import@ubuntu.com-20150605235259-wk00vgk83dh8o19g
Tags: 2.10.5-1
* Team upload.

[ Mehdi Dogguy ]
* New upstream release (Closes: #744278).

[ Lucas Satabin ]
* Update patches
* Update the clean target
* Update paths of elements to install
* Update watch file

[ Frank S. Thomas ]
* Remove myself from Uploaders.

[ Emmanuel Bourg ]
* The package has been adopted by the Java Team (Closes: #754935)
* Patched the build to avoid downloading libraries from the Internet
* Replaced the minified JavaScript files with unobfuscated ones
* No longer build scala-partest.jar until diffutils is packaged or replaced
* debian/watch: Fixed the versions matched (x.y.z instead of x.y.z..z)
* debian/rules:
  - Added the missing get-orig-source target (Closes: #724704)
  - Improved the clean target
* debian/control:
  - Build depend on scala (>= 2.10) and bnd
  - Use canonical URLs for the Vcs-* fields
  - Standards-Version updated to 3.9.6 (no changes)
* Switch to debhelper level 9

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*                     __                                               *\
2
2
**     ________ ___   / /  ___     Scala API                            **
3
 
**    / __/ __// _ | / /  / _ |    (c) 2006-2011, LAMP/EPFL             **
 
3
**    / __/ __// _ | / /  / _ |    (c) 2006-2013, LAMP/EPFL             **
4
4
**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
5
5
** /____/\___/_/ |_/____/_/ | |                                         **
6
6
**                          |/                                          **
8
8
 
9
9
package scala.util.parsing.input
10
10
 
11
 
/** <p>
12
 
 *    <code>Position</code> is the base trait for objects describing a
13
 
 *    position in a ``document''.
14
 
 *  </p>
15
 
 *  <p>
16
 
 *    It provides functionality for:
17
 
 *  </p><ul>
18
 
 *    <li> generating a visual representation of this position (`longString');
19
 
 *    <li> comparing two positions (`<').
20
 
 *  </ul>
21
 
 *  <p>
22
 
 *    To use this class for a concrete kind of ``document'', implement the
23
 
 *    <code>lineContents</code> method.
24
 
 *  </p>
25
 
 *
26
 
 * @author Martin Odersky, Adriaan Moors
 
11
/** `Position` is the base trait for objects describing a position in a ``document''.
 
12
 *
 
13
 *  It provides functionality for:
 
14
 *   - generating a visual representation of this position (`longString`);
 
15
 *   - comparing two positions (`<`).
 
16
 *
 
17
 *  To use this class for a concrete kind of ``document'', implement the `lineContents` method.
 
18
 *
 
19
 * @author Martin Odersky
 
20
 * @author Adriaan Moors
27
21
 */
28
22
trait Position {
29
23
 
30
 
  /** The line number referred to by the position; line numbers start at 1 */
 
24
  /** The line number referred to by the position; line numbers start at 1. */
31
25
  def line: Int
32
26
 
33
 
  /** The column number referred to by the position; column numbers start at 1 */
 
27
  /** The column number referred to by the position; column numbers start at 1. */
34
28
  def column: Int
35
29
 
36
 
  /** The contents of the line numbered `lnum' (must not contain a new-line character).
37
 
   *
38
 
   * @param lnum a 1-based integer index into the `document'
39
 
   * @return the line at `lnum' (not including a newline)
 
30
  /** The contents of the line at this position. (must not contain a new-line character).
40
31
   */
41
32
  protected def lineContents: String
42
33
 
43
 
  /** Returns a string representation of the `Position', of the form `line.column' */
 
34
  /** Returns a string representation of the `Position`, of the form `line.column`. */
44
35
  override def toString = ""+line+"."+column
45
36
 
46
37
  /** Returns a more ``visual'' representation of this position.
47
 
   *  More precisely, the resulting string consists of two lines: <ol>
48
 
   *    <li> the line in the document referred to by this position </li>
49
 
   *    <li>a caret indicating the column</li></ol>
 
38
   *  More precisely, the resulting string consists of two lines:
 
39
   *   1. the line in the document referred to by this position
 
40
   *   2. a caret indicating the column
50
41
   *
51
42
   *  Example:
52
 
   *
53
 
   *<pre>    List(this, is, a, line, from, the, document)
54
 
   *                  ^</pre>
 
43
   *  {{{
 
44
   *    List(this, is, a, line, from, the, document)
 
45
   *                 ^
 
46
   *  }}}
55
47
   */
56
48
  def longString = lineContents+"\n"+lineContents.take(column-1).map{x => if (x == '\t') x else ' ' } + "^"
57
49
 
58
50
  /** Compare this position to another, by first comparing their line numbers,
59
51
   * and then -- if necessary -- using the columns to break a tie.
60
52
   *
61
 
   * @param `that' a `Position' to compare to this `Position'
62
 
   * @return true if this position's line or (in case of a tie wrt. line numbers)
63
 
   *         its column is smaller than the corresponding components of `that'
 
53
   * @param `that` a `Position` to compare to this `Position`
 
54
   * @return true if this position's line number or (in case of equal line numbers)
 
55
   *         column is smaller than the corresponding components of `that`
64
56
   */
65
57
  def <(that: Position) = {
66
58
    this.line < that.line ||