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

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/functions/BufferedDocumentScanner.java

Issue 8905009: Add syntax coloring support for raw strings and string interpolation (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years 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
Index: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/functions/BufferedDocumentScanner.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/functions/BufferedDocumentScanner.java (revision 2344)
+++ editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/functions/BufferedDocumentScanner.java (working copy)
@@ -1,16 +1,14 @@
/*
* Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
+ *
+ * Licensed under the Eclipse Public License v1.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.dart.tools.ui.internal.text.functions;
@@ -58,9 +56,6 @@
fBuffer = new char[size];
}
- /*
- * @see ICharacterScanner#getColumn()
- */
@Override
public final int getColumn() {
@@ -75,17 +70,46 @@
return -1;
}
- /*
- * @see ICharacterScanner#getLegalLineDelimiters()
- */
@Override
public final char[][] getLegalLineDelimiters() {
return fDelimiters;
}
- /*
- * @see ICharacterScanner#read()
+ /**
+ * Peek ahead in the buffer without changing the current offset. The distance, which must be both
+ * non-negative and less than the maximum size of the buffer, is the number of characters past the
+ * current position to look. A distance of zero (<code>0</code>) will return the same character
+ * that {@link #read()} would return, but without advancing the position.
+ *
+ * @param distance the number of characters past the current character to look
+ * @return the character at the specified position, or {@link ICharacterScanner#EOF} if the
+ * position is past the end of the document
*/
+ public final int peek(int distance) {
+ if (distance < 0) {
+ throw new IllegalArgumentException("Cannot peek before current position (distance = "
+ + distance + ")");
+ } else if (distance >= fBuffer.length) {
+ throw new IllegalArgumentException("Cannot peek more than " + (fBuffer.length - 1)
+ + " character after the current position (distance = " + distance + ")");
+ }
+ int targetOffset = fOffset + distance;
+ if (targetOffset >= fBufferLength) {
+ int end = fBufferOffset + fBufferLength;
+ if (end == fDocument.getLength() || end == fRangeOffset + fRangeLength) {
+ return EOF;
+ } else {
+ updateBuffer(fBufferOffset + fBufferLength);
+ fOffset = 0;
+ }
+ }
+ if (targetOffset < fBufferLength) {
+ return fBuffer[targetOffset];
+ } else {
+ return EOF;
+ }
+ }
+
@Override
public final int read() {
@@ -142,9 +166,6 @@
fOffset = 0;
}
- /*
- * @see ICharacterScanner#unread
- */
@Override
public final void unread() {
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/functions/FastDartPartitionScanner.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698