import net.sourceforge.phpeclipse.ui.text.rules.AbstractPartitioner;
-import org.eclipse.jface.text.Assert;
+//incastrix
+//import org.eclipse.jface.text.Assert;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.rules.ICharacterScanner;
import org.eclipse.jface.text.rules.IPartitionTokenScanner;
* This scanner recognizes the JavaDoc comments, Java multi line comments, Java
* single line comments, Java strings.
*/
-public class FastJavaPartitionScanner implements IPartitionTokenScanner, IPHPPartitions {
+public class FastJavaPartitionScanner implements IPartitionTokenScanner,
+ IPHPPartitions {
// states
private static final int PHP = 0;
// beginning of prefixes and postfixes
private static final int NONE = 0;
- private static final int BACKSLASH = 1; // postfix for STRING_DQ and CHARACTER
+ private static final int BACKSLASH = 1; // postfix for STRING_DQ and
+ // CHARACTER
- private static final int SLASH = 2; // prefix for SINGLE_LINE or MULTI_LINE or
- // JAVADOC
+ private static final int SLASH = 2; // prefix for SINGLE_LINE or MULTI_LINE
+ // or
- private static final int SLASH_STAR = 3; // prefix for MULTI_LINE_COMMENT or
- // JAVADOC
+ // JAVADOC
- private static final int SLASH_STAR_STAR = 4; // prefix for MULTI_LINE_COMMENT
- // or JAVADOC
+ private static final int SLASH_STAR = 3; // prefix for MULTI_LINE_COMMENT
+ // or
+
+ // JAVADOC
+
+ private static final int SLASH_STAR_STAR = 4; // prefix for
+ // MULTI_LINE_COMMENT
+
+ // or JAVADOC
private static final int STAR = 5; // postfix for MULTI_LINE_COMMENT or
- // JAVADOC
+
+ // JAVADOC
private static final int CARRIAGE_RETURN = 6; // postfix for STRING_DQ,
- // CHARACTER and
- // SINGLE_LINE_COMMENT
+
+ // CHARACTER and
+ // SINGLE_LINE_COMMENT
// private static final int HEREDOC = 7;
/** The scanner. */
- private final BufferedDocumentScanner fScanner = new BufferedDocumentScanner(1000); // faster
- // implementation
+ private final BufferedDocumentScanner fScanner = new BufferedDocumentScanner(
+ 1000); // faster
+
+ // implementation
/** The offset of the last returned token. */
private int fTokenOffset;
private int fJavaLength;
- private final IToken[] fTokens = new IToken[] { new Token(null), new Token(PHP_SINGLELINE_COMMENT),
- new Token(PHP_MULTILINE_COMMENT), new Token(PHP_PHPDOC_COMMENT), new Token(PHP_STRING_DQ), new Token(PHP_STRING_SQ),
+ private final IToken[] fTokens = new IToken[] { new Token(null),
+ new Token(PHP_SINGLELINE_COMMENT),
+ new Token(PHP_MULTILINE_COMMENT), new Token(PHP_PHPDOC_COMMENT),
+ new Token(PHP_STRING_DQ), new Token(PHP_STRING_SQ),
new Token(PHP_STRING_HEREDOC) };
public FastJavaPartitionScanner(boolean emulate) {
// emulate JavaPartitionScanner
if (fEmulate) {
- if (fJavaOffset != -1 && fTokenOffset + fTokenLength != fJavaOffset + fJavaLength) {
+ if (fJavaOffset != -1
+ && fTokenOffset + fTokenLength != fJavaOffset + fJavaLength) {
fTokenOffset += fTokenLength;
return fTokens[PHP];
} else {
fScanner.unread();
fScanner.unread();
return postFix(fState);
- }
- else {
+ } else {
// bug #1404228: Crash on <?php // comment ?>
- fScanner.unread();
+ if (nextch != ICharacterScanner.EOF) {
+ fScanner.unread();
+ }
}
}
case '*':
if (fLast == SLASH) {
if (fTokenLength - getLastLength(fLast) > 0)
- return preFix(PHP, MULTI_LINE_COMMENT, SLASH_STAR, 2);
+ return preFix(PHP, MULTI_LINE_COMMENT, SLASH_STAR,
+ 2);
else {
preFix(PHP, MULTI_LINE_COMMENT, SLASH_STAR, 2);
fTokenOffset += fTokenLength;
return fTokens[state];
}
- private final IToken preFix(int state, int newState, int last, int prefixLength) {
+ private final IToken preFix(int state, int newState, int last,
+ int prefixLength) {
// emulate JavaPartitionScanner
- if (fEmulate && state == PHP && (fTokenLength - getLastLength(fLast) > 0)) {
+ if (fEmulate && state == PHP
+ && (fTokenLength - getLastLength(fLast) > 0)) {
fTokenLength -= getLastLength(fLast);
fJavaOffset = fTokenOffset;
fJavaLength = fTokenLength;
* @see IPartitionTokenScanner#setPartialRange(IDocument, int, int, String,
* int)
*/
- public void setPartialRange(IDocument document, int offset, int length, String contentType, int partitionOffset) {
+ public void setPartialRange(IDocument document, int offset, int length,
+ String contentType, int partitionOffset) {
fScanner.setRange(document, offset, length);
setRange(document, offset, length);
fTokenOffset = partitionOffset;