From 5358c015a3c5ff21be42c8bed418dbf7f517c001 Mon Sep 17 00:00:00 2001 From: Chris Recoskie Date: Tue, 2 Jun 2009 14:38:25 +0000 Subject: [PATCH] RESOLVED - bug 258385: xlC error parser should extend AbstractErrorParser (to disambiguate files with the same name) https://bugs.eclipse.org/bugs/show_bug.cgi?id=258385 --- .../META-INF/MANIFEST.MF | 2 + .../xlc/tests/AllXlcErrorParserTests.java | 8 + .../xlc/tests/TestCompatibility.java | 39 +++ .../xlc/tests/TestConditional.java | 8 +- .../xlc/tests/TestFloatingPoint.java | 8 +- .../errorparsers/xlc/tests/TestFuncArg.java | 8 +- .../xlc/tests/TestLinkerDuplicateSymbol.java | 40 +++ .../tests/TestLinkerErrorWhileReading.java | 40 +++ .../xlc/tests/TestLinkerInfo.java | 40 +++ .../xlc/tests/TestLinkerSevereError.java | 40 +++ .../xlc/tests/TestLinkerUndefinedSymbol.java | 40 +++ .../xlc/tests/TestMacroRedefinition.java | 42 +++ .../xlc/tests/TestMissingArg.java | 8 +- .../xlc/tests/TestNoFuncProto.java | 8 +- .../errorparsers/xlc/tests/TestOperModi.java | 8 +- .../xlc/tests/TestSyntaxError.java | 8 +- .../xlc/tests/TestUndeclIdent.java | 8 +- .../xlc/tests/TestUnrecoverableError.java | 40 +++ .../errorparsers/xlc/tests/TestsPlugin.java | 6 +- .../xlc/tests/XlcErrorParserTester.java | 133 ++++++++ .../cdt/errorparsers/xlc/Messages.java | 38 +++ .../cdt/errorparsers/xlc/XlcErrorParser.java | 314 ++++++------------ .../cdt/errorparsers/xlc/messages.properties | 37 +++ 23 files changed, 683 insertions(+), 240 deletions(-) create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestCompatibility.java create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerDuplicateSymbol.java create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerErrorWhileReading.java create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerInfo.java create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerSevereError.java create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerUndefinedSymbol.java create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestMacroRedefinition.java create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUnrecoverableError.java create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/XlcErrorParserTester.java create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc/src/org/eclipse/cdt/errorparsers/xlc/Messages.java create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc/src/org/eclipse/cdt/errorparsers/xlc/messages.properties diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/META-INF/MANIFEST.MF b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/META-INF/MANIFEST.MF index 0713adeca1f..a0af1819a53 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/META-INF/MANIFEST.MF +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/META-INF/MANIFEST.MF @@ -6,6 +6,8 @@ Bundle-Version: 1.0.0 Bundle-Activator: org.eclipse.cdt.errorparsers.xlc.tests.TestsPlugin Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, + org.eclipse.core.resources, + org.eclipse.cdt.core, org.eclipse.cdt.errorparsers.xlc, org.junit Bundle-ActivationPolicy: lazy diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/AllXlcErrorParserTests.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/AllXlcErrorParserTests.java index 72bcdaa7f52..f4edce873be 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/AllXlcErrorParserTests.java +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/AllXlcErrorParserTests.java @@ -30,6 +30,14 @@ public class AllXlcErrorParserTests { suite.addTestSuite(TestConditional.class); suite.addTestSuite(TestSyntaxError.class); suite.addTestSuite(TestNoFuncProto.class); + suite.addTestSuite(TestCompatibility.class); + suite.addTestSuite(TestUnrecoverableError.class); + suite.addTestSuite(TestMacroRedefinition.class); + suite.addTestSuite(TestLinkerUndefinedSymbol.class); + suite.addTestSuite(TestLinkerDuplicateSymbol.class); + suite.addTestSuite(TestLinkerSevereError.class); + suite.addTestSuite(TestLinkerErrorWhileReading.class); + suite.addTestSuite(TestLinkerInfo.class); //$JUnit-END$ return suite; } diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestCompatibility.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestCompatibility.java new file mode 100644 index 00000000000..8ede91fc8f7 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestCompatibility.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2006 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 + *******************************************************************************/ +package org.eclipse.cdt.errorparsers.xlc.tests; + +import junit.framework.TestCase; + +import org.eclipse.cdt.core.IMarkerGenerator; + +public class TestCompatibility extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. Error message generated by + * xlC compiler without message number or quotes around file name + * which was OK in older version. + */ + public void testparseLine() + { + XlcErrorParserTester aix = new XlcErrorParserTester(); + aix.parseLine(err_msg); + assertEquals("temp1.c", aix.getFileName()); + assertEquals(5, aix.getLineNumber()); + assertEquals(IMarkerGenerator.SEVERITY_INFO, aix.getSeverity()); + assertEquals(" Compatibility test",aix.getMessage()); + } + public TestCompatibility( String name) + { + super(name); + err_msg = "temp1.c, line 5.1: (I) Compatibility test"; + } +} diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestConditional.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestConditional.java index 0da09d25f3c..442d232e587 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestConditional.java +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestConditional.java @@ -11,10 +11,10 @@ package org.eclipse.cdt.errorparsers.xlc.tests; -import org.eclipse.cdt.errorparsers.xlc.XlcErrorParser; - import junit.framework.TestCase; +import org.eclipse.cdt.core.IMarkerGenerator; + public class TestConditional extends TestCase { String err_msg; @@ -25,11 +25,11 @@ public class TestConditional extends TestCase { */ public void testparseLine() { - XlcErrorParser aix = new XlcErrorParser(); + XlcErrorParserTester aix = new XlcErrorParserTester(); aix.parseLine(err_msg); assertEquals("temp8.c", aix.getFileName()); assertEquals(12, aix.getLineNumber()); - assertEquals("I", aix.getSeverity()); + assertEquals(IMarkerGenerator.SEVERITY_INFO, aix.getSeverity()); assertEquals(" The then branch of conditional is an empty statement.",aix.getMessage()); } public TestConditional( String name) diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestFloatingPoint.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestFloatingPoint.java index 0460d5e5789..811bd94f2a1 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestFloatingPoint.java +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestFloatingPoint.java @@ -11,10 +11,10 @@ package org.eclipse.cdt.errorparsers.xlc.tests; -import org.eclipse.cdt.errorparsers.xlc.XlcErrorParser; - import junit.framework.TestCase; +import org.eclipse.cdt.core.IMarkerGenerator; + public class TestFloatingPoint extends TestCase { String err_msg; @@ -26,11 +26,11 @@ public class TestFloatingPoint extends TestCase { */ public void testparseLine() { - XlcErrorParser aix = new XlcErrorParser(); + XlcErrorParserTester aix = new XlcErrorParserTester(); aix.parseLine(err_msg); assertEquals("temp9.c", aix.getFileName()); assertEquals(11, aix.getLineNumber()); - assertEquals("S", aix.getSeverity()); + assertEquals(IMarkerGenerator.SEVERITY_ERROR_RESOURCE, aix.getSeverity()); assertEquals(" Floating point constant 10.23.3 is not valid", aix.getMessage()); } diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestFuncArg.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestFuncArg.java index 96b42de2242..d8642a07418 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestFuncArg.java +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestFuncArg.java @@ -11,10 +11,10 @@ package org.eclipse.cdt.errorparsers.xlc.tests; -import org.eclipse.cdt.errorparsers.xlc.XlcErrorParser; - import junit.framework.TestCase; +import org.eclipse.cdt.core.IMarkerGenerator; + public class TestFuncArg extends TestCase { String err_msg; /** @@ -25,11 +25,11 @@ public class TestFuncArg extends TestCase { */ public void testparseLine() { - XlcErrorParser aix = new XlcErrorParser(); + XlcErrorParserTester aix = new XlcErrorParserTester(); aix.parseLine(err_msg); assertEquals("temp9.c", aix.getFileName()); assertEquals(12, aix.getLineNumber()); - assertEquals("S", aix.getSeverity()); + assertEquals(IMarkerGenerator.SEVERITY_ERROR_RESOURCE, aix.getSeverity()); assertEquals(" Function argument assignment between types " + "\"int\" and \"char*\" is not allowed.", aix.getMessage()); diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerDuplicateSymbol.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerDuplicateSymbol.java new file mode 100644 index 00000000000..7003cd0cf99 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerDuplicateSymbol.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2006 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 + *******************************************************************************/ + +package org.eclipse.cdt.errorparsers.xlc.tests; + +import junit.framework.TestCase; + +import org.eclipse.cdt.core.IMarkerGenerator; + +public class TestLinkerDuplicateSymbol extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. Error message generated by + * xlc linker with "WARNING" level is given as + * input for testing. + */ + public void testparseLine() + { + XlcErrorParserTester aix = new XlcErrorParserTester(); + aix.parseLine(err_msg); + assertEquals("", aix.getFileName()); + assertEquals(0, aix.getLineNumber()); + assertEquals(IMarkerGenerator.SEVERITY_WARNING, aix.getSeverity()); + assertEquals("Duplicate symbol: dupefun",aix.getMessage()); + } + public TestLinkerDuplicateSymbol( String name) + { + super(name); + err_msg = "ld: 0711-224 WARNING: Duplicate symbol: dupefun"; + } +} diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerErrorWhileReading.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerErrorWhileReading.java new file mode 100644 index 00000000000..9fdaa1d496c --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerErrorWhileReading.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2006 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 + *******************************************************************************/ + +package org.eclipse.cdt.errorparsers.xlc.tests; + +import junit.framework.TestCase; + +import org.eclipse.cdt.core.IMarkerGenerator; + +public class TestLinkerErrorWhileReading extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. Error message generated by + * xlc linker with "ERROR" level is given as + * input for testing. + */ + public void testparseLine() + { + XlcErrorParserTester aix = new XlcErrorParserTester(); + aix.parseLine(err_msg); + assertEquals("", aix.getFileName()); + assertEquals(0, aix.getLineNumber()); + assertEquals(IMarkerGenerator.SEVERITY_ERROR_RESOURCE, aix.getSeverity()); + assertEquals("Error occurred while reading file",aix.getMessage()); + } + public TestLinkerErrorWhileReading( String name) + { + super(name); + err_msg = "ld: 0711-987 Error occurred while reading file"; + } +} diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerInfo.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerInfo.java new file mode 100644 index 00000000000..c3c81cd323f --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerInfo.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2006 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 + *******************************************************************************/ + +package org.eclipse.cdt.errorparsers.xlc.tests; + +import junit.framework.TestCase; + +import org.eclipse.cdt.core.IMarkerGenerator; + +public class TestLinkerInfo extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. Informational message generated by + * xlc linker is given as + * input for testing. + */ + public void testparseLine() + { + XlcErrorParserTester aix = new XlcErrorParserTester(); + aix.parseLine(err_msg); + assertEquals("", aix.getFileName()); + assertEquals(0, aix.getLineNumber()); + assertEquals(IMarkerGenerator.SEVERITY_INFO, aix.getSeverity()); + assertEquals("Use the -bloadmap or -bnoquiet option to obtain more information.",aix.getMessage()); + } + public TestLinkerInfo( String name) + { + super(name); + err_msg = "ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information."; + } +} diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerSevereError.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerSevereError.java new file mode 100644 index 00000000000..0cac0ebec97 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerSevereError.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2006 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 + *******************************************************************************/ + +package org.eclipse.cdt.errorparsers.xlc.tests; + +import junit.framework.TestCase; + +import org.eclipse.cdt.core.IMarkerGenerator; + +public class TestLinkerSevereError extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. Error message generated by + * xlc linker with "SEVERE ERROR" level is given as + * input for testing. + */ + public void testparseLine() + { + XlcErrorParserTester aix = new XlcErrorParserTester(); + aix.parseLine(err_msg); + assertEquals("", aix.getFileName()); + assertEquals(0, aix.getLineNumber()); + assertEquals(IMarkerGenerator.SEVERITY_ERROR_RESOURCE, aix.getSeverity()); + assertEquals("EXEC binder commands nested too deeply.",aix.getMessage()); + } + public TestLinkerSevereError( String name) + { + super(name); + err_msg = "ld: 0711-634 SEVERE ERROR: EXEC binder commands nested too deeply."; + } +} diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerUndefinedSymbol.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerUndefinedSymbol.java new file mode 100644 index 00000000000..25fea59c611 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerUndefinedSymbol.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2006 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 + *******************************************************************************/ + +package org.eclipse.cdt.errorparsers.xlc.tests; + +import junit.framework.TestCase; + +import org.eclipse.cdt.core.IMarkerGenerator; + +public class TestLinkerUndefinedSymbol extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. Error message generated by + * xlc linker with "ERROR" level is given as + * input for testing. + */ + public void testparseLine() + { + XlcErrorParserTester aix = new XlcErrorParserTester(); + aix.parseLine(err_msg); + assertEquals("", aix.getFileName()); + assertEquals(0, aix.getLineNumber()); + assertEquals(IMarkerGenerator.SEVERITY_ERROR_RESOURCE, aix.getSeverity()); + assertEquals("Undefined symbol: nofun()",aix.getMessage()); + } + public TestLinkerUndefinedSymbol( String name) + { + super(name); + err_msg = "ld: 0711-317 ERROR: Undefined symbol: nofun()"; + } +} diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestMacroRedefinition.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestMacroRedefinition.java new file mode 100644 index 00000000000..11df2657eec --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestMacroRedefinition.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2006 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 + *******************************************************************************/ +package org.eclipse.cdt.errorparsers.xlc.tests; + +import junit.framework.TestCase; + +import org.eclipse.cdt.core.IMarkerGenerator; + +public class TestMacroRedefinition extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. The second message generated by + * xlc compiler for macro redefinition problem is given as + * input for testing. + */ + public void testparseLine() + { + XlcErrorParserTester aix = new XlcErrorParserTester(); + aix.parseLine(err_msg); + assertEquals("temp1.h", aix.getFileName()); + assertEquals(3, aix.getLineNumber()); + assertEquals(IMarkerGenerator.SEVERITY_WARNING, aix.getSeverity()); + assertEquals(" Macro name TEMP_1 originally defined in file temp1.h",aix.getMessage()); + } + public TestMacroRedefinition( String name) + { + super(name); + // Macro redefinition warning provides 2 lines. First line is captured as regular warning message. + // "temp1.c", line 5.9: 1506-236 (W) Macro name TEMP_1 has been redefined. + // Second line is re-parsed to stay close to the first one and point to file with original definition + err_msg = "\"temp1.c\", line 5.9: 1506-358 (I) \"TEMP_1\" is defined on line 3 of temp1.h."; + } +} \ No newline at end of file diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestMissingArg.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestMissingArg.java index bf2cb85eb1a..2983514e2a0 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestMissingArg.java +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestMissingArg.java @@ -11,10 +11,10 @@ package org.eclipse.cdt.errorparsers.xlc.tests; -import org.eclipse.cdt.errorparsers.xlc.XlcErrorParser; - import junit.framework.TestCase; +import org.eclipse.cdt.core.IMarkerGenerator; + public class TestMissingArg extends TestCase { String err_msg; @@ -26,11 +26,11 @@ public class TestMissingArg extends TestCase { */ public void testparseLine() { - XlcErrorParser aix = new XlcErrorParser(); + XlcErrorParserTester aix = new XlcErrorParserTester(); aix.parseLine(err_msg); assertEquals("temp8.c", aix.getFileName()); assertEquals(9, aix.getLineNumber()); - assertEquals("E", aix.getSeverity()); + assertEquals(IMarkerGenerator.SEVERITY_ERROR_RESOURCE, aix.getSeverity()); assertEquals(" Missing argument(s).",aix.getMessage()); } public TestMissingArg( String name) diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestNoFuncProto.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestNoFuncProto.java index c8e66ad653f..5a327681e3d 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestNoFuncProto.java +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestNoFuncProto.java @@ -10,10 +10,10 @@ *******************************************************************************/ package org.eclipse.cdt.errorparsers.xlc.tests; -import org.eclipse.cdt.errorparsers.xlc.XlcErrorParser; - import junit.framework.TestCase; +import org.eclipse.cdt.core.IMarkerGenerator; + public class TestNoFuncProto extends TestCase { String err_msg; /** @@ -23,11 +23,11 @@ public class TestNoFuncProto extends TestCase { */ public void testparseLine() { - XlcErrorParser aix = new XlcErrorParser(); + XlcErrorParserTester aix = new XlcErrorParserTester(); aix.parseLine(err_msg); assertEquals("temp1.c", aix.getFileName()); assertEquals(5, aix.getLineNumber()); - assertEquals("W", aix.getSeverity()); + assertEquals(IMarkerGenerator.SEVERITY_WARNING, aix.getSeverity()); assertEquals(" No function prototype given for \"printf\".",aix.getMessage()); } public TestNoFuncProto( String name) diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestOperModi.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestOperModi.java index aac5e04c101..af301cfd7c6 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestOperModi.java +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestOperModi.java @@ -10,10 +10,10 @@ *******************************************************************************/ package org.eclipse.cdt.errorparsers.xlc.tests; -import org.eclipse.cdt.errorparsers.xlc.XlcErrorParser; - import junit.framework.TestCase; +import org.eclipse.cdt.core.IMarkerGenerator; + public class TestOperModi extends TestCase { String err_msg; @@ -25,11 +25,11 @@ public class TestOperModi extends TestCase { */ public void testparseLine() { - XlcErrorParser aix = new XlcErrorParser(); + XlcErrorParserTester aix = new XlcErrorParserTester(); aix.parseLine(err_msg); assertEquals("temp9.c", aix.getFileName()); assertEquals(13, aix.getLineNumber()); - assertEquals("S", aix.getSeverity()); + assertEquals(IMarkerGenerator.SEVERITY_ERROR_RESOURCE, aix.getSeverity()); assertEquals(" Operand must be a modifiable lvalue.",aix.getMessage()); } public TestOperModi( String name) diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSyntaxError.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSyntaxError.java index d71de9a2815..64a172b7ac5 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSyntaxError.java +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSyntaxError.java @@ -10,10 +10,10 @@ *******************************************************************************/ package org.eclipse.cdt.errorparsers.xlc.tests; -import org.eclipse.cdt.errorparsers.xlc.XlcErrorParser; - import junit.framework.TestCase; +import org.eclipse.cdt.core.IMarkerGenerator; + public class TestSyntaxError extends TestCase { String err_msg; /** @@ -24,11 +24,11 @@ public class TestSyntaxError extends TestCase { */ public void testparseLine() { - XlcErrorParser aix = new XlcErrorParser(); + XlcErrorParserTester aix = new XlcErrorParserTester(); aix.parseLine(err_msg); assertEquals("temp1.c", aix.getFileName()); assertEquals(5, aix.getLineNumber()); - assertEquals("S", aix.getSeverity()); + assertEquals(IMarkerGenerator.SEVERITY_ERROR_RESOURCE, aix.getSeverity()); assertEquals(" Syntax error: possible missing ')'?",aix.getMessage()); } public TestSyntaxError( String name) diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUndeclIdent.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUndeclIdent.java index d9ddcb0b67b..2c2dc4468bd 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUndeclIdent.java +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUndeclIdent.java @@ -11,10 +11,10 @@ package org.eclipse.cdt.errorparsers.xlc.tests; -import org.eclipse.cdt.errorparsers.xlc.XlcErrorParser; - import junit.framework.TestCase; +import org.eclipse.cdt.core.IMarkerGenerator; + public class TestUndeclIdent extends TestCase { String err_msg; /** @@ -25,11 +25,11 @@ public class TestUndeclIdent extends TestCase { */ public void testparseLine() { - XlcErrorParser aix = new XlcErrorParser(); + XlcErrorParserTester aix = new XlcErrorParserTester(); aix.parseLine(err_msg); assertEquals("temp5.c", aix.getFileName()); assertEquals(5, aix.getLineNumber()); - assertEquals("S", aix.getSeverity()); + assertEquals(IMarkerGenerator.SEVERITY_ERROR_RESOURCE, aix.getSeverity()); assertEquals(" Undeclared identifier y.",aix.getMessage()); } public TestUndeclIdent( String name) diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUnrecoverableError.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUnrecoverableError.java new file mode 100644 index 00000000000..5c3e26f0c0b --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUnrecoverableError.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2006 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 + *******************************************************************************/ +package org.eclipse.cdt.errorparsers.xlc.tests; + +import junit.framework.TestCase; + +import org.eclipse.cdt.core.IMarkerGenerator; + +public class TestUnrecoverableError extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. Error message generated by + * xlc compiler with unrecoverable severity (U) is given as + * input for testing. + */ + public void testparseLine() + { + XlcErrorParserTester aix = new XlcErrorParserTester(); + aix.parseLine(err_msg); + assertEquals("temp1.c", aix.getFileName()); + assertEquals(5, aix.getLineNumber()); + assertEquals(IMarkerGenerator.SEVERITY_ERROR_BUILD, aix.getSeverity()); + assertEquals(" INTERNAL COMPILER ERROR",aix.getMessage()); + } + public TestUnrecoverableError( String name) + { + super(name); + err_msg = "\"temp1.c\", line 5.1: 1506-001 (U) " + + "INTERNAL COMPILER ERROR"; + } +} diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestsPlugin.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestsPlugin.java index f9d6b719eba..bccab9e8970 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestsPlugin.java +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestsPlugin.java @@ -11,10 +11,12 @@ package org.eclipse.cdt.errorparsers.xlc.tests; -import org.eclipse.ui.plugin.*; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import java.util.*; /** * The main plugin class to be used in the desktop. diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/XlcErrorParserTester.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/XlcErrorParserTester.java new file mode 100644 index 00000000000..3cc193b8660 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/XlcErrorParserTester.java @@ -0,0 +1,133 @@ +/******************************************************************************* + * 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: + * IBM Corporation - initial API and implementation + * Andrew Gvozdev + *******************************************************************************/ + +package org.eclipse.cdt.errorparsers.xlc.tests; + +import junit.framework.Assert; + +import org.eclipse.cdt.core.ErrorParserManager; +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; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; + +/* + * Helper tester class to be able to test XlcErrorParser which extends AbstractErrorParser. + */ + +public class XlcErrorParserTester { + static private int counter=0; + IProject fTempProject = ResourcesPlugin.getWorkspace().getRoot().getProject("XlcErrorParserTester.temp." + counter++); + + XlcErrorParserTester() { + try { + fTempProject.create(null); + } catch (CoreException e) { + e.printStackTrace(); + Assert.fail("Exception creating temporary project "+fTempProject.getName()+": "+e); + } + } + + private String fileName; + private int lineNumber; + private int severity; + private String message; + + /* + * Dummy class implementing IMarkerGenerator lets get through testing + * without NPE. + */ + private class MockMarkerGenerator implements IMarkerGenerator { + + public void addMarker(IResource file, int lineNumber, String errorDesc, + int severity, String errorVar) { + // dummy + } + + public void addMarker(ProblemMarkerInfo problemMarkerInfo) { + // dummy + } + + } + + /* + * Class MockErrorParserManager replaces ErrorParserManager + * with the purpose to be able to inquire how the line was parsed. + * fileName, lineNumber, message and severity are populated + * to be accessed from the test cases. + * Relying on internal implementation of ErrorPattern.RecordError() + * to provide necessary data via generateExternalMarker() call + */ + private class MockErrorParserManager extends ErrorParserManager { + + private MockErrorParserManager() { + super(fTempProject, new MockMarkerGenerator()); + } + + /* + * A stub function just to return non-null IFile. + * Necessary to trick ErrorPattern.RecordError() to generate markers. + */ + @Override + public IFile findFileName(String fileName) { + return fTempProject.getFile(fileName); + } + + /** + * 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(); + } else { + fileName=""; + } + lineNumber = lineNumb; + message = desc; + severity = sev; + } + } + + /** + * Main method called by individual error parser tests. + * @param line one xlC error message + * @return + */ + boolean parseLine(String line) { + XlcErrorParser errorParser = new XlcErrorParser(); + + MockErrorParserManager epManager = new MockErrorParserManager(); + return errorParser.processLine(line, epManager); + } + + String getFileName() { + return fileName; + } + + int getLineNumber() { + return lineNumber; + } + + int getSeverity() { + return severity; + } + + String getMessage() { + return message; + } +} diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc/src/org/eclipse/cdt/errorparsers/xlc/Messages.java b/xlc/org.eclipse.cdt.errorparsers.xlc/src/org/eclipse/cdt/errorparsers/xlc/Messages.java new file mode 100644 index 00000000000..24c533c5e62 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc/src/org/eclipse/cdt/errorparsers/xlc/Messages.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * 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() { + } +} diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc/src/org/eclipse/cdt/errorparsers/xlc/XlcErrorParser.java b/xlc/org.eclipse.cdt.errorparsers.xlc/src/org/eclipse/cdt/errorparsers/xlc/XlcErrorParser.java index dd94fd4afff..342aa9c1bac 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc/src/org/eclipse/cdt/errorparsers/xlc/XlcErrorParser.java +++ b/xlc/org.eclipse.cdt.errorparsers.xlc/src/org/eclipse/cdt/errorparsers/xlc/XlcErrorParser.java @@ -1,225 +1,127 @@ /******************************************************************************* - * 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: + * 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: * IBM Corporation - initial API and implementation + * Andrew Gvozdev (Quoin Inc.) *******************************************************************************/ - - package org.eclipse.cdt.errorparsers.xlc; -import java.util.StringTokenizer; -import org.eclipse.cdt.core.ErrorParserManager; -import org.eclipse.cdt.core.IErrorParser; -import org.eclipse.cdt.core.IMarkerGenerator; -import org.eclipse.core.resources.IFile; /** - * This class provides methods for parsing the error messages - * generated by xlc compiler. - * @author ravisankar + * This class provides for parsing the error messages generated by IBM AIX xlC compiler. * */ -public class XlcErrorParser implements IErrorParser -{ - private String fileName; - private int lineNumber; - private String severity; - private String message; - private int severityNum; - public XlcErrorParser() - { - fileName = null; - lineNumber = -1; - severity = null; - message = null; - severityNum = -1; - } - /** - * This function returns the file name extracted from - * the error message. - * @return The string value of the given file name. - */ - public String getFileName() - { - return fileName; - } - /** - * This function returns the line number of - * the error. - * @return The integer value of the line number. - */ - public int getLineNumber() - { - return lineNumber; - } - /** - * This function returns the severity of the - * error that has occured. - * @return The string value of the severity. - */ - public String getSeverity() - { - return severity; - } - /** - * This function returns the descriptive string of the - * error that has occured. - * @return The string value of the message. - */ - public String getMessage() - { - return message; - } - /** - * This function parses the error message occured and fills the - * class variables fileName, lineNumber, message, severity. - * @param line is the error message generated by the xlC compiler. - * @return a boolean value indicating the success/failure of - * extracting the values for fileName, lineNumber, message, severity. - */ - public boolean parseLine(String line) - { - String lineNum = null; - String secondPart = null; - StringTokenizer tok = null; - int firstComma = line.indexOf(','); //$NON-NLS-1$ - // Check for the first occurance of comma. - if( firstComma != -1 ) - { - String firstPart = line.substring(0,firstComma); - /* Check for double-quotes before the first occurance - of comma. */ - tok = new StringTokenizer(firstPart,"\""); //$NON-NLS-1$ - if(tok.hasMoreTokens()) - { - fileName = tok.nextToken(); - } - else - { - /* If the file name doesnot exist return - false. */ - return false; - } - secondPart = line.substring(firstComma + 1); - /* look for '.' character after the first occurance - of comma. */ - tok = new StringTokenizer(secondPart,"."); //$NON-NLS-1$ - if(tok.countTokens()>1) - { - String token = tok.nextToken(); - /* look for the string "line " before the - the occurance of '.' operator. */ - int index; - if( (index = token.indexOf("line ")) != -1) //$NON-NLS-1$ - { - /* The string that begins after "line " and ends - before '.' operator is the line number. */ - lineNum = token.substring(index + 5); - lineNumber = Integer.parseInt(lineNum); - } - else - { - return false; - } - } - int index = -1; - /* look for the first occurance of ")" after the - * first occurance of comma. + +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) */ - index = secondPart.indexOf(")"); //$NON-NLS-1$ - if( -1 == index ) - { - return false; + @Override + public int getSeverity(Matcher matcher) { + return IMarkerGenerator.SEVERITY_WARNING; } - /* The character that resides before the ")" operator - * indicates the severity of the message. The part of the - * error message that follows ")" is the description of the - * error. + /* + * @see org.eclipse.cdt.core.errorparsers.ErrorPattern#getDesc(java.util.regex.Matcher) */ - message = secondPart.substring(index + 1); - severity = secondPart.substring(index - 1, index); - if( severity.equals("I") ) //$NON-NLS-1$ - { - severityNum = IMarkerGenerator.SEVERITY_INFO; + @Override + public String getDesc(Matcher matcher) { + return " Macro name " + matcher.group(4) + " originally defined in file " + getFileName(matcher); } - else if( severity.equals("W") ) //$NON-NLS-1$ - { - severityNum = IMarkerGenerator.SEVERITY_WARNING; - } - else if( severity.equals("E") || severity.equals("S") ) //$NON-NLS-1$ //$NON-NLS-2$ - { - severityNum = IMarkerGenerator.SEVERITY_ERROR_RESOURCE; - } - else if( severity.equals("U") ) //$NON-NLS-1$ - { - severityNum = IMarkerGenerator.SEVERITY_ERROR_BUILD; - } - else - { - return false; - } - } - else - { - return false; - } - return true; - } - /** - * This function processes the error message and passed the information - * to the ErrorParserManager. - * @param line is the error message generated by the xlc compiler - * and eoParser is the ErrorParserManager object. - * @return a boolean value indicating the success/failure of - * extracing values from the error message. - */ - public boolean processLine(String line, ErrorParserManager eoParser) - { - try - { - if( parseLine(line) ) - { - IFile file = null; - if (fileName != null) - { - file = eoParser.findFileName(fileName); - if (file != null) - { - /* Check if there are conflicting file - * names. - */ - if (eoParser.isConflictingName(fileName)) - { - file = null; - } - } - else - { - // Find the path of the file. - file = eoParser.findFilePath(fileName); - } - if (file == null) - { - message = fileName + " " + message; //$NON-NLS-1$ + }, + 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; } } - eoParser.generateMarker(file, lineNumber, message, severityNum, null); - return true; + return IMarkerGenerator.SEVERITY_INFO; } - else - { - return false; + }, + 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; } - } - catch(NumberFormatException e ) - { - return false; - } + }, + 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); } -} \ No newline at end of file + +} diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc/src/org/eclipse/cdt/errorparsers/xlc/messages.properties b/xlc/org.eclipse.cdt.errorparsers.xlc/src/org/eclipse/cdt/errorparsers/xlc/messages.properties new file mode 100644 index 00000000000..62032b49e76 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc/src/org/eclipse/cdt/errorparsers/xlc/messages.properties @@ -0,0 +1,37 @@ +############################################################################### +# 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])\\)(.*) +# "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\\) [\"]?(\\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]+) (.*) + +