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 bf89097..e73e00d 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 @@ -13,12 +13,15 @@ package net.sourceforge.phpeclipse.phpeditor.php; import java.util.ArrayList; import java.util.List; +import java.util.Vector; import net.sourceforge.phpeclipse.IPreferenceConstants; import net.sourceforge.phpeclipse.PHPeclipsePlugin; +import net.sourceforge.phpeclipse.phpeditor.PHPSyntaxRdr; import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider; import net.sourceforge.phpeclipse.phpeditor.util.PHPWhitespaceDetector; import net.sourceforge.phpeclipse.phpeditor.util.PHPWordDetector; + import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.text.TextAttribute; @@ -71,7 +74,7 @@ public class PHPCodeScanner extends RuleBasedScanner implements IPreferenceConst do { fBuffer.append((char) c); c = scanner.read(); - } while (c != scanner.EOF && fDetector.isWordPart((char) c)); + } while (c != ICharacterScanner.EOF && fDetector.isWordPart((char) c)); scanner.unread(); if (isVariable) { @@ -106,7 +109,7 @@ public class PHPCodeScanner extends RuleBasedScanner implements IPreferenceConst * Creates a PHP code scanner */ public PHPCodeScanner(PHPColorProvider provider) { - final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); + final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); variable = new Token(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PHP_VARIABLE)))); keyword = new Token(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PHP_KEYWORD)))); @@ -116,7 +119,6 @@ public class PHPCodeScanner extends RuleBasedScanner implements IPreferenceConst multi_comment = new Token(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PHP_MULTILINE_COMMENT)))); other = new Token(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PHP_DEFAULT)))); - List rules = new ArrayList(); // Add rule for single line comments. @@ -135,10 +137,33 @@ public class PHPCodeScanner extends RuleBasedScanner implements IPreferenceConst // Add word rule for keywords, types, and constants. PHPWordRule wordRule = new PHPWordRule(new PHPWordDetector(), other); + //choochter--> for (int i = 0; i < PHPKeywords.PHP_KEYWORS.length; i++) wordRule.addWord(PHPKeywords.PHP_KEYWORS[i], keyword); - for (int i = 0; i < PHPFunctionNames.FUNCTION_NAMES.length; i++) - wordRule.addWord(PHPFunctionNames.FUNCTION_NAMES[i], functionName); + + /*Read in the keywords from the XML file*/ + PHPSyntaxRdr syntaxRdr = new PHPSyntaxRdr(); + syntaxRdr.readFromFile( + "C:\\eclipse\\workspace\\net.sourceforge.phpeclipse\\src\\net\\sourceforge\\phpeclipse\\phpeditor" + + java.io.File.separator + + "syntax.xml"); + { + Vector Vbuffer = syntaxRdr.getKeywords(); + String VString = null; + //Read keywords + while ((Vbuffer != null) && (!Vbuffer.isEmpty() && ((VString = (String) Vbuffer.remove(0)) != null))) { + wordRule.addWord(VString, keyword); + } + //Read functions - to be tested + Vbuffer = syntaxRdr.getFunctions(); + while ((Vbuffer != null) && (!Vbuffer.isEmpty() && ((VString = (String) Vbuffer.remove(0)) != null))) { + wordRule.addWord(VString, functionName); + } + } + + //for (int i = 0; i < PHPFunctionNames.FUNCTION_NAMES.length; i++) + // wordRule.addWord(PHPFunctionNames.FUNCTION_NAMES[i], functionName); + //<--choochter for (int i = 0; i < fgConstants.length; i++) wordRule.addWord(fgConstants[i], functionName); rules.add(wordRule); @@ -158,6 +183,6 @@ public class PHPCodeScanner extends RuleBasedScanner implements IPreferenceConst comment.setData(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PHP_SINGLELINE_COMMENT)))); multi_comment.setData(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PHP_MULTILINE_COMMENT)))); other.setData(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PHP_DEFAULT)))); - + } }