X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/test/PHPParserSuperclass.java b/net.sourceforge.phpeclipse/src/test/PHPParserSuperclass.java index c500582..3962da9 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParserSuperclass.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParserSuperclass.java @@ -8,7 +8,6 @@ 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 net.sourceforge.phpdt.internal.compiler.parser.Parser; import java.text.MessageFormat; import java.util.Hashtable; @@ -24,6 +23,7 @@ public abstract class PHPParserSuperclass { public static final int ERROR = 2; public static final int WARNING = 1; public static final int INFO = 0; + public static final int TASK = 3; /** * Call the php parse command ( php -l -f <filename> ) @@ -32,17 +32,17 @@ public abstract class PHPParserSuperclass { */ public static void phpExternalParse(final IFile file) { //IFile file = (IFile) resource; - // final IPath path = file.getFullPath(); + // final IPath path = file.getFullPath(); final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); final String filename = file.getLocation().toString(); - final String[] arguments = { filename }; + final String[] arguments = {filename}; final MessageFormat form = - new MessageFormat(store.getString(PHPeclipsePlugin.EXTERNAL_PARSER_PREF)); + new MessageFormat(store.getString(PHPeclipsePlugin.EXTERNAL_PARSER_PREF)); final String command = form.format(arguments); final String parserResult = - PHPStartApacheAction.getParserOutput(command, "External parser: "); + PHPStartApacheAction.getParserOutput(command, "External parser: "); try { // parse the buffer to find the errors and warnings @@ -53,9 +53,11 @@ public abstract class PHPParserSuperclass { /** * Create markers according to the external parser output. + * @param output the external parser output + * @param file the file that was parsed. */ - private 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); @@ -78,15 +80,15 @@ public abstract class PHPParserSuperclass { } private static void scanLine(final String output, final IFile file, final int indx, final int brIndx) - throws CoreException { + throws CoreException { String current; - // String outLineNumberString; never used + // 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) { + || current.indexOf(PARSE_ERROR_STRING) != -1) { final int onLine = current.indexOf("on line "); if (onLine != -1) { lineNumberBuffer.delete(0, lineNumberBuffer.length()); @@ -110,8 +112,8 @@ public abstract class PHPParserSuperclass { 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)); + IMarker.SEVERITY, + new Integer(IMarker.SEVERITY_WARNING)); else attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO)); MarkerUtilities.setLineNumber(attributes, lineNumber); @@ -148,7 +150,7 @@ public abstract class PHPParserSuperclass { * @param charStart the starting character * @param charEnd the end character * @param errorLevel the error level ({@link PHPParserSuperclass#ERROR}, - * {@link PHPParserSuperclass#INFO},{@link PHPParserSuperclass#WARNING}) + * {@link PHPParserSuperclass#INFO},{@link PHPParserSuperclass#WARNING}),{@link PHPParserSuperclass#TASK}) * @throws CoreException an exception throwed by the MarkerUtilities */ public static void setMarker(final IFile file, @@ -156,20 +158,23 @@ public abstract class PHPParserSuperclass { final int charStart, final int charEnd, final int errorLevel) - throws CoreException { + throws CoreException { if (file != null) { final Hashtable attributes = new Hashtable(); MarkerUtilities.setMessage(attributes, message); switch (errorLevel) { - case Parser.ERROR : + case ERROR: attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR)); break; - case Parser.WARNING : + case WARNING: attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING)); break; - case Parser.INFO : + case INFO: attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO)); break; + case TASK: + attributes.put(IMarker.SEVERITY, new Integer(IMarker.TASK)); + break; } MarkerUtilities.setCharStart(attributes, charStart); MarkerUtilities.setCharEnd(attributes, charEnd); @@ -181,6 +186,46 @@ public abstract class PHPParserSuperclass { * This will set a marker. * @param file the file that generated the marker * @param message the message + * @param line the line number + * @param errorLevel the error level ({@link PHPParserSuperclass#ERROR}, + * {@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 { + if (file != null) { + String markerKind = IMarker.PROBLEM; + final Hashtable attributes = new Hashtable(); + MarkerUtilities.setMessage(attributes, message); + switch (errorLevel) { + case ERROR: + attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR)); + break; + case WARNING: + attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING)); + break; + case INFO: + attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO)); + break; + case TASK: + attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO)); + markerKind = IMarker.TASK; + break; + } + attributes.put(IMarker.LOCATION, location); + MarkerUtilities.setLineNumber(attributes, line); + MarkerUtilities.createMarker(file, attributes, markerKind); + } + } + + /** + * This will set a marker. + * @param file the file that generated the marker + * @param message the message * @param charStart the starting character * @param charEnd the end character * @param errorLevel the error level ({@link PHPParserSuperclass#ERROR}, @@ -194,22 +239,25 @@ public abstract class PHPParserSuperclass { final int charEnd, final int errorLevel, final String location) - throws CoreException { + throws CoreException { if (file != null) { final Hashtable attributes = new Hashtable(); MarkerUtilities.setMessage(attributes, message); switch (errorLevel) { - case Parser.ERROR : + case ERROR: attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR)); break; - case Parser.WARNING : + case WARNING: attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING)); break; - case Parser.INFO : + case INFO: attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO)); break; + case TASK: + attributes.put(IMarker.SEVERITY, new Integer(IMarker.TASK)); + break; } - attributes.put(IMarker.LOCATION,location); + attributes.put(IMarker.LOCATION, location); MarkerUtilities.setCharStart(attributes, charStart); MarkerUtilities.setCharEnd(attributes, charEnd); MarkerUtilities.createMarker(file, attributes, IMarker.PROBLEM);