OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012, the Dart project authors. | 2 * Copyright (c) 2012, the Dart project authors. |
3 * | 3 * |
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 this.reader = reader; | 59 this.reader = reader; |
60 } | 60 } |
61 | 61 |
62 /** | 62 /** |
63 * Return the first token in the range of tokens that are different from the t
okens in the | 63 * Return the first token in the range of tokens that are different from the t
okens in the |
64 * original token stream or {@code null} if the new tokens are the same as the
original tokens | 64 * original token stream or {@code null} if the new tokens are the same as the
original tokens |
65 * except for offset. | 65 * except for offset. |
66 * | 66 * |
67 * @return the first token in the range of new tokens | 67 * @return the first token in the range of new tokens |
68 */ | 68 */ |
| 69 @Override |
69 public Token getFirstToken() { | 70 public Token getFirstToken() { |
70 return firstToken; | 71 return firstToken; |
71 } | 72 } |
72 | 73 |
73 /** | 74 /** |
74 * Return the last token in the range of tokens that are different from the to
kens in the original | 75 * Return the last token in the range of tokens that are different from the to
kens in the original |
75 * token stream or {@code null} if the new tokens are the same as the original
tokens except for | 76 * token stream or {@code null} if the new tokens are the same as the original
tokens except for |
76 * offset. | 77 * offset. |
77 * | 78 * |
78 * @return the last token in the range of new tokens | 79 * @return the last token in the range of new tokens |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 while (originalStream.getType() != TokenType.EOF) { | 166 while (originalStream.getType() != TokenType.EOF) { |
166 originalStream = copyAndAdvance(originalStream, delta); | 167 originalStream = copyAndAdvance(originalStream, delta); |
167 } | 168 } |
168 Token eof = copyAndAdvance(originalStream, delta); | 169 Token eof = copyAndAdvance(originalStream, delta); |
169 eof.setNextWithoutSettingPrevious(eof); | 170 eof.setNextWithoutSettingPrevious(eof); |
170 // | 171 // |
171 // TODO(brianwilkerson) Begin tokens are not getting associated with the cor
responding end | 172 // TODO(brianwilkerson) Begin tokens are not getting associated with the cor
responding end |
172 // tokens (because the end tokens have not been copied when we're copyin
g the begin tokens). | 173 // tokens (because the end tokens have not been copied when we're copyin
g the begin tokens). |
173 // TODO(brianwilkerson) Update the lineInfo. | 174 // TODO(brianwilkerson) Update the lineInfo. |
174 // | 175 // |
175 return firstToken(); | 176 return super.getFirstToken(); |
176 } | 177 } |
177 | 178 |
178 private Token copyAndAdvance(Token originalToken, int delta) { | 179 private Token copyAndAdvance(Token originalToken, int delta) { |
179 Token copiedToken = originalToken.copy(); | 180 Token copiedToken = originalToken.copy(); |
180 tokenMap.put(originalToken, copiedToken); | 181 tokenMap.put(originalToken, copiedToken); |
181 copiedToken.applyDelta(delta); | 182 copiedToken.applyDelta(delta); |
182 appendToken(copiedToken); | 183 appendToken(copiedToken); |
183 | 184 |
184 Token originalComment = originalToken.getPrecedingComments(); | 185 Token originalComment = originalToken.getPrecedingComments(); |
185 Token copiedComment = originalToken.getPrecedingComments(); | 186 Token copiedComment = originalToken.getPrecedingComments(); |
186 while (originalComment != null) { | 187 while (originalComment != null) { |
187 tokenMap.put(originalComment, copiedComment); | 188 tokenMap.put(originalComment, copiedComment); |
188 originalComment = originalComment.getNext(); | 189 originalComment = originalComment.getNext(); |
189 copiedComment = copiedComment.getNext(); | 190 copiedComment = copiedComment.getNext(); |
190 } | 191 } |
191 return originalToken.getNext(); | 192 return originalToken.getNext(); |
192 } | 193 } |
193 } | 194 } |
OLD | NEW |