1 11 package org.eclipse.jdt.internal.codeassist.select; 12 13 19 import org.eclipse.jdt.internal.compiler.parser.Scanner; 20 21 public class SelectionScanner extends Scanner { 22 23 public char[] selectionIdentifier; 24 public int selectionStart, selectionEnd; 25 30 31 public SelectionScanner(long sourceLevel) { 32 super(false , false , false , sourceLevel, null , null, true); 33 } 34 35 public char[] getCurrentIdentifierSource() { 36 37 if (selectionIdentifier == null){ 38 if (selectionStart == startPosition && selectionEnd == currentPosition-1){ 39 if (withoutUnicodePtr != 0){ System.arraycopy(withoutUnicodeBuffer, 1, selectionIdentifier = new char[withoutUnicodePtr], 0, withoutUnicodePtr); 41 } else { 42 int length = currentPosition - startPosition; 43 System.arraycopy(source, startPosition, (selectionIdentifier = new char[length]), 0, length); 45 } 46 return selectionIdentifier; 47 } 48 } 49 return super.getCurrentIdentifierSource(); 50 } 51 55 public int scanIdentifierOrKeyword() { 56 57 int id = super.scanIdentifierOrKeyword(); 58 59 if (id != TokenNameIdentifier 61 && startPosition == selectionStart 62 && currentPosition == selectionEnd+1){ 63 return TokenNameIdentifier; 64 } 65 return id; 66 } 67 } 68 | Popular Tags |