annotate graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/SourceSection.java @ 20131:4b12d5355811

Truffle: do not use iterators for visitors.
author Christian Humer <christian.humer@gmail.com>
date Thu, 02 Apr 2015 01:27:27 +0200
parents 33bdafbf285d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16068
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
1 /*
19695
33bdafbf285d Truffle: SourceSection can now produce the line/column coordinates of its final character
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16068
diff changeset
2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
16068
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
4 *
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation. Oracle designates this
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
8 * particular file as subject to the "Classpath" exception as provided
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
9 * by Oracle in the LICENSE file that accompanied this code.
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
10 *
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
11 * This code is distributed in the hope that it will be useful, but WITHOUT
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
14 * version 2 for more details (a copy is included in the LICENSE file that
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
15 * accompanied this code).
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
16 *
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License version
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
18 * 2 along with this work; if not, write to the Free Software Foundation,
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
20 *
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
22 * or visit www.oracle.com if you need additional information or have any
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
23 * questions.
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
24 */
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
25 package com.oracle.truffle.api.source;
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
26
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
27 /**
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
28 * Description of contiguous section of text within a {@link Source} of program code; supports
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
29 * multiple modes of access to the text and its location. A special {@linkplain NullSourceSection
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
30 * null subtype} should be used for code that is not available from source, e.g language builtins.
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
31 *
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
32 * @see Source#createSection(String, int, int, int, int)
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
33 * @see Source#createSection(String, int, int, int)
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
34 * @see Source#createSection(String, int, int)
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
35 * @see Source#createSection(String, int)
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
36 * @see NullSourceSection
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
37 */
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
38 public interface SourceSection {
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
39
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
40 // TODO support alternate text representations/encodings
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
41
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
42 /**
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
43 * Representation of the source program that contains this section.
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
44 *
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
45 * @return the source object
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
46 */
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
47 Source getSource();
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
48
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
49 /**
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
50 * Returns 1-based line number of the first character in this section (inclusive).
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
51 *
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
52 * @return the starting line number
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
53 */
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
54 int getStartLine();
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
55
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
56 /**
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
57 * Gets a representation of the first line of the section, suitable for a hash key.
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
58 */
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
59 LineLocation getLineLocation();
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
60
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
61 /**
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
62 * Returns the 1-based column number of the first character in this section (inclusive).
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
63 *
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
64 * @return the starting column number
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
65 */
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
66 int getStartColumn();
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
67
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
68 /**
19695
33bdafbf285d Truffle: SourceSection can now produce the line/column coordinates of its final character
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16068
diff changeset
69 * Returns 1-based line number of the last character in this section (inclusive).
33bdafbf285d Truffle: SourceSection can now produce the line/column coordinates of its final character
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16068
diff changeset
70 *
33bdafbf285d Truffle: SourceSection can now produce the line/column coordinates of its final character
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16068
diff changeset
71 * @return the starting line number
33bdafbf285d Truffle: SourceSection can now produce the line/column coordinates of its final character
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16068
diff changeset
72 */
33bdafbf285d Truffle: SourceSection can now produce the line/column coordinates of its final character
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16068
diff changeset
73 int getEndLine();
33bdafbf285d Truffle: SourceSection can now produce the line/column coordinates of its final character
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16068
diff changeset
74
33bdafbf285d Truffle: SourceSection can now produce the line/column coordinates of its final character
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16068
diff changeset
75 /**
33bdafbf285d Truffle: SourceSection can now produce the line/column coordinates of its final character
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16068
diff changeset
76 * Returns the 1-based column number of the last character in this section (inclusive).
33bdafbf285d Truffle: SourceSection can now produce the line/column coordinates of its final character
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16068
diff changeset
77 *
33bdafbf285d Truffle: SourceSection can now produce the line/column coordinates of its final character
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16068
diff changeset
78 * @return the starting column number
33bdafbf285d Truffle: SourceSection can now produce the line/column coordinates of its final character
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16068
diff changeset
79 */
33bdafbf285d Truffle: SourceSection can now produce the line/column coordinates of its final character
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16068
diff changeset
80 int getEndColumn();
33bdafbf285d Truffle: SourceSection can now produce the line/column coordinates of its final character
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16068
diff changeset
81
33bdafbf285d Truffle: SourceSection can now produce the line/column coordinates of its final character
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16068
diff changeset
82 /**
16068
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
83 * Returns the 0-based index of the first character in this section.
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
84 *
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
85 * @return the starting character index
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
86 */
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
87 int getCharIndex();
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
88
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
89 /**
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
90 * Returns the length of this section in characters.
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
91 *
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
92 * @return the number of characters in the section
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
93 */
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
94 int getCharLength();
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
95
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
96 /**
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
97 * Returns the index of the text position immediately following the last character in the
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
98 * section.
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
99 *
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
100 * @return the end position of the section
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
101 */
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
102 int getCharEndIndex();
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
103
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
104 /**
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
105 * Returns terse text describing this source section, typically used for printing the section.
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
106 *
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
107 * @return the identifier of the section
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
108 */
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
109 String getIdentifier();
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
110
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
111 /**
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
112 * Returns text described by this section.
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
113 *
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
114 * @return the code as a String object
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
115 */
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
116 String getCode();
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
117
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
118 /**
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
119 * Returns a short description of the source section, using just the file name, rather than its
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
120 * full path.
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
121 *
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
122 * @return a short description of the source section
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
123 */
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
124 String getShortDescription();
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
125
74e142bd2b12 Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
126 }