Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/text/folding/DartFoldingStructureProvider.java

Issue 17567005: Stop looking for a start token if the last token is detected. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/text/folding/DartFoldingStructureProvider.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/text/folding/DartFoldingStructureProvider.java (revision 24333)
+++ editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/text/folding/DartFoldingStructureProvider.java (working copy)
@@ -244,11 +244,7 @@
return model;
}
- private TokenStream getScanner() {
- return getScanner(0);
- }
-
- private TokenStream getScanner(int start) {
+ private TokenStream getScanner(int start) throws InvalidSourceException {
tokenStream.begin(start);
return tokenStream;
}
@@ -565,7 +561,7 @@
}
}
- void begin(int start) {
+ void begin(int start) throws InvalidSourceException {
if (start == begin) {
return;
}
@@ -573,8 +569,13 @@
begin = 0;
currentToken = firstToken;
}
+ Token prev = currentToken;
while (begin < start) {
currentToken = currentToken.getNext();
+ if (currentToken == prev) {
+ throw new InvalidSourceException();
+ }
+ prev = currentToken;
begin = currentToken.getOffset();
}
}
@@ -819,7 +820,12 @@
}
}
int shift = range.getOffset();
- TokenStream scanner = ctx.getScanner(shift);
+ TokenStream scanner;
+ try {
+ scanner = ctx.getScanner(shift);
+ } catch (InvalidSourceException ex) {
+ return new IRegion[0];
+ }
int start = shift;
Token token = scanner.next();
start = token.getOffset();
@@ -974,7 +980,12 @@
private IRegion computeHeaderComment(FoldingStructureComputationContext ctx) {
// search at most up to the first element
- TokenStream scanner = ctx.getScanner();
+ TokenStream scanner;
+ try {
+ scanner = ctx.getScanner(0);
+ } catch (InvalidSourceException ex) {
+ return null;
+ }
int headerStart = -1;
int headerEnd = -1;
boolean foundComment = false;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698