Different syntax coloring for '$_' variables possible
authoraxelcl <axelcl>
Sat, 16 Jul 2005 09:10:59 +0000 (09:10 +0000)
committeraxelcl <axelcl>
Sat, 16 Jul 2005 09:10:59 +0000 (09:10 +0000)
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/ui/PreferenceConstants.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/text/PHPStringDQCodeScanner.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/IPreferenceConstants.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPSyntaxEditorPreferencePage.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/HTMLCodeScanner.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCodeScanner.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/SmartyCodeScanner.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPPreferencesMessages.properties

index 42c40a9..c0de54e 100644 (file)
@@ -111,6 +111,8 @@ public class JavaEditorPreferencePage extends PreferencePage implements IWorkben
       //$NON-NLS-1$
       { PreferencesMessages.getString("JavaEditorPreferencePage.variables"), PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR },
       //$NON-NLS-1$
+      { PreferencesMessages.getString("JavaEditorPreferencePage.variables_dollar"), PreferenceConstants.EDITOR_PHP_VARIABLE_DOLLAR_COLOR },
+      //$NON-NLS-1$
       { PreferencesMessages.getString("JavaEditorPreferencePage.constants"), PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR },
       //$NON-NLS-1$
       { PreferencesMessages.getString("JavaEditorPreferencePage.types"), PreferenceConstants.EDITOR_PHP_TYPE_COLOR },
@@ -340,6 +342,10 @@ public class JavaEditorPreferencePage extends PreferencePage implements IWorkben
     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
         PreferenceConstants.EDITOR_PHP_VARIABLE_BOLD));
     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+        PreferenceConstants.EDITOR_PHP_VARIABLE_DOLLAR_COLOR));
+    overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+        PreferenceConstants.EDITOR_PHP_VARIABLE_DOLLAR_BOLD));
+    overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
         PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR));
     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
         PreferenceConstants.EDITOR_PHP_CONSTANT_BOLD));
index 1e8544f..a3d7935 100644 (file)
@@ -102,7 +102,8 @@ JavaEditorPreferencePage.singleLineComment=Single-line comment
 JavaEditorPreferencePage.returnKeyword= Keyword 'return'
 JavaEditorPreferencePage.keywords=Keywords excluding 'return'
 JavaEditorPreferencePage.functionNames=Predefined function names 
-JavaEditorPreferencePage.variables=Variables
+JavaEditorPreferencePage.variables='$' Variables
+JavaEditorPreferencePage.variables_dollar='$_' Variables
 JavaEditorPreferencePage.constants=Constants
 JavaEditorPreferencePage.types=Types
 JavaEditorPreferencePage.strings_dq=Double Quoted Strings
index 718a021..45af042 100644 (file)
@@ -1252,6 +1252,25 @@ public class PreferenceConstants {
   public final static String EDITOR_PHP_FUNCTIONNAME_BOLD = IPreferenceConstants.PHP_FUNCTIONNAME + EDITOR_BOLD_SUFFIX;
 
   /**
+   * A named preference that holds the color used to render php variables with prefix '$_'.
+   * <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
+   */
+  public final static String EDITOR_PHP_VARIABLE_DOLLAR_COLOR = IPreferenceConstants.PHP_VARIABLE_DOLLAR;
+
+  /**
+   * A named preference that controls whether variables  with prefix '$_' are rendered in bold.
+   * <p>
+   * Value is of type <code>Boolean</code>.
+   * </p>
+   */
+  public final static String EDITOR_PHP_VARIABLE_DOLLAR_BOLD = IPreferenceConstants.PHP_VARIABLE_DOLLAR + EDITOR_BOLD_SUFFIX;
+
+  /**
    * A named preference that holds the color used to render php variables.
    * <p>
    * Value is of type <code>String</code>. A RGB color value encoded as a string using class <code>PreferenceConverter</code>
@@ -1269,7 +1288,6 @@ public class PreferenceConstants {
    * </p>
    */
   public final static String EDITOR_PHP_VARIABLE_BOLD = IPreferenceConstants.PHP_VARIABLE + EDITOR_BOLD_SUFFIX;
-
   /**
    * A named preference that holds the color used to render php constants.
    * <p>
@@ -2404,6 +2422,9 @@ public class PreferenceConstants {
     PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR, new RGB(127, 159, 191));
     store.setDefault(PreferenceConstants.EDITOR_PHP_VARIABLE_BOLD, false);
 
+    PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_PHP_VARIABLE_DOLLAR_COLOR, new RGB(127, 159, 191));
+    store.setDefault(PreferenceConstants.EDITOR_PHP_VARIABLE_DOLLAR_BOLD, false);
+    
     PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR, new RGB(127, 0, 85));
     store.setDefault(PreferenceConstants.EDITOR_PHP_CONSTANT_BOLD, false);
 
index 943f0df..df0bf72 100644 (file)
@@ -30,7 +30,7 @@ import org.eclipse.jface.text.rules.WordRule;
  */
 public final class PHPStringDQCodeScanner extends AbstractJavaScanner {
 
-  private static String[] fgTokenProperties = { IPreferenceConstants.PHP_STRING_DQ, IPreferenceConstants.PHP_VARIABLE };
+  private static String[] fgTokenProperties = { IPreferenceConstants.PHP_STRING_DQ, IPreferenceConstants.PHP_VARIABLE, IPreferenceConstants.PHP_VARIABLE_DOLLAR};
 
   private class PHPWordRule extends WordRule {
     private StringBuffer fBuffer = new StringBuffer();
@@ -45,17 +45,24 @@ public final class PHPStringDQCodeScanner extends AbstractJavaScanner {
 
     public IToken evaluate(ICharacterScanner scanner) {
       int c = scanner.read();
-
+      boolean isUnderscore = false;
       if (fDetector.isWordStart((char) c)) {
         if (fColumn == UNDEFINED || (fColumn == scanner.getColumn() - 1)) {
 
           fBuffer.setLength(0);
-          do {
+          fBuffer.append((char) c);
+          c = scanner.read();
+          if (c=='_') {
+               isUnderscore = true;
+          }
+          while (c != ICharacterScanner.EOF && fDetector.isWordPart((char) c)) {
             fBuffer.append((char) c);
             c = scanner.read();
-          } while (c != ICharacterScanner.EOF && fDetector.isWordPart((char) c));
+          } 
           scanner.unread();
-
+          if (isUnderscore) {
+               return getToken(IPreferenceConstants.PHP_VARIABLE_DOLLAR);
+          }
           return getToken(IPreferenceConstants.PHP_VARIABLE);
         }
       }
index 657bda0..cec00dc 100644 (file)
@@ -230,6 +230,14 @@ public interface IPreferenceConstants {
 
   public static final String PHP_VARIABLE_UNDERLINE = "_php_variable_underline";//$NON-NLS-1$
 
+  public static final String PHP_VARIABLE_DOLLAR = "_php_variable_dollar";//$NON-NLS-1$
+
+  public static final String PHP_VARIABLE_DOLLAR_BOLD = "_php_variable_dollar_bold";//$NON-NLS-1$
+
+  public static final String PHP_VARIABLE_DOLLAR_ITALIC = "_php_variable_dollar_italic";//$NON-NLS-1$
+
+  public static final String PHP_VARIABLE_DOLLAR_UNDERLINE = "_php_variable_dollar_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$
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPSyntaxEditorPreferencePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPSyntaxEditorPreferencePage.java
deleted file mode 100644 (file)
index 2a8f746..0000000
+++ /dev/null
@@ -1,565 +0,0 @@
-package net.sourceforge.phpeclipse;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import net.sourceforge.phpeclipse.preferences.ColorEditor;
-import net.sourceforge.phpeclipse.preferences.OverlayPreferenceStore;
-import net.sourceforge.phpeclipse.preferences.PHPPreferencesMessages;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.preference.FileFieldEditor;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-
-/*
- * The preference page for setting the PHP Editor options.
- */
-public class PHPSyntaxEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
-  public final OverlayPreferenceStore.OverlayKey[] Keys =
-    new OverlayPreferenceStore.OverlayKey[] {
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_MULTILINE_COMMENT),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_MULTILINE_COMMENT_BOLD),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_MULTILINE_COMMENT_ITALIC),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_MULTILINE_COMMENT_UNDERLINE),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_SINGLELINE_COMMENT),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_SINGLELINE_COMMENT_BOLD),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_SINGLELINE_COMMENT_ITALIC),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_SINGLELINE_COMMENT_UNDERLINE),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_KEYWORD),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_KEYWORD_BOLD),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_KEYWORD_ITALIC),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_KEYWORD_UNDERLINE),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_VARIABLE),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_VARIABLE_BOLD),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_VARIABLE_ITALIC),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_VARIABLE_UNDERLINE),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_TYPE),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_TYPE_BOLD),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_TYPE_ITALIC),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_TYPE_UNDERLINE),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_CONSTANT),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_CONSTANT_BOLD),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_CONSTANT_ITALIC),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_CONSTANT_UNDERLINE),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_FUNCTIONNAME),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_FUNCTIONNAME_BOLD),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_FUNCTIONNAME_ITALIC),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_FUNCTIONNAME_UNDERLINE),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_STRING_DQ),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_STRING_BOLD_DQ),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_STRING_ITALIC_DQ),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_STRING_UNDERLINE_DQ),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_STRING_SQ),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_STRING_BOLD_SQ),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_STRING_ITALIC_SQ),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_STRING_UNDERLINE_SQ),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_DEFAULT),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_DEFAULT_BOLD),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_DEFAULT_ITALIC),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_DEFAULT_UNDERLINE),
-      
-                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHPDOC_KEYWORD),
-                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_KEYWORD_BOLD),
-                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_KEYWORD_ITALIC),
-                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_KEYWORD_UNDERLINE),
-                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHPDOC_TAG),
-                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_TAG_BOLD),
-                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_TAG_ITALIC),
-                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_TAG_UNDERLINE),
-                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHPDOC_LINK),
-                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_LINK_BOLD),
-                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_LINK_ITALIC),
-                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_LINK_UNDERLINE),
-                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHPDOC_DEFAULT),
-                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_DEFAULT_BOLD),
-                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_DEFAULT_ITALIC),
-                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_DEFAULT_UNDERLINE),
-      
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_USERDEF_XMLFILE),
-  //    new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING_DQ, IPreferenceConstants.PHP_EDITOR_BACKGROUND)
-  };
-
-  private final String[][] SyntaxColorListModel =
-    new String[][] {
-      {
-        PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.multiLineComment"),
-        IPreferenceConstants.PHP_MULTILINE_COMMENT },
-      {
-      PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.singleLineComment"),
-        IPreferenceConstants.PHP_SINGLELINE_COMMENT },
-        {
-      PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.keywords"), IPreferenceConstants.PHP_KEYWORD }, {
-      PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.variables"), IPreferenceConstants.PHP_VARIABLE }, {
-      PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.types"), IPreferenceConstants.PHP_TYPE }, {
-      PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.constants"), IPreferenceConstants.PHP_CONSTANT }, {
-      PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.functions"), IPreferenceConstants.PHP_FUNCTIONNAME }, {
-      PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.strings_dq"), IPreferenceConstants.PHP_STRING_DQ }, {
-      PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.strings_sq"), IPreferenceConstants.PHP_STRING_SQ }, {
-      PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.others"), IPreferenceConstants.PHP_DEFAULT }, {
-         PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.phpdoc_keywords"), IPreferenceConstants.PHPDOC_KEYWORD }, {
-         PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.phpdoc_tags"), IPreferenceConstants.PHPDOC_TAG }, {
-         PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.phpdoc_links"), IPreferenceConstants.PHPDOC_LINK }, {
-         PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.phpdoc_others"), IPreferenceConstants.PHPDOC_DEFAULT }
-  };
-
-  private OverlayPreferenceStore OverlayStore;
-
-  private Map ColorButtons = new HashMap();
-  private SelectionListener ColorButtonListener = new SelectionListener() {
-    public void widgetDefaultSelected(SelectionEvent e) {
-    }
-    public void widgetSelected(SelectionEvent e) {
-      ColorEditor editor = (ColorEditor) e.widget.getData();
-      PreferenceConverter.setValue(OverlayStore, (String) ColorButtons.get(editor), editor.getColorValue());
-    }
-  };
-
-  private Map CheckBoxes = new HashMap();
-  private SelectionListener CheckBoxListener = new SelectionListener() {
-    public void widgetDefaultSelected(SelectionEvent e) {
-    }
-    public void widgetSelected(SelectionEvent e) {
-      Button button = (Button) e.widget;
-      OverlayStore.setValue((String) CheckBoxes.get(button), button.getSelection());
-    }
-  };
-
-  private List SyntaxColorList;
-  /** The ColorEditor that choose the foreground color. */
-  private ColorEditor SyntaxForegroundColorEditor;
-  private Button BoldCheckBox;
-  private Button ItalicCheckBox;
-  private Button UnderlineCheckBox;
-  private FileFieldEditor userdefPHPSyntaxFileFFE;
-  // private BooleanFieldEditor showLineNumber;
-  // private IntegerFieldEditor formatterTabSize;
-  // private BooleanFieldEditor spacesForTabs;
-
-  public PHPSyntaxEditorPreferencePage() {
-    setDescription(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.description")); //$NON-NLS-1$
-    setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
-    OverlayStore = new OverlayPreferenceStore(getPreferenceStore(), Keys);
-  }
-
-  public void init(IWorkbench workbench) {
-  }
-
-  public void createControl(Composite parent) {
-    super.createControl(parent);
-  }
-
-  private void handleSyntaxColorListSelection() {
-    int i = SyntaxColorList.getSelectionIndex();
-    String key = SyntaxColorListModel[i][1];
-    RGB rgb = PreferenceConverter.getColor(OverlayStore, key);
-    SyntaxForegroundColorEditor.setColorValue(rgb);
-    BoldCheckBox.setSelection(OverlayStore.getBoolean(key + "_bold"));
-    ItalicCheckBox.setSelection(OverlayStore.getBoolean(key + "_italic"));
-    UnderlineCheckBox.setSelection(OverlayStore.getBoolean(key + "_underline"));
-  }
-
-  /**
-   * Create the group of options for other parameters (background color for example).
-   * @param parent the parent component
-   */
-  private void backgroundOptionPage(Composite parent) {
-    Label label = new Label(parent, SWT.LEFT);
-    label.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.color")); //$NON-NLS-1$
-    GridData gd = new GridData();
-    gd.horizontalAlignment = GridData.BEGINNING;
-    label.setLayoutData(gd);
-//    final ColorEditor syntaxBackgroundColorEditor = new ColorEditor(parent);
-//    RGB rgb = PreferenceConverter.getColor(OverlayStore, IPreferenceConstants.PHP_EDITOR_BACKGROUND);
-//    syntaxBackgroundColorEditor.setColorValue(rgb);
-//    Button backgroundColorButton = syntaxBackgroundColorEditor.getButton();
-//    gd = new GridData(GridData.FILL_HORIZONTAL);
-//    gd.horizontalAlignment = GridData.BEGINNING;
-//    backgroundColorButton.setLayoutData(gd);
-//    backgroundColorButton.addSelectionListener(new SelectionListener() {
-//      public void widgetDefaultSelected(SelectionEvent e) {
-//        // do nothing
-//      }
-//      public void widgetSelected(SelectionEvent e) {
-//        PreferenceConverter.setValue(OverlayStore, IPreferenceConstants.PHP_EDITOR_BACKGROUND, syntaxBackgroundColorEditor.getColorValue());
-//      }
-//    });
-  }
-
-  /**
-   * Create the group of options for the syntax parameters.
-   * @param parent the parent component
-   * @return
-   */
-  private Control createSyntaxPage(Composite parent) {
-
-    Composite colorComposite = new Composite(parent, SWT.NULL);
-    colorComposite.setLayout(new GridLayout());
-
-    Label label = new Label(colorComposite, SWT.LEFT);
-    label.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.syntax")); //$NON-NLS-1$
-    label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
-    Composite editorComposite = new Composite(colorComposite, SWT.NONE);
-    GridLayout layout = new GridLayout();
-    layout.numColumns = 2;
-    layout.marginHeight = 0;
-    layout.marginWidth = 0;
-    editorComposite.setLayout(layout);
-    GridData gd = new GridData(GridData.FILL_BOTH);
-    editorComposite.setLayoutData(gd);
-
-    SyntaxColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
-    gd = new GridData(GridData.FILL_BOTH);
-    gd.heightHint = convertHeightInCharsToPixels(5);
-    SyntaxColorList.setLayoutData(gd);
-
-    Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
-    layout = new GridLayout();
-    layout.marginHeight = 0;
-    layout.marginWidth = 0;
-    layout.numColumns = 2;
-    stylesComposite.setLayout(layout);
-    stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
-    label = new Label(stylesComposite, SWT.LEFT);
-    label.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.color")); //$NON-NLS-1$
-    gd = new GridData();
-    gd.horizontalAlignment = GridData.BEGINNING;
-    label.setLayoutData(gd);
-
-    SyntaxForegroundColorEditor = new ColorEditor(stylesComposite);
-    Button foregroundColorButton = SyntaxForegroundColorEditor.getButton();
-    gd = new GridData(GridData.FILL_HORIZONTAL);
-    gd.horizontalAlignment = GridData.BEGINNING;
-    foregroundColorButton.setLayoutData(gd);
-
-    BoldCheckBox = new Button(stylesComposite, SWT.CHECK);
-    BoldCheckBox.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.bold")); //$NON-NLS-1$
-    gd = new GridData(GridData.FILL_HORIZONTAL);
-    gd.horizontalAlignment = GridData.BEGINNING;
-    gd.horizontalSpan = 2;
-    BoldCheckBox.setLayoutData(gd);
-
-    ItalicCheckBox = new Button(stylesComposite, SWT.CHECK);
-    ItalicCheckBox.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.italic")); //$NON-NLS-1$
-    ItalicCheckBox.setEnabled(false);
-    gd = new GridData(GridData.FILL_HORIZONTAL);
-    gd.horizontalAlignment = GridData.BEGINNING;
-    gd.horizontalSpan = 2;
-    ItalicCheckBox.setLayoutData(gd);
-
-    UnderlineCheckBox = new Button(stylesComposite, SWT.CHECK);
-    UnderlineCheckBox.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.underline")); //$NON-NLS-1$
-    UnderlineCheckBox.setEnabled(false);
-    gd = new GridData(GridData.FILL_HORIZONTAL);
-    gd.horizontalAlignment = GridData.BEGINNING;
-    gd.horizontalSpan = 2;
-    UnderlineCheckBox.setLayoutData(gd);
-
-    Composite customSyntaxComposite = new Composite(colorComposite, SWT.NONE);
-    layout = new GridLayout();
-    layout.marginHeight = 0;
-    layout.marginWidth = 0;
-    layout.numColumns = 3;
-    stylesComposite.setLayout(layout);
-    stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
-    userdefPHPSyntaxFileFFE =
-      new FileFieldEditor(
-        IPreferenceConstants.PHP_USERDEF_XMLFILE,
-        PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.syntaxdialog"),
-        colorComposite);
-    userdefPHPSyntaxFileFFE.setPreferencePage(this);
-    userdefPHPSyntaxFileFFE.setPreferenceStore(getPreferenceStore());
-    userdefPHPSyntaxFileFFE.load();
-
-    SyntaxColorList.addSelectionListener(new SelectionListener() {
-      public void widgetDefaultSelected(SelectionEvent e) {
-        // do nothing
-      }
-      public void widgetSelected(SelectionEvent e) {
-        handleSyntaxColorListSelection();
-      }
-    });
-
-    foregroundColorButton.addSelectionListener(new SelectionListener() {
-      public void widgetDefaultSelected(SelectionEvent e) {
-        // do nothing
-      }
-      public void widgetSelected(SelectionEvent e) {
-        int i = SyntaxColorList.getSelectionIndex();
-        String key = SyntaxColorListModel[i][1];
-
-        PreferenceConverter.setValue(OverlayStore, key, SyntaxForegroundColorEditor.getColorValue());
-      }
-    });
-    BoldCheckBox.addSelectionListener(new SelectionListener() {
-      public void widgetDefaultSelected(SelectionEvent e) {
-        // do nothing
-      }
-      public void widgetSelected(SelectionEvent e) {
-        int i = SyntaxColorList.getSelectionIndex();
-        String key = SyntaxColorListModel[i][1];
-        OverlayStore.setValue(key + "_bold", BoldCheckBox.getSelection());
-      }
-    });
-
-    ItalicCheckBox.addSelectionListener(new SelectionListener() {
-      public void widgetDefaultSelected(SelectionEvent e) {
-        // do nothing
-      }
-      public void widgetSelected(SelectionEvent e) {
-        int i = SyntaxColorList.getSelectionIndex();
-        String key = SyntaxColorListModel[i][1];
-        OverlayStore.setValue(key + "_italic", ItalicCheckBox.getSelection());
-      }
-    });
-
-    UnderlineCheckBox.addSelectionListener(new SelectionListener() {
-      public void widgetDefaultSelected(SelectionEvent e) {
-        // do nothing
-      }
-      public void widgetSelected(SelectionEvent e) {
-        int i = SyntaxColorList.getSelectionIndex();
-        String key = SyntaxColorListModel[i][1];
-        OverlayStore.setValue(key + "_underline", UnderlineCheckBox.getSelection());
-      }
-    });
-    return colorComposite;
-  }
-
-  private void initializeViewerColors(ISourceViewer viewer) {
-
-    IPreferenceStore store = OverlayStore;
-    if (store != null) {
-
-      StyledText styledText = viewer.getTextWidget();
-    }
-  }
-
-  private Color createColor(IPreferenceStore store, String key, Display display) {
-    RGB rgb = null;
-    if (store.contains(key)) {
-      if (store.isDefault(key))
-        rgb = PreferenceConverter.getDefaultColor(store, key);
-      else
-        rgb = PreferenceConverter.getColor(store, key);
-      if (rgb != null)
-        return new Color(display, rgb);
-    }
-    return null;
-  }
-
-  private static void setEnabled(Control control, boolean enable) {
-    control.setEnabled(enable);
-    if (control instanceof Composite) {
-      Composite composite = (Composite) control;
-      Control[] children = composite.getChildren();
-      for (int i = 0; i < children.length; i++)
-        setEnabled(children[i], enable);
-    }
-  }
-
-  private static void indent(Control control) {
-    GridData gridData = new GridData();
-    gridData.horizontalIndent = 20;
-    control.setLayoutData(gridData);
-  }
-
-  private static void createDependency(final Button master, final Control slave) {
-    indent(slave);
-    master.addSelectionListener(new SelectionListener() {
-      public void widgetSelected(SelectionEvent e) {
-        slave.setEnabled(master.getSelection());
-      }
-
-      public void widgetDefaultSelected(SelectionEvent e) {
-      }
-    });
-  }
-
-  protected Control createContents(Composite parent) {
-    OverlayStore.load();
-    OverlayStore.start();
-    //Create overall composite
-    Composite composite = new Composite(parent, SWT.NONE);
-    GridLayout layout = new GridLayout();
-    layout.marginHeight = 0;
-    layout.marginWidth = 0;
-    composite.setLayout(layout);
-    Composite syntaxComposite = new Composite(composite, SWT.NULL);
-    syntaxComposite.setLayout(new GridLayout());
-    layout = new GridLayout();
-    layout.numColumns = 3;
-    Group syntaxGroup = new Group(syntaxComposite, SWT.NONE);
-    syntaxGroup.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.foreground"));
-    syntaxGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-    syntaxGroup.setLayout(layout);
-    createSyntaxPage(syntaxGroup);
-
-    Composite backgroundOptions = new Composite(composite,SWT.NULL);
-    backgroundOptions.setLayout(new GridLayout());
-    layout = new GridLayout();
-    layout.numColumns = 3;
-    Group backgroundOptionsGroup = new Group(backgroundOptions,SWT.NONE);
-    backgroundOptionsGroup.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.background"));
-    backgroundOptionsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-    backgroundOptionsGroup.setLayout(layout);
-    backgroundOptionPage(backgroundOptionsGroup);
-
-    initialize();
-    
-   
-//    showLineNumber = new BooleanFieldEditor(PHPeclipsePlugin.LINE_NUMBER_RULER, 
-//    "Show line numbers", composite);
-//    showLineNumber.setPreferencePage(this);
-//    showLineNumber.setPreferenceStore(getPreferenceStore());
-//    showLineNumber.load();
-    
-//    formatterTabSize = new IntegerFieldEditor(PHPeclipsePlugin.FORMATTER_TAB_SIZE, 
-//    "Displayed tab width", composite, 3);
-//    formatterTabSize.setPreferencePage(this);
-//    formatterTabSize.setPreferenceStore(getPreferenceStore());
-//    formatterTabSize.load();
-//    
-//    spacesForTabs = new BooleanFieldEditor(PHPeclipsePlugin.SPACES_FOR_TABS, 
-//    "Spaces for Tabs", composite);
-//    spacesForTabs.setPreferencePage(this);
-//    spacesForTabs.setPreferenceStore(getPreferenceStore());
-//    spacesForTabs.load();
-    return composite;
-  }
-
-  private void initialize() {
-    initializeFields();
-    for (int i = 0; i < SyntaxColorListModel.length; i++)
-      SyntaxColorList.add(SyntaxColorListModel[i][0]);
-    SyntaxColorList.getDisplay().asyncExec(new Runnable() {
-      public void run() {
-        if (SyntaxColorList != null && !SyntaxColorList.isDisposed()) {
-          SyntaxColorList.select(0);
-          handleSyntaxColorListSelection();
-        }
-      }
-    });
-  }
-
-  private void initializeFields() {
-
-    Iterator e = ColorButtons.keySet().iterator();
-    while (e.hasNext()) {
-      ColorEditor c = (ColorEditor) e.next();
-      String key = (String) ColorButtons.get(c);
-      RGB rgb = PreferenceConverter.getColor(OverlayStore, key);
-      c.setColorValue(rgb);
-    }
-
-    e = CheckBoxes.keySet().iterator();
-    while (e.hasNext()) {
-      Button b = (Button) e.next();
-      String key = (String) CheckBoxes.get(b);
-      b.setSelection(OverlayStore.getBoolean(key));
-    }
-  }
-
-  public boolean performOk() {
-    OverlayStore.propagate();
-    IPreferenceStore store = getPreferenceStore();
-    PHPeclipsePlugin.getDefault().savePluginPreferences();
-    userdefPHPSyntaxFileFFE.store();
-   // showLineNumber.store();
-   // spacesForTabs.store();
-   // formatterTabSize.store();
-    return true;
-  }
-
-  protected void performDefaults() {
-    OverlayStore.loadDefaults();
-    initializeFields();
-    handleSyntaxColorListSelection();
-    userdefPHPSyntaxFileFFE.loadDefault();
-  //  showLineNumber.loadDefault();
-  //  spacesForTabs.loadDefault();
-  //  showLineNumber.loadDefault();
-  //  formatterTabSize.loadDefault();
-    super.performDefaults();
-  }
-
-  public void dispose() {
-    if (OverlayStore != null) {
-      OverlayStore.stop();
-      OverlayStore = null;
-    }
-    super.dispose();
-  }
-
-  private Control addColorButton(Composite composite, String label, String key, int indentation) {
-    Label labelControl = new Label(composite, SWT.NONE);
-    labelControl.setText(label);
-    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
-    gd.horizontalIndent = indentation;
-    labelControl.setLayoutData(gd);
-    ColorEditor editor = new ColorEditor(composite);
-    Button button = editor.getButton();
-    button.setData(editor);
-    gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
-    button.setLayoutData(gd);
-    button.addSelectionListener(ColorButtonListener);
-    ColorButtons.put(editor, key);
-    return composite;
-  }
-
-  private Button addCheckBox(Composite parent, String label, String key, int indentation) {
-    Button checkBox = new Button(parent, SWT.CHECK);
-    checkBox.setText(label);
-    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
-    gd.horizontalIndent = indentation;
-    gd.horizontalSpan = 2;
-    checkBox.setLayoutData(gd);
-    checkBox.addSelectionListener(CheckBoxListener);
-    CheckBoxes.put(checkBox, key);
-    return checkBox;
-  }
-
-  private void updateStatus(IStatus status) {
-  }
-
-  /**
-   * @deprecated Inline to avoid reference to preference page
-   */
-  public static boolean indicateQuixFixableProblems() {
-    //         return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_CORRECTION_INDICATION);
-    return false;
-  }
-
-  /**
-   * @deprecated Inline to avoid reference to preference page
-   */
-  static public boolean synchronizeOutlineOnCursorMove() {
-    //         return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE);
-    return false;
-  }
-
-}
\ No newline at end of file
index ccceb88..699801e 100644 (file)
@@ -775,6 +775,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
     PreferenceConverter.setDefault(store, PHP_TAG, PHPColorProvider.TAG);
     PreferenceConverter.setDefault(store, PHP_KEYWORD, PHPColorProvider.KEYWORD);
     PreferenceConverter.setDefault(store, PHP_VARIABLE, PHPColorProvider.VARIABLE);
+    PreferenceConverter.setDefault(store, PHP_VARIABLE_DOLLAR, PHPColorProvider.VARIABLE);
     PreferenceConverter.setDefault(store, PHP_FUNCTIONNAME, PHPColorProvider.FUNCTION_NAME);
     PreferenceConverter.setDefault(store, PHP_CONSTANT, PHPColorProvider.CONSTANT);
     PreferenceConverter.setDefault(store, PHP_TYPE, PHPColorProvider.TYPE);
index 28f0e13..a21ea07 100644 (file)
@@ -51,6 +51,7 @@ public class HTMLCodeScanner extends AbstractJavaScanner {
     IPreferenceConstants.PHP_KEYWORD,
     IPreferenceConstants.PHP_FUNCTIONNAME,
     IPreferenceConstants.PHP_VARIABLE,
+    IPreferenceConstants.PHP_VARIABLE_DOLLAR,
     IPreferenceConstants.PHP_STRING_DQ,
     IPreferenceConstants.PHP_STRING_SQ,
     IPreferenceConstants.PHP_TYPE,
index 2a75cd9..1efa21d 100644 (file)
@@ -210,6 +210,7 @@ public class PHPCodeScanner extends AbstractJavaScanner {
     public IToken evaluate(ICharacterScanner scanner) {
       int c = scanner.read();
       boolean isVariable = false;
+      boolean isUnderscore = false;
       if (c == '<') {
         c = scanner.read();
         if (c != '?') {
@@ -260,13 +261,21 @@ public class PHPCodeScanner extends AbstractJavaScanner {
         if (fColumn == UNDEFINED || (fColumn == scanner.getColumn() - 1)) {
 
           fBuffer.setLength(0);
-          do {
-            fBuffer.append((char) c);
+          fBuffer.append((char) c);
+          c = scanner.read();
+          if (c == '_') {
+            isUnderscore = true;
+          }
+          while (c != ICharacterScanner.EOF && fDetector.isWordPart((char) c)) {
+               fBuffer.append((char) c);
             c = scanner.read();
-          } while (c != ICharacterScanner.EOF && fDetector.isWordPart((char) c));
+          }
           scanner.unread();
 
           if (isVariable) {
+               if (isUnderscore) {
+                       return getToken(IPreferenceConstants.PHP_VARIABLE_DOLLAR);
+               }
             return getToken(IPreferenceConstants.PHP_VARIABLE);
           }
           IToken token = (IToken) fWords.get(fBuffer.toString());
@@ -294,6 +303,7 @@ public class PHPCodeScanner extends AbstractJavaScanner {
       IPreferenceConstants.PHP_KEYWORD,
       IPreferenceConstants.PHP_FUNCTIONNAME,
       IPreferenceConstants.PHP_VARIABLE,
+      IPreferenceConstants.PHP_VARIABLE_DOLLAR,
       IPreferenceConstants.PHP_STRING_DQ,
       IPreferenceConstants.PHP_STRING_SQ,
       IPreferenceConstants.PHP_TYPE,
index 9240bbd..36a9abc 100644 (file)
@@ -130,10 +130,11 @@ public class SmartyCodeScanner 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_VARIABLE_DOLLAR,
       IPreferenceConstants.PHP_STRING_DQ,
       IPreferenceConstants.PHP_STRING_SQ,
       IPreferenceConstants.PHP_TYPE,
index 19b09d6..6d1f225 100644 (file)
@@ -72,7 +72,8 @@ PHPEditorSyntaxPreferencePage.multiLineComment=Multi-line comment
 PHPEditorSyntaxPreferencePage.singleLineComment=Single-line comment
 PHPEditorSyntaxPreferencePage.tags=PHP Tags
 PHPEditorSyntaxPreferencePage.keywords=Keywords
-PHPEditorSyntaxPreferencePage.variables=Variables
+PHPEditorSyntaxPreferencePage.variables='$' Variables
+PHPEditorSyntaxPreferencePage.variables_dollar='$_' Variables
 PHPEditorSyntaxPreferencePage.types=Types
 PHPEditorSyntaxPreferencePage.functions=Functions
 PHPEditorSyntaxPreferencePage.constants=Constants