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 687cbf4..c500582 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParserSuperclass.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParserSuperclass.java @@ -2,7 +2,6 @@ package test; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; -import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.ui.texteditor.MarkerUtilities; @@ -28,20 +27,21 @@ public abstract class PHPParserSuperclass { /** * Call the php parse command ( php -l -f <filename> ) - * and create markers according to the external parser output + * and create markers according to the external parser output. + * @param file the file that will be parsed */ - public static void phpExternalParse(IFile file) { + public static void phpExternalParse(final IFile file) { //IFile file = (IFile) resource; - IPath path = file.getFullPath(); - IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); - String filename = file.getLocation().toString(); + // final IPath path = file.getFullPath(); + final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); + final String filename = file.getLocation().toString(); - String[] arguments = { filename }; - MessageFormat form = + final String[] arguments = { filename }; + final MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.EXTERNAL_PARSER_PREF)); - String command = form.format(arguments); + final String command = form.format(arguments); - String parserResult = + final String parserResult = PHPStartApacheAction.getParserOutput(command, "External parser: "); try { @@ -52,15 +52,15 @@ public abstract class PHPParserSuperclass { } /** - * Create markers according to the external parser output + * Create markers according to the external parser output. */ - private static void createMarkers(String output, IFile file) + private static void createMarkers(final String output, final IFile file) throws CoreException { // delete all markers file.deleteMarkers(IMarker.PROBLEM, false, 0); int indx = 0; - int brIndx = 0; + int brIndx; boolean flag = true; while ((brIndx = output.indexOf("
", indx)) != -1) { // newer php error output (tested with 4.2.3) @@ -77,17 +77,17 @@ public abstract class PHPParserSuperclass { } } - private static void scanLine(String output, IFile file, int indx, int brIndx) + private static void scanLine(final String output, final IFile file, final int indx, final int brIndx) throws CoreException { String current; - String outLineNumberString; - StringBuffer lineNumberBuffer = new StringBuffer(10); + // 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) { - int onLine = current.indexOf("on line "); + final int onLine = current.indexOf("on line "); if (onLine != -1) { lineNumberBuffer.delete(0, lineNumberBuffer.length()); for (int i = onLine; i < current.length(); i++) { @@ -97,9 +97,9 @@ public abstract class PHPParserSuperclass { } } - int lineNumber = Integer.parseInt(lineNumberBuffer.toString()); + final int lineNumber = Integer.parseInt(lineNumberBuffer.toString()); - Hashtable attributes = new Hashtable(); + final Hashtable attributes = new Hashtable(); current = current.replaceAll("\n", ""); current = current.replaceAll("", ""); @@ -120,21 +120,45 @@ public abstract class PHPParserSuperclass { } } + /** + * This will parse the file and generate the outline info + * @param parent the parent object + * @param s the string that should be parsed + * @return the outline info + */ public abstract PHPOutlineInfo parseInfo(Object parent, String s); + /** + * This will change the file to parse. + * @param fileToParse the file that should be parsed + */ public abstract void setFileToParse(IFile fileToParse); + /** + * This will parse the given string + * @param s the string to parse + * @throws CoreException an exception that can be launched + */ public abstract void parse(String s) throws CoreException; - public static void setMarker( - IFile file, - String message, - int charStart, - int charEnd, - int errorLevel) + /** + * 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}, + * {@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 charStart, + final int charEnd, + final int errorLevel) throws CoreException { if (file != null) { - Hashtable attributes = new Hashtable(); + final Hashtable attributes = new Hashtable(); MarkerUtilities.setMessage(attributes, message); switch (errorLevel) { case Parser.ERROR : @@ -149,20 +173,30 @@ public abstract class PHPParserSuperclass { } MarkerUtilities.setCharStart(attributes, charStart); MarkerUtilities.setCharEnd(attributes, charEnd); - // setLineNumber(attributes, lineNumber); MarkerUtilities.createMarker(file, attributes, IMarker.PROBLEM); } } - public static void setMarker(IFile file, - String message, - int charStart, - int charEnd, - int errorLevel, - String location) + /** + * 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}, + * {@link PHPParserSuperclass#INFO},{@link PHPParserSuperclass#WARNING}) + * @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 { if (file != null) { - Hashtable attributes = new Hashtable(); + final Hashtable attributes = new Hashtable(); MarkerUtilities.setMessage(attributes, message); switch (errorLevel) { case Parser.ERROR : @@ -178,7 +212,6 @@ public abstract class PHPParserSuperclass { attributes.put(IMarker.LOCATION,location); MarkerUtilities.setCharStart(attributes, charStart); MarkerUtilities.setCharEnd(attributes, charEnd); - // setLineNumber(attributes, lineNumber); MarkerUtilities.createMarker(file, attributes, IMarker.PROBLEM); } }