Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Builder/erroparser refactoring and bug fixes.

2002-10-23 Alain Magloire

        * src/.../core/resource/ACBuilder.java (mapMarkerSeverity):
        New method to convert IMarkerGenerator to IMarker.
        * src/.../core/ErrorParserManager.java: New file.
        * src/.../core/IErrorParser.java: New file.
        * src/.../core/IMarkerGenerator.java: Define a set of new fields:
         IMarkerGenerator.SEVERITY_INFO
         IMarkerGenerator.SEVERITY_WARNING
         IMarkerGenerator.SEVERITY_ERROR_RESOURCE
         IMarkerGenerator.SEVERITY_ERROR_BUILD
         IMarkerGenerator.SEVERITY_INFO
        * src/.../core/erroparsers: Removed
        * src/.../core/erroparsers/ErrorParserManager.java: Removed
        * src/.../core/erroparsers/IErrorParser.java: Removed
        * src/.../internal/core/CBuilder.java (invokeMake): new field
        fatalBuild to check return of ErrorParserManager.reporProblems().
        * src/.../internal/core/ProcessClosure.java (isAlive): the test
        shoule be an || the errorstream __or__ the outputstream thread
        is alive.
        * src/.../internal/errorparsers/GASErrorParser.java (processLine):
        * src/.../internal/errorparsers/GCCErrorParser.java (processLine):
        * src/.../internal/errorparsers/GLDErrorParser.java (processLine):
        * src/.../internal/errorparsers/VCErrorParser.java (processLine):
        Use the IMarkerGenerator fields.
        * src/.../internal/errorparsers/MakeErrorParser.java (processLine):
        Catch GNU Make build errors, something like:
        "make: *** No targets specified and no makefile found.  Stop."


Index: org/eclipse/cdt/core/ErrorParserManager.java
===================================================================
RCS file: org/eclipse/cdt/core/ErrorParserManager.java
diff -N org/eclipse/cdt/core/ErrorParserManager.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ org/eclipse/cdt/core/ErrorParserManager.java	23 Oct 2002 18:18:41 -0000
@@ -0,0 +1,407 @@
+package org.eclipse.cdt.core;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import org.eclipse.cdt.core.resources.ACBuilder;
+import org.eclipse.cdt.internal.errorparsers.GASErrorParser;
+import org.eclipse.cdt.internal.errorparsers.GCCErrorParser;
+import org.eclipse.cdt.internal.errorparsers.GLDErrorParser;
+import org.eclipse.cdt.internal.errorparsers.MakeErrorParser;
+import org.eclipse.cdt.internal.errorparsers.VCErrorParser;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+public class ErrorParserManager extends OutputStream {
+	private int nOpens;
+
+	private static String PREF_ERROR_PARSER = "errorOutputParser";
+
+	private IProject fProject;
+	private IMarkerGenerator fMarkerGenerator;
+	private Map fFilesInProject;
+	private List fNameConflicts;
+
+	private ArrayList fErrorParsers;
+	private ArrayList fErrors;
+
+	private Vector fDirectoryStack;
+	private IPath fBaseDirectory;
+
+	private String previousLine;
+	private OutputStream outputStream;
+	private StringBuffer currentLine = new StringBuffer();
+
+	public ErrorParserManager(ACBuilder builder) {
+		this(builder.getProject(), builder);
+	}
+
+	public ErrorParserManager(IProject project, IMarkerGenerator markerGenerator) {
+		fProject = project;
+		fErrorParsers = new ArrayList();
+		fMarkerGenerator = markerGenerator;
+		readPreferences();
+		initParser();
+	}
+
+	private void initParser() {
+		fFilesInProject = new HashMap();
+		fNameConflicts = new ArrayList();
+		fDirectoryStack = new Vector();
+		fErrors = new ArrayList();
+
+		// prepare file lists
+		fFilesInProject.clear();
+		fNameConflicts.clear();
+
+		List collectedFiles = new ArrayList();
+		fBaseDirectory = fProject.getLocation();
+		collectFiles(fProject, collectedFiles);
+
+		for (int i = 0; i < collectedFiles.size(); i++) {
+			IFile curr = (IFile) collectedFiles.get(i);
+			Object existing = fFilesInProject.put(curr.getName(), curr);
+			if (existing != null) {
+				fNameConflicts.add(curr.getName());
+			}
+		}
+	}
+
+	public IPath getWorkingDirectory() {
+		if (fDirectoryStack.size() != 0) {
+			return (IPath) fDirectoryStack.lastElement();
+		}
+		return new Path("");
+	}
+
+	public void pushDirectory(IPath dir) {
+		if (dir != null) {
+			IPath pwd = null;
+			if (fBaseDirectory.isPrefixOf(dir)) {
+				int segments = fBaseDirectory.matchingFirstSegments(dir);
+				pwd = dir.removeFirstSegments(segments);
+			}
+			else {
+				pwd = dir;
+			}
+			fDirectoryStack.addElement(pwd);
+		}
+	}
+
+	public IPath popDirectory() {
+		int i = fDirectoryStack.size();
+		IPath dir = (IPath) fDirectoryStack.lastElement();
+		if (i != 0) {
+			fDirectoryStack.removeElementAt(i - 1);
+		}
+		return dir;
+	}
+
+	public int getDirectoryLevel() {
+		return fDirectoryStack.size();
+	}
+
+	protected void addParser(IErrorParser parser) {
+		fErrorParsers.add(parser);
+	}
+
+	private void readPreferences() {
+		fErrorParsers.clear();
+		String parserNames = CCorePlugin.getDefault().getPluginPreferences().getString(PREF_ERROR_PARSER);
+		if (parserNames != null && parserNames.length() > 0) {
+			StringTokenizer tok = new StringTokenizer(parserNames, ";");
+			while (tok.hasMoreElements()) {
+				String clName = tok.nextToken();
+				try {
+					IErrorParser parser = (IErrorParser) getClass().forName(clName).newInstance();
+					fErrorParsers.add(parser);
+				}
+				catch (ClassNotFoundException e) {
+					// not found
+					CCorePlugin.log(e);
+				}
+				catch (InstantiationException e) {
+					CCorePlugin.log(e);
+				}
+				catch (IllegalAccessException e) {
+					CCorePlugin.log(e);
+				}
+				catch (ClassCastException e) {
+					CCorePlugin.log(e);
+				}
+			}
+		}
+		if (fErrorParsers.size() == 0) {
+			initErrorParsersArray(fErrorParsers);
+		}
+		savePreferences();
+	}
+
+	private void initErrorParsersArray(List errorParsers) {
+		errorParsers.add(new VCErrorParser());
+		errorParsers.add(new GCCErrorParser());
+		errorParsers.add(new GLDErrorParser());
+		errorParsers.add(new GASErrorParser());
+		errorParsers.add(new MakeErrorParser());
+	}
+
+	private void savePreferences() {
+		StringBuffer buf = new StringBuffer();
+		for (int i = 0; i < fErrorParsers.size(); i++) {
+			buf.append(fErrorParsers.get(i).getClass().getName());
+			buf.append(';');
+		}
+		CCorePlugin.getDefault().getPluginPreferences().setValue(PREF_ERROR_PARSER, buf.toString());
+	}
+
+	protected void collectFiles(IContainer parent, List result) {
+		try {
+			IResource[] resources = parent.members();
+			for (int i = 0; i < resources.length; i++) {
+				IResource resource = resources[i];
+				if (resource instanceof IFile) {
+					result.add(resource);
+				}
+				else if (resource instanceof IContainer) {
+					collectFiles((IContainer) resource, result);
+				}
+			}
+		}
+		catch (CoreException e) {
+			CCorePlugin.log(e.getStatus());
+		}
+	}
+
+	/**
+	 * Parses the input and try to generate error or warning markers
+	 */
+	public void parse(String output) {
+		BufferedReader rd = new BufferedReader(new StringReader(output));
+		try {
+			String line = rd.readLine();
+			while (line != null) {
+				processLine(line);
+				previousLine = line;
+				line = rd.readLine();
+			}
+		}
+		catch (IOException e) {
+			CCorePlugin.log(e);
+		}
+		finally {
+			try {
+				rd.close();
+			}
+			catch (IOException e) {
+			}
+		}
+
+		fDirectoryStack.removeAllElements();
+		fBaseDirectory = null;
+	}
+
+	private void processLine(String line) {
+		int top = fErrorParsers.size() - 1;
+		int i = top;
+		do {
+			IErrorParser curr = (IErrorParser) fErrorParsers.get(i);
+			if (curr.processLine(line, this)) {
+				if (i != top) {
+					// move to top
+					Object used = fErrorParsers.remove(i);
+					fErrorParsers.add(used);
+					savePreferences();
+				}
+				return;
+			}
+			i--;
+		}
+		while (i >= 0);
+	}
+
+	/**
+	 * Called by the error parsers.
+	 */
+	public IFile findFileName(String fileName) {
+		IPath path = new Path(fileName);
+		return (IFile) fFilesInProject.get(path.lastSegment());
+	}
+
+	/**
+	 * Called by the error parsers.
+	 */
+	public boolean isConflictingName(String fileName) {
+		IPath path = new Path(fileName);
+		return fNameConflicts.contains(path.lastSegment());
+	}
+
+	/**
+	 * Called by the error parsers.
+	 */
+	public IFile findFilePath(String filePath) {
+		IPath path = null;
+		IPath fp = new Path(filePath);
+		if (fp.isAbsolute()) {
+			if (fBaseDirectory.isPrefixOf(fp)) {
+				int segments = fBaseDirectory.matchingFirstSegments(fp);
+				path = fp.removeFirstSegments(segments);
+			}
+			else {
+				path = fp;
+			}
+		}
+		else {
+			path = (IPath) getWorkingDirectory().append(filePath);
+		}
+		return (IFile) fProject.getFile(path);
+	}
+
+	protected class Problem {
+		protected IResource file;
+		protected int lineNumber;
+		protected String description;
+		protected int severity;
+		protected String variableName;
+
+		public Problem(IResource file, int lineNumber, String desciption, int severity, String variableName) {
+			this.file = file;
+			this.lineNumber = lineNumber;
+			this.description = desciption;
+			this.severity = severity;
+			this.variableName = variableName;
+		}
+	}
+
+	/**
+	 * Called by the error parsers.
+	 */
+	public void generateMarker(IResource file, int lineNumber, String desc, int severity, String varName) {
+		Problem problem = new Problem(file, lineNumber, desc, severity, varName);
+		fErrors.add(problem);
+	}
+
+	/**
+	 * Called by the error parsers.  Return the previous line, save in the working buffer.
+	 */
+	public String getPreviousLine() {
+		return new String((previousLine) == null ? "" : previousLine);
+	}
+
+	/**
+	 * Method setOutputStream.
+	 * @param cos
+	 */
+	public void setOutputStream(OutputStream os) {
+		outputStream = os;
+	}
+
+	/**
+	 * Method getInputStream.
+	 * @return OutputStream
+	 */
+	public OutputStream getOutputStream() {
+		nOpens++;
+		return this;
+	}
+
+	/**
+	 * @see java.io.OutputStream#close()
+	 */
+	public void close() throws IOException {
+		if (nOpens > 0 && --nOpens == 0) {
+			fDirectoryStack.removeAllElements();
+			fBaseDirectory = null;
+			outputStream.close();
+		}
+	}
+
+	/**
+	 * @see java.io.OutputStream#flush()
+	 */
+	public void flush() throws IOException {
+		outputStream.flush();
+	}
+
+	/**
+	 * @see java.io.OutputStream#write(int)
+	 */
+	public void write(int b) throws IOException {
+		currentLine.append((char) b);
+		checkLine();
+		outputStream.write(b);
+	}
+
+	public synchronized void write(byte[] b, int off, int len) throws IOException {
+		if (b == null) {
+			throw new NullPointerException();
+		}
+		else if (off != 0 || (len < 0) || (len > b.length)) {
+			throw new IndexOutOfBoundsException();
+		}
+		else if (len == 0) {
+			return;
+		}
+		currentLine.append(new String(b, 0, len));
+		checkLine();
+		outputStream.write(b, off, len);
+	}
+
+	private void checkLine() {
+		String line = currentLine.toString();
+		if (line.endsWith("\n")) {
+			processLine(line);
+			previousLine = line;
+			currentLine.setLength(0);
+		}
+	}
+
+	public boolean reportProblems() {
+		boolean reset = false;	
+		if (nOpens == 0) {
+			Iterator iter = fErrors.iterator();
+			while (iter.hasNext()) {
+				Problem problem = (Problem) iter.next();
+				if (problem.severity == IMarkerGenerator.SEVERITY_ERROR_BUILD) {
+					reset = true;
+				}
+				if (problem.file == null) {
+					fMarkerGenerator.addMarker(
+						fProject,
+						problem.lineNumber,
+						problem.description,
+						problem.severity,
+						problem.variableName);
+				}
+				else {
+					fMarkerGenerator.addMarker(
+						problem.file,
+						problem.lineNumber,
+						problem.description,
+						problem.severity,
+						problem.variableName);
+				}
+			}
+			fErrors.clear();
+		}
+		return reset;
+	}
+}
Index: org/eclipse/cdt/core/IErrorParser.java
===================================================================
RCS file: org/eclipse/cdt/core/IErrorParser.java
diff -N org/eclipse/cdt/core/IErrorParser.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ org/eclipse/cdt/core/IErrorParser.java	23 Oct 2002 18:18:42 -0000
@@ -0,0 +1,15 @@
+package org.eclipse.cdt.core;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+public interface IErrorParser {
+	/**
+	 * Finds error or warnings on the given line
+	 */
+	boolean processLine(String line, ErrorParserManager eoParser);
+
+}
+
Index: org/eclipse/cdt/core/IMarkerGenerator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IMarkerGenerator.java,v
retrieving revision 1.1
diff -u -r1.1 IMarkerGenerator.java
--- org/eclipse/cdt/core/IMarkerGenerator.java	3 Oct 2002 01:56:00 -0000	1.1
+++ org/eclipse/cdt/core/IMarkerGenerator.java	23 Oct 2002 18:18:42 -0000
@@ -6,5 +6,10 @@
  * @author sam.robb
  */
 public interface IMarkerGenerator {
-	public void addMarker(IResource file, int lineNumber, String errorDesc, int severity, String errorVar);
+	int SEVERITY_INFO = 0;
+	int SEVERITY_WARNING = 1;
+	int SEVERITY_ERROR_RESOURCE = 2;
+	int SEVERITY_ERROR_BUILD = 3;
+
+	void addMarker(IResource file, int lineNumber, String errorDesc, int severity, String errorVar);
 }
Index: org/eclipse/cdt/core/resources/ACBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ACBuilder.java,v
retrieving revision 1.4
diff -u -r1.4 ACBuilder.java
--- org/eclipse/cdt/core/resources/ACBuilder.java	13 Oct 2002 21:30:41 -0000	1.4
+++ org/eclipse/cdt/core/resources/ACBuilder.java	23 Oct 2002 18:18:42 -0000
@@ -33,7 +33,7 @@
 			IMarker marker= file.createMarker(ICModelMarker.C_MODEL_PROBLEM_MARKER);
 			marker.setAttribute(IMarker.LOCATION, lineNumber);
 			marker.setAttribute(IMarker.MESSAGE, errorDesc);
-			marker.setAttribute(IMarker.SEVERITY, severity);
+			marker.setAttribute(IMarker.SEVERITY, mapMarkerSeverity(severity));
 			marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
 			marker.setAttribute(IMarker.CHAR_START, -1);
 			marker.setAttribute(IMarker.CHAR_END, -1);
@@ -44,6 +44,19 @@
 			CCorePlugin.log(e.getStatus());
 		}
 		
+	}
+	
+	int mapMarkerSeverity (int severity) {
+		switch (severity) {
+			case SEVERITY_ERROR_BUILD:
+			case SEVERITY_ERROR_RESOURCE:
+				return IMarker.SEVERITY_ERROR;
+			case SEVERITY_INFO:
+				return IMarker.SEVERITY_INFO;
+			case SEVERITY_WARNING:
+				return IMarker.SEVERITY_WARNING;
+		}
+		return IMarker.SEVERITY_ERROR;
 	}
 
     public abstract IPath getWorkingDirectory();
Index: org/eclipse/cdt/errorparsers/ErrorParserManager.java
===================================================================
RCS file: org/eclipse/cdt/errorparsers/ErrorParserManager.java
diff -N org/eclipse/cdt/errorparsers/ErrorParserManager.java
--- org/eclipse/cdt/errorparsers/ErrorParserManager.java	23 Oct 2002 13:07:33 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,404 +0,0 @@
-package org.eclipse.cdt.errorparsers;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.IMarkerGenerator;
-import org.eclipse.cdt.core.resources.ACBuilder;
-import org.eclipse.cdt.internal.errorparsers.GASErrorParser;
-import org.eclipse.cdt.internal.errorparsers.GCCErrorParser;
-import org.eclipse.cdt.internal.errorparsers.GLDErrorParser;
-import org.eclipse.cdt.internal.errorparsers.MakeErrorParser;
-import org.eclipse.cdt.internal.errorparsers.VCErrorParser;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-public class ErrorParserManager extends OutputStream {
-	private int nOpens;
-
-	private static String PREF_ERROR_PARSER = "errorOutputParser";
-
-	private IProject fProject;
-	private IMarkerGenerator fMarkerGenerator;
-	private Map fFilesInProject;
-	private List fNameConflicts;
-
-	private ArrayList fErrorParsers;
-	private ArrayList fErrors;
-
-	private Vector fDirectoryStack;
-	private IPath fBaseDirectory;
-
-	private String previousLine;
-	private OutputStream outputStream;
-	private StringBuffer currentLine = new StringBuffer();
-
-	public ErrorParserManager(ACBuilder builder) {
-		this(builder.getProject(), builder);
-	}
-
-	public ErrorParserManager(IProject project, IMarkerGenerator markerGenerator) {
-		fProject = project;
-		fErrorParsers = new ArrayList();
-		fMarkerGenerator = markerGenerator;
-		readPreferences();
-		initParser();
-	}
-
-	private void initParser() {
-		fFilesInProject = new HashMap();
-		fNameConflicts = new ArrayList();
-		fDirectoryStack = new Vector();
-		fErrors = new ArrayList();
-
-		// prepare file lists
-		fFilesInProject.clear();
-		fNameConflicts.clear();
-
-		List collectedFiles = new ArrayList();
-		fBaseDirectory = fProject.getLocation();
-		collectFiles(fProject, collectedFiles);
-
-		for (int i = 0; i < collectedFiles.size(); i++) {
-			IFile curr = (IFile) collectedFiles.get(i);
-			Object existing = fFilesInProject.put(curr.getName(), curr);
-			if (existing != null) {
-				fNameConflicts.add(curr.getName());
-			}
-		}
-	}
-
-	public IPath getWorkingDirectory() {
-		if (fDirectoryStack.size() != 0) {
-			return (IPath) fDirectoryStack.lastElement();
-		}
-		return new Path("");
-	}
-
-	public void pushDirectory(IPath dir) {
-		if (dir != null) {
-			IPath pwd = null;
-			if (fBaseDirectory.isPrefixOf(dir)) {
-				int segments = fBaseDirectory.matchingFirstSegments(dir);
-				pwd = dir.removeFirstSegments(segments);
-			}
-			else {
-				pwd = dir;
-			}
-			fDirectoryStack.addElement(pwd);
-		}
-	}
-
-	public IPath popDirectory() {
-		int i = fDirectoryStack.size();
-		IPath dir = (IPath) fDirectoryStack.lastElement();
-		if (i != 0) {
-			fDirectoryStack.removeElementAt(i - 1);
-		}
-		return dir;
-	}
-
-	public int getDirectoryLevel() {
-		return fDirectoryStack.size();
-	}
-
-	protected void addParser(IErrorParser parser) {
-		fErrorParsers.add(parser);
-	}
-
-	private void readPreferences() {
-		fErrorParsers.clear();
-		String parserNames = CCorePlugin.getDefault().getPluginPreferences().getString(PREF_ERROR_PARSER);
-		if (parserNames != null && parserNames.length() > 0) {
-			StringTokenizer tok = new StringTokenizer(parserNames, ";");
-			while (tok.hasMoreElements()) {
-				String clName = tok.nextToken();
-				try {
-					IErrorParser parser = (IErrorParser) getClass().forName(clName).newInstance();
-					fErrorParsers.add(parser);
-				}
-				catch (ClassNotFoundException e) {
-					// not found
-					CCorePlugin.log(e);
-				}
-				catch (InstantiationException e) {
-					CCorePlugin.log(e);
-				}
-				catch (IllegalAccessException e) {
-					CCorePlugin.log(e);
-				}
-				catch (ClassCastException e) {
-					CCorePlugin.log(e);
-				}
-			}
-		}
-		if (fErrorParsers.size() == 0) {
-			initErrorParsersArray(fErrorParsers);
-		}
-		savePreferences();
-	}
-
-	private void initErrorParsersArray(List errorParsers) {
-		errorParsers.add(new VCErrorParser());
-		errorParsers.add(new GCCErrorParser());
-		errorParsers.add(new GLDErrorParser());
-		errorParsers.add(new GASErrorParser());
-		errorParsers.add(new MakeErrorParser());
-	}
-
-	private void savePreferences() {
-		StringBuffer buf = new StringBuffer();
-		for (int i = 0; i < fErrorParsers.size(); i++) {
-			buf.append(fErrorParsers.get(i).getClass().getName());
-			buf.append(';');
-		}
-		CCorePlugin.getDefault().getPluginPreferences().setValue(PREF_ERROR_PARSER, buf.toString());
-	}
-
-	protected void collectFiles(IContainer parent, List result) {
-		try {
-			IResource[] resources = parent.members();
-			for (int i = 0; i < resources.length; i++) {
-				IResource resource = resources[i];
-				if (resource instanceof IFile) {
-					result.add(resource);
-				}
-				else if (resource instanceof IContainer) {
-					collectFiles((IContainer) resource, result);
-				}
-			}
-		}
-		catch (CoreException e) {
-			CCorePlugin.log(e.getStatus());
-		}
-	}
-
-	/**
-	 * Parses the input and try to generate error or warning markers
-	 */
-	public void parse(String output) {
-		BufferedReader rd = new BufferedReader(new StringReader(output));
-		try {
-			String line = rd.readLine();
-			while (line != null) {
-				processLine(line);
-				previousLine = line;
-				line = rd.readLine();
-			}
-		}
-		catch (IOException e) {
-			CCorePlugin.log(e);
-		}
-		finally {
-			try {
-				rd.close();
-			}
-			catch (IOException e) {
-			}
-		}
-
-		fDirectoryStack.removeAllElements();
-		fBaseDirectory = null;
-	}
-
-	private void processLine(String line) {
-		int top = fErrorParsers.size() - 1;
-		int i = top;
-		do {
-			IErrorParser curr = (IErrorParser) fErrorParsers.get(i);
-			if (curr.processLine(line, this)) {
-				if (i != top) {
-					// move to top
-					Object used = fErrorParsers.remove(i);
-					fErrorParsers.add(used);
-					savePreferences();
-				}
-				return;
-			}
-			i--;
-		}
-		while (i >= 0);
-	}
-
-	/**
-	 * Called by the error parsers.
-	 */
-	public IFile findFileName(String fileName) {
-		IPath path = new Path(fileName);
-		return (IFile) fFilesInProject.get(path.lastSegment());
-	}
-
-	/**
-	 * Called by the error parsers.
-	 */
-	public boolean isConflictingName(String fileName) {
-		IPath path = new Path(fileName);
-		return fNameConflicts.contains(path.lastSegment());
-	}
-
-	/**
-	 * Called by the error parsers.
-	 */
-	public IFile findFilePath(String filePath) {
-		IPath path = null;
-		IPath fp = new Path(filePath);
-		if (fp.isAbsolute()) {
-			if (fBaseDirectory.isPrefixOf(fp)) {
-				int segments = fBaseDirectory.matchingFirstSegments(fp);
-				path = fp.removeFirstSegments(segments);
-			}
-			else {
-				path = fp;
-			}
-		}
-		else {
-			path = (IPath) getWorkingDirectory().append(filePath);
-		}
-		return (IFile) fProject.getFile(path);
-	}
-
-	protected class Problem {
-		protected IResource file;
-		protected int lineNumber;
-		protected String description;
-		protected int severity;
-		protected String variableName;
-
-		public Problem(IResource file, int lineNumber, String desciption, int severity, String variableName) {
-			this.file = file;
-			this.lineNumber = lineNumber;
-			this.description = desciption;
-			this.severity = severity;
-			this.variableName = variableName;
-		}
-	}
-
-	/**
-	 * Called by the error parsers.
-	 */
-	public void generateMarker(IResource file, int lineNumber, String desc, int severity, String varName) {
-		Problem problem = new Problem(file, lineNumber, desc, severity, varName);
-		fErrors.add(problem);
-	}
-
-	/**
-	 * Called by the error parsers.  Return the previous line, save in the working buffer.
-	 */
-	public String getPreviousLine() {
-		return new String((previousLine) == null ? "" : previousLine);
-	}
-
-	/**
-	 * Method setOutputStream.
-	 * @param cos
-	 */
-	public void setOutputStream(OutputStream os) {
-		outputStream = os;
-	}
-
-	/**
-	 * Method getInputStream.
-	 * @return OutputStream
-	 */
-	public OutputStream getOutputStream() {
-		nOpens++;
-		return this;
-	}
-
-	/**
-	 * @see java.io.OutputStream#close()
-	 */
-	public void close() throws IOException {
-		if (nOpens > 0 && --nOpens == 0) {
-			fDirectoryStack.removeAllElements();
-			fBaseDirectory = null;
-			outputStream.close();
-		}
-	}
-
-	/**
-	 * @see java.io.OutputStream#flush()
-	 */
-	public void flush() throws IOException {
-		outputStream.flush();
-	}
-
-	/**
-	 * @see java.io.OutputStream#write(int)
-	 */
-	public void write(int b) throws IOException {
-		currentLine.append((char) b);
-		checkLine();
-		outputStream.write(b);
-	}
-
-	public synchronized void write(byte[] b, int off, int len) throws IOException {
-		if (b == null) {
-			throw new NullPointerException();
-		}
-		else if (off != 0 || (len < 0) || (len > b.length)) {
-			throw new IndexOutOfBoundsException();
-		}
-		else if (len == 0) {
-			return;
-		}
-		currentLine.append(new String(b, 0, len));
-		checkLine();
-		outputStream.write(b, off, len);
-	}
-
-	private void checkLine() {
-		String line = currentLine.toString();
-		if (line.endsWith("\n")) {
-			processLine(line);
-			previousLine = line;
-			currentLine.setLength(0);
-		}
-	}
-
-	public void reportProblems() {
-		if (nOpens == 0) {
-			Iterator iter = fErrors.iterator();
-			while (iter.hasNext()) {
-				Problem problem = (Problem) iter.next();
-				if (problem.file == null) {
-					fMarkerGenerator.addMarker(
-						fProject,
-						problem.lineNumber,
-						problem.description,
-						problem.severity,
-						problem.variableName);
-				}
-				else {
-					fMarkerGenerator.addMarker(
-						problem.file,
-						problem.lineNumber,
-						problem.description,
-						problem.severity,
-						problem.variableName);
-				}
-			}
-			fErrors.clear();
-		}
-	}
-}
Index: org/eclipse/cdt/errorparsers/IErrorParser.java
===================================================================
RCS file: org/eclipse/cdt/errorparsers/IErrorParser.java
diff -N org/eclipse/cdt/errorparsers/IErrorParser.java
--- org/eclipse/cdt/errorparsers/IErrorParser.java	23 Oct 2002 13:07:33 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,15 +0,0 @@
-package org.eclipse.cdt.errorparsers;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-public interface IErrorParser {
-	/**
-	 * Finds error or warnings on the given line
-	 */
-	boolean processLine(String line, ErrorParserManager eoParser);
-
-}
-
Index: org/eclipse/cdt/internal/core/CBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CBuilder.java,v
retrieving revision 1.8
diff -u -r1.8 CBuilder.java
--- org/eclipse/cdt/internal/core/CBuilder.java	23 Oct 2002 13:07:33 -0000	1.8
+++ org/eclipse/cdt/internal/core/CBuilder.java	23 Oct 2002 18:18:42 -0000
@@ -15,11 +15,11 @@
 import org.eclipse.cdt.core.CProjectNature;
 import org.eclipse.cdt.core.CommandLauncher;
 import org.eclipse.cdt.core.ConsoleOutputStream;
+import org.eclipse.cdt.core.ErrorParserManager;
 import org.eclipse.cdt.core.model.ICModelMarker;
 import org.eclipse.cdt.core.resources.ACBuilder;
 import org.eclipse.cdt.core.resources.IConsole;
 import org.eclipse.cdt.core.resources.MakeUtil;
-import org.eclipse.cdt.errorparsers.ErrorParserManager;
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
@@ -63,6 +63,7 @@
 	
 	private boolean invokeMake(boolean fullBuild, IProgressMonitor monitor) {
 		boolean isClean = false;
+		boolean fatalBuild = false;
 		IProject currProject= getProject();
 		SubProgressMonitor subMonitor = null;
 
@@ -132,21 +133,20 @@
 					String errorDesc= CCorePlugin.getFormattedString(BUILD_ERROR, makepath.toString());
 					StringBuffer buf= new StringBuffer(errorDesc);
 					buf.append(System.getProperty("line.separator", "\n"));
-					buf.append("(");
-					buf.append(errMsg);
-					buf.append(")");
+					buf.append("(").append(errMsg).append(")");
 					cos.write(buf.toString().getBytes());
 					cos.flush();
+					fatalBuild = true;
+				} else {
+					fatalBuild = epm.reportProblems();
 				}
-				epm.close();
-				epm.reportProblems();
 				subMonitor.done();
 			}
 		} catch (Exception e) {
 			CCorePlugin.log(e);
 		}
 		monitor.done();
-		return isClean;
+		return (isClean || fatalBuild);
 	}
 	
 	private String[] parseArguments(boolean fullBuild, String override_args) {
Index: org/eclipse/cdt/internal/core/ProcessClosure.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ProcessClosure.java,v
retrieving revision 1.2
diff -u -r1.2 ProcessClosure.java
--- org/eclipse/cdt/internal/core/ProcessClosure.java	23 Oct 2002 13:07:33 -0000	1.2
+++ org/eclipse/cdt/internal/core/ProcessClosure.java	23 Oct 2002 18:18:42 -0000
@@ -166,7 +166,7 @@
 	
 	public boolean isAlive() {
 		if (fProcess != null) {
-			if (fOutputReader.isAlive() && fErrorReader.isAlive()) {
+			if (fOutputReader.isAlive() || fErrorReader.isAlive()) {
 				return true;
 			} else {
 				fProcess= null;
Index: org/eclipse/cdt/internal/errorparsers/GASErrorParser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GASErrorParser.java,v
retrieving revision 1.2
diff -u -r1.2 GASErrorParser.java
--- org/eclipse/cdt/internal/errorparsers/GASErrorParser.java	23 Oct 2002 13:07:33 -0000	1.2
+++ org/eclipse/cdt/internal/errorparsers/GASErrorParser.java	23 Oct 2002 18:18:42 -0000
@@ -5,10 +5,10 @@
  * All Rights Reserved.
  */
 
-import org.eclipse.cdt.errorparsers.ErrorParserManager;
-import org.eclipse.cdt.errorparsers.IErrorParser;
+import org.eclipse.cdt.core.ErrorParserManager;
+import org.eclipse.cdt.core.IErrorParser;
+import org.eclipse.cdt.core.IMarkerGenerator;
 import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
 
 public class GASErrorParser implements IErrorParser {
 
@@ -22,7 +22,7 @@
 			String fileName = "";
 			IFile file = null;
 			int num = 0;
-			int severity = IMarker.SEVERITY_ERROR;
+			int severity = IMarkerGenerator.SEVERITY_ERROR_RESOURCE;
 			String desc = line;
 			if (previous != null && previous.startsWith("Assembler")) {
 				if (! line.startsWith("FATAL")) {
Index: org/eclipse/cdt/internal/errorparsers/GCCErrorParser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GCCErrorParser.java,v
retrieving revision 1.2
diff -u -r1.2 GCCErrorParser.java
--- org/eclipse/cdt/internal/errorparsers/GCCErrorParser.java	23 Oct 2002 13:07:33 -0000	1.2
+++ org/eclipse/cdt/internal/errorparsers/GCCErrorParser.java	23 Oct 2002 18:18:42 -0000
@@ -5,10 +5,10 @@
  * All Rights Reserved.
  */
 
-import org.eclipse.cdt.errorparsers.ErrorParserManager;
-import org.eclipse.cdt.errorparsers.IErrorParser;
+import org.eclipse.cdt.core.ErrorParserManager;
+import org.eclipse.cdt.core.IErrorParser;
+import org.eclipse.cdt.core.IMarkerGenerator;
 import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
 
 public class GCCErrorParser implements IErrorParser {
 
@@ -40,7 +40,7 @@
 					String lineNumber = line.substring(firstColon + 1, secondColon);
 					String varName = null;
 					String desc = line.substring(secondColon + 1).trim();
-					int severity = IMarker.SEVERITY_ERROR;
+					int severity = IMarkerGenerator.SEVERITY_ERROR_RESOURCE;
 					int	num  = 0;
 
 					try {
@@ -126,14 +126,14 @@
 						}
 					}
 					if (desc.startsWith("warning") || desc.startsWith("Warning")) {
-						severity = IMarker.SEVERITY_WARNING;
+						severity = IMarkerGenerator.SEVERITY_WARNING;
 					}
 					eoParser.generateMarker(file, num, desc, severity, varName);
 				}
 			} catch (StringIndexOutOfBoundsException e) {
 			} catch (NumberFormatException e) {
 			}
-    	}
+		}
 		return false;
 	}
 }
Index: org/eclipse/cdt/internal/errorparsers/GLDErrorParser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GLDErrorParser.java,v
retrieving revision 1.2
diff -u -r1.2 GLDErrorParser.java
--- org/eclipse/cdt/internal/errorparsers/GLDErrorParser.java	23 Oct 2002 13:07:33 -0000	1.2
+++ org/eclipse/cdt/internal/errorparsers/GLDErrorParser.java	23 Oct 2002 18:18:42 -0000
@@ -5,10 +5,10 @@
  * All Rights Reserved.
  */
 
-import org.eclipse.cdt.errorparsers.ErrorParserManager;
-import org.eclipse.cdt.errorparsers.IErrorParser;
+import org.eclipse.cdt.core.ErrorParserManager;
+import org.eclipse.cdt.core.IErrorParser;
+import org.eclipse.cdt.core.IMarkerGenerator;
 import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
 
 public class GLDErrorParser implements IErrorParser {
 
@@ -44,14 +44,14 @@
 				if (file == null) {
 					desc = fileName + " " + desc;
 				} 
-				eoParser.generateMarker(file, 0, desc, IMarker.SEVERITY_ERROR, null);
+				eoParser.generateMarker(file, 0, desc, IMarkerGenerator.SEVERITY_ERROR_RESOURCE, null);
 			} else if (buf.endsWith("ld")){
 				String fileName = line.substring(0, firstColon);
 				IFile file = eoParser.findFilePath(fileName);
 				if (file == null) {
 					desc = fileName + " " + desc;
 				} 
-				eoParser.generateMarker(file, 0, desc, IMarker.SEVERITY_ERROR, null);
+				eoParser.generateMarker(file, 0, desc, IMarkerGenerator.SEVERITY_ERROR_RESOURCE, null);
 			}
 		}
 		return false;
Index: org/eclipse/cdt/internal/errorparsers/MakeErrorParser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/MakeErrorParser.java,v
retrieving revision 1.2
diff -u -r1.2 MakeErrorParser.java
--- org/eclipse/cdt/internal/errorparsers/MakeErrorParser.java	23 Oct 2002 13:07:33 -0000	1.2
+++ org/eclipse/cdt/internal/errorparsers/MakeErrorParser.java	23 Oct 2002 18:18:42 -0000
@@ -5,8 +5,9 @@
  * All Rights Reserved.
  */
 
-import org.eclipse.cdt.errorparsers.ErrorParserManager;
-import org.eclipse.cdt.errorparsers.IErrorParser;
+import org.eclipse.cdt.core.ErrorParserManager;
+import org.eclipse.cdt.core.IErrorParser;
+import org.eclipse.cdt.core.IMarkerGenerator;
 import org.eclipse.core.runtime.Path;
 
 public class MakeErrorParser implements IErrorParser {
@@ -55,6 +56,8 @@
 			    		/* Could check to see if they match */
 			    	}
 				}
+			} else if (msg.startsWith(" ***")) {
+				eoParser.generateMarker(null, 0, msg, IMarkerGenerator.SEVERITY_ERROR_BUILD, null);
 			}
 		}
 		return false;
Index: org/eclipse/cdt/internal/errorparsers/VCErrorParser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/VCErrorParser.java,v
retrieving revision 1.2
diff -u -r1.2 VCErrorParser.java
--- org/eclipse/cdt/internal/errorparsers/VCErrorParser.java	23 Oct 2002 13:07:33 -0000	1.2
+++ org/eclipse/cdt/internal/errorparsers/VCErrorParser.java	23 Oct 2002 18:18:42 -0000
@@ -8,10 +8,10 @@
 import java.io.File;
 import java.util.StringTokenizer;
 
-import org.eclipse.cdt.errorparsers.ErrorParserManager;
-import org.eclipse.cdt.errorparsers.IErrorParser;
+import org.eclipse.cdt.core.ErrorParserManager;
+import org.eclipse.cdt.core.IErrorParser;
+import org.eclipse.cdt.core.IMarkerGenerator;
 import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
 
 public class VCErrorParser implements IErrorParser {
 
@@ -37,9 +37,9 @@
 			    if (file == null) {
 				desc= "*" + desc;
 			    }
-			    int severity= IMarker.SEVERITY_ERROR;
+			    int severity= IMarkerGenerator.SEVERITY_ERROR_RESOURCE;
 			    if (desc.startsWith("warning")) {
-				severity= IMarker.SEVERITY_WARNING;
+				severity= IMarkerGenerator.SEVERITY_WARNING;
 			    }
 			    eoParser.generateMarker(file, num, desc, severity, null);
 			    return true;



Back to the top