1) Moved net.sourceforge.phpeclipse.ui\src\net\sourceforge\phpdt back to net.sourcefo...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / text / template / BuiltInProposal.java
index daafd3d..900604a 100644 (file)
@@ -39,15 +39,16 @@ public class BuiltInProposal extends AbstractProposal {
 
        /**
         * Creates a template proposal with a template and its context.
-        *
+        * 
         * @param template
-        *          the template
+        *            the template
         * @param context
-        *          the context in which the template was requested.
+        *            the context in which the template was requested.
         * @param image
-        *          the icon of the proposal.
+        *            the icon of the proposal.
         */
-       public BuiltInProposal(String functionName, PHPFunction function, TemplateContext context, IRegion region, ITextViewer viewer) {
+       public BuiltInProposal(String functionName, PHPFunction function,
+                       TemplateContext context, IRegion region, ITextViewer viewer) {
                super(viewer);
                fBuiltinFunctionName = functionName;
                fFunction = function;
@@ -68,7 +69,8 @@ public class BuiltInProposal extends AbstractProposal {
                        int end = fRegion.getOffset() + fRegion.getLength();
 
                        // insert template string
-                       // String templateString = fTemplate; // fTemplateBuffer.getString();
+                       // String templateString = fTemplate; //
+                       // fTemplateBuffer.getString();
                        document.replace(start, end - start, fBuiltinFunctionName + "()");
 
                        // translate positions
@@ -88,8 +90,10 @@ public class BuiltInProposal extends AbstractProposal {
                        // }
 
                        LinkedPositionUI editor = new LinkedPositionUI(fViewer, manager);
-                       editor.setFinalCaretOffset(fBuiltinFunctionName.length() + start + 1);
-                       // editor.setFinalCaretOffset(getCaretOffset(fTemplateBuffer) + start);
+                       editor.setFinalCaretOffset(fBuiltinFunctionName.length() + start
+                                       + 1);
+                       // editor.setFinalCaretOffset(getCaretOffset(fTemplateBuffer) +
+                       // start);
                        editor.enter();
 
                        fSelectedRegion = editor.getSelectedRegion();
@@ -104,9 +108,6 @@ public class BuiltInProposal extends AbstractProposal {
                // }
        }
 
-       /*
-        * @see ICompletionProposal#getAdditionalProposalInfo()
-        */
        public String getAdditionalProposalInfo() {
                return fFunction.getHoverText();
        }
@@ -117,15 +118,19 @@ public class BuiltInProposal extends AbstractProposal {
                        if (contextInfoString != null && contextInfoString.length() > 0) {
                                // extract the parameter context information for the function:
                                int i0 = contextInfoString.indexOf('(');
-                               if (i0 >= 0) {
+                               int newline = contextInfoString.indexOf('\n');
+                               if (i0 >= 0 && (i0 < newline || newline < 0)) {
                                        int i1 = contextInfoString.indexOf(')', i0 + 1);
                                        if (i1 > 0) {
-                                               fContextInfo = new ContextInformation(null, contextInfoString.substring(i0, i1+1));
+                                               fContextInfo = new ContextInformation(null,
+                                                               contextInfoString.substring(i0 + 1, i1));
                                        } else {
-                                               fContextInfo = new ContextInformation(null, contextInfoString);
+                                               fContextInfo = new ContextInformation(null,
+                                                               contextInfoString);
                                        }
                                } else {
-                                       fContextInfo = new ContextInformation(null, contextInfoString);
+                                       fContextInfo = new ContextInformation(null,
+                                                       contextInfoString);
                                }
                        }
                }
@@ -136,7 +141,8 @@ public class BuiltInProposal extends AbstractProposal {
         * @see ICompletionProposal#getDisplayString()
         */
        public String getDisplayString() {
-               return fBuiltinFunctionName + TemplateMessages.getString("TemplateProposal.delimiter") + fFunction.getUsage(); // $NON-NLS-1$
+               return fBuiltinFunctionName
+                               + TemplateMessages.getString("TemplateProposal.delimiter") + fFunction.getUsage(); // $NON-NLS-1$
                // //$NON-NLS-1$
        }