// single file:
IFile file = (IFile) resource;
String localhostURL;
-// IPath path = file.getFullPath();
-//
-// String localhostURL = file.getLocation().toString();
-// String lowerCaseFileName = localhostURL.toLowerCase();
-// // fileName = "http://localhost"+fileName.replaceAll("c:", "");
-// String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF);
-// documentRoot = documentRoot.replace('\\', '/');
-// documentRoot = documentRoot.toLowerCase();
-//
-// if (lowerCaseFileName.startsWith(documentRoot)) {
-// localhostURL = localhostURL.substring(documentRoot.length());
-// } else {
-// MessageDialog.openInformation(shell, "Wrong DocumentRoot", "Adjust DocumentRoot: " + documentRoot);
-// return;
-// }
-//
-// localhostURL = store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL.replaceAll(documentRoot, "");
-
if ((localhostURL=getLocalhostURL(store, (IFile) resource)) == null) {
MessageDialog.openInformation(shell, "Couldn't create localhost URL", "Please configure your localhost and documentRoot");
return;
String localhostURL = file.getLocation().toString();
String lowerCaseFileName = localhostURL.toLowerCase();
- // fileName = "http://localhost"+fileName.replaceAll("c:", "");
String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF);
documentRoot = documentRoot.replace('\\', '/');
documentRoot = documentRoot.toLowerCase();
return null;
}
- return store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL.replaceAll(documentRoot, "");
+ return store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL;
}
package test;
+import java.text.MessageFormat;
+import java.util.Hashtable;
+
+import net.sourceforge.phpdt.internal.compiler.parser.PHPOutlineInfo;
+import net.sourceforge.phpdt.internal.ui.util.StringUtil;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+import net.sourceforge.phpeclipse.actions.PHPStartApacheAction;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.texteditor.MarkerUtilities;
-import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-import net.sourceforge.phpeclipse.actions.PHPStartApacheAction;
-import net.sourceforge.phpdt.internal.compiler.parser.PHPOutlineInfo;
-
-import java.text.MessageFormat;
-import java.util.Hashtable;
/**
* The superclass for our PHP parsers.
final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
final String filename = file.getLocation().toString();
- final String[] arguments = {filename};
- final MessageFormat form =
- new MessageFormat(store.getString(PHPeclipsePlugin.EXTERNAL_PARSER_PREF));
+ final String[] arguments = { filename };
+ final MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.EXTERNAL_PARSER_PREF));
final String command = form.format(arguments);
- final String parserResult =
- PHPStartApacheAction.getParserOutput(command, "External parser: ");
+ final String parserResult = PHPStartApacheAction.getParserOutput(command, "External parser: ");
try {
// parse the buffer to find the errors and warnings
* @param output the external parser output
* @param file the file that was parsed.
*/
- protected static void createMarkers(final String output, final IFile file)
- throws CoreException {
+ protected static void createMarkers(final String output, final IFile file) throws CoreException {
// delete all markers
file.deleteMarkers(IMarker.PROBLEM, false, 0);
}
}
- private static void scanLine(final String output, final IFile file, final int indx, final int brIndx)
- throws CoreException {
+ private static void scanLine(final String output, final IFile file, final int indx, final int brIndx) throws CoreException {
String current;
// String outLineNumberString; never used
final StringBuffer lineNumberBuffer = new StringBuffer(10);
char ch;
current = output.substring(indx, brIndx);
- if (current.indexOf(PARSE_WARNING_STRING) != -1
- || current.indexOf(PARSE_ERROR_STRING) != -1) {
+ if (current.indexOf(PARSE_WARNING_STRING) != -1 || current.indexOf(PARSE_ERROR_STRING) != -1) {
final int onLine = current.indexOf("on line <b>");
if (onLine != -1) {
lineNumberBuffer.delete(0, lineNumberBuffer.length());
final Hashtable attributes = new Hashtable();
- current = current.replaceAll("\n", "");
- current = current.replaceAll("<b>", "");
- current = current.replaceAll("</b>", "");
+ current = StringUtil.replaceAll(current, "\n", "");
+ current = StringUtil.replaceAll(current, "<b>", "");
+ current = StringUtil.replaceAll(current, "</b>", "");
MarkerUtilities.setMessage(attributes, current);
if (current.indexOf(PARSE_ERROR_STRING) != -1)
attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
else if (current.indexOf(PARSE_WARNING_STRING) != -1)
- attributes.put(
- IMarker.SEVERITY,
- new Integer(IMarker.SEVERITY_WARNING));
+ attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
else
attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
MarkerUtilities.setLineNumber(attributes, lineNumber);
* {@link PHPParserSuperclass#INFO},{@link PHPParserSuperclass#WARNING}),{@link PHPParserSuperclass#TASK})
* @throws CoreException an exception throwed by the MarkerUtilities
*/
- public static void setMarker(final IFile file,
- final String message,
- final int charStart,
- final int charEnd,
- final int errorLevel)
- throws CoreException {
+ public static void setMarker(
+ final IFile file,
+ final String message,
+ final int charStart,
+ final int charEnd,
+ final int errorLevel)
+ throws CoreException {
if (file != null) {
final Hashtable attributes = new Hashtable();
MarkerUtilities.setMessage(attributes, message);
switch (errorLevel) {
- case ERROR:
+ case ERROR :
attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
break;
- case WARNING:
+ case WARNING :
attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
break;
- case INFO:
+ case INFO :
attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
break;
- case TASK:
+ case TASK :
attributes.put(IMarker.SEVERITY, new Integer(IMarker.TASK));
break;
}
* {@link PHPParserSuperclass#INFO},{@link PHPParserSuperclass#WARNING})
* @throws CoreException an exception throwed by the MarkerUtilities
*/
- public static void setMarker(final IFile file,
- final String message,
- final int line,
- final int errorLevel,
- final String location)
- throws CoreException {
+ public static void setMarker(final IFile file, final String message, final int line, final int errorLevel, final String location)
+ throws CoreException {
if (file != null) {
String markerKind = IMarker.PROBLEM;
final Hashtable attributes = new Hashtable();
MarkerUtilities.setMessage(attributes, message);
switch (errorLevel) {
- case ERROR:
+ case ERROR :
attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
break;
- case WARNING:
+ case WARNING :
attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
break;
- case INFO:
+ case INFO :
attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
break;
- case TASK:
+ case TASK :
attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
markerKind = IMarker.TASK;
break;
* @param location the location of the error
* @throws CoreException an exception throwed by the MarkerUtilities
*/
- public static void setMarker(final IFile file,
- final String message,
- final int charStart,
- final int charEnd,
- final int errorLevel,
- final String location)
- throws CoreException {
+ public static void setMarker(
+ final IFile file,
+ final String message,
+ final int charStart,
+ final int charEnd,
+ final int errorLevel,
+ final String location)
+ throws CoreException {
if (file != null) {
final Hashtable attributes = new Hashtable();
MarkerUtilities.setMessage(attributes, message);
switch (errorLevel) {
- case ERROR:
+ case ERROR :
attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
break;
- case WARNING:
+ case WARNING :
attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
break;
- case INFO:
+ case INFO :
attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
break;
- case TASK:
+ case TASK :
attributes.put(IMarker.SEVERITY, new Integer(IMarker.TASK));
break;
}