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

Side by Side Diff: compiler/java/com/google/dart/compiler/parser/CompletionHooksParserBase.java

Issue 10704180: Use 'int' instead of Position. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
Brian Wilkerson 2012/07/12 15:35:11 nit: copyright year
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 package com.google.dart.compiler.parser; 5 package com.google.dart.compiler.parser;
6 6
7 import com.google.dart.compiler.common.HasSourceInfo; 7 import com.google.dart.compiler.common.HasSourceInfo;
8 8
9 /** 9 /**
10 * This class exists to enforce constraints on begin calls so code 10 * This class exists to enforce constraints on begin calls so code
11 * completion works. 11 * completion works.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 private int minPositionRange = Integer.MAX_VALUE; 48 private int minPositionRange = Integer.MAX_VALUE;
49 private int threshold = THRESHOLD; 49 private int threshold = THRESHOLD;
50 50
51 /* 51 /*
52 * Guard against parser termination bugs. Called from begin(). 52 * Guard against parser termination bugs. Called from begin().
53 * If the parser does not consume tokens it is an indication that it is not 53 * If the parser does not consume tokens it is an indication that it is not
54 * making progress. Look at the stack in the exception for hints of 54 * making progress. Look at the stack in the exception for hints of
55 * productions at fault. Called from begin() 55 * productions at fault. Called from begin()
56 */ 56 */
57 public boolean assertProgress() { 57 public boolean assertProgress() {
58 int currentPosition = position().getPos(); 58 int currentPosition = position();
59 if (currentPosition > maxPositionRange) { 59 if (currentPosition > maxPositionRange) {
60 minPositionRange = maxPositionRange; 60 minPositionRange = maxPositionRange;
61 maxPositionRange = currentPosition; 61 maxPositionRange = currentPosition;
62 threshold = THRESHOLD; 62 threshold = THRESHOLD;
63 } else if (currentPosition < minPositionRange) { 63 } else if (currentPosition < minPositionRange) {
64 minPositionRange = currentPosition; 64 minPositionRange = currentPosition;
65 threshold = THRESHOLD; 65 threshold = THRESHOLD;
66 } 66 }
67 if (threshold-- <= 0) { 67 if (threshold-- <= 0) {
68 StringBuilder sb = new StringBuilder(); 68 StringBuilder sb = new StringBuilder();
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 * Begin a grammatical structure, saving the current location to later set in 449 * Begin a grammatical structure, saving the current location to later set in
450 * an AST node. This may be followed by zero or more 450 * an AST node. This may be followed by zero or more
451 * {@link #doneWithoutConsuming(Object)} calls, and is terminated by exactly 451 * {@link #doneWithoutConsuming(Object)} calls, and is terminated by exactly
452 * one {@link #done(Object)} or {@link #rollback()} call. 452 * one {@link #done(Object)} or {@link #rollback()} call.
453 */ 453 */
454 private void begin() { 454 private void begin() {
455 assert guard.assertProgress(); 455 assert guard.assertProgress();
456 ctx.begin(); 456 ctx.begin();
457 } 457 }
458 } 458 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698