From 59db91ccde502bfa98c46b3b873b9e516b53eaab Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Tue, 12 Dec 2006 22:09:35 +0000 Subject: [PATCH] Modernized the Visual C++ Error Parser. Now handles errors from the linker that were getting missed. --- .../internal/errorparsers/VCErrorParser.java | 77 ++++--------------- 1 file changed, 14 insertions(+), 63 deletions(-) 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 49445d50ecc..67ba25c1e66 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 @@ -10,73 +10,24 @@ *******************************************************************************/ package org.eclipse.cdt.internal.errorparsers; -import java.io.File; -import java.util.StringTokenizer; -import org.eclipse.cdt.core.ErrorParserManager; -import org.eclipse.cdt.core.IErrorParser; +import java.util.regex.Matcher; + import org.eclipse.cdt.core.IMarkerGenerator; -import org.eclipse.core.resources.IFile; -public class VCErrorParser implements IErrorParser { +public class VCErrorParser extends AbstractErrorParser { - public boolean processLine(String line, ErrorParserManager eoParser) { - // msdev: filname(linenumber) : error/warning error_desc - int firstColon = line.indexOf(':'); - if (firstColon != -1) { - /* Guard against drive in Windows platform. */ - if (firstColon == 1) { - try { - String os = System.getProperty("os.name"); //$NON-NLS-1$ - if (os != null && os.startsWith("Win")) { //$NON-NLS-1$ - try { - if (Character.isLetter(line.charAt(0))) { - firstColon = line.indexOf(':', 2); - } - } catch (StringIndexOutOfBoundsException e) { - } - } - } catch (SecurityException e) { - } + private static final ErrorPattern[] patterns = { + new ErrorPattern("(.+?)(\\(([0-9]+)\\))? : (error|warning) (.*)", 1, 3, 5, 0, 0) { + public int getSeverity(Matcher matcher) { + return "error".equals(matcher.group(4)) + ? IMarkerGenerator.SEVERITY_ERROR_RESOURCE + : IMarkerGenerator.SEVERITY_WARNING; } } - - if (firstColon != -1) { - String firstPart = line.substring(0, firstColon); - StringTokenizer tok = new StringTokenizer(firstPart, "()"); //$NON-NLS-1$ - if (tok.hasMoreTokens()) { - String fileName = tok.nextToken(); - if (tok.hasMoreTokens()) { - // Line number can either be ### or ###,## - String lineNumber = tok.nextToken(); - try { - int firstComma = lineNumber.indexOf(','); - if (firstComma != -1) { - lineNumber = lineNumber.substring(0, firstComma); - } - int num = Integer.parseInt(lineNumber); - int i = fileName.lastIndexOf(File.separatorChar); - if (i != -1) { - fileName = fileName.substring(i + 1); - } - IFile file = eoParser.findFileName(fileName); - if (file != null || eoParser.isConflictingName(fileName)) { - String desc = line.substring(firstColon + 1).trim(); - if (file == null) { - desc = "*" + desc; //$NON-NLS-1$ - } - String compareDesc = desc.toLowerCase(); - int severity = IMarkerGenerator.SEVERITY_ERROR_RESOURCE; - if (compareDesc.startsWith("warning") || compareDesc.startsWith("remark")) { //$NON-NLS-1$ //$NON-NLS-2$ - severity = IMarkerGenerator.SEVERITY_WARNING; - } - eoParser.generateMarker(file, num, desc, severity, null); - return true; - } - } catch (NumberFormatException e) { - } - } - } - } - return false; + }; + + public VCErrorParser() { + super(patterns); } + }