From b87f4ffff212c944240e45d8019c42293d01b372 Mon Sep 17 00:00:00 2001 From: Chris Recoskie Date: Mon, 24 Jul 2006 18:34:31 +0000 Subject: [PATCH] initial commit of xlC error parser --- .../.classpath | 7 + .../.project | 28 +++ .../META-INF/MANIFEST.MF | 15 ++ .../about.html | 24 ++ .../build.properties | 8 + .../plugin.xml | 2 + .../xlc/tests/AllXlcErrorParserTests.java | 36 +++ .../xlc/tests/TestConditional.java | 41 ++++ .../xlc/tests/TestFloatingPoint.java | 43 ++++ .../errorparsers/xlc/tests/TestFuncArg.java | 44 ++++ .../xlc/tests/TestMissingArg.java | 42 ++++ .../xlc/tests/TestNoFuncProto.java | 39 +++ .../errorparsers/xlc/tests/TestOperModi.java | 41 ++++ .../xlc/tests/TestSyntaxError.java | 40 ++++ .../xlc/tests/TestUndeclIdent.java | 41 ++++ .../errorparsers/xlc/tests/TestsPlugin.java | 95 ++++++++ .../.classpath | 7 + xlc/org.eclipse.cdt.errorparsers.xlc/.project | 28 +++ .../META-INF/MANIFEST.MF | 14 ++ .../about.html | 24 ++ .../build.properties | 4 + .../plugin.properties | 4 + .../plugin.xml | 7 + .../cdt/errorparsers/xlc/Activator.java | 61 +++++ .../cdt/errorparsers/xlc/XlcErrorParser.java | 225 ++++++++++++++++++ 25 files changed, 920 insertions(+) create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/.classpath create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/.project create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/META-INF/MANIFEST.MF create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/about.html create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/build.properties create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/plugin.xml create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/AllXlcErrorParserTests.java create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestConditional.java create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestFloatingPoint.java create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestFuncArg.java create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestMissingArg.java create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestNoFuncProto.java create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestOperModi.java create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSyntaxError.java create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUndeclIdent.java create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestsPlugin.java create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc/.classpath create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc/.project create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc/META-INF/MANIFEST.MF create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc/about.html create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc/build.properties create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc/plugin.properties create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc/plugin.xml create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc/src/org/eclipse/cdt/errorparsers/xlc/Activator.java create mode 100644 xlc/org.eclipse.cdt.errorparsers.xlc/src/org/eclipse/cdt/errorparsers/xlc/XlcErrorParser.java diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/.classpath b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/.classpath new file mode 100644 index 00000000000..7398f97e2d0 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/.project b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/.project new file mode 100644 index 00000000000..ab9159afd4b --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/.project @@ -0,0 +1,28 @@ + + + org.eclipse.cdt.errorparsers.xlc.tests + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + 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 new file mode 100644 index 00000000000..9aea0bd0bba --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/META-INF/MANIFEST.MF @@ -0,0 +1,15 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: xlC Error Parser Tests Plug-in +Bundle-SymbolicName: org.eclipse.cdt.errorparsers.xlc.tests +Bundle-Version: 1.0.0 +Bundle-Activator: org.eclipse.cdt.errorparsers.xlc.tests.TestsPlugin +Bundle-Localization: plugin +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.cdt.errorparsers.xlc, + org.junit +Eclipse-LazyStart: true +Export-Package: org.eclipse.cdt.errorparsers.xlc.tests +Bundle-ClassPath: . +Bundle-Vendor: Eclipse.org diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/about.html b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/about.html new file mode 100644 index 00000000000..f8a1ce18403 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/about.html @@ -0,0 +1,24 @@ + + +About + + +

About This Content

+ +

July 24, 2006

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + \ No newline at end of file diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/build.properties b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/build.properties new file mode 100644 index 00000000000..64ed0af057d --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/build.properties @@ -0,0 +1,8 @@ +bin.includes = META-INF/,\ + . +jars.compile.order = org.eclipse.cdt.errorparsers.xlc.tests.jar +src.includes = META-INF/,\ + build.properties,\ + .project,\ + .classpath +source.. = src/ diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/plugin.xml b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/plugin.xml new file mode 100644 index 00000000000..2407ba63304 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/plugin.xml @@ -0,0 +1,2 @@ + + 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 new file mode 100644 index 00000000000..72bcdaa7f52 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/AllXlcErrorParserTests.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * 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.Test; +import junit.framework.TestSuite; + +public class AllXlcErrorParserTests { + public static void main(String[] args) { + junit.textui.TestRunner.run(AllXlcErrorParserTests.suite()); + } + + public static Test suite() { + TestSuite suite = new TestSuite( + "Testsuite for xlc compiler error parser"); + //$JUnit-BEGIN$ + suite.addTestSuite(TestUndeclIdent.class); + suite.addTestSuite(TestMissingArg.class); + suite.addTestSuite(TestFloatingPoint.class); + suite.addTestSuite(TestFuncArg.class); + suite.addTestSuite(TestOperModi.class); + suite.addTestSuite(TestConditional.class); + suite.addTestSuite(TestSyntaxError.class); + suite.addTestSuite(TestNoFuncProto.class); + //$JUnit-END$ + return suite; + } +} \ No newline at end of file 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 new file mode 100644 index 00000000000..0da09d25f3c --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestConditional.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * 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 org.eclipse.cdt.errorparsers.xlc.XlcErrorParser; + +import junit.framework.TestCase; + + +public class TestConditional extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. Informative message generated + * by the xlc compiler is given as input for testing. + */ + public void testparseLine() + { + XlcErrorParser aix = new XlcErrorParser(); + aix.parseLine(err_msg); + assertEquals("temp8.c", aix.getFileName()); + assertEquals(12, aix.getLineNumber()); + assertEquals("I", aix.getSeverity()); + assertEquals(" The then branch of conditional is an empty statement.",aix.getMessage()); + } + public TestConditional( String name) + { + super(name); + err_msg = "\"temp8.c\", line 12.9: 1506-478 (I) " + + "The then branch of conditional is an empty statement."; + } +} \ No newline at end of file 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 new file mode 100644 index 00000000000..0460d5e5789 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestFloatingPoint.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * 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 org.eclipse.cdt.errorparsers.xlc.XlcErrorParser; + +import junit.framework.TestCase; + + +public class TestFloatingPoint extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. Error message generated by + * xlc compiler with high severity (S) is given as + * input for testing. + */ + public void testparseLine() + { + XlcErrorParser aix = new XlcErrorParser(); + aix.parseLine(err_msg); + assertEquals("temp9.c", aix.getFileName()); + assertEquals(11, aix.getLineNumber()); + assertEquals("S", aix.getSeverity()); + assertEquals(" Floating point constant 10.23.3 is not valid", + aix.getMessage()); + } + public TestFloatingPoint( String name) + { + super(name); + err_msg = "\"temp9.c\", line 11.18: 1506-189 (S) " + + "Floating point constant 10.23.3 is not valid"; + } +} \ No newline at end of file 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 new file mode 100644 index 00000000000..96b42de2242 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestFuncArg.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * 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 org.eclipse.cdt.errorparsers.xlc.XlcErrorParser; + +import junit.framework.TestCase; + +public class TestFuncArg extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. Error message generated by + * xlc compiler with high severity (S) is given as + * input for testing. + */ + public void testparseLine() + { + XlcErrorParser aix = new XlcErrorParser(); + aix.parseLine(err_msg); + assertEquals("temp9.c", aix.getFileName()); + assertEquals(12, aix.getLineNumber()); + assertEquals("S", aix.getSeverity()); + assertEquals(" Function argument assignment between types " + + "\"int\" and \"char*\" is not allowed.", + aix.getMessage()); + } + public TestFuncArg( String name) + { + super(name); + err_msg = "\"temp9.c\", line 12.18: 1506-280 (S) " + + "Function argument assignment between types " + + "\"int\" and \"char*\" is not allowed."; + } +} \ 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 new file mode 100644 index 00000000000..bf2cb85eb1a --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestMissingArg.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 org.eclipse.cdt.errorparsers.xlc.XlcErrorParser; + +import junit.framework.TestCase; + + +public class TestMissingArg extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. Error message generated by + * xlc compiler with medium severity (E) is given as + * input for testing. + */ + public void testparseLine() + { + XlcErrorParser aix = new XlcErrorParser(); + aix.parseLine(err_msg); + assertEquals("temp8.c", aix.getFileName()); + assertEquals(9, aix.getLineNumber()); + assertEquals("E", aix.getSeverity()); + assertEquals(" Missing argument(s).",aix.getMessage()); + } + public TestMissingArg( String name) + { + super(name); + err_msg = "\"temp8.c\", line 9.17: 1506-098 (E) " + + "Missing argument(s)."; + } +} \ No newline at end of file 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 new file mode 100644 index 00000000000..c8e66ad653f --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestNoFuncProto.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 org.eclipse.cdt.errorparsers.xlc.XlcErrorParser; + +import junit.framework.TestCase; + +public class TestNoFuncProto extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. Warning message generated by + * xlc compiler (W) is given as input for testing. + */ + public void testparseLine() + { + XlcErrorParser aix = new XlcErrorParser(); + aix.parseLine(err_msg); + assertEquals("temp1.c", aix.getFileName()); + assertEquals(5, aix.getLineNumber()); + assertEquals("W", aix.getSeverity()); + assertEquals(" No function prototype given for \"printf\".",aix.getMessage()); + } + public TestNoFuncProto( String name) + { + super(name); + err_msg = "\"temp1.c\", line 5.9: 1506-304 (W) " + + "No function prototype given for \"printf\"."; + } +} \ No newline at end of file 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 new file mode 100644 index 00000000000..aac5e04c101 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestOperModi.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * 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 org.eclipse.cdt.errorparsers.xlc.XlcErrorParser; + +import junit.framework.TestCase; + + +public class TestOperModi extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. Error message generated by + * xlc compiler with high severity (S) is given as + * input for testing. + */ + public void testparseLine() + { + XlcErrorParser aix = new XlcErrorParser(); + aix.parseLine(err_msg); + assertEquals("temp9.c", aix.getFileName()); + assertEquals(13, aix.getLineNumber()); + assertEquals("S", aix.getSeverity()); + assertEquals(" Operand must be a modifiable lvalue.",aix.getMessage()); + } + public TestOperModi( String name) + { + super(name); + err_msg = "\"temp9.c\", line 13.9: 1506-025 (S) " + + "Operand must be a modifiable lvalue."; + } +} \ No newline at end of file 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 new file mode 100644 index 00000000000..d71de9a2815 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSyntaxError.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 org.eclipse.cdt.errorparsers.xlc.XlcErrorParser; + +import junit.framework.TestCase; + +public class TestSyntaxError extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. Error message generated by + * xlc compiler with high severity (S) is given as + * input for testing. + */ + public void testparseLine() + { + XlcErrorParser aix = new XlcErrorParser(); + aix.parseLine(err_msg); + assertEquals("temp1.c", aix.getFileName()); + assertEquals(5, aix.getLineNumber()); + assertEquals("S", aix.getSeverity()); + assertEquals(" Syntax error: possible missing ')'?",aix.getMessage()); + } + public TestSyntaxError( String name) + { + super(name); + err_msg = "\"temp1.c\", line 5.1: 1506-276 (S) " + + "Syntax error: possible missing ')'?"; + } +} \ No newline at end of file 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 new file mode 100644 index 00000000000..d9ddcb0b67b --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUndeclIdent.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * 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 org.eclipse.cdt.errorparsers.xlc.XlcErrorParser; + +import junit.framework.TestCase; + +public class TestUndeclIdent extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. Error message generated by + * xlc compiler with high severity (S) is given as + * input for testing. + */ + public void testparseLine() + { + XlcErrorParser aix = new XlcErrorParser(); + aix.parseLine(err_msg); + assertEquals("temp5.c", aix.getFileName()); + assertEquals(5, aix.getLineNumber()); + assertEquals("S", aix.getSeverity()); + assertEquals(" Undeclared identifier y.",aix.getMessage()); + } + public TestUndeclIdent( String name) + { + super(name); + err_msg = "\"temp5.c\", line 5.9: 1506-045 (S) " + + "Undeclared identifier y."; + } +} \ No newline at end of file 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 new file mode 100644 index 00000000000..f9d6b719eba --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestsPlugin.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * 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 org.eclipse.ui.plugin.*; +import org.eclipse.jface.resource.ImageDescriptor; +import org.osgi.framework.BundleContext; +import java.util.*; + +/** + * The main plugin class to be used in the desktop. + */ +public class TestsPlugin extends AbstractUIPlugin { + //The shared instance. + private static TestsPlugin plugin; + //Resource bundle. + private ResourceBundle resourceBundle; + + /** + * The constructor. + */ + public TestsPlugin() { + super(); + plugin = this; + } + + /** + * This method is called upon plug-in activation + */ + public void start(BundleContext context) throws Exception { + super.start(context); + } + + /** + * This method is called when the plug-in is stopped + */ + public void stop(BundleContext context) throws Exception { + super.stop(context); + plugin = null; + resourceBundle = null; + } + + /** + * Returns the shared instance. + */ + public static TestsPlugin getDefault() { + return plugin; + } + + /** + * Returns the string from the plugin's resource bundle, + * or 'key' if not found. + */ + public static String getResourceString(String key) { + ResourceBundle bundle = TestsPlugin.getDefault().getResourceBundle(); + try { + return (bundle != null) ? bundle.getString(key) : key; + } catch (MissingResourceException e) { + return key; + } + } + + /** + * Returns the plugin's resource bundle, + */ + public ResourceBundle getResourceBundle() { + try { + if (resourceBundle == null) + resourceBundle = ResourceBundle.getBundle("org.eclipse.cdt.errorparsers.xlc.tests.TestsPluginResources"); + } catch (MissingResourceException x) { + resourceBundle = null; + } + return resourceBundle; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path. + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.cdt.errorparsers.xlc.tests", path); + } +} diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc/.classpath b/xlc/org.eclipse.cdt.errorparsers.xlc/.classpath new file mode 100644 index 00000000000..7398f97e2d0 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc/.project b/xlc/org.eclipse.cdt.errorparsers.xlc/.project new file mode 100644 index 00000000000..510561ddc19 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc/.project @@ -0,0 +1,28 @@ + + + org.eclipse.cdt.errorparsers.xlc + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc/META-INF/MANIFEST.MF b/xlc/org.eclipse.cdt.errorparsers.xlc/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..6606588dae1 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc/META-INF/MANIFEST.MF @@ -0,0 +1,14 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: xlC Error Parser Plug-in +Bundle-SymbolicName: org.eclipse.cdt.errorparsers.xlc; singleton:=true +Bundle-Version: 1.0.0 +Bundle-Activator: org.eclipse.cdt.errorparsers.xlc.Activator +Bundle-Localization: plugin +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.cdt.core, + org.eclipse.core.resources +Eclipse-LazyStart: true +Export-Package: org.eclipse.cdt.errorparsers.xlc +Bundle-Vendor: Eclipse.org diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc/about.html b/xlc/org.eclipse.cdt.errorparsers.xlc/about.html new file mode 100644 index 00000000000..f8a1ce18403 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc/about.html @@ -0,0 +1,24 @@ + + +About + + +

About This Content

+ +

July 24, 2006

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + \ No newline at end of file diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc/build.properties b/xlc/org.eclipse.cdt.errorparsers.xlc/build.properties new file mode 100644 index 00000000000..34d2e4d2dad --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc/plugin.properties b/xlc/org.eclipse.cdt.errorparsers.xlc/plugin.properties new file mode 100644 index 00000000000..94c78914da3 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc/plugin.properties @@ -0,0 +1,4 @@ +pluginName=Error parser for xlc compiler +providerName=Eclipse.org + +CDTXLCErrorParser.name=CDT Xlc Error Parser \ No newline at end of file diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc/plugin.xml b/xlc/org.eclipse.cdt.errorparsers.xlc/plugin.xml new file mode 100644 index 00000000000..42da3e3d9f2 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc/plugin.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc/src/org/eclipse/cdt/errorparsers/xlc/Activator.java b/xlc/org.eclipse.cdt.errorparsers.xlc/src/org/eclipse/cdt/errorparsers/xlc/Activator.java new file mode 100644 index 00000000000..f7da1236975 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc/src/org/eclipse/cdt/errorparsers/xlc/Activator.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * 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; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.cdt.errorparsers.xlc"; + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} 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 new file mode 100644 index 00000000000..49eaa0f2731 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc/src/org/eclipse/cdt/errorparsers/xlc/XlcErrorParser.java @@ -0,0 +1,225 @@ +/******************************************************************************* + * 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; + +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 + * + */ +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.hasMoreTokens()) + { + 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. + */ + index = secondPart.indexOf(")"); //$NON-NLS-1$ + if( -1 == index ) + { + return false; + } + /* 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. + */ + message = secondPart.substring(index + 1); + severity = secondPart.substring(index - 1, index); + if( severity.equals("I") ) //$NON-NLS-1$ + { + severityNum = IMarkerGenerator.SEVERITY_INFO; + } + 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$ + } + } + eoParser.generateMarker(file, lineNumber, message, severityNum, null); + return true; + } + else + { + return false; + } + } + catch(NumberFormatException e ) + { + throw e; + } + } +} \ No newline at end of file