01: /*
02: * Spoon - http://spoon.gforge.inria.fr/
03: * Copyright (C) 2006 INRIA Futurs <renaud.pawlak@inria.fr>
04: *
05: * This software is governed by the CeCILL-C License under French law and
06: * abiding by the rules of distribution of free software. You can use, modify
07: * and/or redistribute the software under the terms of the CeCILL-C license as
08: * circulated by CEA, CNRS and INRIA at http://www.cecill.info.
09: *
10: * This program is distributed in the hope that it will be useful, but WITHOUT
11: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12: * FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details.
13: *
14: * The fact that you are presently reading this means that you have had
15: * knowledge of the CeCILL-C license and that you accept its terms.
16: */
17:
18: package spoon.reflect.cu;
19:
20: import java.io.File;
21:
22: import spoon.processing.Environment;
23:
24: /**
25: * This interface represents the position of a program element in a source file.
26: */
27: public interface SourcePosition extends Cloneable {
28:
29: /**
30: * Returns a string representation of this position in the form
31: * "sourcefile:line", or "sourcefile" if no line number is available.
32: */
33: String toString();
34:
35: /**
36: * Gets the file for this position.
37: */
38: File getFile();
39:
40: /**
41: * Gets the compilation unit for this position.
42: */
43: CompilationUnit getCompilationUnit();
44:
45: /**
46: * Gets the line in the source file (1 indexed). Prefer using
47: * {@link #getSourceStart()}}.
48: */
49: int getLine();
50:
51: /**
52: * Gets the end line in the source file (1 indexed). Prefer using
53: * {@link #getSourceEnd()}}.
54: */
55: int getEndLine();
56:
57: /**
58: * Gets the column in the source file (1 indexed). This method is slow
59: * because it has to calculate the column number depending on
60: * {@link Environment#getTabulationSize()} and
61: * {@link CompilationUnit#getOriginalSourceCode()}. Prefer {@link #getSourceStart()}.
62: */
63: int getColumn();
64:
65: /**
66: * Gets the end column in the source file (1 indexed). This method is slow
67: * because it has to calculate the column number depending on
68: * {@link Environment#getTabulationSize()} and
69: * {@link CompilationUnit#getOriginalSourceCode()}. Prefer {@link #getSourceEnd()}.
70: */
71: int getEndColumn();
72:
73: /**
74: * Clones this position.
75: */
76: Object clone() throws CloneNotSupportedException;
77:
78: /**
79: * Gets the index at which the position ends in the source file.
80: */
81: int getSourceEnd();
82:
83: /**
84: * Gets the index at which the position starts in the source file.
85: */
86: int getSourceStart();
87:
88: }
|