# HG changeset patch # User Michael Van De Vanter # Date 1370907986 25200 # Node ID b9b8af46c2b72d0a94d5390e4e26fb67ac06ce8c # Parent b8b4d7f3e4aa09a341836ac8ca8bb54c139f3b0f Upgrade the documentation for SourceSection, especially with respect to the specification of text locations. diff -r b8b4d7f3e4aa -r b9b8af46c2b7 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/SourceSection.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/SourceSection.java Mon Jun 10 17:00:14 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/SourceSection.java Mon Jun 10 16:46:26 2013 -0700 @@ -23,7 +23,7 @@ package com.oracle.truffle.api; /** - * Represents a section in the source code of a guest language program. + * Represents a contiguous text section within the source code of a guest language program. */ public class SourceSection { @@ -35,13 +35,26 @@ private final int charLength; /** - * Creates a new object representing a section in the source code of a guest language program. + * Creates a new object representing a contiguous text section within the source code of a guest + * language program. + *

+ * The starting location of the section is specified using two different coordinate: + *

+ * The newline that terminates each line counts as a single character for the purpose of + * a character index. The (row,column) coordinates of a newline character should never appear in + * a text section. + *

* - * @param source object representing the source program this is should be a section of + * @param source object representing the complete source program that contains this section * @param identifier an identifier used when printing the section - * @param startLine the index of the start line of the section - * @param startColumn the index of the start column of the section - * @param charIndex the index of the first character of the section + * @param startLine the 1-based number of the start line of the section + * @param startColumn the 1-based number of the start column of the section + * @param charIndex the 0-based index of the first character of the section * @param charLength the length of the section in number of characters */ public SourceSection(Source source, String identifier, int startLine, int startColumn, int charIndex, int charLength) { @@ -54,7 +67,7 @@ } /** - * Returns the source object representing the source program this is a section of. + * Returns the object representing the source program that contains this section. * * @return the source object */ @@ -63,38 +76,42 @@ } /** - * Returns the index of the start line of this source section (inclusive). + * Returns 1-based line number of the first character in this source section (inclusive). * - * @return the start line + * @return the starting line number */ public final int getStartLine() { return startLine; } /** - * Returns the index of the start column of this source section (inclusive). + * Returns the 1-based column number of the first character in this source section (inclusive). * - * @return the start column + * @return the starting column number */ public final int getStartColumn() { return startColumn; } /** - * Returns the index of the first character of this section. All characters of the source can be - * retrieved via the {@link Source#getCode()} method. + * Returns the 0-based index of the first character in this source section. + *

+ * The complete text of the source that contains this section can be retrieved via + * {@link Source#getCode()}. * - * @return the character index + * @return the starting character index */ public final int getCharIndex() { return charIndex; } /** - * Returns the length of this section in characters. All characters of the source can be - * retrieved via the {@link Source#getCode()} method. + * Returns the length of this source section in characters. + *

+ * The complete text of the source that contains this section can be retrieved via + * {@link Source#getCode()}. * - * @return the character length + * @return the number of characters in the section */ public final int getCharLength() { return charLength; @@ -110,7 +127,7 @@ } /** - * Returns the code represented by this code section. + * Returns text of the code represented by this source section. * * @return the code as a String object */