colored "operators and brackets"
authorkhartlage <khartlage>
Sat, 12 Jun 2004 09:30:51 +0000 (09:30 +0000)
committerkhartlage <khartlage>
Sat, 12 Jun 2004 09:30:51 +0000 (09:30 +0000)
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/lookup/ImportBinding.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/ImportDeclaration.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/jdom/DOMImport.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/JavaEditorPreferencePage.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/PreferencesMessages.properties
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/CombinedWordRule.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/PreferenceConstants.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/IPreferenceConstants.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/CompilationUnitDeclaration.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCodeScanner.java

index 8fc5dce..22a123a 100644 (file)
@@ -40,6 +40,6 @@ public char[] readableName() {
                return CharOperation.concatWith(compoundName, '.');
 }
 public String toString() {
-       return "import : " + new String(readableName()); //$NON-NLS-1$
+       return "include : " + new String(readableName()); //$NON-NLS-1$
 }
 }
index 0f3ad98..ff360b3 100644 (file)
@@ -101,7 +101,7 @@ public String readableName() {
  */
 protected void toStringInfo(int tab, StringBuffer buffer, Object info) {
        buffer.append(this.tabString(tab));
-       buffer.append("import "); //$NON-NLS-1$
+       buffer.append("include "); //$NON-NLS-1$
        toStringName(buffer);
        if (info == null) {
                buffer.append(" (not open)"); //$NON-NLS-1$
index 3ff5280..535071b 100644 (file)
@@ -83,7 +83,7 @@ DOMImport(char[] document, int[] sourceRange, String name, boolean onDemand) {
 protected void appendFragmentedContents(CharArrayBuffer buffer) {
        if (fNameRange[0] < 0) {
                buffer
-                       .append("import ") //$NON-NLS-1$
+                       .append("include ") //$NON-NLS-1$
                        .append(fName)
                        .append(';')
                        .append(Util.LINE_SEPARATOR);
index c702b12..c8ed48e 100644 (file)
@@ -151,8 +151,13 @@ public class JavaEditorPreferencePage extends PreferencePage
           PreferenceConstants.EDITOR_STRING_COLOR},
       //$NON-NLS-1$
       {PreferencesMessages.getString("PHPEditorPreferencePage.others"),
-          PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR},
+          PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR}, //$NON-NLS-1$
+      { PreferencesMessages.getString("JavaEditorPreferencePage.operators"),
+        PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR },  
       //$NON-NLS-1$
+        { PreferencesMessages.getString("JavaEditorPreferencePage.returnKeyword"),
+          PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR },  
+        //$NON-NLS-1$
       {PreferencesMessages.getString("PHPEditorPreferencePage.phpDocKeywords"),
           PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR},
       //$NON-NLS-1$
@@ -390,12 +395,18 @@ public class JavaEditorPreferencePage extends PreferencePage
     //         overlayKeys.add(new
     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
     // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD));
-    //         overlayKeys.add(new
-    // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
-    // PreferenceConstants.EDITOR_JAVA_OPERATOR_COLOR));
-    //         overlayKeys.add(new
-    // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
-    // PreferenceConstants.EDITOR_JAVA_OPERATOR_BOLD));
+    overlayKeys.add(new
+       OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+       PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR));
+    overlayKeys.add(new
+       OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+       PreferenceConstants.EDITOR_PHP_OPERATOR_BOLD));
+    overlayKeys.add(new
+        OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+        PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR));
+     overlayKeys.add(new
+        OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+        PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_BOLD));
     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
         OverlayPreferenceStore.STRING,
         PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR));
index d56f36e..602acdc 100644 (file)
@@ -104,7 +104,8 @@ JavaEditorPreferencePage.annotations.showInVerticalRuler= Show in vertical r&ule
 JavaEditorPreferencePage.annotations.color= C&olor:
 JavaEditorPreferencePage.multiLineComment=Multi-line comment
 JavaEditorPreferencePage.singleLineComment=Single-line comment
-JavaEditorPreferencePage.keywords=Keywords
+JavaEditorPreferencePage.returnKeyword= Keyword 'return'
+JavaEditorPreferencePage.keywords=Keywords excluding 'return'
 JavaEditorPreferencePage.strings=Strings
 JavaEditorPreferencePage.others=Others
 JavaEditorPreferencePage.methodNames=Method names
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/CombinedWordRule.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/CombinedWordRule.java
new file mode 100644 (file)
index 0000000..f6f5b6f
--- /dev/null
@@ -0,0 +1,371 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.text;
+
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+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;
+import org.eclipse.jface.text.rules.IWordDetector;
+import org.eclipse.jface.text.rules.Token;
+
+
+/**
+ * An implementation of <code>IRule</code> capable of detecting words.
+ * <p>
+ * Word rules also allow for the association of tokens with specific words. 
+ * That is, not only can the rule be used to provide tokens for exact matches, 
+ * but also for the generalized notion of a word in the context in which it is used.
+ * A word rules uses a word detector to determine what a word is.</p>
+ * <p>
+ * This word rule allows a word detector to be shared among different word matchers.
+ * Its up to the word matchers to decide if a word matches and, in this a case, which
+ * token is associated with that word.
+ * </p>
+ * 
+ * @see IWordDetector
+ * @since 3.0
+ */
+public class CombinedWordRule implements IRule {
+       
+       /**
+        * Word matcher, that associates matched words with tokens.
+        */
+       public static class WordMatcher {
+               
+               /** The table of predefined words and token for this matcher */
+               private Map fWords= new HashMap();
+
+               /**
+                * 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 <code>null</code>
+                * @param token the token to be returned if the word has been found, may not be <code>null</code>
+                */
+               public void addWord(String word, IToken token) {
+                       Assert.isNotNull(word);
+                       Assert.isNotNull(token);                
+               
+                       fWords.put(new CharacterBuffer(word), token);
+               }
+               
+               /**
+                * Returns the token associated to the given word and the scanner state.
+                * 
+                * @param scanner the scanner
+                * @param word the word
+                * @return the token or <code>null</code> if none is associated by this matcher
+                */
+               public IToken evaluate(ICharacterScanner scanner, CharacterBuffer word) {
+                       IToken token= (IToken) fWords.get(word);
+                       if (token != null)
+                               return token;
+                       return Token.UNDEFINED;
+               }
+               
+               /**
+                * Removes all words.
+                */
+               public void clearWords() {
+                       fWords.clear();
+               }
+       }
+       
+       /**
+        * Character buffer, mutable <b>or</b> suitable for use as key in hash maps.
+        */
+       public static class CharacterBuffer {
+               
+               /** Buffer content */
+               private char[] fContent;
+               /** Buffer content size */
+               private int fLength= 0;
+               
+               /** Is hash code cached? */
+               private boolean fIsHashCached= false;
+               /** The hash code */
+               private int fHashCode;
+               
+               /**
+                * Initialize with the given capacity.
+                *
+                * @param capacity the initial capacity
+                */
+               public CharacterBuffer(int capacity) {
+                       fContent= new char[capacity];
+               }
+               
+               /**
+                * Initialize with the given content.
+                *
+                * @param string the initial content
+                */
+               public CharacterBuffer(String content) {
+                       fContent= content.toCharArray();
+                       fLength= content.length();
+               }
+               
+               /**
+                * Empties this buffer.
+                */
+               public void clear() {
+                       fIsHashCached= false;
+                       fLength= 0;
+               }
+               
+               /**
+                * Appends the given character to the buffer.
+                * 
+                * @param c the character
+                */
+               public void append(char c) {
+                       fIsHashCached= false;
+                       if (fLength == fContent.length) {
+                               char[] old= fContent;
+                               fContent= new char[old.length << 1];
+                               System.arraycopy(old, 0, fContent, 0, old.length);
+                       }
+                       fContent[fLength++]= c;
+               }
+               
+               /**
+                * Returns the length of the content.
+                * 
+                * @return the length
+                */
+               public int length() {
+                       return fLength;
+               }
+               
+               /**
+                * Returns the content as string.
+                * 
+                * @return the content
+                */
+               public String toString() {
+                       return new String(fContent, 0, fLength);
+               }
+               
+               /**
+                * Returns the character at the given position.
+                * 
+                * @param i the position
+                * @return the character at position <code>i</code>
+                */
+               public char charAt(int i) {
+                       return fContent[i];
+               }
+               
+               /*
+                * @see java.lang.Object#hashCode()
+                */
+               public int hashCode() {
+                       if (fIsHashCached)
+                               return fHashCode;
+                       
+                       int hash= 0;
+                       for (int i= 0, n= fLength; i < n; i++)
+                               hash= 29*hash + fContent[i];
+                       fHashCode= hash;
+                       fIsHashCached= true;
+                       return hash;
+               }
+               
+               
+               /*
+                * @see java.lang.Object#equals(java.lang.Object)
+                */
+               public boolean equals(Object obj) {
+                       if (obj == this)
+                               return true;
+                       if (!(obj instanceof CharacterBuffer))
+                               return false;
+                       CharacterBuffer buffer= (CharacterBuffer) obj;
+                       int length= buffer.length();
+                       if (length != fLength)
+                               return false;
+                       for (int i= 0; i < length; i++)
+                               if (buffer.charAt(i) != fContent[i])
+                                       return false;
+                       return true;
+               }
+               
+               /**
+                * Is the content equal to the given string?
+                * 
+                * @param string the string
+                * @return <code>true</code> iff the content is the same character sequence as in the string
+                */
+               public boolean equals(String string) {
+                       int length= string.length();
+                       if (length != fLength)
+                               return false;
+                       for (int i= 0; i < length; i++)
+                               if (string.charAt(i) != fContent[i])
+                                       return false;
+                       return true;
+               }
+       }
+
+       /** Internal setting for the uninitialized column constraint */
+       private static final int UNDEFINED= -1;
+       
+       /** The word detector used by this rule */
+       private IWordDetector fDetector;
+       /** The default token to be returned on success and if nothing else has been specified. */
+       private IToken fDefaultToken;
+       /** The column constraint */
+       private int fColumn= UNDEFINED;
+       /** Buffer used for pattern detection */
+       private CharacterBuffer fBuffer= new CharacterBuffer(16);
+       
+       /** List of word matchers */
+       private List fMatchers= new ArrayList();
+
+       /**
+        * Creates a rule which, with the help of an word detector, will return the token
+        * associated with the detected word. If no token has been associated, the scanner 
+        * will be rolled back and an undefined token will be returned in order to allow 
+        * any subsequent rules to analyze the characters.
+        *
+        * @param detector the word detector to be used by this rule, may not be <code>null</code>
+        *
+        * @see #addWord(String, IToken)
+        */
+       public CombinedWordRule(IWordDetector detector) {
+               this(detector, null, Token.UNDEFINED);
+       }
+
+       /**
+        * Creates a rule which, with the help of an word detector, will return the token
+        * associated with the detected word. If no token has been associated, the
+        * specified default token will be returned.
+        *
+        * @param detector the word detector to be used by this rule, may not be <code>null</code>
+        * @param defaultToken the default token to be returned on success 
+        *              if nothing else is specified, may not be <code>null</code>
+        *
+        * @see #addWord(String, IToken)
+        */
+       public CombinedWordRule(IWordDetector detector, IToken defaultToken) {
+               this(detector, null, defaultToken);
+       }
+
+       /**
+        * Creates a rule which, with the help of an word detector, will return the token
+        * associated with the detected word. If no token has been associated, the scanner 
+        * will be rolled back and an undefined token will be returned in order to allow 
+        * any subsequent rules to analyze the characters.
+        *
+        * @param detector the word detector to be used by this rule, may not be <code>null</code>
+        * @param matcher the initial word matcher
+        *
+        * @see #addWord(String, IToken)
+        */
+       public CombinedWordRule(IWordDetector detector, WordMatcher matcher) {
+               this(detector, matcher, Token.UNDEFINED);
+       }
+
+       /**
+        * Creates a rule which, with the help of an word detector, will return the token
+        * associated with the detected word. If no token has been associated, the
+        * specified default token will be returned.
+        *
+        * @param detector the word detector to be used by this rule, may not be <code>null</code>
+        * @param matcher the initial word matcher
+        * @param defaultToken the default token to be returned on success 
+        *              if nothing else is specified, may not be <code>null</code>
+        *
+        * @see #addWord(String, IToken)
+        */
+       public CombinedWordRule(IWordDetector detector, WordMatcher matcher, IToken defaultToken) {
+               
+               Assert.isNotNull(detector);
+               Assert.isNotNull(defaultToken);
+               
+               fDetector= detector;
+               fDefaultToken= defaultToken;
+               if (matcher != null)
+                       addWordMatcher(matcher);
+       }
+
+       
+       /**
+        * Adds the given matcher.
+        * 
+        * @param matcher the matcher
+        */
+       public void addWordMatcher(WordMatcher matcher) {
+               fMatchers.add(matcher);
+       }
+       
+       /**
+        * Sets a column constraint for this rule. If set, the rule's token
+        * will only be returned if the pattern is detected starting at the 
+        * specified column. If the column is smaller then 0, the column
+        * constraint is considered removed.
+        *
+        * @param column the column in which the pattern starts
+        */
+       public void setColumnConstraint(int column) {
+               if (column < 0)
+                       column= UNDEFINED;
+               fColumn= column;
+       }
+       
+       /*
+        * @see IRule#evaluate(ICharacterScanner)
+        */
+       public IToken evaluate(ICharacterScanner scanner) {
+               int c= scanner.read();
+               if (fDetector.isWordStart((char) c)) {
+                       if (fColumn == UNDEFINED || (fColumn == scanner.getColumn() - 1)) {
+                               
+                               fBuffer.clear();
+                               do {
+                                       fBuffer.append((char) c);
+                                       c= scanner.read();
+                               } while (c != ICharacterScanner.EOF && fDetector.isWordPart((char) c));
+                               scanner.unread();
+                               
+                               for (int i= 0, n= fMatchers.size(); i < n; i++) {
+                                       IToken token= ((WordMatcher) fMatchers.get(i)).evaluate(scanner, fBuffer);
+                                       if (!token.isUndefined())
+                                               return token;
+                               }
+                                       
+                               if (fDefaultToken.isUndefined())
+                                       unreadBuffer(scanner);
+                                       
+                               return fDefaultToken;
+                       }
+               }
+               
+               scanner.unread();
+               return Token.UNDEFINED;
+       }
+       
+       /**
+        * Returns the characters in the buffer to the scanner.
+        *
+        * @param scanner the scanner to be used
+        */
+       private void unreadBuffer(ICharacterScanner scanner) {
+               for (int i= fBuffer.length() - 1; i >= 0; i--)
+                       scanner.unread();
+       }
+}
index 1df600e..8c71647 100644 (file)
@@ -959,6 +959,10 @@ public class PreferenceConstants {
   public static final String EDITOR_BOLD_SUFFIX = "_bold"; //$NON-NLS-1$
 
   /**
+   * Preference key suffix for bold text style preference keys.
+   */
+  public static final String EDITOR_ITALIC_SUFFIX = "_italic"; //$NON-NLS-1$
+  /**
    * A named preference that holds the color used to render multi line comments.
    * <p>
    * Value is of type <code>String</code>. A RGB color value encoded as a string
@@ -1007,6 +1011,71 @@ public final static String EDITOR_TEXT_FONT= "net.sourceforge.phpdt.ui.editors.t
    * </p>
    */
   public final static String EDITOR_SINGLE_LINE_COMMENT_BOLD = IPreferenceConstants.PHP_SINGLELINE_COMMENT + EDITOR_BOLD_SUFFIX;
+  /**
+        * A named preference that holds the color used to render operators and brackets.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        * 
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        * @since 3.0
+        */
+       public final static String EDITOR_PHP_OPERATOR_COLOR= IPreferenceConstants.PHP_OPERATOR;        
+
+       /**
+        * A named preference that controls whether operators and brackets are rendered in bold.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        * 
+        * @since 3.0
+        */
+       public final static String EDITOR_PHP_OPERATOR_BOLD= IPreferenceConstants.PHP_OPERATOR + EDITOR_BOLD_SUFFIX;
+       
+       /**
+        * A named preference that controls whether operators and brackets are rendered in italic.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        * 
+        * @since 3.0
+        */
+       public final static String EDITOR_PHP_OPERATOR_ITALIC= IPreferenceConstants.PHP_OPERATOR + EDITOR_ITALIC_SUFFIX;
+
+        /**
+        * A named preference that holds the color used to render the 'return' keyword.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        * 
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        * @since 3.0
+        */
+       public final static String EDITOR_PHP_KEYWORD_RETURN_COLOR= IPreferenceConstants.PHP_KEYWORD_RETURN;    
+
+       /**
+        * A named preference that controls whether 'return' keyword is rendered in bold.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        * 
+        * @since 3.0
+        */
+       public final static String EDITOR_PHP_KEYWORD_RETURN_BOLD= IPreferenceConstants.PHP_KEYWORD_RETURN + EDITOR_BOLD_SUFFIX;
+       
+       /**
+        * A named preference that controls whether 'return' keyword is rendered in italic.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        * 
+        * @since 3.0
+        */
+       public final static String EDITOR_PHP_KEYWORD_RETURN_ITALIC= IPreferenceConstants.PHP_KEYWORD_RETURN + EDITOR_ITALIC_SUFFIX;
 
   /**
         * A named preference that holds the color used to render php start and stop tags.
index 9c36457..9016106 100644 (file)
@@ -11,10 +11,26 @@ Contributors:
 **********************************************************************/
 package net.sourceforge.phpeclipse;
 
+
+
 /**
  * Predefined prference constants
  */
 public interface IPreferenceConstants {
+       /**
+        * Preference key suffix for bold text style preference keys.
+        * 
+        * @since 2.1
+        */
+       public static final String EDITOR_BOLD_SUFFIX= "_bold"; //$NON-NLS-1$
+
+       /**
+        * Preference key suffix for italic text style preference keys.
+        * 
+        * @since 3.0
+        */
+       public static final String EDITOR_ITALIC_SUFFIX= "_italic"; //$NON-NLS-1$
+       
   public static final String LOCALHOST_PREF = "_localhost";
   public static final String DOCUMENTROOT_PREF = "_documentroot";
   public static final String USE_EXTERNAL_BROWSER_PREF = "_use_external_browser";
@@ -41,35 +57,111 @@ public interface IPreferenceConstants {
   public static final String PHP_MULTILINE_COMMENT_BOLD = "_php_multilineComment_bold";
   public static final String PHP_MULTILINE_COMMENT_ITALIC = "_php_multilineComment_italic";
   public static final String PHP_MULTILINE_COMMENT_UNDERLINE = "_php_multilineComment_underline";
-  public static final String PHP_SINGLELINE_COMMENT = "_php_singlelineComment";
-  public static final String PHP_SINGLELINE_COMMENT_BOLD = "_php_singlelineComment_bold";
-  public static final String PHP_SINGLELINE_COMMENT_ITALIC = "_php_singlelineComment_italic";
-  public static final String PHP_SINGLELINE_COMMENT_UNDERLINE = "_php_singlelineComment_underline";
-       public static final String PHP_TAG = "_php_tag";
-       public static final String PHP_TAG_BOLD = "_php_tag_bold";
-       public static final String PHP_TAG_ITALIC = "_php_tag_italic";
-       public static final String PHP_TAG_UNDERLINE = "_php_tag_underline";
-  public static final String PHP_KEYWORD = "_php_keyword";
-  public static final String PHP_KEYWORD_BOLD = "_php_keyword_bold";
-  public static final String PHP_KEYWORD_ITALIC = "_php_keyword_italic";
-  public static final String PHP_KEYWORD_UNDERLINE = "_php_keyword_underline";
-  public static final String PHP_VARIABLE = "_php_variable";
-  public static final String PHP_VARIABLE_BOLD = "_php_variable_bold";
-  public static final String PHP_VARIABLE_ITALIC = "_php_variable_italic";
-  public static final String PHP_VARIABLE_UNDERLINE = "_php_variable_underline";
-  public static final String PHP_TYPE = "_php_type";
-  public static final String PHP_TYPE_BOLD = "_php_type_bold";
-  public static final String PHP_TYPE_ITALIC = "_php_type_italic";
-  public static final String PHP_TYPE_UNDERLINE = "_php_type_underline";
-  public static final String PHP_CONSTANT = "_php_constant";
-  public static final String PHP_CONSTANT_BOLD = "_php_constant_bold";
-  public static final String PHP_CONSTANT_ITALIC = "_php_constant_italic";
-  public static final String PHP_CONSTANT_UNDERLINE = "_php_constant_underline";
-  public static final String PHP_FUNCTIONNAME = "_php_functionname";
-  public static final String PHP_FUNCTIONNAME_BOLD = "_php_functionname_bold";
-  public static final String PHP_FUNCTIONNAME_ITALIC = "_php_functionname_italic";
-  public static final String PHP_FUNCTIONNAME_UNDERLINE = "_php_functionname_underline";
-  public static final String PHP_STRING = "_php_string";
+  /** The color key for operators and brackets in PHP code
+        * (value <code>"__php_operator"</code>).
+        * @since 3.0
+        */
+  public static final String PHP_OPERATOR= "__php_operator"; //$NON-NLS-1$
+  /**
+        * A named preference that holds the color used to render operators and brackets.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        * 
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        * @since 3.0
+        */
+       public final static String EDITOR_PHP_OPERATOR_COLOR= PHP_OPERATOR;     
+
+       /**
+        * A named preference that controls whether operators and brackets are rendered in bold.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        * 
+        * @since 3.0
+        */
+       public final static String EDITOR_PHP_OPERATOR_BOLD= PHP_OPERATOR + EDITOR_BOLD_SUFFIX;
+       
+       /**
+        * A named preference that controls whether operators and brackets are rendered in italic.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        * 
+        * @since 3.0
+        */
+       public final static String EDITOR_PHP_OPERATOR_ITALIC= PHP_OPERATOR + EDITOR_ITALIC_SUFFIX;
+
+  /** The color key for keyword 'return' in PHP code
+        * (value <code>"__php_keyword_return"</code>).
+        * @since 3.0
+        */
+  public static final String PHP_KEYWORD_RETURN= "__php_keyword_return"; //$NON-NLS-1$
+  /**
+        * A named preference that holds the color used to render the 'return' keyword.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        * 
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        * @since 3.0
+        */
+       public final static String EDITOR_PHP_KEYWORD_RETURN_COLOR= PHP_KEYWORD_RETURN; 
+
+       /**
+        * A named preference that controls whether 'return' keyword is rendered in bold.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        * 
+        * @since 3.0
+        */
+       public final static String EDITOR_PHP_KEYWORD_RETURN_BOLD= PHP_KEYWORD_RETURN + EDITOR_BOLD_SUFFIX;
+       
+       /**
+        * A named preference that controls whether 'return' keyword is rendered in italic.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        * 
+        * @since 3.0
+        */
+       public final static String EDITOR_PHP_KEYWORD_RETURN_ITALIC= PHP_KEYWORD_RETURN + EDITOR_ITALIC_SUFFIX;
+       
+       public static final String PHP_SINGLELINE_COMMENT = "_php_singlelineComment";  
+  public static final String PHP_SINGLELINE_COMMENT_BOLD = "_php_singlelineComment_bold";//$NON-NLS-1$
+  public static final String PHP_SINGLELINE_COMMENT_ITALIC = "_php_singlelineComment_italic";//$NON-NLS-1$
+  public static final String PHP_SINGLELINE_COMMENT_UNDERLINE = "_php_singlelineComment_underline";//$NON-NLS-1$
+       public static final String PHP_TAG = "_php_tag";//$NON-NLS-1$
+       public static final String PHP_TAG_BOLD = "_php_tag_bold";//$NON-NLS-1$
+       public static final String PHP_TAG_ITALIC = "_php_tag_italic";//$NON-NLS-1$
+       public static final String PHP_TAG_UNDERLINE = "_php_tag_underline";//$NON-NLS-1$
+  public static final String PHP_KEYWORD = "_php_keyword";//$NON-NLS-1$
+  public static final String PHP_KEYWORD_BOLD = "_php_keyword_bold";//$NON-NLS-1$
+  public static final String PHP_KEYWORD_ITALIC = "_php_keyword_italic";//$NON-NLS-1$
+  public static final String PHP_KEYWORD_UNDERLINE = "_php_keyword_underline";//$NON-NLS-1$
+  public static final String PHP_VARIABLE = "_php_variable";//$NON-NLS-1$
+  public static final String PHP_VARIABLE_BOLD = "_php_variable_bold";//$NON-NLS-1$
+  public static final String PHP_VARIABLE_ITALIC = "_php_variable_italic";//$NON-NLS-1$
+  public static final String PHP_VARIABLE_UNDERLINE = "_php_variable_underline";//$NON-NLS-1$
+  public static final String PHP_TYPE = "_php_type";//$NON-NLS-1$
+  public static final String PHP_TYPE_BOLD = "_php_type_bold";//$NON-NLS-1$
+  public static final String PHP_TYPE_ITALIC = "_php_type_italic";//$NON-NLS-1$
+  public static final String PHP_TYPE_UNDERLINE = "_php_type_underline";//$NON-NLS-1$
+  public static final String PHP_CONSTANT = "_php_constant";//$NON-NLS-1$
+  public static final String PHP_CONSTANT_BOLD = "_php_constant_bold";//$NON-NLS-1$
+  public static final String PHP_CONSTANT_ITALIC = "_php_constant_italic";//$NON-NLS-1$
+  public static final String PHP_CONSTANT_UNDERLINE = "_php_constant_underline";//$NON-NLS-1$
+  public static final String PHP_FUNCTIONNAME = "_php_functionname";//$NON-NLS-1$
+  public static final String PHP_FUNCTIONNAME_BOLD = "_php_functionname_bold";//$NON-NLS-1$
+  public static final String PHP_FUNCTIONNAME_ITALIC = "_php_functionname_italic";//$NON-NLS-1$
+  public static final String PHP_FUNCTIONNAME_UNDERLINE = "_php_functionname_underline";//$NON-NLS-1$
+  public static final String PHP_STRING = "_php_string";//$NON-NLS-1$
   public static final String PHP_STRING_BOLD = "_php_string_bold";
   public static final String PHP_STRING_ITALIC = "_php_string_italic";
   public static final String PHP_STRING_UNDERLINE = "_php_string_underline";
@@ -105,28 +197,6 @@ public interface IPreferenceConstants {
   //  public static final String PHP_EDITOR_BACKGROUND = "_php_editor_background";
   public static final String PHP_USERDEF_XMLFILE = "_userdef_xmlfile";
 
-  //  /** The color key for PHPDoc keywords (<code>@foo</code>) in PHPDoc comments. */
-  //  public static final String PHPDOC_KEYWORD= "_php_doc_keyword"; //$NON-NLS-1$
-  //  /** The color key for HTML tags (<code>&lt;foo&gt;</code>) in PHPDoc comments. */
-  //  public static final String PHPDOC_TAG= "_php_doc_tag"; //$NON-NLS-1$
-  //  /** The color key for PHPDoc links (<code>{foo}</code>) in PHPDoc comments. */
-  //  public static final String PHPDOC_LINK= "_php_doc_link"; //$NON-NLS-1$
-  //  /** The color key for everthing in PHPDoc comments for which no other color is specified. */
-  //  public static final String PHPDOC_DEFAULT= "_php_doc_default"; //$NON-NLS-1$
-
-  /*Language stuff  - under dev*/
-//  public static final String RESOURCE_BUNDLE = "_php_editor_res_bundle"; //$NON-NLS-1$
-//  public static final String LANGUAGE_DEFAULT = "net.sourceforge.phpeclipse.newPHPPreferencesMessages_en_GB";
-//  public static final String RESOURCE_BUNDLE_DE = "net.sourceforge.phpeclipse.newPHPPreferencesMessages_DE";
-//  public static final String RESOURCE_BUNDLE_FR = "net.sourceforge.phpeclipse.newPHPPreferencesMessages_FR";
-//  public static final String RESOURCE_BUNDLE_ES = "net.sourceforge.phpeclipse.newPHPPreferencesMessages_es_ES";
-//  public static final String RESOURCE_BUNDLE_EN_GB = "net.sourceforge.phpeclipse.newPHPPreferencesMessages_en_GB";
-//     public static final String RESOURCE_BUNDLE_JA = "net.sourceforge.phpeclipse.newPHPPreferencesMessages_JA";
-
-  //public static final String FORMATTER_TAB_SIZE = "_formatter_tab_size";
-  //public static final String SPACES_FOR_TABS = "_formatter_tab_size";
-
-  public static final String EDITOR_BOLD_SUFFIX = "_editor_bold_suffix";
   /** Preference key for showing the line number ruler */
   // public final static String LINE_NUMBER_RULER = "_lineNumberRuler"; //$NON-NLS-1$
   /** Preference key for the foreground color of the line numbers */
index e59ece1..0d7154f 100644 (file)
@@ -77,6 +77,7 @@ import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.IEditorDescriptor;
@@ -532,6 +533,15 @@ public class PHPeclipsePlugin extends AbstractUIPlugin
         PHPColorProvider.PHPDOC_LINK);
     PreferenceConverter.setDefault(store, PHPDOC_DEFAULT,
         PHPColorProvider.PHPDOC_DEFAULT);
+    
+    PreferenceConverter.setDefault(store, EDITOR_PHP_KEYWORD_RETURN_COLOR, new RGB(127, 0, 85));
+       store.setDefault(EDITOR_PHP_KEYWORD_RETURN_BOLD, true);
+       store.setDefault(EDITOR_PHP_KEYWORD_RETURN_ITALIC, false);
+
+       PreferenceConverter.setDefault(store, EDITOR_PHP_OPERATOR_COLOR, new RGB(0, 0, 0));
+       store.setDefault(EDITOR_PHP_OPERATOR_BOLD, false);
+       store.setDefault(EDITOR_PHP_OPERATOR_ITALIC, false);
+       
     //    PreferenceConverter.setDefault(
     //      store,
     //      PHP_EDITOR_BACKGROUND,
index b21bac7..dc49be5 100644 (file)
@@ -289,7 +289,7 @@ public class CompilationUnitDeclaration extends AstNode implements ProblemSeveri
 
     if (imports != null)
       for (int i = 0; i < imports.length; i++) {
-        s += tabString(tab) + "import " + imports[i].toString() + ";\n"; //$NON-NLS-1$ //$NON-NLS-2$
+        s += tabString(tab) + "include " + imports[i].toString() + ";\n"; //$NON-NLS-1$ //$NON-NLS-2$
       };
 
     if (types != null)
index 09d6734..b227ae2 100644 (file)
@@ -15,6 +15,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import net.sourceforge.phpdt.internal.ui.text.AbstractJavaScanner;
+import net.sourceforge.phpdt.internal.ui.text.CombinedWordRule;
 import net.sourceforge.phpdt.ui.text.IColorManager;
 import net.sourceforge.phpeclipse.IPreferenceConstants;
 import net.sourceforge.phpeclipse.phpeditor.PHPSyntaxRdr;
@@ -24,6 +25,7 @@ import net.sourceforge.phpeclipse.phpeditor.util.PHPWordDetector;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.text.rules.EndOfLineRule;
 import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IRule;
 import org.eclipse.jface.text.rules.IToken;
 import org.eclipse.jface.text.rules.IWordDetector;
 import org.eclipse.jface.text.rules.MultiLineRule;
@@ -35,7 +37,64 @@ import org.eclipse.jface.text.rules.WordRule;
  * PHP Code Scanner
  */
 public class PHPCodeScanner extends AbstractJavaScanner {
-
+  /**
+   * Rule to detect java operators.
+   * 
+   * @since 3.0
+   */
+       protected class OperatorRule implements IRule {
+       
+               /** Java operators */
+               private final char[] JAVA_OPERATORS= { ';', '(', ')', '{', '}', '.', '=', '/', '\\', '+', '-', '*', '[', ']', '<', '>', ':', '?', '!', ',', '|', '&', '^', '%', '~', '@'};
+               /** Token to return for this rule */
+               private final IToken fToken;
+       
+               /**
+     * Creates a new operator rule.
+     * 
+     * @param token
+     *          Token to use for this rule
+     */
+               public OperatorRule(IToken token) {
+                       fToken= token;
+               }
+               
+               /**
+     * Is this character an operator character?
+     * 
+     * @param character
+     *          Character to determine whether it is an operator character
+     * @return <code>true</code> iff the character is an operator,
+     *         <code>false</code> otherwise.
+     */
+               public boolean isOperator(char character) {
+                       for (int index= 0; index < JAVA_OPERATORS.length; index++) {
+                               if (JAVA_OPERATORS[index] == character)
+                                       return true;
+                       }
+                       return false;
+               }
+       
+               /*
+     * @see org.eclipse.jface.text.rules.IRule#evaluate(org.eclipse.jface.text.rules.ICharacterScanner)
+     */
+               public IToken evaluate(ICharacterScanner scanner) {
+       
+                       int character= scanner.read();
+                       if (isOperator((char) character)) {
+                               do {
+                                       character= scanner.read();
+                               } while (isOperator((char) character));
+                               scanner.unread();
+                               return fToken;
+                       } else {
+                               scanner.unread();
+                               return Token.UNDEFINED;
+                       }
+               }
+       }
+       
   private class PHPWordRule extends WordRule {
     private StringBuffer fBuffer = new StringBuffer();
 
@@ -119,23 +178,28 @@ public class PHPCodeScanner extends AbstractJavaScanner {
     {
       IPreferenceConstants.PHP_MULTILINE_COMMENT,
       IPreferenceConstants.PHP_SINGLELINE_COMMENT,
-                       IPreferenceConstants.PHP_TAG,
+         IPreferenceConstants.PHP_TAG,
       IPreferenceConstants.PHP_KEYWORD,
       IPreferenceConstants.PHP_FUNCTIONNAME,
       IPreferenceConstants.PHP_VARIABLE,
       IPreferenceConstants.PHP_STRING,
       IPreferenceConstants.PHP_TYPE,
       IPreferenceConstants.PHP_CONSTANT,
-      IPreferenceConstants.PHP_DEFAULT };
+      IPreferenceConstants.PHP_DEFAULT,
+      IPreferenceConstants.PHP_OPERATOR,
+      IPreferenceConstants.PHP_KEYWORD_RETURN};
   /**
-       * Creates a PHP code scanner
-       */
+   * Creates a PHP code scanner
+   */
   // public PHPCodeScanner(JavaColorManager provider, IPreferenceStore store) {
   public PHPCodeScanner(IColorManager manager, IPreferenceStore store) {
     super(manager, store);
     initialize();
-    //  //  final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
-    //   Color BackgroundColor = provider.getColor(PreferenceConverter.getColor(store, PHP_EDITOR_BACKGROUND));
+    //  // final IPreferenceStore store =
+    // PHPeclipsePlugin.getDefault().getPreferenceStore();
+    //   Color BackgroundColor =
+    // provider.getColor(PreferenceConverter.getColor(store,
+    // PHP_EDITOR_BACKGROUND));
     //    variable =
     //      new Token(
     //        new TextAttribute(
@@ -148,13 +212,15 @@ public class PHPCodeScanner extends AbstractJavaScanner {
     //          provider.getColor(PreferenceConverter.getColor(store, PHP_KEYWORD)),
     //          BackgroundColor,
     //    //SWT.NONE));
-    //   (store.getBoolean(PHP_KEYWORD_BOLD) ? SWT.BOLD : SWT.NONE) + (store.getBoolean(PHP_KEYWORD_ITALIC) ? SWT.ITALIC : SWT.NONE)));
+    //   (store.getBoolean(PHP_KEYWORD_BOLD) ? SWT.BOLD : SWT.NONE) +
+    // (store.getBoolean(PHP_KEYWORD_ITALIC) ? SWT.ITALIC : SWT.NONE)));
     //      type =
     //        new Token(new TextAttribute(
     //          provider.getColor(PreferenceConverter.getColor(store, PHP_TYPE)),
     //          BackgroundColor,
     //    //SWT.NONE));
-    //   (store.getBoolean(PHP_TYPE_BOLD) ? SWT.BOLD : SWT.NONE) + (store.getBoolean(PHP_TYPE_ITALIC) ? SWT.ITALIC : SWT.NONE)));
+    //   (store.getBoolean(PHP_TYPE_BOLD) ? SWT.BOLD : SWT.NONE) +
+    // (store.getBoolean(PHP_TYPE_ITALIC) ? SWT.ITALIC : SWT.NONE)));
     //      functionName =
     //        new Token(new TextAttribute(
     //          provider.getColor(PreferenceConverter.getColor(store, PHP_FUNCTIONNAME)),
@@ -167,40 +233,56 @@ public class PHPCodeScanner extends AbstractJavaScanner {
     //          provider.getColor(PreferenceConverter.getColor(store, PHP_CONSTANT)),
     //          BackgroundColor,
     //    //SWT.NONE));
-    //   (store.getBoolean(PHP_CONSTANT_BOLD) ? SWT.BOLD : SWT.NONE) + (store.getBoolean(PHP_CONSTANT_ITALIC) ? SWT.ITALIC : SWT.NONE)));
+    //   (store.getBoolean(PHP_CONSTANT_BOLD) ? SWT.BOLD : SWT.NONE) +
+    // (store.getBoolean(PHP_CONSTANT_ITALIC) ? SWT.ITALIC : SWT.NONE)));
     //      string =
     //        new Token(new TextAttribute(
     //          provider.getColor(PreferenceConverter.getColor(store, PHP_STRING)),
     //          BackgroundColor,
     //    //SWT.NONE));
-    //   (store.getBoolean(PHP_STRING_BOLD) ? SWT.BOLD : SWT.NONE ) + (store.getBoolean(PHP_STRING_ITALIC) ? SWT.ITALIC : SWT.NONE)));
+    //   (store.getBoolean(PHP_STRING_BOLD) ? SWT.BOLD : SWT.NONE ) +
+    // (store.getBoolean(PHP_STRING_ITALIC) ? SWT.ITALIC : SWT.NONE)));
     //      comment =
     //        new Token(new TextAttribute(
-    //          provider.getColor(PreferenceConverter.getColor(store, PHP_SINGLELINE_COMMENT)),
+    //          provider.getColor(PreferenceConverter.getColor(store,
+    // PHP_SINGLELINE_COMMENT)),
     //          BackgroundColor,
     //    //SWT.NONE));
     //  (store.getBoolean(PHP_SINGLELINE_COMMENT_BOLD) ? SWT.BOLD : SWT.NONE )
-    //    + (store.getBoolean(PHP_SINGLELINE_COMMENT_ITALIC) ? SWT.ITALIC : SWT.NONE)));
+    //    + (store.getBoolean(PHP_SINGLELINE_COMMENT_ITALIC) ? SWT.ITALIC :
+    // SWT.NONE)));
     //      multi_comment =
     //        new Token(new TextAttribute(
-    //          provider.getColor(PreferenceConverter.getColor(store, PHP_MULTILINE_COMMENT)),
+    //          provider.getColor(PreferenceConverter.getColor(store,
+    // PHP_MULTILINE_COMMENT)),
     //          BackgroundColor,
     //    //SWT.NONE));
     //  (store.getBoolean(PHP_MULTILINE_COMMENT_BOLD) ? SWT.BOLD : SWT.NONE)
-    //    + (store.getBoolean(PHP_MULTILINE_COMMENT_ITALIC) ? SWT.ITALIC : SWT.NONE)));
+    //    + (store.getBoolean(PHP_MULTILINE_COMMENT_ITALIC) ? SWT.ITALIC :
+    // SWT.NONE)));
     //      other =
     //        new Token(new TextAttribute(
     //          provider.getColor(PreferenceConverter.getColor(store, PHP_DEFAULT)),
     //          BackgroundColor,
     //    //SWT.NONE));
-    //   (store.getBoolean(PHP_DEFAULT_BOLD) ? SWT.BOLD : SWT.NONE) + (store.getBoolean(PHP_DEFAULT_ITALIC) ? SWT.ITALIC : SWT.NONE)));
+    //   (store.getBoolean(PHP_DEFAULT_BOLD) ? SWT.BOLD : SWT.NONE) +
+    // (store.getBoolean(PHP_DEFAULT_ITALIC) ? SWT.ITALIC : SWT.NONE)));
     //    updateWordRules();
   }
 
+  /*
+   * @see AbstractJavaScanner#getTokenProperties()
+   */
+  protected String[] getTokenProperties() {
+    return fgTokenProperties;
+  }
   //  public void updateToken(JavaColorManager provider) {
-  //    final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
+  //    final IPreferenceStore store =
+  // PHPeclipsePlugin.getDefault().getPreferenceStore();
   //
-  //    Color BackgroundColor = provider.getColor(PreferenceConverter.getColor(store, PHP_EDITOR_BACKGROUND));
+  //    Color BackgroundColor =
+  // provider.getColor(PreferenceConverter.getColor(store,
+  // PHP_EDITOR_BACKGROUND));
   //
   //    variable.setData(
   //      new TextAttribute(
@@ -218,7 +300,8 @@ public class PHPCodeScanner extends AbstractJavaScanner {
   //      new TextAttribute(
   //        provider.getColor(PreferenceConverter.getColor(store, PHP_TYPE)),
   //        BackgroundColor,
-  //        (store.getBoolean(PHP_TYPE_BOLD) ? SWT.BOLD : SWT.NONE) + (store.getBoolean(PHP_TYPE_ITALIC) ? SWT.ITALIC : SWT.NONE)));
+  //        (store.getBoolean(PHP_TYPE_BOLD) ? SWT.BOLD : SWT.NONE) +
+  // (store.getBoolean(PHP_TYPE_ITALIC) ? SWT.ITALIC : SWT.NONE)));
   //    functionName.setData(
   //      new TextAttribute(
   //        provider.getColor(PreferenceConverter.getColor(store, PHP_FUNCTIONNAME)),
@@ -235,19 +318,24 @@ public class PHPCodeScanner extends AbstractJavaScanner {
   //      new TextAttribute(
   //        provider.getColor(PreferenceConverter.getColor(store, PHP_STRING)),
   //        BackgroundColor,
-  //        (store.getBoolean(PHP_STRING_BOLD) ? SWT.BOLD : SWT.NONE) + (store.getBoolean(PHP_STRING_ITALIC) ? SWT.ITALIC : SWT.NONE)));
+  //        (store.getBoolean(PHP_STRING_BOLD) ? SWT.BOLD : SWT.NONE) +
+  // (store.getBoolean(PHP_STRING_ITALIC) ? SWT.ITALIC : SWT.NONE)));
   //    comment.setData(
   //      new TextAttribute(
-  //        provider.getColor(PreferenceConverter.getColor(store, PHP_SINGLELINE_COMMENT)),
+  //        provider.getColor(PreferenceConverter.getColor(store,
+  // PHP_SINGLELINE_COMMENT)),
   //        BackgroundColor,
   //        (store.getBoolean(PHP_SINGLELINE_COMMENT_BOLD) ? SWT.BOLD : SWT.NONE)
-  //          + (store.getBoolean(PHP_SINGLELINE_COMMENT_ITALIC) ? SWT.ITALIC : SWT.NONE)));
+  //          + (store.getBoolean(PHP_SINGLELINE_COMMENT_ITALIC) ? SWT.ITALIC :
+  // SWT.NONE)));
   //    multi_comment.setData(
   //      new TextAttribute(
-  //        provider.getColor(PreferenceConverter.getColor(store, PHP_MULTILINE_COMMENT)),
+  //        provider.getColor(PreferenceConverter.getColor(store,
+  // PHP_MULTILINE_COMMENT)),
   //        BackgroundColor,
   //        (store.getBoolean(PHP_MULTILINE_COMMENT_BOLD) ? SWT.BOLD : SWT.NONE)
-  //          + (store.getBoolean(PHP_MULTILINE_COMMENT_ITALIC) ? SWT.ITALIC : SWT.NONE)));
+  //          + (store.getBoolean(PHP_MULTILINE_COMMENT_ITALIC) ? SWT.ITALIC :
+  // SWT.NONE)));
   //    other.setData(
   //      new TextAttribute(
   //        provider.getColor(PreferenceConverter.getColor(store, PHP_DEFAULT)),
@@ -258,12 +346,7 @@ public class PHPCodeScanner extends AbstractJavaScanner {
 
   // public void updateWordRules() {
 
-  /*
-   * @see AbstractJavaScanner#getTokenProperties()
-   */
-  protected String[] getTokenProperties() {
-    return fgTokenProperties;
-  }
+
   /*
    * @see AbstractJavaScanner#createRules()
    */
@@ -279,9 +362,10 @@ public class PHPCodeScanner extends AbstractJavaScanner {
     rules.add(new MultiLineRule("`", "`", token, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
     rules.add(new MultiLineRule("'", "'", token, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
 
-    //previous version
-    //rules.add(new SingleLineRule("'", "'", token, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
-
+//  Add rule for operators and brackets
+       token= getToken(IPreferenceConstants.PHP_OPERATOR);
+       rules.add(new OperatorRule(token));
+       
     token = getToken(IPreferenceConstants.PHP_MULTILINE_COMMENT);
     rules.add(new MultiLineRule("/*", "*/", token)); //$NON-NLS-2$ //$NON-NLS-1$
     // Add generic whitespace rule.
@@ -289,33 +373,44 @@ public class PHPCodeScanner extends AbstractJavaScanner {
     // Add word rule for keywords, types, and constants.
     token = getToken(IPreferenceConstants.PHP_DEFAULT);
     PHPWordRule wordRule = new PHPWordRule(new PHPWordDetector(), token);
-
+       CombinedWordRule combinedWordRule= new CombinedWordRule(new PHPWordDetector(), token);
+       
     Token keyword = getToken(IPreferenceConstants.PHP_KEYWORD);
     Token functionName = getToken(IPreferenceConstants.PHP_FUNCTIONNAME);
     Token type = getToken(IPreferenceConstants.PHP_TYPE);
     Token constant = getToken(IPreferenceConstants.PHP_CONSTANT);
 
     ArrayList buffer = PHPSyntaxRdr.getSyntaxData();
-    //  String strbuffer = null;  unused
+    //  String strbuffer = null; unused
     PHPElement elbuffer = null;
+    String name;
     for (int i = 0; i < buffer.size(); i++) {
       //    while ((buffer != null)
       //      && (!buffer.isEmpty()
       //        && ((elbuffer = (PHPElement) buffer.remove(0)) != null))) {
       elbuffer = (PHPElement) buffer.get(i);
-      if (elbuffer instanceof PHPKeyword)
-        wordRule.addWord(((PHPKeyword) elbuffer).getName(), keyword);
-      if (elbuffer instanceof PHPFunction)
+      if (elbuffer instanceof PHPKeyword) {
+        name = ((PHPKeyword) elbuffer).getName();
+//        if (!name.equals("return")) {
+          wordRule.addWord(name, keyword);
+//        }
+      } else if (elbuffer instanceof PHPFunction) {
         wordRule.addWord(((PHPFunction) elbuffer).getName(), functionName);
-      if (elbuffer instanceof PHPType)
+      } else if (elbuffer instanceof PHPType) {
         wordRule.addWord(elbuffer.getName(), type);
-      if (elbuffer instanceof PHPConstant)
+      } else if (elbuffer instanceof PHPConstant) {
         wordRule.addWord(elbuffer.getName(), constant);
+      }
     }
     rules.add(wordRule);
-    // IRule[] result = new IRule[rules.size()];unused
-    //    rules.toArray(result);
-    //    setRules(result);
+    
+//      Add word rule for keyword 'return'.
+//     CombinedWordRule.WordMatcher returnWordRule= new CombinedWordRule.WordMatcher();
+//     token= getToken(IPreferenceConstants.PHP_KEYWORD_RETURN);
+//     returnWordRule.addWord("return", token);  //$NON-NLS-1$
+//     combinedWordRule.addWordMatcher(returnWordRule);
+//     rules.add(combinedWordRule);
+//     
     return rules;
   }
 }