X-Git-Url: http://git.phpeclipse.com
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPExternalParserAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPExternalParserAction.java
index a7f1dc0..6daa442 100644
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPExternalParserAction.java
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPExternalParserAction.java
@@ -11,31 +11,19 @@ Contributors:
**********************************************************************/
package net.sourceforge.phpeclipse.actions;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Hashtable;
import java.util.Iterator;
-import java.util.StringTokenizer;
-import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.texteditor.MarkerUtilities;
+
public class PHPExternalParserAction implements IObjectActionDelegate {
- private static final String PARSE_ERROR = "Parse error"; //$NON-NLS-1$
- private static final String WARNING = "Warning"; //$NON-NLS-1$
private IWorkbenchPart workbenchPart;
/**
@@ -68,9 +56,7 @@ public class PHPExternalParserAction implements IObjectActionDelegate {
StructuredSelection selection = null;
selection = (StructuredSelection) selectionProvider.getSelection();
- IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
-
- Shell shell = null;
+ //Shell shell = null;
Iterator iterator = null;
iterator = selection.iterator();
while (iterator.hasNext()) {
@@ -83,26 +69,11 @@ public class PHPExternalParserAction implements IObjectActionDelegate {
// check if it's a file resource
switch (resource.getType()) {
-
+
case IResource.FILE :
// single file:
- IFile file = (IFile) resource;
- IPath path = file.getFullPath();
-
- String filename = file.getLocation().toString();
-
- String[] arguments = { filename };
- MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.EXTERNAL_PARSER_PREF));
- String command = form.format(arguments);
-
- String parserResult = PHPStartApacheAction.execute(command, "External parser: ");
-
- try {
- // parse the buffer to find the errors and warnings
- createMarkers(parserResult, file);
- } catch (CoreException e) {
- }
-
+ ExternalPHPParser parser = new ExternalPHPParser((IFile)resource);
+ parser.phpExternalParse();
}
}
}
@@ -114,70 +85,4 @@ public class PHPExternalParserAction implements IObjectActionDelegate {
public void selectionChanged(IAction action, ISelection selection) {
}
- /**
- * Create markers according to the compiler output
- */
- protected void createMarkers(String output, IFile file) throws CoreException {
- // delete all markers
- file.deleteMarkers(IMarker.PROBLEM, false, 0);
-
- int indx = 0;
- int brIndx = 0;
- boolean flag = true;
- while ((brIndx = output.indexOf("
", indx)) != -1) {
- // newer php error output (tested with 4.2.3)
- scanLine(output, file, indx, brIndx);
- indx = brIndx + 6;
- flag = false;
- }
- if (flag) {
- while ((brIndx = output.indexOf("
", indx)) != -1) {
- // older php error output (tested with 4.2.3)
- scanLine(output, file, indx, brIndx);
- indx = brIndx + 4;
- }
- }
- }
- private void scanLine(String output, IFile file, int indx, int brIndx) throws CoreException {
- String current;
- String outLineNumberString;
- StringBuffer lineNumberBuffer = new StringBuffer(10);
- char ch;
- current = output.substring(indx, brIndx);
-
- if (current.indexOf(WARNING) != -1 || current.indexOf(PARSE_ERROR) != -1) {
- int onLine = current.indexOf("on line ");
- if (onLine != -1) {
- lineNumberBuffer.delete(0, lineNumberBuffer.length());
- for (int i = onLine; i < current.length(); i++) {
- ch = current.charAt(i);
- if ('0' <= ch && '9' >= ch) {
- lineNumberBuffer.append(ch);
- }
- }
-
- // String line = current.substring(current.indexOf(fullPath) + fullPath.length(), current.length());
- // String errorsLocation = line.substring(1, line.indexOf(":") - 1); //$NON-NLS-1$
- // String message = line.substring(line.indexOf(":") + 2, line.length() - 1); //$NON-NLS-1$
-
- int lineNumber = Integer.parseInt(lineNumberBuffer.toString());
-
- Hashtable attributes = new Hashtable();
-
- current = current.replaceAll("\n", "");
- current = current.replaceAll("", "");
- current = current.replaceAll("", "");
- MarkerUtilities.setMessage(attributes, current);
-
- if (current.indexOf(PARSE_ERROR) != -1)
- attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
- else if (current.indexOf(WARNING) != -1)
- attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
- else
- attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
- MarkerUtilities.setLineNumber(attributes, lineNumber);
- MarkerUtilities.createMarker(file, attributes, IMarker.PROBLEM);
- }
- }
- }
}