mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Modernized the Visual C++ Error Parser. Now handles errors from the linker that were getting missed.
This commit is contained in:
parent
e4f24af8d1
commit
59db91ccde
1 changed files with 14 additions and 63 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue