Lines 21-27
Link Here
|
21 |
* n means completion behind the n-th character |
21 |
* n means completion behind the n-th character |
22 |
*/ |
22 |
*/ |
23 |
import org.eclipse.jdt.core.compiler.*; |
23 |
import org.eclipse.jdt.core.compiler.*; |
24 |
import org.eclipse.jdt.core.compiler.InvalidInputException; |
|
|
25 |
import org.eclipse.jdt.internal.compiler.parser.Scanner; |
24 |
import org.eclipse.jdt.internal.compiler.parser.Scanner; |
26 |
|
25 |
|
27 |
public class CompletionScanner extends Scanner { |
26 |
public class CompletionScanner extends Scanner { |
Lines 82-87
Link Here
|
82 |
return super.getCurrentIdentifierSource(); |
81 |
return super.getCurrentIdentifierSource(); |
83 |
} |
82 |
} |
84 |
|
83 |
|
|
|
84 |
public char[] getCurrentTokenSourceString() { |
85 |
if (this.completionIdentifier == null){ |
86 |
if (this.cursorLocation+1 >= this.startPosition && this.cursorLocation < this.currentPosition){ |
87 |
// remember actual identifier positions |
88 |
this.completedIdentifierStart = this.startPosition; |
89 |
this.completedIdentifierEnd = this.currentPosition - 1; |
90 |
if (this.withoutUnicodePtr != 0){ // check unicode scenario |
91 |
int length = this.cursorLocation - this.startPosition - this.unicodeCharSize; |
92 |
System.arraycopy(this.withoutUnicodeBuffer, 2, this.completionIdentifier = new char[length], 0, length); |
93 |
} else { |
94 |
// no char[] sharing around completionIdentifier, we want it to be unique so as to use identity checks |
95 |
int length = this.cursorLocation - this.startPosition; |
96 |
System.arraycopy(this.source, this.startPosition + 1, (this.completionIdentifier = new char[length]), 0, length); |
97 |
} |
98 |
return this.completionIdentifier; |
99 |
} |
100 |
} |
101 |
return super.getCurrentTokenSourceString(); |
102 |
} |
85 |
public int getNextToken() throws InvalidInputException { |
103 |
public int getNextToken() throws InvalidInputException { |
86 |
|
104 |
|
87 |
this.wasAcr = false; |
105 |
this.wasAcr = false; |
Lines 490-498
Link Here
|
490 |
} |
508 |
} |
491 |
throw e; // rethrow |
509 |
throw e; // rethrow |
492 |
} |
510 |
} |
493 |
if (this.startPosition <= this.cursorLocation && this.cursorLocation <= this.currentPosition-1){ |
|
|
494 |
throw new InvalidCursorLocation(InvalidCursorLocation.NO_COMPLETION_INSIDE_STRING); |
495 |
} |
496 |
return TokenNameStringLiteral; |
511 |
return TokenNameStringLiteral; |
497 |
case '/' : |
512 |
case '/' : |
498 |
{ |
513 |
{ |
Lines 760-766
Link Here
|
760 |
public final void getNextUnicodeChar() throws InvalidInputException { |
775 |
public final void getNextUnicodeChar() throws InvalidInputException { |
761 |
int temp = this.currentPosition; // the \ is already read |
776 |
int temp = this.currentPosition; // the \ is already read |
762 |
super.getNextUnicodeChar(); |
777 |
super.getNextUnicodeChar(); |
763 |
this.unicodeCharSize += (this.currentPosition - temp); |
778 |
if(this.cursorLocation > temp) { |
|
|
779 |
this.unicodeCharSize += (this.currentPosition - temp); |
780 |
} |
764 |
if (temp < this.cursorLocation && this.cursorLocation < this.currentPosition-1){ |
781 |
if (temp < this.cursorLocation && this.cursorLocation < this.currentPosition-1){ |
765 |
throw new InvalidCursorLocation(InvalidCursorLocation.NO_COMPLETION_INSIDE_UNICODE); |
782 |
throw new InvalidCursorLocation(InvalidCursorLocation.NO_COMPLETION_INSIDE_UNICODE); |
766 |
} |
783 |
} |