import java.util.Arrays;
import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
+import net.sourceforge.phpeclipse.phpeditor.php.PHPDocumentPartitioner;
import org.eclipse.jface.text.Assert;
import org.eclipse.jface.text.BadLocationException;
* the document to scan.
*/
public JavaHeuristicScanner(IDocument document) {
+// this(document, IPHPPartitions.PHP_PARTITIONING,
+// IDocument.DEFAULT_CONTENT_TYPE);
this(document, IPHPPartitions.PHP_PARTITIONING,
- IDocument.DEFAULT_CONTENT_TYPE);
+ PHPDocumentPartitioner.PHP_SCRIPT_CODE);
}
/**
case QUESTIONMARK:
return TokenQUESTIONMARK;
case EQUAL:
+ try {
+ if (fDocument.getChar(fPos) == '>') {
+ fPos++;
+ return TokenOTHER;
+ }
+ } catch (BadLocationException e) {
+ }
return TokenEQUAL;
+ case '<':
+ try {
+ if (fDocument.get(fPos, 4).equalsIgnoreCase("?php")) {
+ fPos += 4;
+ return TokenEOF;
+ } else if (fDocument.getChar(fPos) == '?') {
+ fPos++;
+ return TokenEOF;
+ }
+ } catch (BadLocationException e) {
+ }
}
// else
return TokenQUESTIONMARK;
case EQUAL:
return TokenEQUAL;
+ case '>':
+ try {
+ switch (fDocument.getChar(fPos)) {
+ case '=':
+ fPos--;
+ return TokenOTHER;
+ case '?':
+ fPos--;
+ return TokenEOF;
+ }
+ } catch (BadLocationException e) {
+ }
}
// else
while (fPos < bound) {
fChar = fDocument.getChar(fPos);
+ // omit closing tag
+ if (fChar == '?') {
+ if (fPos < fDocument.getLength() - 1) {
+ if (fDocument.get(fPos - 1, 2).equalsIgnoreCase("?>")) {
+ fPos++;
+ return NOT_FOUND;
+ }
+ }
+ }
if (condition.stop(fChar, fPos, true))
return fPos;
while (fPos > bound) {
fChar = fDocument.getChar(fPos);
+ // omit opening tag
+ if (fChar == 'p' || fChar == 'P') {
+ if (fPos >= 4) {
+ if (fDocument.get(fPos - 4, 5).equalsIgnoreCase("<?php")) {
+ fPos -= 4;
+ return NOT_FOUND;
+ }
+ }
+ } else if (fChar == '?') {
+ if (fPos >= 1) {
+ if (fDocument.get(fPos - 1, 2).equalsIgnoreCase("<?")) {
+ fPos--;
+ return NOT_FOUND;
+ }
+ }
+ }
if (condition.stop(fChar, fPos, false))
return fPos;