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 ee76b81..bdf9f88 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParserSuperclass.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParserSuperclass.java @@ -9,6 +9,7 @@ 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; @@ -21,6 +22,9 @@ public abstract class PHPParserSuperclass { // strings for external parser call private static final String PARSE_ERROR_STRING = "Parse error"; //$NON-NLS-1$ private static final String PARSE_WARNING_STRING = "Warning"; //$NON-NLS-1$ + public static final int ERROR = 2; + public static final int WARNING = 1; + public static final int INFO = 0; /** * Call the php parse command ( php -l -f <filename> ) @@ -121,4 +125,32 @@ public abstract class PHPParserSuperclass { public abstract void setFileToParse(IFile fileToParse); public abstract void parse(String s) throws CoreException; + + public static void setMarker( + IFile file, + String message, + int charStart, + int charEnd, + int errorLevel) + throws CoreException { + if (file != null) { + Hashtable attributes = new Hashtable(); + MarkerUtilities.setMessage(attributes, message); + switch (errorLevel) { + case Parser.ERROR : + attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR)); + break; + case Parser.WARNING : + attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING)); + break; + case Parser.INFO : + attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO)); + break; + } + MarkerUtilities.setCharStart(attributes, charStart); + MarkerUtilities.setCharEnd(attributes, charEnd); + // setLineNumber(attributes, lineNumber); + MarkerUtilities.createMarker(file, attributes, IMarker.PROBLEM); + } + } }