first PHP parser version (doesn't work actually)
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / php / PHPCompletionProcessor.java
index 57e4372..6fd4ce7 100644 (file)
@@ -62,7 +62,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
     }
   };
 
-  protected final static String[] fgProposals = PHPCodeScanner.fgFunctionNames;
+  protected final static String[] fgProposals = PHPFunctionNames.FUNCTION_NAMES;
   //    {
   //      "array",
   //      "break",
@@ -134,21 +134,26 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
     //
     //    }
 
-    //    if (documentOffset > 0) {
-    //      try {
-    //        char character = document.getChar(documentOffset - 1);
-    //        if (character=='$') {
-    //          
-    //        }
-    //        result = new ICompletionProposal[fgProposals.length];
-    //        for (int i = 0; i < fgProposals.length; i++) {
-    //          IContextInformation info = new ContextInformation(fgProposals[i], MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.Proposal.ContextInfo.pattern"), new Object[] { fgProposals[i] })); //$NON-NLS-1$
-    //          result[i] = new CompletionProposal(fgProposals[i], documentOffset, 0, fgProposals[i].length(), null, fgProposals[i], info, MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.Proposal.hoverinfo.pattern"), new Object[] { fgProposals[i] })); //$NON-NLS-1$
-    //        }
-    //      } catch (BadLocationException e) {
-    //      }
-    //
-    //    } else {
+    ArrayList arrList = new ArrayList(5);
+    IDocument document = viewer.getDocument();
+    if (documentOffset > 0) {
+      try {
+        ICompletionProposal[] result;
+        char character = document.getChar(documentOffset - 1);
+        if (character == '$') {
+//viewer.  .getActivePage().getActiveEditor();
+          result = new ICompletionProposal[fgProposals.length];
+          for (int i = 0; i < fgProposals.length; i++) {
+            IContextInformation info = new ContextInformation(fgProposals[i], MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.Proposal.ContextInfo.pattern"), new Object[] { fgProposals[i] })); //$NON-NLS-1$
+            result[i] = new CompletionProposal(fgProposals[i], documentOffset, 0, fgProposals[i].length(), null, fgProposals[i], info, MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.Proposal.hoverinfo.pattern"), new Object[] { fgProposals[i] })); //$NON-NLS-1$
+          }
+          return result;
+        }
+      } catch (BadLocationException e) {
+        return new ICompletionProposal[0];
+      }
+    }
+
     ICompletionProposal[] result = new ICompletionProposal[fgProposals.length];
     for (int i = 0; i < fgProposals.length; i++) {
       IContextInformation info = new ContextInformation(fgProposals[i], MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.Proposal.ContextInfo.pattern"), new Object[] { fgProposals[i] })); //$NON-NLS-1$