Deleted PHPFunctionNames use only phpsyntax.xml instead !
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / text / template / DeclarationProposal.java
index 41c9f61..4d95555 100644 (file)
@@ -9,22 +9,17 @@ import net.sourceforge.phpdt.internal.corext.template.TemplateContext;
 import net.sourceforge.phpdt.internal.corext.template.TemplateMessages;
 import net.sourceforge.phpdt.internal.corext.template.php.PHPUnitContext;
 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
-import net.sourceforge.phpdt.internal.ui.text.java.IPHPCompletionProposal;
 import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionManager;
 import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionUI;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpeclipse.builder.PHPIdentifierLocation;
 
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.IRegion;
 import org.eclipse.jface.text.ITextViewer;
 import org.eclipse.jface.text.contentassist.IContextInformation;
 import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Shell;
 //import org.eclipse.jdt.internal.ui.text.link.LinkedPositionManager;
 //import org.eclipse.jdt.internal.ui.text.link.LinkedPositionUI;
 //import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
@@ -32,19 +27,19 @@ import org.eclipse.swt.widgets.Shell;
 /**
  * A PHP identifier proposal.
  */
-public class DeclarationProposal implements IPHPCompletionProposal {
-
-  private final String fTemplate;
-  private final PHPIdentifierLocation fLocation;
+public class DeclarationProposal extends AbstractProposal {//implements IPHPCompletionProposal {
   private final TemplateContext fContext;
-  private final ITextViewer fViewer;
+  private final PHPIdentifierLocation fLocation;
+
+  //private TemplateBuffer fTemplateBuffer;
+  private String fOldText;
   //  private final Image fImage_fun;
   //  private final Image fImage_var;
   private final IRegion fRegion;
+//  private IRegion fSelectedRegion; // initialized by apply()
 
-  //private TemplateBuffer fTemplateBuffer;
-  private String fOldText;
-  private IRegion fSelectedRegion; // initialized by apply()
+  private final String fTemplate;
+//  private final ITextViewer fViewer;
 
   /**
    * Creates a template proposal with a template and its context.
@@ -58,12 +53,13 @@ public class DeclarationProposal implements IPHPCompletionProposal {
     TemplateContext context,
     IRegion region,
     ITextViewer viewer) {
+       super(viewer);
     //    Image image_fun,
     //    Image image_var) {
     fTemplate = template;
     fLocation = location;
     fContext = context;
-    fViewer = viewer;
+//    fViewer = viewer;
     //    fImage_fun = image_fun;
     //    fImage_var = image_var;
     fRegion = region;
@@ -117,26 +113,6 @@ public class DeclarationProposal implements IPHPCompletionProposal {
     //     }       
   }
 
-  //  private static int getCaretOffset(TemplateBuffer buffer) {
-  //    TemplatePosition[] variables = buffer.getVariables();
-  //    for (int i = 0; i != variables.length; i++) {
-  //      TemplatePosition variable = variables[i];
-  //
-  //      if (variable.getName().equals(JavaTemplateMessages.getString("GlobalVariables.variable.name.cursor"))) //$NON-NLS-1$
-  //        return variable.getOffsets()[0];
-  //    }
-  //
-  //    return buffer.getString().length();
-  //  }
-
-  /*
-   * @see ICompletionProposal#getSelection(IDocument)
-   */
-  public Point getSelection(IDocument document) {
-    return new Point(fSelectedRegion.getOffset(), fSelectedRegion.getLength());
-    //   return null;
-  }
-
   /*
    * @see ICompletionProposal#getAdditionalProposalInfo()
    */
@@ -149,6 +125,13 @@ public class DeclarationProposal implements IPHPCompletionProposal {
   }
 
   /*
+   * @see ICompletionProposal#getContextInformation()
+   */
+  public IContextInformation getContextInformation() {
+    return null;
+  }
+
+  /*
    * @see ICompletionProposal#getDisplayString()
    */
   public String getDisplayString() {
@@ -176,62 +159,6 @@ public class DeclarationProposal implements IPHPCompletionProposal {
   }
 
   /*
-   * @see ICompletionProposal#getContextInformation()
-   */
-  public IContextInformation getContextInformation() {
-    return null;
-  }
-
-  private static String textToHTML(String string) {
-    StringBuffer buffer = new StringBuffer(string.length());
-    buffer.append("<pre>"); //$NON-NLS-1$
-
-    for (int i = 0; i != string.length(); i++) {
-      char ch = string.charAt(i);
-
-      switch (ch) {
-        case '&' :
-          buffer.append("&amp;"); //$NON-NLS-1$
-          break;
-
-        case '<' :
-          buffer.append("&lt;"); //$NON-NLS-1$
-          break;
-
-        case '>' :
-          buffer.append("&gt;"); //$NON-NLS-1$
-          break;
-
-        case '\t' :
-          buffer.append("    "); //$NON-NLS-1$
-          break;
-
-        case '\n' :
-          buffer.append("<br>"); //$NON-NLS-1$
-          break;
-
-        default :
-          buffer.append(ch);
-          break;
-      }
-    }
-
-    buffer.append("</pre>"); //$NON-NLS-1$
-    return buffer.toString();
-  }
-
-  private void openErrorDialog(BadLocationException e) {
-    Shell shell = fViewer.getTextWidget().getShell();
-    MessageDialog.openError(shell, TemplateMessages.getString("TemplateEvaluator.error.title"), e.getMessage()); //$NON-NLS-1$
-  }
-
-  private void handleException(CoreException e) {
-    Shell shell = fViewer.getTextWidget().getShell();
-    PHPeclipsePlugin.log(e);
-    //         ExceptionHandler.handle(e, shell, ObfuscatorMessages.getString("TemplateEvaluator.error.title"), null); //$NON-NLS-1$
-  }
-
-  /*
    * @see IJavaCompletionProposal#getRelevance()
    */
   public int getRelevance() {
@@ -254,4 +181,5 @@ public class DeclarationProposal implements IPHPCompletionProposal {
     }
   }
 
+
 }
\ No newline at end of file