Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2009 IBM Corporation 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 Contributors: IBM Corporation - initial API and implementation /
 * Scanner aware of a selection range. If finding an identifier which source range is exactly
 * the same, then will record it so that the parser can make use of it.
 * Source positions are zero-based and inclusive.
public class SelectionScanner extends Scanner {
	public char[] selectionIdentifier;
 * Truncate the current identifier if it is containing the cursor location. Since completion is performed
 * on an identifier prefix.
public SelectionScanner(long sourceLevel) {
	super(false /*comment*/false /*whitespace*/false /*nls*/sourceLevelnull /*taskTags*/null/*taskPriorities*/true/*taskCaseSensitive*/);
public char[] getCurrentIdentifierSource() {
	if (this. == null){
		if (this. == this. && this. == this.-1){
			if (this. != 0){			// check unicode scenario
				System.arraycopy(this., 1, this. = new char[this.], 0, this.);
else {
				int length = this. - this.;
				// no char[] sharing around completionIdentifier, we want it to be unique so as to use identity checks
				System.arraycopy(this.this., (this. = new char[length]), 0, length);
			return this.;
 * In case we actually read a keyword which corresponds to the selected
 * range, we pretend we read an identifier.
public int scanIdentifierOrKeyword() {
	int id = super.scanIdentifierOrKeyword();
	// convert completed keyword into an identifier
	if (id != 
		&& this. == this.
		&& this. == this.+1){
	return id;
New to GrepCode? Check out our FAQ X