Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2011 itemis AG (http://www.itemis.eu) and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html /
  
  package org.eclipse.xtext.ui.editor.model;
  
 
 import  org.eclipse.core.runtime.Assert;
 
Copied from org.eclipse.jdt.internal.ui.text.JavaWordIterator.
 
 /*
  * @see org.eclipse.jdt.internal.ui.text.JavaWordIterator
   */
 public class CommonWordIterator extends BreakIterator {

The underlying common break iterator. It returns all breaks, including before and after every whitespace.
 
The current index for the stateful operations.
 
 	private int fIndex;

Creates a new word iterator.
 
 	public CommonWordIterator(boolean camelCase) {
 		first();
 	}
 
 	protected CommonBreakIterator createIteratorDelegate(boolean camelCase) {
 		return new CommonBreakIterator(camelCase);
 	}
 
 	/*
 	 * @see java.text.BreakIterator#first()
 	 */
 	public int first() {
 		return ;
 	}
 
 	/*
 	 * @see java.text.BreakIterator#last()
 	 */
 	public int last() {
 		return ;
 	}
 
 	/*
 	 * @see java.text.BreakIterator#next(int)
 	 */
 	public int next(int n) {
 		int next = 0;
 		while (--n > 0 && next != ) {
 			next = next();
 		}
 		return next;
 	}
 
 	/*
 	 * @see java.text.BreakIterator#next()
 	 */
 	public int next() {
 		return ;
 	}
 
 	/*
 	 * @see java.text.BreakIterator#previous()
 	 */
 	public int previous() {
 		return ;
 	}
 
 	/*
 	 * @see java.text.BreakIterator#preceding(int)
 	 */
 	public int preceding(int offset) {
 		int first = .preceding(offset);
 		if (isWhitespace(firstoffset)) {
 			int second = .preceding(first);
			if (second !=  && !isDelimiter(secondfirst))
				return second;
		}
		return first;
	}
	/*
	 * @see java.text.BreakIterator#following(int)
	 */
	public int following(int offset) {
		int first = .following(offset);
		if (eatFollowingWhitespace(offsetfirst)) {
			int second = .following(first);
			if (isWhitespace(firstsecond))
				return second;
		}
		return first;
	}
	protected boolean eatFollowingWhitespace(int offsetint exclusiveEnd) {
		if (exclusiveEnd ==  || offset == )
			return false;
		if (isWhitespace(offsetexclusiveEnd))
			return false;
		if (isDelimiter(offsetexclusiveEnd))
			return false;
		return true;
	}

Returns true if the given sequence into the underlying text represents a delimiter, false otherwise.

Parameters:
offset the offset
exclusiveEnd the end offset
Returns:
true if the given range is a delimiter
	protected boolean isDelimiter(int offsetint exclusiveEnd) {
		if (exclusiveEnd ==  || offset == )
			return false;
		Assert.isTrue(offset >= 0);
		Assert.isTrue(exclusiveEnd <= getText().getEndIndex());
		Assert.isTrue(exclusiveEnd > offset);
		while (offset < exclusiveEnd) {
			char ch = seq.charAt(offset);
			if (ch != '\n' && ch != '\r')
				return false;
			offset++;
		}
		return true;
	}

Returns true if the given sequence into the underlying text represents whitespace, but not a delimiter, false otherwise.

Parameters:
offset the offset
exclusiveEnd the end offset
Returns:
true if the given range is whitespace
	protected boolean isWhitespace(int offsetint exclusiveEnd) {
		if (exclusiveEnd ==  || offset == )
			return false;
		Assert.isTrue(offset >= 0);
		Assert.isTrue(exclusiveEnd <= getText().getEndIndex());
		Assert.isTrue(exclusiveEnd > offset);
		while (offset < exclusiveEnd) {
			char ch = seq.charAt(offset);
			if (!Character.isWhitespace(ch))
				return false;
			if (ch == '\n' || ch == '\r')
				return false;
			offset++;
		}
		return true;
	}
	/*
	 * @see java.text.BreakIterator#current()
	 */
	public int current() {
		return ;
	}
	/*
	 * @see java.text.BreakIterator#getText()
	 */
		return .getText();
	}

Sets the text as CharSequence.

Parameters:
newText the new text
	public void setText(CharSequence newText) {
	}
	/*
	 * @see java.text.BreakIterator#setText(java.text.CharacterIterator)
	 */
	public void setText(CharacterIterator newText) {
	}
	/*
	 * @see java.text.BreakIterator#setText(java.lang.String)
	 */
	public void setText(String newText) {
		setText((CharSequencenewText);
	}
New to GrepCode? Check out our FAQ X