1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-09 11:33:20 +02:00

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
This commit is contained in:
Chris Recoskie 2009-06-02 14:38:25 +00:00
parent 61b9542da8
commit 5358c015a3
23 changed files with 683 additions and 240 deletions

View file

@ -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

View file

@ -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;
}

View file

@ -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";
}
}

View file

@ -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)

View file

@ -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());
}

View file

@ -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());

View file

@ -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";
}
}

View file

@ -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";
}
}

View file

@ -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.";
}
}

View file

@ -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.";
}
}

View file

@ -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()";
}
}

View file

@ -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.";
}
}

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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";
}
}

View file

@ -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.

View file

@ -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;
}
}

View file

@ -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() {
}
}

View file

@ -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);
}
}
}

View file

@ -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]+) (.*)