X-Git-Url: http://git.phpeclipse.com
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCodeScanner.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCodeScanner.java
index 9ad50d5..fd92df4 100644
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCodeScanner.java
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCodeScanner.java
@@ -12,7 +12,9 @@
package net.sourceforge.phpeclipse.phpeditor.php;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import net.sourceforge.phpdt.internal.ui.text.AbstractJavaScanner;
import net.sourceforge.phpdt.ui.text.IColorManager;
@@ -22,6 +24,7 @@ import net.sourceforge.phpeclipse.phpeditor.util.PHPWhitespaceDetector;
import net.sourceforge.phpeclipse.phpeditor.util.PHPWordDetector;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.Assert;
import org.eclipse.jface.text.rules.ICharacterScanner;
import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.IToken;
@@ -38,7 +41,7 @@ public class PHPCodeScanner extends AbstractJavaScanner {
/**
* Rule to detect java operators.
- *
+ *
* @since 3.0
*/
protected class OperatorRule implements IRule {
@@ -78,7 +81,7 @@ public class PHPCodeScanner extends AbstractJavaScanner {
/**
* Creates a new operator rule.
- *
+ *
* @param token
* Token to use for this rule
*/
@@ -90,7 +93,7 @@ public class PHPCodeScanner extends AbstractJavaScanner {
/**
* Is this character an operator character?
- *
+ *
* @param character
* Character to determine whether it is an operator character
* @return true
iff the character is an operator, false
otherwise.
@@ -139,7 +142,7 @@ public class PHPCodeScanner extends AbstractJavaScanner {
/**
* Check if lastCharacter/character are a PHP start or end token ( <? ... ?> )
- *
+ *
* @param scanner
* @param lastCharacter
* @param character
@@ -199,6 +202,7 @@ public class PHPCodeScanner extends AbstractJavaScanner {
private class PHPWordRule extends WordRule {
private StringBuffer fBuffer = new StringBuffer();
+ protected Map fWordsIgnoreCase = new HashMap();
public PHPWordRule(IWordDetector detector) {
super(detector, Token.UNDEFINED);
@@ -208,10 +212,24 @@ public class PHPCodeScanner extends AbstractJavaScanner {
super(detector, defaultToken);
}
+ /**
+ * Adds a word and the token to be returned if it is detected.
+ *
+ * @param word the word this rule will search for, may not be null
+ * @param token the token to be returned if the word has been found, may not be null
+ */
+ public void addWordIgnoreCase(String word, IToken token) {
+ Assert.isNotNull(word);
+ Assert.isNotNull(token);
+
+ fWordsIgnoreCase.put(word, token);
+ }
+
public IToken evaluate(ICharacterScanner scanner) {
int c = scanner.read();
boolean isVariable = false;
boolean isUnderscore = false;
+ String word;
if (c == '<') {
c = scanner.read();
if (c != '?') {
@@ -279,7 +297,12 @@ public class PHPCodeScanner extends AbstractJavaScanner {
}
return getToken(IPreferenceConstants.PHP_VARIABLE);
}
- IToken token = (IToken) fWords.get(fBuffer.toString());
+ word = fBuffer.toString();
+ IToken token = (IToken) fWords.get(word);
+ if (token != null)
+ return token;
+
+ token = (IToken) fWordsIgnoreCase.get(word.toLowerCase());
if (token != null)
return token;
@@ -374,7 +397,7 @@ public class PHPCodeScanner extends AbstractJavaScanner {
wordRule.addWord(name, keyword);
}
} else if (elbuffer instanceof PHPFunction) {
- wordRule.addWord(((PHPFunction) elbuffer).getName(), functionName);
+ wordRule.addWordIgnoreCase(((PHPFunction) elbuffer).getName(), functionName);
} else if (elbuffer instanceof PHPType) {
wordRule.addWord(elbuffer.getName(), type);
} else if (elbuffer instanceof PHPConstant) {