1 /******************************************************************************* 2 * Copyright (c) 2000, 2004 IBM Corporation and others. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Common Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/cpl-v10.html 7 * 8 * Contributors: 9 * IBM Corporation - initial API and implementation 10 *******************************************************************************/ 11 package org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer; 12 13 14 15 /** 16 * For performing a so-called "token compare" on a line of text. 17 * This interface extends the <code>IRangeComparator</code> interface 18 * so that it can be used by the <code>TextMergeViewer</code>. 19 * <p> 20 * <code>TextMergeViewer</code> activates the token compare when navigating into 21 * a range of differing lines. At first the lines are selected as a block. 22 * When navigating into this block the token compare shows for every line 23 * the differing token by selecting them. 24 * <p> 25 * <code>TextMergeViewer</code>'s default token comparator works on characters separated 26 * by whitespace. If a different strategy is needed (for example, to use Java tokens in 27 * a Java-aware merge viewer), clients may create their own token 28 * comparators by implementing this interface (and overriding the 29 * <code>TextMergeViewer.createTokenComparator</code> factory method). 30 * </p> 31 * 32 * @see TextMergeViewer 33 * @since 3.0 34 */ 35 public interface ITokenComparator extends IRangeComparator { 36 37 /** 38 * Returns the start character position of the token with the given index. 39 * If the index is out of range (but not negative) the character position 40 * behind the last character (the length of the input string) is returned. 41 * 42 * @param index index of the token for which to return the start position 43 * @return the start position of the token with the given index 44 * @throws java.lang.IndexOutOfBoundsException if index is negative 45 */ 46 int getTokenStart(int index); 47 48 /** 49 * Returns the character length of the token with the given index. 50 * If the index is out of range (but not negative) the value 0 is returned. 51 * 52 * @param index index of the token for which to return the start position 53 * @return the character length of the token with the given index 54 * @throws java.lang.IndexOutOfBoundsException if index is negative 55 */ 56 int getTokenLength(int index); 57 } 58