1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 06:05:24 +02:00

initial commit of xlC error parser

This commit is contained in:
Chris Recoskie 2006-07-24 18:34:31 +00:00
parent 197ef4fc33
commit b87f4ffff2
25 changed files with 920 additions and 0 deletions

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry path="src" kind="src"/>
<classpathentry path="org.eclipse.jdt.launching.JRE_CONTAINER" kind="con"/>
<classpathentry path="org.eclipse.pde.core.requiredPlugins" kind="con"/>
<classpathentry path="bin" kind="output"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.cdt.errorparsers.xlc.tests</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

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

View file

@ -0,0 +1,24 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>About</title></head>
<body lang="EN-US">
<h2>About This Content</h2>
<p>July 24, 2006</p>
<h3>License</h3>
<p>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 <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
For purposes of the EPL, "Program" will mean the Content.</p>
<p>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 <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
</body></html>

View file

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

View file

@ -0,0 +1,2 @@
<plugin>
</plugin>

View file

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

View file

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

View file

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

View file

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

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

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

View file

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

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 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 ')'?";
}
}

View file

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

View file

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

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry path="src" kind="src"/>
<classpathentry path="org.eclipse.jdt.launching.JRE_CONTAINER" kind="con"/>
<classpathentry path="org.eclipse.pde.core.requiredPlugins" kind="con"/>
<classpathentry path="bin" kind="output"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.cdt.errorparsers.xlc</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

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

View file

@ -0,0 +1,24 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>About</title></head>
<body lang="EN-US">
<h2>About This Content</h2>
<p>July 24, 2006</p>
<h3>License</h3>
<p>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 <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
For purposes of the EPL, "Program" will mean the Content.</p>
<p>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 <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
</body></html>

View file

@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

View file

@ -0,0 +1,4 @@
pluginName=Error parser for xlc compiler
providerName=Eclipse.org
CDTXLCErrorParser.name=CDT Xlc Error Parser

View file

@ -0,0 +1,7 @@
<plugin>
<extension id="XlcErrorParser"
name="%CDTXLCErrorParser.name"
point="org.eclipse.cdt.core.ErrorParser">
<errorparser class="org.eclipse.cdt.errorparsers.xlc.XlcErrorParser" />
</extension>
</plugin>

View file

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

View file

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