mirror of
https://github.com/eclipse-cdt/cdt
synced 2024-10-28 12:09:40 +01:00
bug 308322: Converted to RegexErrorParser
This commit is contained in:
parent
857c5eae68
commit
2dc29833ff
7 changed files with 109 additions and 218 deletions
|
@ -28,7 +28,7 @@ public class TestUnrecoverableError extends TestCase {
|
|||
aix.parseLine(err_msg);
|
||||
assertEquals("temp1.c", aix.getFileName());
|
||||
assertEquals(5, aix.getLineNumber());
|
||||
assertEquals(IMarkerGenerator.SEVERITY_ERROR_BUILD, aix.getSeverity());
|
||||
assertEquals(IMarkerGenerator.SEVERITY_ERROR_RESOURCE, aix.getSeverity());
|
||||
assertEquals("INTERNAL COMPILER ERROR",aix.getMessage());
|
||||
}
|
||||
public TestUnrecoverableError( String name)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2008 IBM Corporation and others.
|
||||
* Copyright (c) 2006, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -15,9 +15,9 @@ package org.eclipse.cdt.errorparsers.xlc.tests;
|
|||
import junit.framework.Assert;
|
||||
|
||||
import org.eclipse.cdt.core.ErrorParserManager;
|
||||
import org.eclipse.cdt.core.IErrorParserNamed;
|
||||
import org.eclipse.cdt.core.IMarkerGenerator;
|
||||
import org.eclipse.cdt.core.ProblemMarkerInfo;
|
||||
import org.eclipse.cdt.errorparsers.xlc.XlcErrorParser;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -30,6 +30,8 @@ import org.eclipse.core.runtime.IPath;
|
|||
*/
|
||||
|
||||
public class XlcErrorParserTester {
|
||||
public static final String XLC_ERROR_PARSER_ID = "org.eclipse.cdt.errorparsers.xlc.XlcErrorParser";
|
||||
|
||||
static private int counter=0;
|
||||
IProject fTempProject = ResourcesPlugin.getWorkspace().getRoot().getProject("XlcErrorParserTester.temp." + counter++);
|
||||
|
||||
|
@ -84,16 +86,19 @@ public class XlcErrorParserTester {
|
|||
*/
|
||||
@Override
|
||||
public IFile findFileName(String fileName) {
|
||||
return fTempProject.getFile(fileName);
|
||||
if (fileName!=null && fileName.trim().length()>0)
|
||||
return fTempProject.getFile(fileName);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by ErrorPattern.RecordError() for external problem markers
|
||||
*/
|
||||
@Override
|
||||
public void generateExternalMarker(IResource file, int lineNumb, String desc, int sev, String varName, IPath externalPath) {
|
||||
if (file!=null) {
|
||||
fileName = file.getName();
|
||||
public void generateExternalMarker(IResource rc, int lineNumb, String desc, int sev, String varName, IPath externalPath) {
|
||||
// if rc is this project it means that file was not found
|
||||
if (rc!=null && rc!=fTempProject) {
|
||||
fileName = rc.getName();
|
||||
} else {
|
||||
fileName="";
|
||||
}
|
||||
|
@ -109,7 +114,8 @@ public class XlcErrorParserTester {
|
|||
* @return
|
||||
*/
|
||||
boolean parseLine(String line) {
|
||||
XlcErrorParser errorParser = new XlcErrorParser();
|
||||
IErrorParserNamed errorParser = ErrorParserManager.getErrorParserCopy(XLC_ERROR_PARSER_ID);
|
||||
Assert.assertNotNull(errorParser);
|
||||
|
||||
MockErrorParserManager epManager = new MockErrorParserManager();
|
||||
return errorParser.processLine(line, epManager);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2006, 2009 IBM Corporation and others.
|
||||
# Copyright (c) 2006, 2010 IBM Corporation and others.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
|
@ -13,7 +13,28 @@
|
|||
# "%foo" in feature.xml corresponds to the key "foo" in this file
|
||||
# java.io.Properties file (ISO 8859-1 with "\" escapes)
|
||||
# This file should be translated.
|
||||
pluginName=xlC Error Parser Plugin
|
||||
pluginName=xlC Error Parser Test Plugin
|
||||
providerName=Eclipse CDT
|
||||
|
||||
CDTXLCErrorParser.name=CDT xlC Error Parser
|
||||
CDTXLCErrorParser.name=CDT xlC Error Parser
|
||||
|
||||
# Translators: do not translate patterns below. We currently do not support NL versions of the XL C/C++ compilers.
|
||||
# Following are patterns of xlC compiler messages. While translating the patterns should be replaced
|
||||
# with corresponding patterns matchind localized compiler messages
|
||||
|
||||
# "hello.c", line 5.9: 1506-358 (I) "MACRO" is defined on line 3 of hello.h.
|
||||
CDTXLCErrorParser.pattern.macro=["]?(.*?)["]?, line ([0-9]+)\\.[0-9]+:( [0-9]*-[0-9]*)? \\(I\\)\\s*["]?(\\w*)["]? is defined on line ([0-9]+) of (.*)\\.
|
||||
CDTXLCErrorParser.pattern.macro.replacement=Macro name $4 originally defined in file $6
|
||||
# "main.cpp", line 10.6: 1540-0064 (S) Syntax error: "name" was expected but "char" was found.
|
||||
CDTXLCErrorParser.pattern.error=["]?(.*?)["]?, line ([0-9]+)\\.[0-9]+:( [0-9]*-[0-9]*)? \\([USE]\\)\\s*(.*)
|
||||
CDTXLCErrorParser.pattern.warning=["]?(.*?)["]?, line ([0-9]+)\\.[0-9]+:( [0-9]*-[0-9]*)? \\(W\\)\\s*(.*)
|
||||
CDTXLCErrorParser.pattern.info=["]?(.*?)["]?, line ([0-9]+)\\.[0-9]+:( [0-9]*-[0-9]*)? \\(I\\)\\s*(.*)
|
||||
# ld: 0711-224 WARNING: Duplicate symbol: symboldupe
|
||||
# WARNING, ERROR, SEVERE ERROR etc.
|
||||
CDTXLCErrorParser.pattern.ld.error=ld: ([0-9]+-[0-9]+).*ERROR:\\s*(.*)
|
||||
CDTXLCErrorParser.pattern.ld.warning=ld: ([0-9]+-[0-9]+)\\s*WARNING:\\s*(.*)
|
||||
# ld: 0711-987 Error occurred while reading file
|
||||
CDTXLCErrorParser.pattern.ld.error2=ld: ([0-9]+-[0-9]+)\\s*(Error .*)
|
||||
# ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
|
||||
CDTXLCErrorParser.pattern.ld.info=ld: ([0-9]+-[0-9]+)\\s*(.*)
|
||||
|
||||
|
|
|
@ -1,9 +1,75 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.2"?>
|
||||
<plugin>
|
||||
<extension id="XlcErrorParser"
|
||||
name="%CDTXLCErrorParser.name"
|
||||
point="org.eclipse.cdt.core.ErrorParser">
|
||||
<errorparser class="org.eclipse.cdt.errorparsers.xlc.XlcErrorParser" />
|
||||
</extension>
|
||||
<extension id="XlcErrorParser" name="%CDTXLCErrorParser.name" point="org.eclipse.cdt.core.ErrorParser">
|
||||
<errorparser
|
||||
class="org.eclipse.cdt.core.errorparsers.RegexErrorParser"
|
||||
id="org.eclipse.cdt.errorparsers.xlc.XlcErrorParser"
|
||||
name="%CDTXLCErrorParser.name">
|
||||
<pattern
|
||||
regex="%CDTXLCErrorParser.pattern.error"
|
||||
severity="Error"
|
||||
file-expr="$1"
|
||||
line-expr="$2"
|
||||
description-expr="$4"
|
||||
eat-processed-line="true">
|
||||
</pattern>
|
||||
<pattern
|
||||
regex="%CDTXLCErrorParser.pattern.warning"
|
||||
severity="Warning"
|
||||
file-expr="$1"
|
||||
line-expr="$2"
|
||||
description-expr="$4"
|
||||
eat-processed-line="true">
|
||||
</pattern>
|
||||
<pattern
|
||||
regex="%CDTXLCErrorParser.pattern.macro"
|
||||
severity="Warning"
|
||||
file-expr="$6"
|
||||
line-expr="$5"
|
||||
description-expr="%CDTXLCErrorParser.pattern.macro.replacement"
|
||||
eat-processed-line="true">
|
||||
</pattern>
|
||||
<pattern
|
||||
regex="%CDTXLCErrorParser.pattern.info"
|
||||
severity="Info"
|
||||
description-expr="$4"
|
||||
file-expr="$1"
|
||||
line-expr="$2"
|
||||
eat-processed-line="true">
|
||||
</pattern>
|
||||
<pattern
|
||||
regex="%CDTXLCErrorParser.pattern.ld.error"
|
||||
severity="Error"
|
||||
file-expr=""
|
||||
line-expr=""
|
||||
description-expr="$2"
|
||||
eat-processed-line="true">
|
||||
</pattern>
|
||||
<pattern
|
||||
regex="%CDTXLCErrorParser.pattern.ld.error2"
|
||||
severity="Error"
|
||||
file-expr=""
|
||||
line-expr=""
|
||||
description-expr="$2"
|
||||
eat-processed-line="true">
|
||||
</pattern>
|
||||
<pattern
|
||||
regex="%CDTXLCErrorParser.pattern.ld.warning"
|
||||
severity="Warning"
|
||||
file-expr=""
|
||||
line-expr=""
|
||||
description-expr="$2"
|
||||
eat-processed-line="true">
|
||||
</pattern>
|
||||
<pattern
|
||||
regex="%CDTXLCErrorParser.pattern.ld.info"
|
||||
severity="Info"
|
||||
file-expr=""
|
||||
line-expr=""
|
||||
description-expr="$2"
|
||||
eat-processed-line="true">
|
||||
</pattern>
|
||||
</errorparser>
|
||||
</extension>
|
||||
</plugin>
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2008 IBM Corporation and others.
|
||||
* All rights reserved. This content and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Gvozdev - Initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.errorparsers.xlc;
|
||||
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
public class Messages extends NLS {
|
||||
private static final String BUNDLE_NAME = "org.eclipse.cdt.errorparsers.xlc.messages"; //$NON-NLS-1$
|
||||
public static String XlcErrorParser_MacroRedefinitionErrorPattern;
|
||||
public static String XlcErrorParser_CompilerErrorPattern;
|
||||
public static String XlcErrorParser_FlagUnrecoverable;
|
||||
public static String XlcErrorParser_FlagSevere;
|
||||
public static String XlcErrorParser_FlagError;
|
||||
public static String XlcErrorParser_FlagWarning;
|
||||
public static String XlcErrorParser_FlagInfo;
|
||||
|
||||
public static String XlcErrorParser_LinkerErrorPattern;
|
||||
public static String XlcErrorParser_LinkerErrorPattern2;
|
||||
public static String XlcErrorParser_LinkerInfoPattern;
|
||||
public static String XlcErrorParser_LinkerWarning;
|
||||
public static String XlcErrorParser_LinkerError;
|
||||
|
||||
static {
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
||||
}
|
||||
|
||||
private Messages() {
|
||||
}
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Andrew Gvozdev (Quoin Inc.)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.errorparsers.xlc;
|
||||
|
||||
|
||||
/**
|
||||
* This class provides for parsing the error messages generated by IBM AIX xlC compiler.
|
||||
*
|
||||
*/
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import org.eclipse.cdt.core.IMarkerGenerator;
|
||||
import org.eclipse.cdt.core.errorparsers.AbstractErrorParser;
|
||||
import org.eclipse.cdt.core.errorparsers.ErrorPattern;
|
||||
|
||||
/**
|
||||
* Class XlcErrorParser provides for parsing of error output messages
|
||||
* produced by AIX xlC compiler and linker.
|
||||
*
|
||||
* @see org.eclipse.cdt.core.errorparsers.AbstractErrorParser
|
||||
* @see org.eclipse.cdt.core.errorparsers.ErrorPattern
|
||||
*/
|
||||
public class XlcErrorParser extends AbstractErrorParser {
|
||||
private static final ErrorPattern[] patterns = {
|
||||
/**
|
||||
* xlC produces 2 warning messages in case of macro redefinition:
|
||||
* "hello.c", line 3.9: 1506-236 (W) Macro name HELLO has been redefined.
|
||||
* "hello.c", line 3.9: 1506-358 (I) "HELLO" is defined on line 4 of hello.h.
|
||||
* Both can be captured by regular XlcErrorParser_CompilerErrorPattern. However
|
||||
* different severity puts them apart in different groups. In addition
|
||||
* the second entry in Problems view won't let you jump to the original definition.
|
||||
* This ErrorPattern fixes those shortcomings.
|
||||
*/
|
||||
new ErrorPattern(Messages.XlcErrorParser_MacroRedefinitionErrorPattern, 6, 5, -1, 0, -1) {
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.errorparsers.ErrorPattern#getSeverity(java.util.regex.Matcher)
|
||||
*/
|
||||
@Override
|
||||
public int getSeverity(Matcher matcher) {
|
||||
return IMarkerGenerator.SEVERITY_WARNING;
|
||||
}
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.errorparsers.ErrorPattern#getDesc(java.util.regex.Matcher)
|
||||
*/
|
||||
@Override
|
||||
public String getDesc(Matcher matcher) {
|
||||
return "Macro name " + matcher.group(4) + " originally defined in file " + getFileName(matcher);
|
||||
}
|
||||
},
|
||||
new ErrorPattern(Messages.XlcErrorParser_CompilerErrorPattern, 1, 2, 5, 0, -1) {
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.errorparsers.ErrorPattern#getSeverity(java.util.regex.Matcher)
|
||||
*/
|
||||
@Override
|
||||
public int getSeverity(Matcher matcher) {
|
||||
String warningGroup = matcher.group(4);
|
||||
if (warningGroup != null) {
|
||||
if (warningGroup.equals(Messages.XlcErrorParser_FlagUnrecoverable)) {
|
||||
return IMarkerGenerator.SEVERITY_ERROR_BUILD;
|
||||
} else if (warningGroup.equals(Messages.XlcErrorParser_FlagSevere)
|
||||
|| warningGroup.equals(Messages.XlcErrorParser_FlagError)) {
|
||||
return IMarkerGenerator.SEVERITY_ERROR_RESOURCE;
|
||||
} else if (warningGroup.equals(Messages.XlcErrorParser_FlagWarning)) {
|
||||
return IMarkerGenerator.SEVERITY_WARNING;
|
||||
} else if (warningGroup.equals(Messages.XlcErrorParser_FlagInfo)) {
|
||||
return IMarkerGenerator.SEVERITY_INFO;
|
||||
}
|
||||
}
|
||||
return IMarkerGenerator.SEVERITY_INFO;
|
||||
}
|
||||
},
|
||||
new ErrorPattern(Messages.XlcErrorParser_LinkerErrorPattern, 0, 0, 3, 0, -1) {
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.errorparsers.ErrorPattern#getSeverity(java.util.regex.Matcher)
|
||||
*/
|
||||
@Override
|
||||
public int getSeverity(Matcher matcher) {
|
||||
String warningGroup = matcher.group(2);
|
||||
if (warningGroup != null) {
|
||||
if (warningGroup.indexOf(Messages.XlcErrorParser_LinkerWarning) >= 0) {
|
||||
return IMarkerGenerator.SEVERITY_WARNING;
|
||||
} else if (warningGroup.indexOf(Messages.XlcErrorParser_LinkerError) >= 0) {
|
||||
return IMarkerGenerator.SEVERITY_ERROR_RESOURCE;
|
||||
}
|
||||
}
|
||||
return IMarkerGenerator.SEVERITY_INFO;
|
||||
}
|
||||
},
|
||||
new ErrorPattern(Messages.XlcErrorParser_LinkerErrorPattern2, 0, 0, 2, 0, -1) {
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.errorparsers.ErrorPattern#getSeverity(java.util.regex.Matcher)
|
||||
*/
|
||||
@Override
|
||||
public int getSeverity(Matcher matcher) {
|
||||
return IMarkerGenerator.SEVERITY_ERROR_RESOURCE;
|
||||
}
|
||||
},
|
||||
new ErrorPattern(Messages.XlcErrorParser_LinkerInfoPattern, 0, 0, 2, 0, -1) {
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.errorparsers.ErrorPattern#getSeverity(java.util.regex.Matcher)
|
||||
*/
|
||||
@Override
|
||||
public int getSeverity(Matcher matcher) {
|
||||
return IMarkerGenerator.SEVERITY_INFO;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* The constructor.
|
||||
*/
|
||||
public XlcErrorParser() {
|
||||
super(patterns);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2006, 2008 IBM Corporation and others.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Contributors:
|
||||
# Andrew Gvozdev - Initial implementation
|
||||
###############################################################################
|
||||
|
||||
# Translators: do not translate this file. We currently do not support NL versions of the XL C/C++ compilers.
|
||||
|
||||
# "main.cpp", line 10.6: 1540-0064 (S) Syntax error: "name" was expected but "char" was found.
|
||||
XlcErrorParser_CompilerErrorPattern=[\"]?(.*?)[\"]?, line ([0-9]+)\\.[0-9]+:( [0-9]*-[0-9]*)? \\(([USEWI])\\)\\s*(.*)
|
||||
# "hello.c", line 5.9: 1506-358 (I) "MACRO" is defined on line 3 of hello.h.
|
||||
XlcErrorParser_MacroRedefinitionErrorPattern=[\"]?(.*?)[\"]?, line ([0-9]+)\\.[0-9]+:( [0-9]*-[0-9]*)? \\(I\\)\\s*[\"]?(\\w*)[\"]? is defined on line ([0-9]+) of (.*)\\.
|
||||
|
||||
XlcErrorParser_FlagUnrecoverable=U
|
||||
XlcErrorParser_FlagSevere=S
|
||||
XlcErrorParser_FlagError=E
|
||||
XlcErrorParser_FlagWarning=W
|
||||
XlcErrorParser_FlagInfo=I
|
||||
|
||||
# ld: 0711-224 WARNING: Duplicate symbol: symboldupe
|
||||
# WARNING, ERROR, SEVERE ERROR etc.
|
||||
XlcErrorParser_LinkerErrorPattern=ld: ([0-9]+-[0-9]+) (.*[(WARNING)(ERROR)]:)? (.*)
|
||||
XlcErrorParser_LinkerWarning=WARNING
|
||||
XlcErrorParser_LinkerError=ERROR
|
||||
|
||||
# ld: 0711-987 Error occurred while reading file
|
||||
XlcErrorParser_LinkerErrorPattern2=ld: ([0-9]+-[0-9]+) (Error .*)
|
||||
|
||||
# ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
|
||||
XlcErrorParser_LinkerInfoPattern=ld: ([0-9]+-[0-9]+) (.*)
|
||||
|
||||
|
Loading…
Reference in a new issue