diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog index 342a4591014..f0e77d5f983 100644 --- a/core/org.eclipse.cdt.core/ChangeLog +++ b/core/org.eclipse.cdt.core/ChangeLog @@ -1,3 +1,24 @@ +2002-10-23 David Inglis + + Error parsing is now done as the streams from the commands + are read, this reduces memory usage during the build + process, and we can now add options to the build console to + only keep 'n' lines of output, again reducing the memory + usage. Also refactored IErrorParser and ErrorParserManager out + of internal. + + * src/.../errorparser/ErrorParserManager.java: + * src/.../errorparser/IErrorParser.java: + * src/.../internal/errorparser/GASErrorParser.java: + * src/.../internal/errorparser/GCCErrorParser.java: + * src/.../internal/errorparser/GLDErrorParser.java: + * src/.../internal/errorparser/MakeErrorParser.java: + * src/.../internal/errorparser/VCErrorParser.java: + * src/.../internal/core/CBuilder.java: + * src/.../internal/core/ProcessCloseure.java: + * src/.../core/ConsoleOutputStream.java: + + 2002-10-22 Alain Magloire * src/.../internal/parser/LinePositionInputStream.java: diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ConsoleOutputStream.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ConsoleOutputStream.java index d54770c55b4..261af376995 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ConsoleOutputStream.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ConsoleOutputStream.java @@ -15,49 +15,20 @@ import java.io.OutputStream; public class ConsoleOutputStream extends OutputStream { protected StringBuffer fBuffer; - - protected StringBuffer fContent; - - protected int pos; - + public ConsoleOutputStream() { - fBuffer= new StringBuffer(256); - fContent= new StringBuffer(); - pos = 0; + fBuffer= new StringBuffer(); } - /** - * @see OutputStream#flush - */ - public synchronized void flush() throws IOException { - final String content= fBuffer.toString(); + + public String readBuffer() { + String buf = fBuffer.toString(); fBuffer.setLength(0); - fContent.append(content); - } - - public String getContent(int len) { - String s = null; - try { - s = fContent.substring (len); - } catch (StringIndexOutOfBoundsException e) { - s = ""; - } - return s; - } - - public String getContent() { - // return fContent.toString(); - if (pos >= fContent.length()) - pos = 0; - String s = getContent(pos); - pos += s.length(); - return s; + return buf; } public void clear() { fBuffer.setLength (0); - fContent.setLength (0); - pos = 0; } /** @@ -66,8 +37,5 @@ public class ConsoleOutputStream extends OutputStream { */ public synchronized void write(int c) throws IOException { fBuffer.append((char) c); - if (fBuffer.length() > 250) { - flush(); - } } } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/errorparsers/ErrorParserManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/errorparsers/ErrorParserManager.java new file mode 100644 index 00000000000..8baba1503d6 --- /dev/null +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/errorparsers/ErrorParserManager.java @@ -0,0 +1,404 @@ +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(); + } + } +} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/IErrorParser.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/errorparsers/IErrorParser.java similarity index 82% rename from core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/IErrorParser.java rename to core/org.eclipse.cdt.core/src/org/eclipse/cdt/errorparsers/IErrorParser.java index 903aeec01c1..72302bee0e3 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/IErrorParser.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/errorparsers/IErrorParser.java @@ -1,4 +1,4 @@ -package org.eclipse.cdt.internal.errorparsers; +package org.eclipse.cdt.errorparsers; /* * (c) Copyright IBM Corp. 2000, 2001. diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CBuilder.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CBuilder.java index ee642ce27ba..c18ae94265e 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CBuilder.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CBuilder.java @@ -19,7 +19,7 @@ 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.internal.errorparsers.ErrorParserManager; +import org.eclipse.cdt.errorparsers.ErrorParserManager; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -110,13 +110,13 @@ public class CBuilder extends ACBuilder { } env = (String []) envList.toArray(new String [envList.size()]); } - - launcher.execute(makepath, userArgs, env, workingDirectory); - if (launcher.waitAndRead(cos, cos, subMonitor) != CommandLauncher.OK) - errMsg = launcher.getErrorMessage(); + ErrorParserManager epm= new ErrorParserManager(this); + epm.setOutputStream(cos); + launcher.execute(makepath, userArgs, env, workingDirectory); + if (launcher.waitAndRead(epm.getOutputStream(), epm.getOutputStream(), subMonitor) != CommandLauncher.OK) + errMsg = launcher.getErrorMessage(); monitor.setCanceled(false); - subMonitor = new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN); subMonitor.subTask("Refresh From Local"); @@ -127,10 +127,6 @@ public class CBuilder extends ACBuilder { subMonitor = new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN); subMonitor.subTask("Parsing"); - cos.flush(); - - ErrorParserManager epm= new ErrorParserManager(this); - epm.parse(cos.getContent()); if (errMsg != null) { String errorDesc= CCorePlugin.getFormattedString(BUILD_ERROR, makepath.toString()); @@ -142,6 +138,8 @@ public class CBuilder extends ACBuilder { cos.write(buf.toString().getBytes()); cos.flush(); } + epm.close(); + epm.reportProblems(); subMonitor.done(); } } catch (Exception e) { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ProcessClosure.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ProcessClosure.java index 4f3d9374c69..cb264a1e18d 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ProcessClosure.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ProcessClosure.java @@ -5,12 +5,12 @@ package org.eclipse.cdt.internal.core; * All Rights Reserved. */ -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; import java.io.BufferedReader; import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; +import java.io.OutputStream; import java.io.OutputStreamWriter; @@ -29,7 +29,7 @@ public class ProcessClosure { private InputStream fInputStream; private OutputStream fOutputStream; private boolean fFinished = false; - + private String lineSeparator; /* * outputStream can be null */ @@ -38,6 +38,7 @@ public class ProcessClosure { fOutputStream= out; fInputStream= in; setDaemon(true); + lineSeparator = (String) System.getProperty("line.separator"); } public void run() { @@ -46,9 +47,9 @@ public class ProcessClosure { BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fOutputStream)); String line; while ((line = reader.readLine()) != null) { + line += lineSeparator; char[] array = line.toCharArray(); writer.write(array, 0, array.length); - writer.newLine(); writer.flush(); } } catch (IOException x) { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/ErrorParserManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/ErrorParserManager.java deleted file mode 100644 index a8bd109b8be..00000000000 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/ErrorParserManager.java +++ /dev/null @@ -1,282 +0,0 @@ -package org.eclipse.cdt.internal.errorparsers; - -/* - * (c) Copyright IBM Corp. 2000, 2001. - * All Rights Reserved. - */ - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Vector; -import java.util.StringTokenizer; - -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; - -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.IMarkerGenerator; -import org.eclipse.cdt.core.resources.ACBuilder; - -public class ErrorParserManager { - - private static String PREF_ERROR_PARSER= "errorOutputParser"; - - private IProject fProject; - private IMarkerGenerator fMarkerGenerator; - private Map fFilesInProject; - private List fNameConflicts; - - private ArrayList fErrorParsers; - - private Vector fDirectoryStack; - private IPath fBaseDirectory; - - private String previousLine; - - static String SEPARATOR = System.getProperty("file.separator"); - - public ErrorParserManager(ACBuilder builder) { - this(builder.getProject(), builder); - } - - public ErrorParserManager(IProject project, IMarkerGenerator markerGenerator) { - fProject= project; - fMarkerGenerator= markerGenerator; - fFilesInProject= new HashMap(); - fNameConflicts= new ArrayList(); - fErrorParsers= new ArrayList(); - fDirectoryStack = new Vector(); - fBaseDirectory = null; - readPreferences(); - } - - 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) { - // 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()); - } - } - - 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) {} - } - - fFilesInProject.clear(); - fNameConflicts.clear(); - 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); - } - - /** - * Called by the error parsers. - */ - public void generateMarker(IResource file, int lineNumber, String desc, int severity, String varName) { - if (file == null) { - fMarkerGenerator.addMarker (fProject, lineNumber, desc, severity, varName); - - } else { - fMarkerGenerator.addMarker(file, lineNumber, desc, severity, varName); - } - } - - /** - * Called by the error parsers. Return the previous line, save in the working buffer. - */ - public String getPreviousLine() { - return new String ((previousLine) == null ? "" : previousLine); - } - - /** - * Called by the error parsers. Overload in Makebuilder. - */ - public IPath getBuildCommand() { - return new Path(""); - } - -} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GASErrorParser.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GASErrorParser.java index 6c1af416591..38797eb09c2 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GASErrorParser.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GASErrorParser.java @@ -5,6 +5,8 @@ package org.eclipse.cdt.internal.errorparsers; * All Rights Reserved. */ +import org.eclipse.cdt.errorparsers.ErrorParserManager; +import org.eclipse.cdt.errorparsers.IErrorParser; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GCCErrorParser.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GCCErrorParser.java index 1112df7d664..babcd188a82 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GCCErrorParser.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GCCErrorParser.java @@ -5,6 +5,8 @@ package org.eclipse.cdt.internal.errorparsers; * All Rights Reserved. */ +import org.eclipse.cdt.errorparsers.ErrorParserManager; +import org.eclipse.cdt.errorparsers.IErrorParser; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; @@ -37,7 +39,7 @@ public class GCCErrorParser implements IErrorParser { String fileName = line.substring(0, firstColon); String lineNumber = line.substring(firstColon + 1, secondColon); String varName = null; - String desc = line.substring(secondColon + 2); + String desc = line.substring(secondColon + 1).trim(); int severity = IMarker.SEVERITY_ERROR; int num = 0; diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GLDErrorParser.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GLDErrorParser.java index 2db11fa181e..3c9582c5841 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GLDErrorParser.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GLDErrorParser.java @@ -5,6 +5,8 @@ package org.eclipse.cdt.internal.errorparsers; * All Rights Reserved. */ +import org.eclipse.cdt.errorparsers.ErrorParserManager; +import org.eclipse.cdt.errorparsers.IErrorParser; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/MakeErrorParser.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/MakeErrorParser.java index 15b12c397c9..f8f0c48e86b 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/MakeErrorParser.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/MakeErrorParser.java @@ -5,6 +5,8 @@ package org.eclipse.cdt.internal.errorparsers; * All Rights Reserved. */ +import org.eclipse.cdt.errorparsers.ErrorParserManager; +import org.eclipse.cdt.errorparsers.IErrorParser; import org.eclipse.core.runtime.Path; public class MakeErrorParser implements IErrorParser { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/VCErrorParser.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/VCErrorParser.java index 40c16aadb2a..850e29cc52f 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/VCErrorParser.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/VCErrorParser.java @@ -8,6 +8,8 @@ package org.eclipse.cdt.internal.errorparsers; import java.io.File; import java.util.StringTokenizer; +import org.eclipse.cdt.errorparsers.ErrorParserManager; +import org.eclipse.cdt.errorparsers.IErrorParser; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPlugin.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPlugin.java index 07da00bf8c9..bce8943b058 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPlugin.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPlugin.java @@ -151,7 +151,6 @@ public class CPlugin extends AbstractUIPlugin { Display.getDefault().syncExec(new Runnable() { public void run() { fDocument.set(""); - fContent.setLength(0); } }); } @@ -172,7 +171,7 @@ public class CPlugin extends AbstractUIPlugin { bringConsoleOnTop(); try { int len = fDocument.getLength (); - fDocument.replace(len, 0, getContent(len)); + fDocument.replace(len, 0, readBuffer()); } catch (BadLocationException x) { } } @@ -207,37 +206,6 @@ public class CPlugin extends AbstractUIPlugin { public CPlugin(IPluginDescriptor descriptor) { super(descriptor); fgCPlugin= this; -/* - fModel = new ACDebugModel() { - public Object createPresentation() { - return new CDebugModelPresentation(); - } - - public String getIdentifier() { - return PLUGIN_ID; - } - - public IMarker createBreakpoint( final IResource resource, - final Map attributes, - final String markerType ) throws CoreException { - - class BreakpointRunnable implements IWorkspaceRunnable { - IMarker fBreakpoint = null; - - public void run( IProgressMonitor monitor ) throws CoreException - { - fBreakpoint = resource.createMarker( markerType ); - fBreakpoint.setAttributes( attributes ); - } - }; - BreakpointRunnable r = new BreakpointRunnable(); - - resource.getWorkspace().run( r, null ); - - return r.fBreakpoint; - } - }; -*/ fConsoleDocument= new ConsoleDocument(); fDocumentProvider= null; fTextTools= null;