Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultSourceSection.java @ 15371:c54f5fa05fd5
Truffle: add getShortName and getShortDescription to Source and SourceSection for when we don't need full paths.
author | Chris Seaton <chris.seaton@oracle.com> |
---|---|
date | Thu, 24 Apr 2014 23:29:04 +0100 |
parents | 5f532ea846fb |
children |
rev | line source |
---|---|
11610
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. Oracle designates this |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * particular file as subject to the "Classpath" exception as provided |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * by Oracle in the LICENSE file that accompanied this code. |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * accompanied this code). |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License version |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 * or visit www.oracle.com if you need additional information or have any |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 * questions. |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 */ |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 package com.oracle.truffle.api.impl; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 import com.oracle.truffle.api.*; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 /** |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 * Represents a contiguous text section within the source code of a guest language program. |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 */ |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 public class DefaultSourceSection implements SourceSection { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 private final Source source; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 private final String identifier; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 private final int startLine; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 private final int startColumn; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 private final int charIndex; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 private final int charLength; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 /** |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 * Creates a new object representing a contiguous text section within the source code of a guest |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 * language program's text. |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 * <p> |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 * The starting location of the section is specified using two different coordinate: |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 * <ul> |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 * <li><b>(row, column)</b>: rows and columns are 1-based, so the first character in a source |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 * file is at position {@code (1,1)}.</li> |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 * <li><b>character index</b>: 0-based offset of the character from the beginning of the source, |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 * so the first character in a file is at index {@code 0}.</li> |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 * </ul> |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 * The <b>newline</b> that terminates each line counts as a single character for the purpose of |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 * a character index. The (row,column) coordinates of a newline character should never appear in |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 * a text section. |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 * <p> |
15371
c54f5fa05fd5
Truffle: add getShortName and getShortDescription to Source and SourceSection for when we don't need full paths.
Chris Seaton <chris.seaton@oracle.com>
parents:
11610
diff
changeset
|
56 * |
11610
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 * @param source object representing the complete source program that contains this section |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 * @param identifier an identifier used when printing the section |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 * @param startLine the 1-based number of the start line of the section |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 * @param startColumn the 1-based number of the start column of the section |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 * @param charIndex the 0-based index of the first character of the section |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 * @param charLength the length of the section in number of characters |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 */ |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 public DefaultSourceSection(Source source, String identifier, int startLine, int startColumn, int charIndex, int charLength) { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 this.source = source; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 this.identifier = identifier; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 this.startLine = startLine; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 this.startColumn = startColumn; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 this.charIndex = charIndex; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 this.charLength = charLength; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 public final Source getSource() { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 return source; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 public final int getStartLine() { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 return startLine; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
79 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 public final int getStartColumn() { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 return startColumn; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
83 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
84 |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
85 public final int getCharIndex() { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
86 return charIndex; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
87 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
88 |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
89 public final int getCharLength() { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
90 return charLength; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
91 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
92 |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
93 public final int getCharEndIndex() { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
94 return charIndex + charLength; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
95 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
96 |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
97 public final String getIdentifier() { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
98 return identifier; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
99 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
100 |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
101 public final String getCode() { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
102 return getSource().getCode().substring(charIndex, charIndex + charLength); |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
103 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
104 |
15371
c54f5fa05fd5
Truffle: add getShortName and getShortDescription to Source and SourceSection for when we don't need full paths.
Chris Seaton <chris.seaton@oracle.com>
parents:
11610
diff
changeset
|
105 public final String getShortDescription() { |
c54f5fa05fd5
Truffle: add getShortName and getShortDescription to Source and SourceSection for when we don't need full paths.
Chris Seaton <chris.seaton@oracle.com>
parents:
11610
diff
changeset
|
106 return String.format("%s:%d", source.getShortName(), startLine); |
c54f5fa05fd5
Truffle: add getShortName and getShortDescription to Source and SourceSection for when we don't need full paths.
Chris Seaton <chris.seaton@oracle.com>
parents:
11610
diff
changeset
|
107 } |
c54f5fa05fd5
Truffle: add getShortName and getShortDescription to Source and SourceSection for when we don't need full paths.
Chris Seaton <chris.seaton@oracle.com>
parents:
11610
diff
changeset
|
108 |
11610
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
109 @Override |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
110 public String toString() { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
111 return String.format("%s:%d", source.getName(), startLine); |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
112 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
113 |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
114 @Override |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
115 public int hashCode() { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
116 final int prime = 31; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
117 int result = 1; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
118 result = prime * result + charIndex; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
119 result = prime * result + charLength; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
120 result = prime * result + ((identifier == null) ? 0 : identifier.hashCode()); |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
121 result = prime * result + ((source == null) ? 0 : source.hashCode()); |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
122 result = prime * result + startColumn; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
123 result = prime * result + startLine; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
124 return result; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
125 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
126 |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
127 @Override |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
128 public boolean equals(Object obj) { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
129 if (this == obj) { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
130 return true; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
131 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
132 if (obj == null) { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
133 return false; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
134 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
135 if (!(obj instanceof DefaultSourceSection)) { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
136 return false; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
137 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
138 DefaultSourceSection other = (DefaultSourceSection) obj; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
139 if (charIndex != other.charIndex) { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
140 return false; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
141 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
142 if (charLength != other.charLength) { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
143 return false; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
144 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
145 if (identifier == null) { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
146 if (other.identifier != null) { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
147 return false; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
148 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
149 } else if (!identifier.equals(other.identifier)) { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
150 return false; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
151 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
152 if (source == null) { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
153 if (other.source != null) { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
154 return false; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
155 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
156 } else if (!source.equals(other.source)) { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
157 return false; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
158 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
159 if (startColumn != other.startColumn) { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
160 return false; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
161 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
162 if (startLine != other.startLine) { |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
163 return false; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
164 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
165 return true; |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
166 } |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
167 |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
168 } |