1 package net.sourceforge.phpdt.externaltools.variable;
3 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
5 import org.eclipse.core.resources.IResource;
6 import org.eclipse.core.runtime.IPath;
7 import org.eclipse.jface.preference.IPreferenceStore;
10 * Expands a variable into the last opened PHP file
12 * This class is not intended to be extended by clients.
15 public class LastPHPUrlExpander extends ResourceExpander { //implements IVariableTextExpander {
20 public LastPHPUrlExpander() {
25 * Returns a string representation of the path to a file or directory
26 * for the given variable tag and value or <code>null</code>.
28 * @see IVariableTextExpander#getText(String, String, ExpandVariableContext)
30 public String getText(String varTag, String varValue, ExpandVariableContext context) {
31 IPath path = getPath(varTag, varValue, context);
33 IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
34 String localhostURL = path.toString();
35 String lowerCaseFileName = localhostURL.toLowerCase();
36 // fileName = "http://localhost"+fileName.replaceAll("c:", "");
37 String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF);
38 documentRoot = documentRoot.replace('\\', '/');
39 documentRoot = documentRoot.toLowerCase();
41 if (lowerCaseFileName.startsWith(documentRoot)) {
42 localhostURL = localhostURL.substring(documentRoot.length());
47 return store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL.replaceAll(documentRoot, "");