001 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
002 // for details. All rights reserved. Use of this source code is governed by a
003 // BSD-style license that can be found in the LICENSE file.
004
005 package com.google.dart.compiler.common;
006
007 import com.google.dart.compiler.Source;
008
009 import java.io.Serializable;
010
011 /**
012 * Tracks file and line information for AST nodes.
013 */
014 public interface SourceInfo extends Serializable {
015
016 /**
017 * The source code provider.
018 */
019 Source getSource();
020
021 /**
022 * @return A 1-based line number into the original source file indicating
023 * where the source fragment begins.
024 */
025 int getLine();
026
027 /**
028 * @return A 1-based column number into the original source file indicating
029 * where the source fragment begins.
030 */
031 int getColumn();
032
033 /**
034 * Returns the character index into the original source file indicating
035 * where the source fragment corresponding to this node begins.
036 *
037 * <p>
038 * The parser supplies useful well-defined source ranges to the nodes it creates.
039 *
040 * @return the 0-based character index, or <code>-1</code>
041 * if no source startPosition information is recorded for this node
042 * @see #getLength()
043 * @see HasSourceInfo#setSourceLocation(Source, int, int, int, int)
044 */
045 int getStart();
046
047 /**
048 * Returns the length in characters of the original source file indicating
049 * where the source fragment corresponding to this node ends.
050 * <p>
051 * The parser supplies useful well-defined source ranges to the nodes it creates.
052 *
053 * @return a (possibly 0) length, or <code>0</code>
054 * if no source source position information is recorded for this node
055 * @see #getStart()
056 * @see HasSourceInfo#setSourceLocation(Source, int, int, int, int)
057 */
058 int getLength();
059 }