From 25ffcce1cd4727885f55c1b8d176cbda06cb71c9 Mon Sep 17 00:00:00 2001 From: khartlage Date: Sun, 2 Mar 2003 12:26:49 +0000 Subject: [PATCH 1/1] improved PHP Scanner --- .../phpeditor/PHPContentOutlinePage.java | 2 +- .../phpeclipse/phpeditor/PHPParserAction.java | 2 +- .../phpeditor/php/HTMLWordExtractor.java | 4 +++- .../phpeditor/php/PHPDoubleClickSelector.java | 6 ++++-- .../phpeclipse/phpeditor/php/PHPWordExtractor.java | 6 ++++-- .../phpeditor/util/HTMLWordDetector.java | 4 +++- .../phpeclipse/phpeditor/util/PHPWordDetector.java | 6 ++++-- 7 files changed, 20 insertions(+), 10 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java index 5b53646..bdc86d8 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java @@ -82,7 +82,7 @@ public class PHPContentOutlinePage extends ContentOutlinePage { // StringBuffer identifier = new StringBuffer(); // while (i < textLength) { // c = text.charAt(i++); - // if (Character.isJavaIdentifierPart(c) || (c == '$')) { + // if (Scanner.isPHPIdentifierPart(c) || (c == '$')) { // identifier.append(c); // } else if ((i == firstIndex + 1) && (c == '$')) { // identifier.append(c); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPParserAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPParserAction.java index 9ba7e1a..774fbf1 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPParserAction.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPParserAction.java @@ -138,7 +138,7 @@ public class PHPParserAction extends TextEditorAction { // identifier.append((char) c); // try { // while ((c = iStream.read()) != (-1)) { - // if (Character.isJavaIdentifierPart((char) c)) { + // if (Scanner.isPHPIdentifierPart((char) c)) { // identifier.append((char) c); // // } else if ((i == 0) && (c == '$')) { // // identifier.append((char)c); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/HTMLWordExtractor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/HTMLWordExtractor.java index a3bfc0b..e4e0b14 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/HTMLWordExtractor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/HTMLWordExtractor.java @@ -11,6 +11,8 @@ Contributors: **********************************************************************/ package net.sourceforge.phpeclipse.phpeditor.php; +import net.sourceforge.phpdt.internal.compiler.parser.Scanner; + import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.swt.graphics.Point; @@ -39,7 +41,7 @@ public class HTMLWordExtractor { while (position >= 0) { character = document.getChar(position); - if (!Character.isJavaIdentifierPart(character)) + if (!Scanner.isPHPIdentifierPart(character)) break; --position; } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPDoubleClickSelector.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPDoubleClickSelector.java index faa4b3c..52bff9c 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPDoubleClickSelector.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPDoubleClickSelector.java @@ -12,6 +12,8 @@ Contributors: package net.sourceforge.phpeclipse.phpeditor.php; +import net.sourceforge.phpdt.internal.compiler.parser.Scanner; + import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextDoubleClickStrategy; @@ -124,7 +126,7 @@ public class PHPDoubleClickSelector implements ITextDoubleClickStrategy { while (pos >= 0) { c = doc.getChar(pos); - if (!Character.isJavaIdentifierPart(c) && (c != '$')) { + if (!Scanner.isPHPIdentifierPart(c) && (c != '$')) { break; } --pos; @@ -137,7 +139,7 @@ public class PHPDoubleClickSelector implements ITextDoubleClickStrategy { while (pos < length) { c = doc.getChar(pos); - if (!Character.isJavaIdentifierPart(c) && (c != '$')) + if (!Scanner.isPHPIdentifierPart(c) && (c != '$')) break; ++pos; } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPWordExtractor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPWordExtractor.java index 92266eb..4fd5ea3 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPWordExtractor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPWordExtractor.java @@ -11,6 +11,8 @@ Contributors: **********************************************************************/ package net.sourceforge.phpeclipse.phpeditor.php; +import net.sourceforge.phpdt.internal.compiler.parser.Scanner; + import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.swt.graphics.Point; @@ -39,7 +41,7 @@ public class PHPWordExtractor { while (position >= 0) { character = document.getChar(position); - if (!Character.isJavaIdentifierPart(character) && (character != '$')) + if (!Scanner.isPHPIdentifierPart(character) && (character != '$')) break; --position; } @@ -51,7 +53,7 @@ public class PHPWordExtractor { while (position < length) { character = document.getChar(position); - if (!Character.isJavaIdentifierPart(character) && (character != '$')) + if (!Scanner.isPHPIdentifierPart(character) && (character != '$')) break; ++position; } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/HTMLWordDetector.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/HTMLWordDetector.java index 059f56a..6aada83 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/HTMLWordDetector.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/HTMLWordDetector.java @@ -12,6 +12,8 @@ Contributors: Klaus Hartlage - www.eclipseproject.de **********************************************************************/ +import net.sourceforge.phpdt.internal.compiler.parser.Scanner; + import org.eclipse.jface.text.rules.IWordDetector; /** @@ -23,7 +25,7 @@ public class HTMLWordDetector implements IWordDetector { * Method declared on IWordDetector. */ public boolean isWordPart(char character) { - return Character.isJavaIdentifierPart(character)||(character=='/')||(character=='>'); + return Scanner.isPHPIdentifierPart(character)||(character=='/')||(character=='>'); } /* (non-Javadoc) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/PHPWordDetector.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/PHPWordDetector.java index 99e036f..eada1ba 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/PHPWordDetector.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/PHPWordDetector.java @@ -11,6 +11,8 @@ Contributors: **********************************************************************/ package net.sourceforge.phpeclipse.phpeditor.util; +import net.sourceforge.phpdt.internal.compiler.parser.Scanner; + import org.eclipse.jface.text.rules.IWordDetector; /** @@ -22,13 +24,13 @@ public class PHPWordDetector implements IWordDetector { * Method declared on IWordDetector. */ public boolean isWordPart(char character) { - return Character.isJavaIdentifierPart(character); + return Scanner.isPHPIdentifierPart(character); } /* (non-Javadoc) * Method declared on IWordDetector. */ public boolean isWordStart(char character) { - return (character=='$')||Character.isJavaIdentifierStart(character); + return (character=='$')||Scanner.isPHPIdentifierStart(character); } } -- 1.7.1