Fix Request #1431769: Support Context assistance when entering functions arguments
authoraxelcl <axelcl>
Wed, 22 Feb 2006 22:46:38 +0000 (22:46 +0000)
committeraxelcl <axelcl>
Wed, 22 Feb 2006 22:46:38 +0000 (22:46 +0000)
Now available for built-in funcitons

net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/BuiltInProposal.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/DeclarationProposal.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/IdentifierProposal.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/util/PHPFileUtil.java

index daafd3d..a0e1bda 100644 (file)
@@ -104,9 +104,6 @@ public class BuiltInProposal extends AbstractProposal {
                // }
        }
 
-       /*
-        * @see ICompletionProposal#getAdditionalProposalInfo()
-        */
        public String getAdditionalProposalInfo() {
                return fFunction.getHoverText();
        }
@@ -117,10 +114,11 @@ 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);
                                        }
index fe0e1da..bb65147 100644 (file)
@@ -18,152 +18,187 @@ 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.ContextInformation;
 import org.eclipse.jface.text.contentassist.IContextInformation;
 import org.eclipse.jface.text.templates.TemplateContext;
 import org.eclipse.swt.graphics.Image;
-//import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionManager;
-//import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionUI;
-//import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler;
+
+// import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionManager;
+// import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionUI;
+// import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler;
 
 /**
  * A PHP identifier proposal.
  */
-public class DeclarationProposal extends AbstractProposal { //implements IPHPCompletionProposal {
-  private IProject fProject;
-  private final TemplateContext fContext;
-  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 final String fIdentifierName;
-  //  private final ITextViewer fViewer;
-
-  /**
-   * Creates a template proposal with a template and its context.
-   * @param template  the template
-   * @param context   the context in which the template was requested.
-   * @param image     the icon of the proposal.
-   */
-  public DeclarationProposal(
-         IProject project,
-       String identifierName,
-       PHPIdentifierLocation location,
-       TemplateContext context,
-       IRegion region,
-       ITextViewer viewer) {
-       super(viewer);
-       //    Image image_fun,
-       //    Image image_var) {
-       fProject = project;
-       fIdentifierName = identifierName;
-       fLocation = location;
-       fContext = context;
-       fRegion = region;
-  }
-
-  /*
-   * @see ICompletionProposal#apply(IDocument)
-   */
-  public void apply(IDocument document) {
-       try {
-         //                if (fTemplateBuffer == null)
-         //                            fTemplateBuffer= fContext.evaluate(fTemplate);
-
-         int start = fRegion.getOffset();
-         int end = fRegion.getOffset() + fRegion.getLength();
-
-         switch (fLocation.getType()) {
-               case PHPIdentifierLocation.FUNCTION :
-                 document.replace(start, end - start, fIdentifierName + "()");
-                 break;
-               case PHPIdentifierLocation.CONSTRUCTOR :
-                 document.replace(start, end - start, fIdentifierName + "()");
-                 break;
-               case PHPIdentifierLocation.METHOD :
-                 document.replace(start, end - start, fIdentifierName + "()");
-                 break;
-
-               default :
-                 document.replace(start, end - start, fIdentifierName);
-         }
-
-         // translate positions
-         LinkedPositionManager manager = new LinkedPositionManager(document);
-         //                    TemplatePosition[] variables= fTemplateBuffer.getVariables();
-         //                    for (int i= 0; i != variables.length; i++) {
-         //                            TemplatePosition variable= variables[i];
-         //
-         //                            if (variable.isResolved())
-         //                                    continue;
-         //
-         //                            int[] offsets= variable.getOffsets();
-         //                            int length= variable.getLength();
-         //
-         //                            for (int j= 0; j != offsets.length; j++)
-         //                                    manager.addPosition(offsets[j] + start, length);
-         //                    }
-
-         LinkedPositionUI editor = new LinkedPositionUI(fViewer, manager);
-         switch (fLocation.getType()) {
-               case PHPIdentifierLocation.FUNCTION :
-                 editor.setFinalCaretOffset(fIdentifierName.length() + start + 1);
-                 break;
-               case PHPIdentifierLocation.CONSTRUCTOR :
-                 editor.setFinalCaretOffset(fIdentifierName.length() + start + 1);
-                 break;
-               case PHPIdentifierLocation.METHOD :
-                 editor.setFinalCaretOffset(fIdentifierName.length() + start + 1);
-                 break;
-
-               default :
-                 editor.setFinalCaretOffset(fIdentifierName.length() + start);
-         }
-         editor.enter();
-
-         fSelectedRegion = editor.getSelectedRegion();
-
-       } catch (BadLocationException e) {
-         PHPeclipsePlugin.log(e);
-         openErrorDialog(e);
+public class DeclarationProposal extends AbstractProposal { // implements
+       // IPHPCompletionProposal
+       // {
+       private IProject fProject;
+
+       private final TemplateContext fContext;
+
+       private final PHPIdentifierLocation fLocation;
+
+       String fInfo;
+
+       // 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 final String fIdentifierName;
+
+       // private final ITextViewer fViewer;
+
+       /**
+        * Creates a template proposal with a template and its context.
+        *
+        * @param template
+        *          the template
+        * @param context
+        *          the context in which the template was requested.
+        * @param image
+        *          the icon of the proposal.
+        */
+       public DeclarationProposal(IProject project, String identifierName, PHPIdentifierLocation location, TemplateContext context,
+                       IRegion region, ITextViewer viewer) {
+               super(viewer);
+               // Image image_fun,
+               // Image image_var) {
+               fProject = project;
+               fIdentifierName = identifierName;
+               fLocation = location;
+               fContext = context;
+               fRegion = region;
+               fInfo = null;
+       }
+
+       /*
+        * @see ICompletionProposal#apply(IDocument)
+        */
+       public void apply(IDocument document) {
+               try {
+                       // if (fTemplateBuffer == null)
+                       // fTemplateBuffer= fContext.evaluate(fTemplate);
+
+                       int start = fRegion.getOffset();
+                       int end = fRegion.getOffset() + fRegion.getLength();
+
+                       switch (fLocation.getType()) {
+                       case PHPIdentifierLocation.FUNCTION:
+                               document.replace(start, end - start, fIdentifierName + "()");
+                               break;
+                       case PHPIdentifierLocation.CONSTRUCTOR:
+                               document.replace(start, end - start, fIdentifierName + "()");
+                               break;
+                       case PHPIdentifierLocation.METHOD:
+                               document.replace(start, end - start, fIdentifierName + "()");
+                               break;
+
+                       default:
+                               document.replace(start, end - start, fIdentifierName);
+                       }
+
+                       // translate positions
+                       LinkedPositionManager manager = new LinkedPositionManager(document);
+                       // TemplatePosition[] variables= fTemplateBuffer.getVariables();
+                       // for (int i= 0; i != variables.length; i++) {
+                       // TemplatePosition variable= variables[i];
+                       //
+                       // if (variable.isResolved())
+                       // continue;
+                       //
+                       // int[] offsets= variable.getOffsets();
+                       // int length= variable.getLength();
+                       //
+                       // for (int j= 0; j != offsets.length; j++)
+                       // manager.addPosition(offsets[j] + start, length);
+                       // }
+
+                       LinkedPositionUI editor = new LinkedPositionUI(fViewer, manager);
+                       switch (fLocation.getType()) {
+                       case PHPIdentifierLocation.FUNCTION:
+                               editor.setFinalCaretOffset(fIdentifierName.length() + start + 1);
+                               break;
+                       case PHPIdentifierLocation.CONSTRUCTOR:
+                               editor.setFinalCaretOffset(fIdentifierName.length() + start + 1);
+                               break;
+                       case PHPIdentifierLocation.METHOD:
+                               editor.setFinalCaretOffset(fIdentifierName.length() + start + 1);
+                               break;
+
+                       default:
+                               editor.setFinalCaretOffset(fIdentifierName.length() + start);
+                       }
+                       editor.enter();
+
+                       fSelectedRegion = editor.getSelectedRegion();
+
+               } catch (BadLocationException e) {
+                       PHPeclipsePlugin.log(e);
+                       openErrorDialog(e);
+
+               }
+               // catch (CoreException e) {
+               // handleException(e);
+               // }
+       }
 
+       /*
+        * @see ICompletionProposal#getAdditionalProposalInfo()
+        */
+       public String getAdditionalProposalInfo() {
+               if (fInfo == null) {
+                       fInfo = computeProposalInfo();
+               }
+               return fInfo;
        }
-       //      catch (CoreException e) {
-       //                      handleException(e);
-       //          }
-  }
-
-  /*
-   * @see ICompletionProposal#getAdditionalProposalInfo()
-   */
-  public String getAdditionalProposalInfo() {
-       StringBuffer hoverInfoBuffer = new StringBuffer();
-//    String workspaceLocation = PHPeclipsePlugin.getWorkspace().getRoot().getLocation().toString();
-       String workspaceLocation;
-       if (fProject!=null) {
-         workspaceLocation = fProject.getLocation().toString()+'/';
-       } else {
-         // should never happen?
-         workspaceLocation = PHPeclipsePlugin.getWorkspace()
-         .getRoot().getLocation().toString();
+
+       private String computeProposalInfo() {
+               StringBuffer hoverInfoBuffer = new StringBuffer();
+               // String workspaceLocation =
+               // PHPeclipsePlugin.getWorkspace().getRoot().getLocation().toString();
+               String workspaceLocation;
+               if (fProject != null) {
+                       workspaceLocation = fProject.getLocation().toString() + '/';
+               } else {
+                       // should never happen?
+                       workspaceLocation = PHPeclipsePlugin.getWorkspace().getRoot().getLocation().toString();
+               }
+               String filename = workspaceLocation + fLocation.getFilename();
+               PHPDocUtil.appendPHPDoc(hoverInfoBuffer, filename, fLocation);
+               return hoverInfoBuffer.toString();
        }
-       String filename = workspaceLocation + fLocation.getFilename();
-       PHPDocUtil.appendPHPDoc(hoverInfoBuffer, filename, fLocation);
-       return hoverInfoBuffer.toString();
-  }
-
-  /*
-   * @see ICompletionProposal#getContextInformation()
-   */
-  public IContextInformation getContextInformation() {
-       return null;
-  }
-
-  /*
+
+       public IContextInformation getContextInformation() {
+               if (fContextInfo == null) {
+                       if (fLocation != null) {
+                               fInfo = fLocation.getUsage();
+                               if (fInfo != null) {
+                                       // extract the parameter context information for the function:
+                                       int i0 = fInfo.indexOf('(');
+                                       int newline = fInfo.indexOf('\n');
+                                       if (i0 >= 0 && (i0 < newline || newline < 0)) {
+                                               int i1 = fInfo.indexOf(')', i0 + 1);
+                                               if (i1 > 0) {
+
+                                                       fContextInfo = new ContextInformation(null, fInfo.substring(i0+1, i1));
+                                               } else {
+                                                       fContextInfo = new ContextInformation(null, fInfo);
+                                               }
+                                       } else {
+                                               fContextInfo = new ContextInformation(null, fInfo);
+                                       }
+                               }
+                       }
+               }
+               return fContextInfo;
+       }
+
+       /*
         * @see ICompletionProposal#getDisplayString()
         */
        public String getDisplayString() {
@@ -172,67 +207,64 @@ public class DeclarationProposal extends AbstractProposal { //implements IPHPCom
                        workspaceLocation = fProject.getName().toString() + '/';
                } else {
                        // should never happen?
-                       workspaceLocation = PHPeclipsePlugin.getWorkspace().getRoot()
-                                       .getLocation().toString();
+                       workspaceLocation = PHPeclipsePlugin.getWorkspace().getRoot().getLocation().toString();
                }
                String filename = workspaceLocation + fLocation.getFilename();
                String usage = PHPDocUtil.getUsage(filename, fLocation);
-               String result = fIdentifierName
-                               + TemplateMessages.getString("TemplateProposal.delimiter");
+               String result = fIdentifierName + TemplateMessages.getString("TemplateProposal.delimiter");
                if (usage.length() > 0) {
-                       result += usage
-                                       + TemplateMessages.getString("TemplateProposal.delimiter");
+                       result += usage + TemplateMessages.getString("TemplateProposal.delimiter");
                }
                result += filename;
                return result;
        }
 
-  /*
-   * @see ICompletionProposal#getImage()
-   */
-  public Image getImage() {
-       switch (fLocation.getType()) {
-         case PHPIdentifierLocation.FUNCTION :
-               return PHPUiImages.get(PHPUiImages.IMG_FUN);
-         case PHPIdentifierLocation.CLASS :
-               return PHPUiImages.get(PHPUiImages.IMG_CLASS);
-         case PHPIdentifierLocation.CONSTRUCTOR :
-               return PHPUiImages.get(PHPUiImages.IMG_CLASS);
-         case PHPIdentifierLocation.METHOD :
+       /*
+        * @see ICompletionProposal#getImage()
+        */
+       public Image getImage() {
+               switch (fLocation.getType()) {
+               case PHPIdentifierLocation.FUNCTION:
+                       return PHPUiImages.get(PHPUiImages.IMG_FUN);
+               case PHPIdentifierLocation.CLASS:
+                       return PHPUiImages.get(PHPUiImages.IMG_CLASS);
+               case PHPIdentifierLocation.CONSTRUCTOR:
+                       return PHPUiImages.get(PHPUiImages.IMG_CLASS);
+               case PHPIdentifierLocation.METHOD:
+                       return PHPUiImages.get(PHPUiImages.IMG_FUN);
+               case PHPIdentifierLocation.DEFINE:
+                       return PHPUiImages.get(PHPUiImages.IMG_DEFINE);
+               case PHPIdentifierLocation.VARIABLE:
+                       return PHPUiImages.get(PHPUiImages.IMG_VAR);
+               case PHPIdentifierLocation.GLOBAL_VARIABLE:
+                       return PHPUiImages.get(PHPUiImages.IMG_VAR);
+               }
                return PHPUiImages.get(PHPUiImages.IMG_FUN);
-         case PHPIdentifierLocation.DEFINE :
-               return PHPUiImages.get(PHPUiImages.IMG_DEFINE);
-         case PHPIdentifierLocation.VARIABLE :
-               return PHPUiImages.get(PHPUiImages.IMG_VAR);
-         case PHPIdentifierLocation.GLOBAL_VARIABLE :
-               return PHPUiImages.get(PHPUiImages.IMG_VAR);
        }
-       return PHPUiImages.get(PHPUiImages.IMG_FUN);
-  } 
-
-  /*
-   * @see IJavaCompletionProposal#getRelevance()
-   */
-  public int getRelevance() {
-
-       if (fContext instanceof JavaContext) {
-         JavaContext context = (JavaContext) fContext;
-         switch (context.getCharacterBeforeStart()) {
-               // high relevance after whitespace
-               case ' ' :
-               case '\r' :
-               case '\n' :
-               case '\t' :
-                 return 80;
-               case '>' : // ->
-               case ':' : // ::
-                 return 85;
-               default :
-                 return 0;
-         }
-       } else {
-         return 80;
+
+       /*
+        * @see IJavaCompletionProposal#getRelevance()
+        */
+       public int getRelevance() {
+
+               if (fContext instanceof JavaContext) {
+                       JavaContext context = (JavaContext) fContext;
+                       switch (context.getCharacterBeforeStart()) {
+                       // high relevance after whitespace
+                       case ' ':
+                       case '\r':
+                       case '\n':
+                       case '\t':
+                               return 80;
+                       case '>': // ->
+                       case ':': // ::
+                               return 85;
+                       default:
+                               return 0;
+                       }
+               } else {
+                       return 80;
+               }
        }
-  }
 
 }
\ No newline at end of file
index 6ebdb62..967ec7c 100644 (file)
@@ -59,9 +59,7 @@ public class IdentifierProposal extends AbstractProposal {
       openErrorDialog(e);
     }
   }
-  /*
-   * @see ICompletionProposal#getAdditionalProposalInfo()
-   */
+
   public String getAdditionalProposalInfo() {
     return textToHTML(fTemplate); // fTemplateBuffer.getString());
   }
index 88e7f30..172078e 100644 (file)
@@ -6,6 +6,7 @@ package net.sourceforge.phpdt.internal.ui.util;
 
 import java.io.File;
 import java.util.List;
+
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpeclipse.ui.overlaypages.ProjectPrefUtil;
 
@@ -20,170 +21,175 @@ import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.PlatformUI;
 
 public class PHPFileUtil {
-//  private static String[] PHP_EXTENSIONS = null;
-
-  public final static String[] SMARTY_EXTENSIONS = { "tpl" };
-
-  public static boolean isPHPFile(IFile file) {
-//    String extension = file.getFileExtension();
-    return isPHPFileName(file.getLocation().toString());
-  }
-
-//  public final static String getFileExtension(String name) {
-//    int index = name.lastIndexOf('.');
-//    if (index == -1)
-//      return null;
-//    if (index == (name.length() - 1))
-//      return null; //$NON-NLS-1$
-//    return name.substring(index + 1);
-//  }
-
-  /**
-   * Returns true iff str.toLowerCase().endsWith(".php") implementation is not creating extra strings.
-   */
-  public final static boolean isPHPFileName(String name) {
-
-       //avoid handling a file without base name, e.g. ".php", which is a valid Eclipse resource name
-       File file=new File(name);
-       if (file.getName().startsWith(".")) {
-               return false;
+       // private static String[] PHP_EXTENSIONS = null;
+
+       public final static String[] SMARTY_EXTENSIONS = { "tpl" };
+
+       public static boolean isPHPFile(IFile file) {
+               // String extension = file.getFileExtension();
+               return isPHPFileName(file.getLocation().toString());
        }
-       IWorkbench workbench = PlatformUI.getWorkbench();
-       IEditorRegistry registry = workbench.getEditorRegistry();
-       IEditorDescriptor[] descriptors = registry.getEditors(name);
 
-       for (int i = 0; i < descriptors.length; i++) {
+       // public final static String getFileExtension(String name) {
+       // int index = name.lastIndexOf('.');
+       // if (index == -1)
+       // return null;
+       // if (index == (name.length() - 1))
+       // return null; //$NON-NLS-1$
+       // return name.substring(index + 1);
+       // }
+
+       /**
+        * Returns true iff str.toLowerCase().endsWith(".php") implementation is not
+        * creating extra strings.
+        */
+       public final static boolean isPHPFileName(String name) {
+
+               // avoid handling a file without base name, e.g. ".php", which is a valid
+               // Eclipse resource name
+               File file = new File(name);
+               if (file.getName().startsWith(".")) {
+                       return false;
+               }
+               IWorkbench workbench = PlatformUI.getWorkbench();
+               IEditorRegistry registry = workbench.getEditorRegistry();
+               IEditorDescriptor[] descriptors = registry.getEditors(name);
+
+               for (int i = 0; i < descriptors.length; i++) {
                        if (descriptors[i].getId().equals(PHPeclipsePlugin.EDITOR_ID)) {
                                return true;
                        }
                }
-//    String extension = getFileExtension(name);
-//    if (extension == null) {
-//      return false;
-//    }
-//    extension = extension.toLowerCase();
-//    PHP_EXTENSIONS = getExtensions();
-//    if (PHP_EXTENSIONS == null) {
-//      return false;
-//    }
-//    for (int i = 0; i < PHP_EXTENSIONS.length; i++) {
-//      if (extension.equals(PHP_EXTENSIONS[i])) {
-//        return true;
-//      }
-//    }
-    return false;
-  }
-
-  /**
-   * Returns true iff the file extension is a valid PHP Unit name implementation is not creating extra strings.
-   */
-  public final static boolean isValidPHPUnitName(String filename) {
-    return PHPFileUtil.isPHPFileName(filename);
-  }
-
-  /**
-   * @return Returns the PHP extensions.
-   */
-//  public static String[] getExtensions() {
-//    if (PHP_EXTENSIONS == null) {
-//      ArrayList list = new ArrayList();
-//      final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
-//      String extensions = store.getString(PHPeclipsePlugin.PHP_EXTENSION_PREFS);
-//      extensions = extensions.trim();
-//      if (extensions.length() != 0) {
-//        StringTokenizer tokenizer = new StringTokenizer(extensions, " ,;:/-|");
-//        String token;
-//        while (tokenizer.hasMoreTokens()) {
-//          token = tokenizer.nextToken();
-//          if (token != null && token.length() >= 1) {
-//            list.add(token);
-//          }
-//        }
-//        if (list.size() != 0) {
-//          PHP_EXTENSIONS = new String[list.size()];
-//          for (int i = 0; i < list.size(); i++) {
-//            PHP_EXTENSIONS[i] = (String) list.get(i);
-//          }
-//        }
-//      }
-//    }
-//    return PHP_EXTENSIONS;
-//  }
-
-  /**
-   * @param php_extensions
-   *          The PHP extensions to set.
-   */
-//  public static void setExtensions(String[] php_extensions) {
-//    PHP_EXTENSIONS = php_extensions;
-//  }
-
-  /**
-   * Creata the file for the given absolute file path
-   *
-   * @param absoluteFilePath
-   * @param project
-   * @return the file for the given absolute file path or <code>null</code> if no existing file can be found
-   */
-  public static IFile createFile(IPath absoluteFilePath, IProject project) {
-    if (absoluteFilePath == null || project == null) {
-      return null;
-    }
-
-    String projectPath = project.getLocation().toString();
-    String filePath = absoluteFilePath.toString().substring(projectPath.length() + 1);
-    return project.getFile(filePath);
-
-  }
-
-  /**
-   * Determine the path of an include name string
-   *
-   * @param includeNameString
-   * @param resource
-   * @param project
-   * @return the path for the given include filename or <code>null</code> if no existing file can be found
-   */
-  public static IPath determineFilePath(String includeNameString, IResource resource, IProject project) {
-    IPath documentRootPath = ProjectPrefUtil.getDocumentRoot(project);
-    IPath resourcePath = resource.getProjectRelativePath();
-
-    File file = null;
-    IPath path = null;
-    path = documentRootPath.append(includeNameString);
-    file = path.toFile();
-    if (file.exists()) {
-      return path;
-    }
-
-    if (includeNameString.startsWith("../")) {
-      path = project.getLocation().append(resourcePath.removeLastSegments(1));
-      path = path.append(includeNameString);
-      file = path.toFile();
-      if (file.exists()) {
-        return path;
-      }
-    }
-
-    // includeNameString contains no path separator
-    path = project.getLocation().append(resourcePath.removeLastSegments(1));
-    path = path.append(includeNameString);
-    file = path.toFile();
-    if (file.exists()) {
-      return path;
-    }
-    //    }
-
-    List includePaths = ProjectPrefUtil.getIncludePaths(project);
-    if (includePaths.size() > 0) {
-      for (int i = 0; i < includePaths.size(); i++) {
-        path = new Path(includePaths.get(i).toString()).append(includeNameString);
-        file = path.toFile();
-        if (file.exists()) {
-          return path;
-        }
-      }
-    }
-    return null;
-  }
+               // String extension = getFileExtension(name);
+               // if (extension == null) {
+               // return false;
+               // }
+               // extension = extension.toLowerCase();
+               // PHP_EXTENSIONS = getExtensions();
+               // if (PHP_EXTENSIONS == null) {
+               // return false;
+               // }
+               // for (int i = 0; i < PHP_EXTENSIONS.length; i++) {
+               // if (extension.equals(PHP_EXTENSIONS[i])) {
+               // return true;
+               // }
+               // }
+               return false;
+       }
+
+       /**
+        * Returns true iff the file extension is a valid PHP Unit name implementation
+        * is not creating extra strings.
+        */
+       public final static boolean isValidPHPUnitName(String filename) {
+               return PHPFileUtil.isPHPFileName(filename);
+       }
+
+       /**
+        * @return Returns the PHP extensions.
+        */
+       // public static String[] getExtensions() {
+       // if (PHP_EXTENSIONS == null) {
+       // ArrayList list = new ArrayList();
+       // final IPreferenceStore store =
+       // PHPeclipsePlugin.getDefault().getPreferenceStore();
+       // String extensions = store.getString(PHPeclipsePlugin.PHP_EXTENSION_PREFS);
+       // extensions = extensions.trim();
+       // if (extensions.length() != 0) {
+       // StringTokenizer tokenizer = new StringTokenizer(extensions, " ,;:/-|");
+       // String token;
+       // while (tokenizer.hasMoreTokens()) {
+       // token = tokenizer.nextToken();
+       // if (token != null && token.length() >= 1) {
+       // list.add(token);
+       // }
+       // }
+       // if (list.size() != 0) {
+       // PHP_EXTENSIONS = new String[list.size()];
+       // for (int i = 0; i < list.size(); i++) {
+       // PHP_EXTENSIONS[i] = (String) list.get(i);
+       // }
+       // }
+       // }
+       // }
+       // return PHP_EXTENSIONS;
+       // }
+       /**
+        * @param php_extensions
+        *          The PHP extensions to set.
+        */
+       // public static void setExtensions(String[] php_extensions) {
+       // PHP_EXTENSIONS = php_extensions;
+       // }
+       /**
+        * Creata the file for the given absolute file path
+        *
+        * @param absoluteFilePath
+        * @param project
+        * @return the file for the given absolute file path or <code>null</code> if
+        *         no existing file can be found
+        */
+       public static IFile createFile(IPath absoluteFilePath, IProject project) {
+               if (absoluteFilePath == null || project == null) {
+                       return null;
+               }
+
+               String projectPath = project.getLocation().toString();
+               String filePath = absoluteFilePath.toString().substring(projectPath.length() + 1);
+               return project.getFile(filePath);
+
+       }
+
+       /**
+        * Determine the path of an include name string
+        *
+        * @param includeNameString
+        * @param resource
+        * @param project
+        * @return the path for the given include filename or <code>null</code> if
+        *         no existing file can be found
+        */
+       public static IPath determineFilePath(String includeNameString, IResource resource, IProject project) {
+               IPath documentRootPath = ProjectPrefUtil.getDocumentRoot(project);
+               IPath resourcePath = resource.getProjectRelativePath();
+
+               File file = null;
+               IPath path = null;
+               path = documentRootPath.append(includeNameString);
+               file = path.toFile();
+               if (file.exists()) {
+                       return path;
+               }
+
+               if (includeNameString.startsWith("../")) {
+                       path = project.getLocation().append(resourcePath.removeLastSegments(1));
+                       path = path.append(includeNameString);
+                       file = path.toFile();
+                       if (file.exists()) {
+                               return path;
+                       }
+               }
+
+               // includeNameString contains no path separator
+               path = project.getLocation().append(resourcePath.removeLastSegments(1));
+               path = path.append(includeNameString);
+               file = path.toFile();
+               if (file.exists()) {
+                       return path;
+               }
+               // }
+
+               List includePaths = ProjectPrefUtil.getIncludePaths(project);
+               if (includePaths.size() > 0) {
+                       for (int i = 0; i < includePaths.size(); i++) {
+                               path = new Path(includePaths.get(i).toString()).append(includeNameString);
+                               file = path.toFile();
+                               if (file.exists()) {
+                                       return path;
+                               }
+                       }
+               }
+               return null;
+       }
+
 }
\ No newline at end of file