1 /******************************************************************************* 2 * Copyright (c) 2000, 2005 IBM Corporation and others. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * IBM Corporation - initial API and implementation 10 *******************************************************************************/ 11 12 package org.eclipse.jface.text.rules; 13 14 15 import org.eclipse.jface.text.IDocument; 16 17 18 /** 19 * A token scanner scans a range of a document and reports about the token it finds. 20 * A scanner has state. When asked, the scanner returns the offset and the length of the 21 * last found token. 22 * 23 * @see org.eclipse.jface.text.rules.IToken 24 * @since 2.0 25 */ 26 public interface ITokenScanner { 27 28 /** 29 * Configures the scanner by providing access to the document range that should 30 * be scanned. 31 * 32 * @param document the document to scan 33 * @param offset the offset of the document range to scan 34 * @param length the length of the document range to scan 35 */ 36 void setRange(IDocument document, int offset, int length); 37 38 /** 39 * Returns the next token in the document. 40 * 41 * @return the next token in the document 42 */ 43 IToken nextToken(); 44 45 /** 46 * Returns the offset of the last token read by this scanner. 47 * 48 * @return the offset of the last token read by this scanner 49 */ 50 int getTokenOffset(); 51 52 /** 53 * Returns the length of the last token read by this scanner. 54 * 55 * @return the length of the last token read by this scanner 56 */ 57 int getTokenLength(); 58 } 59