fixed accelerator problem; slightly improved PHP Perspective
authorkhartlage <khartlage>
Sun, 16 Feb 2003 19:08:43 +0000 (19:08 +0000)
committerkhartlage <khartlage>
Sun, 16 Feb 2003 19:08:43 +0000 (19:08 +0000)
net.sourceforge.phpeclipse/plugin.properties
net.sourceforge.phpeclipse/plugin.xml
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/actions/PHPdtActionConstants.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPPerspectiveFactory.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorActionDefinitionIds.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSyntaxRdr.java

index b4f9b2e..7070756 100644 (file)
@@ -37,6 +37,32 @@ AddBookmark.tooltip=Add Bookmark...
 AddTask.label=Add &Task
 AddTask.tooltip=Add Task...
 php.menu.label=&Source
-phpActionSet.label=PHP Source Actions
-phpUncommentAction.label=&Uncomment@Ctrl+\\
-phpCommentAction.label=&Comment@Ctrl+/
\ No newline at end of file
+
+##########################################################################
+# Coding Action set
+##########################################################################
+CodingActionSet.label= PHP Coding
+CodingActionSet.description= Action set containing coding related PHP actions
+
+##########################################################################
+# Source Menu
+##########################################################################
+SourceMenu.label= &Source
+
+CommentAction.label= Co&mment@Ctrl+/
+
+UncommentAction.label= &Uncomment@Ctrl+\\
+
+##########################################################################
+# Action Definitions
+##########################################################################
+#--- Edit menu
+ActionDefinition.contentAssistProposals.name= Content Assist
+ActionDefinition.contentAssistProposals.description= Content Assist
+
+#--- Source menu
+ActionDefinition.comment.name= Comment
+ActionDefinition.comment.description= Turn the selected lines into PHP comments
+
+ActionDefinition.uncomment.name= Uncomment
+ActionDefinition.uncomment.description= Uncomment the selected PHP comment lines
index bf59211..3f512ea 100644 (file)
@@ -28,7 +28,7 @@
          point="org.eclipse.core.resources.natures">
       <runtime>
          <run
-               class="net.sourceforge.phpeclipse.PHPProject">
+               class="net.sourceforge.phpeclipse.resourcesview.PHPProject">
          </run>
       </runtime>
    </extension>
@@ -226,38 +226,62 @@ Temporarily replaced until errors can be ironed out...
                id="net.sourceforge.phpeclipse.actions.PHPStartMySQLAction">
          </action>
       </actionSet>
+
       <actionSet
                id="net.sourceforge.phpeclipse.ui.CodingActionSet"
-        label="%phpActionSet.label"
+        label="%CodingActionSet.label"
                visible="false"
                description="%CodingActionSet.description">
-               <menu
+
+        <!-- =========================================================================== -->
+               <!-- Source Menu                                                                 -->
+               <!-- =========================================================================== -->
+
+       <menu
             id="net.sourceforge.phpeclipse.ui.source.menu"
-            label="%php.menu.label"
+            label="%SourceMenu.label"
             path="edit">
                <separator name="editGroup"/>
        </menu>
-       <action id="net.sourceforge.phpdt.ui.actions.Uncomment"
+                       
+               <action id="net.sourceforge.phpeclipse.phpeditor.Uncomment"
                menubarPath="net.sourceforge.phpeclipse.ui.source.menu/editGroup"
-               label="%phpUncommentAction.label"
+               label="%UncommentAction.label"
+                       definitionId="net.sourceforge.phpeclipse.phpeditor.uncomment"
                        retarget="true" />
                        
-               <action id="net.sourceforge.phpdt.ui.actions.Comment"
+               <action id="net.sourceforge.phpeclipse.phpeditor.Comment"
                menubarPath="net.sourceforge.phpeclipse.ui.source.menu/editGroup"
-               label="%phpCommentAction.label"
+               label="%CommentAction.label"
+                       definitionId="net.sourceforge.phpeclipse.phpeditor.comment"
                        retarget="true" />
+
          </actionSet> 
    </extension>
-   <extension
-         point="org.eclipse.ui.actionDefinitions">
-      <actionDefinition
-            id="net.sourceforge.phpdt.ui.actions.comment">
+   
+<!-- =========================================================================== -->
+<!-- PHP Editor Action Definition IDs -->
+<!-- =========================================================================== -->
+   <extension point="org.eclipse.ui.actionDefinitions">
+           <!-- edit -->
+         <actionDefinition
+               id="net.sourceforge.phpeclipse.phpeditor.ContentAssistProposal"
+               name= "%ActionDefinition.contentAssistProposals.name"
+               description="%ActionDefinition.contentAssistProposals.description">
       </actionDefinition>
-      <actionDefinition
-            id="net.sourceforge.phpdt.ui.actions.uncomment">
+      <!-- source -->
+         <actionDefinition
+               id="net.sourceforge.phpeclipse.phpeditor.Comment"
+               name= "%ActionDefinition.comment.name"
+               description= "%ActionDefinition.comment.description">
+         </actionDefinition>
+         <actionDefinition
+               id="net.sourceforge.phpeclipse.phpeditor.Uncomment"
+               name= "%ActionDefinition.uncomment.name"
+               description= "%ActionDefinition.uncomment.description">
       </actionDefinition>
    </extension> 
-   <extension
+<!--   <extension
          point="org.eclipse.ui.acceleratorSets">
       <acceleratorSet
             scopeId="org.eclipse.ui.textEditorScope"
@@ -271,7 +295,7 @@ Temporarily replaced until errors can be ironed out...
                id="net.sourceforge.phpdt.ui.actions.uncomment">
          </accelerator>
       </acceleratorSet>
-   </extension> 
+   </extension> -->
    <extension
          point="org.eclipse.ui.editors">
       <editor
@@ -592,5 +616,45 @@ Temporarily replaced until errors can be ironed out...
             id="net.sourceforge.phpeclipse.views.phpconsoleview">
       </view>
    </extension>
+<!-- =========================================================================== -->
+<!-- Java Editor Key Bindings -->
+<!-- =========================================================================== -->
+   
+   <extension point="org.eclipse.ui.acceleratorSets">
+       <acceleratorSet
+               scopeId="org.eclipse.ui.textEditorScope"
+               configurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
+        <!-- edit --> 
+               <accelerator key="Ctrl+1" id="net.sourceforge.phpeclipse.ui.edit.text.php.content.assist.proposals" />
+               
+        <!-- source -->
+               <accelerator key="Ctrl+/" id="net.sourceforge.phpeclipse.phpeditor.comment" />
+               <accelerator key="Ctrl+\" id="net.sourceforge.phpeclipse.phpeditor.uncomment" />
+    </acceleratorSet>  
+       
+       <acceleratorSet
+               scopeId="org.eclipse.ui.textEditorScope"
+               configurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
+               <!-- edit -->
+               <accelerator key="Ctrl+Space" id="net.sourceforge.phpeclipse.ui.edit.text.php.content.assist.proposals" />
+               
+               <!-- source -->
+               <accelerator key="Ctrl+/" id="net.sourceforge.phpeclipse.phpeditor.comment" />
+               <accelerator key="Ctrl+\" id="net.sourceforge.phpeclipse.phpeditor.uncomment" />
+    </acceleratorSet>
+    
+    <acceleratorSet 
+        scopeId="org.eclipse.ui.textEditorScope" 
+        configurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
+               <!-- edit --> 
+               <accelerator key="Command+1" id="net.sourceforge.phpeclipse.ui.edit.text.php.content.assist.proposals" platform="carbon" />
+
+               <!-- source --> 
+               <accelerator key="Command+/" id="net.sourceforge.phpeclipse.phpeditor.comment" platform="carbon" /> 
+               <accelerator key="Command+\" id="net.sourceforge.phpeclipse.phpeditor.uncomment" platform="carbon" /> 
+               
+       </acceleratorSet>
 
+   </extension>
+    
 </plugin>
index 436dc6a..af602c4 100644 (file)
@@ -21,6 +21,14 @@ package net.sourceforge.phpdt.ui.actions;
  * @since 2.0
  */
 public class PHPdtActionConstants {
+       
+//     Edit menu
+
+       /**
+        * Edit menu: name of standard Code Assist global action
+        * (value <code>"org.phpeclipse.phpdt.ui.actions.ContentAssist"</code>).
+        */
+       public static final String CONTENT_ASSIST= "net.sourceforge.phpeclipse.phpeditor.ContentAssist"; //$NON-NLS-1$
 
        // Source menu  
        
@@ -28,12 +36,12 @@ public class PHPdtActionConstants {
         * Source menu: name of standard Comment global action
         * (value <code>"net.sourceforge.phpdt.ui.actions.Comment"</code>).
         */
-       public static final String COMMENT= "net.sourceforge.phpdt.ui.actions.Comment"; //$NON-NLS-1$
+       public static final String COMMENT= "net.sourceforge.phpeclipse.phpeditor.Comment"; //$NON-NLS-1$
        
        /**
         * Source menu: name of standard Uncomment global action
         * (value <code>"net.sourceforge.phpdt.ui.actions.Uncomment"</code>).
         */
-       public static final String UNCOMMENT= "net.sourceforge.phpdt.ui.actions.Uncomment"; //$NON-NLS-1$
+       public static final String UNCOMMENT= "net.sourceforge.phpeclipse.phpeditor.Uncomment"; //$NON-NLS-1$
        
 }
index 0278f22..8e709d8 100644 (file)
@@ -29,11 +29,13 @@ public class PHPPerspectiveFactory implements IPerspectiveFactory {
     layout.addView(IPageLayout.ID_OUTLINE, IPageLayout.RIGHT, (float) 0.75, editorArea);
 
     layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET);
-
+       layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET);
+       layout.addActionSet(PHPeclipsePlugin.PHP_CODING_ACTION_SET_ID);
+       
     layout.addShowViewShortcut(IDebugUIConstants.ID_CONSOLE_VIEW);
 
-    layout.addShowViewShortcut(PHPeclipsePlugin.PHP_RESOURCES_VIEW_ID);
-
+   // layout.addShowViewShortcut(PHPeclipsePlugin.PHP_RESOURCES_VIEW_ID);
+       
     // views - standard workbench
     layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
     layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST);
index 2fb9c29..152ca9a 100644 (file)
@@ -58,7 +58,9 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
    */
   public static final String PLUGIN_ID = "net.sourceforge.phpeclipse"; //$NON-NLS-1$
   public final static String PHP_NATURE_ID = PLUGIN_ID + ".phpnature";
-  public static final String PHP_RESOURCES_VIEW_ID = PLUGIN_ID + ".resourcesview.ViewPHPResources"; //$NON-NLS-1$
+ // public static final String PHP_RESOURCES_VIEW_ID = PLUGIN_ID + ".resourcesview.ViewPHPResources"; //$NON-NLS-1$
+  public static final String PHP_CODING_ACTION_SET_ID = PLUGIN_ID + ".ui.CodingActionSet"; //$NON-NLS-1$
+
 
   //The shared instance.
   private static PHPeclipsePlugin plugin;
index 277bbf6..7c6d220 100644 (file)
@@ -12,6 +12,7 @@ Contributors:
     Klaus Hartlage - www.eclipseproject.de
 **********************************************************************/
 
+import net.sourceforge.phpdt.ui.IContextMenuConstants;
 import net.sourceforge.phpdt.ui.actions.PHPdtActionConstants;
 
 import org.eclipse.jface.action.IMenuManager;
@@ -20,6 +21,7 @@ import org.eclipse.ui.IActionBars;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IWorkbenchActionConstants;
 import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.actions.RetargetAction;
 import org.eclipse.ui.texteditor.BasicTextEditorActionContributor;
 import org.eclipse.ui.texteditor.ITextEditor;
 import org.eclipse.ui.texteditor.RetargetTextEditorAction;
@@ -29,9 +31,12 @@ import org.eclipse.ui.texteditor.RetargetTextEditorAction;
  */
 public class PHPActionContributor extends BasicTextEditorActionContributor   {
 
-  protected RetargetTextEditorAction fContentAssistProposal;
   // protected RetargetTextEditorAction fContentAssistTip;
   // protected TextEditorAction fTogglePresentation;
+  protected RetargetAction fRetargetContentAssist;
+       
+  protected RetargetTextEditorAction fContentAssist;
+  
   protected PHPParserAction parserAction;
 
   /**
@@ -39,13 +44,41 @@ public class PHPActionContributor extends BasicTextEditorActionContributor   {
    */
   public PHPActionContributor() {
     super();
-    fContentAssistProposal = new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal."); //$NON-NLS-1$
+    
+       fRetargetContentAssist= new RetargetAction(PHPdtActionConstants.CONTENT_ASSIST,  PHPEditorMessages.getString("ContentAssistProposal.label")); //$NON-NLS-1$
+       fRetargetContentAssist.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+               
+       fContentAssist= new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal."); //$NON-NLS-1$
+       fContentAssist.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); 
+//     fContentAssist.setImageDescriptor(JavaPluginImages.DESC_CLCL_CODE_ASSIST);
+//     fContentAssist.setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_CODE_ASSIST);
+
+    
+    // fContentAssist = new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal."); //$NON-NLS-1$
     //  fContentAssistTip = new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistTip."); //$NON-NLS-1$
     //  fTogglePresentation = new PresentationAction();
+    
+       
     parserAction = PHPParserAction.getInstance();
   }
 
   /*
+   * @see EditorActionBarContributor#contributeToMenu(IMenuManager)
+   */
+//  public void contributeToMenu(IMenuManager menu) {
+//             
+//       super.contributeToMenu(menu);
+//             
+//       IMenuManager editMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
+//       if (editMenu != null) {
+//               editMenu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
+//               editMenu.add(new Separator(IContextMenuConstants.GROUP_GENERATE));
+//                     
+//               editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fRetargetContentAssist);
+//       }             
+//  }
+  
+  /*
    * @see IEditorActionBarContributor#init(IActionBars)
    */
   public void init(IActionBars bars) {
@@ -55,10 +88,11 @@ public class PHPActionContributor extends BasicTextEditorActionContributor   {
     IMenuManager editMenu = menuManager.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
     if (editMenu != null) {
       editMenu.add(new Separator());
-      editMenu.add(fContentAssistProposal);
+      editMenu.add(fContentAssist);
       //   editMenu.add(fContentAssistTip);
     }
 
+       bars.setGlobalActionHandler(PHPdtActionConstants.CONTENT_ASSIST, fContentAssist);
     //    IToolBarManager toolBarManager = bars.getToolBarManager();
     //    if (toolBarManager != null) {
     //      toolBarManager.add(new Separator());
@@ -73,9 +107,9 @@ public class PHPActionContributor extends BasicTextEditorActionContributor   {
     if (part instanceof ITextEditor)
       textEditor = (ITextEditor) part;
 
-    fContentAssistProposal.setAction(getAction(textEditor, "ContentAssistProposal")); //$NON-NLS-1$
+    fContentAssist.setAction(getAction(textEditor, "ContentAssistProposal")); //$NON-NLS-1$
     //  fContentAssistTip.setAction(getAction(editor, "ContentAssistTip")); //$NON-NLS-1$
-
+    
     IActionBars bars = getActionBars();
     bars.setGlobalActionHandler(PHPdtActionConstants.COMMENT, getAction(textEditor, "Comment"));
     bars.setGlobalActionHandler(PHPdtActionConstants.UNCOMMENT, getAction(textEditor, "Uncomment"));
index f5f9edf..de893a8 100644 (file)
@@ -43,6 +43,7 @@ import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.actions.ActionContext;
 import org.eclipse.ui.actions.ActionGroup;
 import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.texteditor.ContentAssistAction;
 import org.eclipse.ui.texteditor.DefaultRangeIndicator;
 import org.eclipse.ui.texteditor.ITextEditorActionConstants;
 import org.eclipse.ui.texteditor.TextOperationAction;
@@ -89,13 +90,23 @@ public class PHPEditor extends TextEditor {
    */
   protected void createActions() {
     super.createActions();
-    setAction(
-      "ContentAssistProposal",
-      new TextOperationAction(
-        PHPEditorMessages.getResourceBundle(),
-        "ContentAssistProposal.",
-        this,
-        ISourceViewer.CONTENTASSIST_PROPOSALS));
+    
+       Action action;
+//    setAction(
+//      "ContentAssistProposal",
+//      new TextOperationAction(
+//        PHPEditorMessages.getResourceBundle(),
+//        "ContentAssistProposal.",
+//        this,
+//        ISourceViewer.CONTENTASSIST_PROPOSALS));
+       action= new ContentAssistAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal.", this); //$NON-NLS-1$
+       action.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);            
+       setAction("ContentAssistProposal", action); //$NON-NLS-1$
+       
+
+//     System.out.println(action.getId());
+//     System.out.println(action.getActionDefinitionId());
+       
     setAction(
       "ContentAssistTip",
       new TextOperationAction(
@@ -104,14 +115,21 @@ public class PHPEditor extends TextEditor {
         this,
         ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION));
 
-    Action action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Comment.", this, ITextOperationTarget.PREFIX);
+    action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Comment.", this, ITextOperationTarget.PREFIX);
     action.setActionDefinitionId(PHPEditorActionDefinitionIds.COMMENT);
     setAction("Comment", action);
-
+       
+//     System.out.println(action.getId());
+//     System.out.println(action.getActionDefinitionId());
+       
     action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Uncomment.", this, ITextOperationTarget.STRIP_PREFIX);
     action.setActionDefinitionId(PHPEditorActionDefinitionIds.UNCOMMENT);
     setAction("Uncomment", action);
 
+//     System.out.println(action.getId());
+//     System.out.println(action.getActionDefinitionId());
+       
+
   //  fActionGroups = new PHPActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
 
     markAsStateDependentAction("Comment", true); //$NON-NLS-1$
index 3239f9d..9f769a9 100644 (file)
@@ -2,11 +2,23 @@ package net.sourceforge.phpeclipse.phpeditor;
 
 public interface PHPEditorActionDefinitionIds {
        /**
-        * Value: net.sourceforge.phpeclipse.phpeditor.comment\r  */
-       public static final String COMMENT= "net.sourceforge.phpeclipse.phpeditor.comment";
+        * Value: net.sourceforge.phpeclipse.phpeditor.comment
+        */
+       public static final String COMMENT =
+               "net.sourceforge.phpeclipse.phpeditor.comment";
 
        /**
         * Value: net.sourceforge.phpeclipse.phpeditor.uncomment
         */
-       public static final String UNCOMMENT = "net.sourceforge.phpeclipse.phpeditor.uncomment";
+       public static final String UNCOMMENT =
+               "net.sourceforge.phpeclipse.phpeditor.uncomment";
+       
+       /**
+       * Action definition ID of the edit -> content assist proposal action (value
+       * <code>"org.phpeclipse.phpdt.ui.edit.text.php.content.assist. proposals"
+       * </code>).
+                */
+       public static final String CONTENT_ASSIST_PROPOSALS = 
+        "net.sourceforge.phpeclipse.ui.edit.text.php.content.assist.proposals"; //$NON-NLS-1$
+       
 }
index 6750da0..20f6404 100644 (file)
@@ -41,246 +41,272 @@ import org.xml.sax.SAXException;
  */
 
 public class PHPSyntaxRdr {
-  private static final String PHPDEFAULT_FILE = "default-phpsyntax.xml"; //$NON-NLS-1$
-  private static final String PHPSYNTAX_FILE = "phpsyntax.xml"; //$NON-NLS-1$
-  private static final String USERSYNTAX_FILE = "usersyntax.xml"; //$NON-NLS-1$
-  private static final String USERDEFAULT_FILE = "default-usersyntax.xml"; //$NON-NLS-1$
-  private static final String PHPSYNTAX_TAG = "phpsyntax"; //$NON-NLS-1$
-  private static final String KEYWORD_ATTR = "keyword"; //$NON-NLS-1$
-  private static final String TYPE_ATTR = "type"; //$NON-NLS-1$
-  private static final String CONSTANT_ATTR = "constant"; //$NON-NLS-1$
-  private static final String FN_ATTR = "function"; //$NON-NLS-1$
-  private static final String USAGE_ATTR = "usage"; //$NON-NLS-1$
-  private static final String TOKENVAL_ATTR = "tokenval"; //$NON-NLS-1$
-  private static IPreferenceStore store;
-  private static boolean hasXMLFileBeenRead = true;
+       private static final String PHPDEFAULT_FILE = "default-phpsyntax.xml"; //$NON-NLS-1$
+       private static final String PHPSYNTAX_FILE = "phpsyntax.xml"; //$NON-NLS-1$
+       private static final String USERSYNTAX_FILE = "usersyntax.xml"; //$NON-NLS-1$
+       private static final String USERDEFAULT_FILE = "default-usersyntax.xml"; //$NON-NLS-1$
+       private static final String PHPSYNTAX_TAG = "phpsyntax"; //$NON-NLS-1$
+       private static final String KEYWORD_ATTR = "keyword"; //$NON-NLS-1$
+       private static final String TYPE_ATTR = "type"; //$NON-NLS-1$
+       private static final String CONSTANT_ATTR = "constant"; //$NON-NLS-1$
+       private static final String FN_ATTR = "function"; //$NON-NLS-1$
+       private static final String USAGE_ATTR = "usage"; //$NON-NLS-1$
+       private static final String TOKENVAL_ATTR = "tokenval"; //$NON-NLS-1$
+       private static IPreferenceStore store;
+       private static boolean hasXMLFileBeenRead = true;
 
-  //The following variable is used to hold the syntax from
-  //the suers custom file - if that file should be changed,
-  //then all entries in this variable should be removed from
-  //the word list, reread from the file and then reinserted.
-  private static Vector userdefsyntaxdata;
+       //The following variable is used to hold the syntax from
+       //the suers custom file - if that file should be changed,
+       //then all entries in this variable should be removed from
+       //the word list, reread from the file and then reinserted.
+       private static Vector userdefsyntaxdata;
 
-  private static Vector syntaxdata;
+       private static Vector syntaxdata;
 
-  public PHPSyntaxRdr() {
-    syntaxdata = new Vector();
-    store = PHPeclipsePlugin.getDefault().getPreferenceStore();
-  }
+       public PHPSyntaxRdr() {
+               syntaxdata = new Vector();
+               store = PHPeclipsePlugin.getDefault().getPreferenceStore();
+       }
 
-  public static void readInSyntax() {
-    try {
-      hasXMLFileBeenRead = true;
-      /*Attempt to read the syntax file from the metadata
-       * if this does not work, create metadata from default*/
-      File syntaxFile = getSyntaxFile();
-      if (syntaxFile.exists()) {
-        readFromFile(syntaxFile);
-      } else {
-        readFromStream(PHPSyntaxRdr.class.getResourceAsStream(PHPSYNTAX_FILE));
-        saveToFile(syntaxFile);
-      }
-      /*Read the user-defined syntax file if it exists*/
-      //String buffer = new String(store.getString(PHPeclipsePlugin.PHP_USERDEF_XMLFILE));
-      if (store == null)
-        store = PHPeclipsePlugin.getDefault().getPreferenceStore();
-      String buffer = new String(store.getString(IPreferenceConstants.PHP_USERDEF_XMLFILE));
-      if (!buffer.equals("") || buffer != null) {
-        readFromFile(buffer);
-      }
-    } catch (CoreException ce) {
-      ce.printStackTrace();
-    }
-  }
+       public static void readInSyntax() {
+               try {
+                       hasXMLFileBeenRead = true;
+                       /*Attempt to read the syntax file from the metadata
+                        * if this does not work, create metadata from default*/
+                       File syntaxFile = getSyntaxFile();
+                       if (syntaxFile.exists()) {
+                               readFromFile(syntaxFile);
+                       } else {
+                               readFromStream(
+                                       PHPSyntaxRdr.class.getResourceAsStream(PHPSYNTAX_FILE));
+                               saveToFile(syntaxFile);
+                       }
+                       /*Read the user-defined syntax file if it exists*/
+                       //String buffer = new String(store.getString(PHPeclipsePlugin.PHP_USERDEF_XMLFILE));
+                       if (store == null)
+                               store = PHPeclipsePlugin.getDefault().getPreferenceStore();
+                       String buffer =
+                               new String(
+                                       store.getString(IPreferenceConstants.PHP_USERDEF_XMLFILE));
+                       if (!(buffer.equals("") || buffer == null)) {
+                               readFromFile(buffer);
+                       }
+               } catch (CoreException ce) {
+                       ce.printStackTrace();
+               }
+       }
 
-  public static void readFromFile(String filename) {
-    try {
-      readFromFile(new File(filename));
-    } catch (CoreException e) {
-    }
-  }
+       public static void readFromFile(String filename) {
+               try {
+                       readFromFile(new File(filename));
+               } catch (CoreException e) {
+               }
+       }
 
-  public static void readFromFile(File file) throws CoreException {
-    InputStream stream = null;
-    try {
-      stream = new FileInputStream(file);
-      readFromStream(stream);
-    } catch (IOException e) {
-      throwReadException(e);
-    } finally {
-      try {
-        if (stream != null) {
-          stream.close();
-        }
-      } catch (IOException e) {
-      }
-    }
-  }
-  public static void readFromStream(InputStream stream) throws CoreException {
-    try {
-      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-      DocumentBuilder parser = factory.newDocumentBuilder();
-      Document document = parser.parse(new InputSource(stream));
-      //Read in the Standard PHPSyntax "stuff"
-      NodeList elements = document.getElementsByTagName(PHPSYNTAX_TAG);
+       public static void readFromFile(File file) throws CoreException {
+               InputStream stream = null;
 
-      int count = elements.getLength();
-      for (int i = 0; i != count; i++) {
-        Node node = elements.item(i);
-        NamedNodeMap attributes = node.getAttributes();
+               if (file.exists()) {
+                       try {
+                               stream = new FileInputStream(file);
+                               readFromStream(stream);
+                       } catch (IOException e) {
+                               throwReadException(e);
+                       } finally {
+                               try {
+                                       if (stream != null) {
+                                               stream.close();
+                                       }
+                               } catch (IOException e) {
+                               }
+                       }
+               }
+       }
+       public static void readFromStream(InputStream stream)
+               throws CoreException {
+               try {
+                       DocumentBuilderFactory factory =
+                               DocumentBuilderFactory.newInstance();
+                       DocumentBuilder parser = factory.newDocumentBuilder();
+                       Document document = parser.parse(new InputSource(stream));
+                       //Read in the Standard PHPSyntax "stuff"
+                       NodeList elements = document.getElementsByTagName(PHPSYNTAX_TAG);
 
-        if (attributes == null)
-          continue;
+                       int count = elements.getLength();
+                       for (int i = 0; i != count; i++) {
+                               Node node = elements.item(i);
+                               NamedNodeMap attributes = node.getAttributes();
 
-        String Keyword = getAttributeValue(attributes, KEYWORD_ATTR);
-        String Type = getAttributeValue(attributes, TYPE_ATTR);
-        String Function = getAttributeValue(attributes, FN_ATTR);
-        String Constant = getAttributeValue(attributes, CONSTANT_ATTR);
-        String usage = getAttributeValue(attributes, USAGE_ATTR);
-        String Tokenval = getAttributeValue(attributes, TOKENVAL_ATTR);
+                               if (attributes == null)
+                                       continue;
 
-        StringBuffer buffer= new StringBuffer();
-        NodeList children= node.getChildNodes();
-        for (int j= 0; j != children.getLength(); j++) {
-          String value= children.item(j).getNodeValue();
-          if (value != null)
-            buffer.append(value);
-        }
-        String description = buffer.toString().trim();
-        
-        if (Keyword == null && Type == null && Function == null && Constant == null) {
-          //ignore as it is not a valid phpsyntax tag
-        } else {
-          if (Keyword != null) {
-            syntaxdata.addElement(new PHPKeyword(Keyword, usage, Tokenval));
-          } else if (Type != null) {
-            syntaxdata.addElement(new PHPType(Type, usage));
-          } else if (Function != null) {
-            syntaxdata.addElement(new PHPFunction(Function, usage, description));
-          } else if (Constant != null) {
-            syntaxdata.addElement(new PHPConstant(Constant, usage));
-          }
-        }
-      }
-    } catch (ParserConfigurationException e) {
-      throwReadException(e);
-    } catch (IOException e) {
-      throwReadException(e);
-    } catch (SAXException e) {
-      throwReadException(e);
-    }
-  }
+                               String Keyword = getAttributeValue(attributes, KEYWORD_ATTR);
+                               String Type = getAttributeValue(attributes, TYPE_ATTR);
+                               String Function = getAttributeValue(attributes, FN_ATTR);
+                               String Constant = getAttributeValue(attributes, CONSTANT_ATTR);
+                               String usage = getAttributeValue(attributes, USAGE_ATTR);
+                               String Tokenval = getAttributeValue(attributes, TOKENVAL_ATTR);
 
-  public static Vector getsyntaxdata() {
-    return (Vector) syntaxdata.clone();
-  }
+                               StringBuffer buffer = new StringBuffer();
+                               NodeList children = node.getChildNodes();
+                               for (int j = 0; j != children.getLength(); j++) {
+                                       String value = children.item(j).getNodeValue();
+                                       if (value != null)
+                                               buffer.append(value);
+                               }
+                               String description = buffer.toString().trim();
 
-  public static void replaceUserDefFile() {
-    /*Replace the user-defined syntax file if it exists*/
-    String buffer = new String(store.getString(IPreferenceConstants.PHP_USERDEF_XMLFILE));
-    if (!buffer.equals("") || buffer == null) {
-      readFromFile(buffer);
-    }
-  }
+                               if (Keyword == null
+                                       && Type == null
+                                       && Function == null
+                                       && Constant == null) {
+                                       //ignore as it is not a valid phpsyntax tag
+                               } else {
+                                       if (Keyword != null) {
+                                               syntaxdata.addElement(
+                                                       new PHPKeyword(Keyword, usage, Tokenval));
+                                       } else if (Type != null) {
+                                               syntaxdata.addElement(new PHPType(Type, usage));
+                                       } else if (Function != null) {
+                                               syntaxdata.addElement(
+                                                       new PHPFunction(Function, usage, description));
+                                       } else if (Constant != null) {
+                                               syntaxdata.addElement(new PHPConstant(Constant, usage));
+                                       }
+                               }
+                       }
+               } catch (ParserConfigurationException e) {
+                       throwReadException(e);
+               } catch (IOException e) {
+                       throwReadException(e);
+               } catch (SAXException e) {
+                       throwReadException(e);
+               }
+       }
 
-  public static Vector getUserDefinitions() {
-    return (Vector) userdefsyntaxdata.clone();
-  }
+       public static Vector getsyntaxdata() {
+               return (Vector) syntaxdata.clone();
+       }
 
-  private static File getSyntaxFile() {
-    IPath path = PHPeclipsePlugin.getDefault().getStateLocation();
-    path = path.append(PHPSYNTAX_FILE);
-    return path.toFile();
-  }
+       public static void replaceUserDefFile() {
+               /*Replace the user-defined syntax file if it exists*/
+               String buffer =
+                       new String(
+                               store.getString(IPreferenceConstants.PHP_USERDEF_XMLFILE));
+               if (!buffer.equals("") || buffer == null) {
+                       readFromFile(buffer);
+               }
+       }
 
-  private static String getAttributeValue(NamedNodeMap attributes, String name) {
-    Node node = attributes.getNamedItem(name);
-    return node == null ? null : node.getNodeValue();
-  }
+       public static Vector getUserDefinitions() {
+               return (Vector) userdefsyntaxdata.clone();
+       }
 
-  public static void saveToFile(File file) throws CoreException {
-    OutputStream stream = null;
-    try {
-      stream = new FileOutputStream(file);
-      saveToStream(stream);
-    } catch (IOException e) {
-      throwWriteException(e);
-    } finally {
-      try {
-        if (stream != null)
-          stream.close();
-      } catch (IOException e) {
-      }
-    }
-  }
+       private static File getSyntaxFile() {
+               IPath path = PHPeclipsePlugin.getDefault().getStateLocation();
+               path = path.append(PHPSYNTAX_FILE);
+               return path.toFile();
+       }
 
-  public static void saveToStream(OutputStream stream) throws CoreException {
-    try {
-      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-      DocumentBuilder builder = factory.newDocumentBuilder();
-      Document document = builder.newDocument();
-      Node root = document.createElement("PHPStandardSyntax"); // $NON-NLS-1$ //$NON-NLS-1$
-      document.appendChild(root);
-      for (int i = 0; i != syntaxdata.size(); i++) {
-        Object bufferobj = (Object) syntaxdata.get(i);
-        Attr name = null;
-        Node node = document.createElement(PHPSYNTAX_TAG); // $NON-NLS-1$ //$NON-NLS-1$
-        root.appendChild(node);
-        NamedNodeMap attributes = node.getAttributes();
-        if (bufferobj instanceof PHPType)
-          name = document.createAttribute(TYPE_ATTR);
-        if (bufferobj instanceof PHPKeyword)
-          name = document.createAttribute(KEYWORD_ATTR);
-        if (bufferobj instanceof PHPFunction)
-          name = document.createAttribute(FN_ATTR);
-        if (bufferobj instanceof PHPConstant)
-          name = document.createAttribute(CONSTANT_ATTR);
-        name.setValue(((PHPElement) bufferobj).getName());
-        attributes.setNamedItem(name);
-        Attr description = document.createAttribute(USAGE_ATTR);
-        description.setValue(((PHPElement) bufferobj).getUsage());
-        attributes.setNamedItem(description);
-        if (bufferobj instanceof PHPKeyword) {
-          Attr tokenval = document.createAttribute(TOKENVAL_ATTR);
-          tokenval.setValue((new Integer(((PHPKeyword) bufferobj).gettokenval())).toString());
-          attributes.setNamedItem(tokenval);
-        }
-        if (bufferobj instanceof PHPFunction) {
-    //      Attr usage = document.createAttribute(USAGE_ATTR);
-          Text usage = document.createTextNode(((PHPFunction) bufferobj).getDescription());
-          node.appendChild(usage);
-//          usage.setValue(((PHPFunction) bufferobj).getUsage());
-//          attributes.setNamedItem(usage);
-        }
-      }
-      OutputFormat format = new OutputFormat();
-      format.setPreserveSpace(true);
-      try {
-        Serializer serializer = SerializerFactory.getSerializerFactory("xml").makeSerializer(stream, format);
-        serializer.asDOMSerializer().serialize(document);
-      } catch (UnsupportedEncodingException e) {
-      } catch (IOException e) {
-      } //$NON-NLS-1$
-      //                       Serializer serializer = SerializerFactory.getSerializer().makeSerializer(stream, format); //$NON-NLS-1$
-    } catch (ParserConfigurationException e) {
-      throwWriteException(e);
-      //        } catch (IOException e) {
-      //            throwWriteException(e);
-    }
-  }
+       private static String getAttributeValue(
+               NamedNodeMap attributes,
+               String name) {
+               Node node = attributes.getNamedItem(name);
+               return node == null ? null : node.getNodeValue();
+       }
 
-  private static void throwReadException(Throwable t) throws CoreException {
-    PHPeclipsePlugin.log(t);
-    //         IStatus status= new JavaUIStatus(JavaStatusConstants.TEMPLATE_IO_EXCEPTION,
-    //                 TemplateMessages.getString("TemplateSet.error.read"), t); //$NON-NLS-1$
-    //         throw new JavaUIException(status);
-  }
+       public static void saveToFile(File file) throws CoreException {
+               OutputStream stream = null;
+               try {
+                       stream = new FileOutputStream(file);
+                       saveToStream(stream);
+               } catch (IOException e) {
+                       throwWriteException(e);
+               } finally {
+                       try {
+                               if (stream != null)
+                                       stream.close();
+                       } catch (IOException e) {
+                       }
+               }
+       }
 
-  private static void throwWriteException(Throwable t) throws CoreException {
-    PHPeclipsePlugin.log(t);
-    //         IStatus status= new JavaUIStatus(JavaStatusConstants.TEMPLATE_IO_EXCEPTION,
-    //                 TemplateMessages.getString("TemplateSet.error.write"), t); //$NON-NLS-1$
-    //         throw new JavaUIException(status);
-  }
+       public static void saveToStream(OutputStream stream) throws CoreException {
+               try {
+                       DocumentBuilderFactory factory =
+                               DocumentBuilderFactory.newInstance();
+                       DocumentBuilder builder = factory.newDocumentBuilder();
+                       Document document = builder.newDocument();
+                       Node root = document.createElement("PHPStandardSyntax"); // $NON-NLS-1$ //$NON-NLS-1$
+                       document.appendChild(root);
+                       for (int i = 0; i != syntaxdata.size(); i++) {
+                               Object bufferobj = (Object) syntaxdata.get(i);
+                               Attr name = null;
+                               Node node = document.createElement(PHPSYNTAX_TAG); // $NON-NLS-1$ //$NON-NLS-1$
+                               root.appendChild(node);
+                               NamedNodeMap attributes = node.getAttributes();
+                               if (bufferobj instanceof PHPType)
+                                       name = document.createAttribute(TYPE_ATTR);
+                               if (bufferobj instanceof PHPKeyword)
+                                       name = document.createAttribute(KEYWORD_ATTR);
+                               if (bufferobj instanceof PHPFunction)
+                                       name = document.createAttribute(FN_ATTR);
+                               if (bufferobj instanceof PHPConstant)
+                                       name = document.createAttribute(CONSTANT_ATTR);
+                               name.setValue(((PHPElement) bufferobj).getName());
+                               attributes.setNamedItem(name);
+                               Attr description = document.createAttribute(USAGE_ATTR);
+                               description.setValue(((PHPElement) bufferobj).getUsage());
+                               attributes.setNamedItem(description);
+                               if (bufferobj instanceof PHPKeyword) {
+                                       Attr tokenval = document.createAttribute(TOKENVAL_ATTR);
+                                       tokenval.setValue(
+                                               (new Integer(((PHPKeyword) bufferobj).gettokenval()))
+                                                       .toString());
+                                       attributes.setNamedItem(tokenval);
+                               }
+                               if (bufferobj instanceof PHPFunction) {
+                                       //      Attr usage = document.createAttribute(USAGE_ATTR);
+                                       Text usage =
+                                               document.createTextNode(
+                                                       ((PHPFunction) bufferobj).getDescription());
+                                       node.appendChild(usage);
+                                       //          usage.setValue(((PHPFunction) bufferobj).getUsage());
+                                       //          attributes.setNamedItem(usage);
+                               }
+                       }
+                       OutputFormat format = new OutputFormat();
+                       format.setPreserveSpace(true);
+                       try {
+                               Serializer serializer =
+                                       SerializerFactory.getSerializerFactory(
+                                               "xml").makeSerializer(
+                                               stream,
+                                               format);
+                               serializer.asDOMSerializer().serialize(document);
+                       } catch (UnsupportedEncodingException e) {
+                       } catch (IOException e) {
+                       } //$NON-NLS-1$
+                       //                      Serializer serializer = SerializerFactory.getSerializer().makeSerializer(stream, format); //$NON-NLS-1$
+               } catch (ParserConfigurationException e) {
+                       throwWriteException(e);
+                       //        } catch (IOException e) {
+                       //            throwWriteException(e);
+               }
+       }
+
+       private static void throwReadException(Throwable t) throws CoreException {
+               PHPeclipsePlugin.log(t);
+               //              IStatus status= new JavaUIStatus(JavaStatusConstants.TEMPLATE_IO_EXCEPTION,
+               //                      TemplateMessages.getString("TemplateSet.error.read"), t); //$NON-NLS-1$
+               //              throw new JavaUIException(status);
+       }
+
+       private static void throwWriteException(Throwable t) throws CoreException {
+               PHPeclipsePlugin.log(t);
+               //              IStatus status= new JavaUIStatus(JavaStatusConstants.TEMPLATE_IO_EXCEPTION,
+               //                      TemplateMessages.getString("TemplateSet.error.write"), t); //$NON-NLS-1$
+               //              throw new JavaUIException(status);
+       }
 
 }