Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » Error parser
Error parser [message #160871] Wed, 21 December 2005 08:02 Go to next message
Eclipse UserFriend
Originally posted by: MCondarelli.harmanbecker.com

Hi,
I tried writing an error parser for the coldfire diab compiler.

I'm nowhere near a java programmer, so I could have done some very stupid
error, but I tried to stick to the basics (mainly following what is in the
mail from David H. on Nov 30 2005 18:26:45, but I also read a lot of other
docs, including "Managed Build System Extensibility Document").

I used the wizard to create a new plug-in project and used the gcc
ErrorParser as a template for my class.

Here follows my plugin.xml:
-------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin>
<extension
point="org.eclipse.cdt.core.ErrorParser">
id="diabErrorParser"
name="%diabErrorParser.name"
<errorparser
class="com.soft_in.diabErrorParser">
</errorparser>
</extension>
</plugin>
-------------------------------
... my plugin.properties:
-------------------------------
diabErrorParser.name=diab Error Parser
-------------------------------
... and, finally, my class (DiabErrorParser.java):
-------------------------------
package com.soft_in.diabErrorParser;

import java.util.regex.*;
import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.IErrorParser;
import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;

public class DiabErrorParser implements IErrorParser {

// Known patterns.
// "file", line #: severity-level (compiler:error #): message
private Pattern linePattern = Pattern.compile("\"([^ \"]+)\", line
(\\d+): (\\S+) \\((\\w+):(\\d+)\\): (.*)$");

public boolean processLine(String line, ErrorParserManager eoParser) {
return processLine(line, eoParser,
IMarkerGenerator.SEVERITY_ERROR_RESOURCE);
}

public boolean processLine(String line, ErrorParserManager eoParser, int
inheritedSeverity) {

Matcher m = linePattern.matcher(line);

if (!m.matches()) {
return false;
}
// if we get here the line was matched as a valid error message.
String fileName = m.group(1);
int lineNo = Integer.parseInt(m.group(2));
//String severity = m.group(3);
//String compilePass = m.group(4);
//int errorNo = Integer.parseInt(m.group(5));
String desc = m.group(6);

/* See if we can get a var name (NOT IMPLEMENTED!) */
String varName = "";

if (!Path.EMPTY.isValidPath(fileName)) {
return false;
}
IFile file = eoParser.findFileName(fileName);
if (file != null) {
if (eoParser.isConflictingName(fileName)) {
desc = desc + " [Conflicting names] "; //$NON-NLS-1$
file = null;
}
} else {
file = eoParser.findFilePath(fileName);
if (file == null) {
IPath path = new Path(fileName);
if (path.segmentCount() > 1) {
file = eoParser.findFileName(fileName);
if (file != null) {
if (eoParser.isConflictingName(fileName)) {
desc = desc + " [Conflicting names] "; //$NON-NLS-1$
file = null;
}
}
}
}
}

int severity = extractSeverity(m.group(3).trim(), inheritedSeverity);

// Display the fileName.
if (file == null) {
desc = desc + " [" + fileName + "]"; //$NON-NLS-1$ //$NON-NLS-2$
}

eoParser.generateMarker(file, lineNo, desc, severity, varName);
return false;
}

private int extractSeverity(String sev, int defaultSeverity) {
int severity = defaultSeverity;
if (sev.equalsIgnoreCase("information")) { //$NON-NLS-1$
severity = IMarkerGenerator.SEVERITY_INFO;
} else if (sev.equalsIgnoreCase("warning")) { //$NON-NLS-1$
severity = IMarkerGenerator.SEVERITY_WARNING;
} else if (sev.equalsIgnoreCase("error")) { //$NON-NLS-1$
severity = IMarkerGenerator.SEVERITY_ERROR_BUILD;
} else if (sev.equalsIgnoreCase("fatal" /* NOI18N */)) {
severity = IMarkerGenerator.SEVERITY_ERROR_BUILD;
}
return severity;
}
}
-------------------------------
Unfortunately (?) I get an exception well before my code has any chance to
run:
org.eclipse.core.launcher.Main at localhost:1833
Thread [main] (Suspended (exception NullPointerException))
ErrorParserBlock(AbstractErrorParserBlock).updateListControl (String[])
line: 246
ErrorParserBlock(AbstractErrorParserBlock).setValues() line: 231
ErrorParserBlock(AbstractErrorParserBlock).initializeValues( ) line: 207
ErrorParserBlock(AbstractErrorParserBlock).createControl(Com posite)
line: 287
ErrorParserBlock.createControl(Composite) line: 50
MakeProjectWizardOptionPage$MakeWizardOptionBlock(TabFolderO ptionBlock).addTab(ICOptionPage)
line: 143
MakeProjectWizardOptionPage$MakeWizardOptionBlock(MakeProjec tOptionBlock).addTabs()
line: 44
MakeProjectWizardOptionPage$MakeWizardOptionBlock.addTabs() line: 58
MakeProjectWizardOptionPage$MakeWizardOptionBlock(TabFolderO ptionBlock).createContents(Composite)
line: 98
MakeProjectWizardOptionPage$MakeWizardOptionBlock(MakeProjec tOptionBlock).createContents(Composite)
line: 54
MakeProjectWizardOptionPage(NewCProjectWizardOptionPage).cre ateControl(Composite)
line: 38
NewMakeCProjectWizard(Wizard).createPageControls(Composite) line: 179
NewMakeCProjectWizard(NewMakeProjectWizard).createPageContro ls(Composite)
line: 67
WizardDialog.createPageControls() line: 611
WizardDialog.setWizard(IWizard) line: 965
WizardDialog.updateForPage(IWizardPage) line: 1016
WizardDialog.access$2(WizardDialog, IWizardPage) line: 1013
WizardDialog$4.run() line: 1003
BusyIndicator.showWhile(Display, Runnable) line: 69
WizardDialog.showPage(IWizardPage) line: 1001
WizardDialog.nextPressed() line: 753
WizardDialog.buttonPressed(int) line: 345
Dialog$2.widgetSelected(SelectionEvent) line: 556
TypedListener.handleEvent(Event) line: 90
EventTable.sendEvent(Event) line: 66
Button(Widget).sendEvent(Event) line: 843
Display.runDeferredEvents() line: 3080
Display.readAndDispatch() line: 2713
WizardDialog(Window).runEventLoop(Shell) line: 809
WizardDialog(Window).open() line: 787
NewProjectAction.run() line: 114
NewProjectAction(Action).runWithEvent(Event) line: 996
ActionContributionItem.handleWidgetSelection(Event, boolean) line: 538
ActionContributionItem.access$2(ActionContributionItem, Event, boolean)
line: 488
ActionContributionItem$5.handleEvent(Event) line: 400
EventTable.sendEvent(Event) line: 66
MenuItem(Widget).sendEvent(Event) line: 843
Display.runDeferredEvents() line: 3080
Display.readAndDispatch() line: 2713
Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 1699
Workbench.runUI() line: 1663
Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 367
PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 143
IDEApplication.run(Object) line: 103
PlatformActivator$1.run(Object) line: 226
EclipseStarter.run(Object) line: 376
EclipseStarter.run(String[], Runnable) line: 163
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available
Method.invoke(Object, Object[]) line: not available
Main.invokeFramework(String[], URL[]) line: 334
Main.basicRun(String[]) line: 278
Main.run(String[]) line: 973
Main.main(String[]) line: 948
Thread [Framework Event Dispatcher] (Running)
Thread [Start Level Event Dispatcher] (Running)
Thread [Worker-0] (Running)
Thread [Worker-5] (Running)
Thread [Java indexing] (Running)
Thread [C/C++ Indexer] (Running)
------------------------
... and now the big question: "what did I do wrong ?"

Please advise me :)

Best Regards,
Thanks in Advance and (of course)
Merry Christmas!!

Mauro
Re: Error parser [message #160976 is a reply to message #160871] Thu, 22 December 2005 15:38 Go to previous message
Eclipse UserFriend
Originally posted by: eclipse.dharty.com

hmm, first quick glance, everything looks roughly okay, except...

You didn't mention anything about your plugin class. If you used the
Make Wizard Plugin, likes it looks like you did, then in addition to
your parser class, you should have a class that extends

org.eclipse.core.runtime.Plugin

This class is needed, AFAIK, is to provide the framework for Eclipse to
look into your plugin and find the extensions that you created.

It should be generated automatically and look something like this:


package com.insitu.parsers;

import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;

/**
* The main plugin class to be used in the desktop.
*/
public class InsituParserPlugin extends Plugin
{

//The shared instance.
private static InsituParserPlugin plugin;

/**
* The constructor.
*/
public InsituParserPlugin() {
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;
}

/**
* Returns the shared instance.
*/
public static InsituParserPlugin getDefault() {
return plugin;
}

}



If you don't have that, the rest wont work. If you do, you may have
some other low level problem in your make plugin wizard.

Try creating a plugin with no extensions and see if that causes the same
problem.

David




Mauro Condarelli wrote:
> Hi, I tried writing an error parser for the coldfire diab compiler.
>
> I'm nowhere near a java programmer, so I could have done some very
> stupid error, but I tried to stick to the basics (mainly following what
> is in the mail from David H. on Nov 30 2005 18:26:45, but I also read a
> lot of other docs, including "Managed Build System Extensibility
> Document").
>
> I used the wizard to create a new plug-in project and used the gcc
> ErrorParser as a template for my class.
>
> Here follows my plugin.xml:
> -------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <?eclipse version="3.0"?>
> <plugin>
> <extension
> point="org.eclipse.cdt.core.ErrorParser">
> id="diabErrorParser"
> name="%diabErrorParser.name"
> <errorparser
> class="com.soft_in.diabErrorParser">
> </errorparser>
> </extension>
> </plugin>
> -------------------------------
> .. my plugin.properties:
> -------------------------------
> diabErrorParser.name=diab Error Parser
> -------------------------------
> .. and, finally, my class (DiabErrorParser.java):
> -------------------------------
> package com.soft_in.diabErrorParser;
>
> import java.util.regex.*;
> import org.eclipse.cdt.core.ErrorParserManager;
> import org.eclipse.cdt.core.IErrorParser;
> import org.eclipse.cdt.core.IMarkerGenerator;
> import org.eclipse.core.resources.IFile;
> import org.eclipse.core.runtime.IPath;
> import org.eclipse.core.runtime.Path;
>
> public class DiabErrorParser implements IErrorParser {
>
> // Known patterns.
> // "file", line #: severity-level (compiler:error #): message
> private Pattern linePattern = Pattern.compile("\"([^ \"]+)\", line
> (\\d+): (\\S+) \\((\\w+):(\\d+)\\): (.*)$");
>
> public boolean processLine(String line, ErrorParserManager eoParser) {
> return processLine(line, eoParser,
> IMarkerGenerator.SEVERITY_ERROR_RESOURCE);
> }
>
> public boolean processLine(String line, ErrorParserManager eoParser,
> int inheritedSeverity) {
>
> Matcher m = linePattern.matcher(line);
>
> if (!m.matches()) {
> return false;
> }
> // if we get here the line was matched as a valid error message.
> String fileName = m.group(1);
> int lineNo = Integer.parseInt(m.group(2)); //String
> severity = m.group(3);
> //String compilePass = m.group(4);
> //int errorNo = Integer.parseInt(m.group(5));
> String desc = m.group(6);
>
> /* See if we can get a var name (NOT IMPLEMENTED!) */
> String varName = "";
>
> if (!Path.EMPTY.isValidPath(fileName)) {
> return false;
> }
> IFile file = eoParser.findFileName(fileName);
> if (file != null) {
> if (eoParser.isConflictingName(fileName)) {
> desc = desc + " [Conflicting names] "; //$NON-NLS-1$
> file = null;
> }
> } else {
> file = eoParser.findFilePath(fileName);
> if (file == null) {
> IPath path = new Path(fileName);
> if (path.segmentCount() > 1) {
> file = eoParser.findFileName(fileName);
> if (file != null) {
> if (eoParser.isConflictingName(fileName)) {
> desc = desc + " [Conflicting names] ";
> //$NON-NLS-1$
> file = null;
> }
> }
> }
> }
> }
>
> int severity = extractSeverity(m.group(3).trim(),
> inheritedSeverity);
>
> // Display the fileName.
> if (file == null) {
> desc = desc + " [" + fileName + "]"; //$NON-NLS-1$
> //$NON-NLS-2$
> }
>
> eoParser.generateMarker(file, lineNo, desc, severity, varName);
> return false;
> }
>
> private int extractSeverity(String sev, int defaultSeverity) {
> int severity = defaultSeverity; if
> (sev.equalsIgnoreCase("information")) { //$NON-NLS-1$
> severity = IMarkerGenerator.SEVERITY_INFO;
> } else if (sev.equalsIgnoreCase("warning")) { //$NON-NLS-1$
> severity = IMarkerGenerator.SEVERITY_WARNING;
> } else if (sev.equalsIgnoreCase("error")) { //$NON-NLS-1$
> severity = IMarkerGenerator.SEVERITY_ERROR_BUILD;
> } else if (sev.equalsIgnoreCase("fatal" /* NOI18N */)) {
> severity = IMarkerGenerator.SEVERITY_ERROR_BUILD;
> }
> return severity;
> }
> }
> -------------------------------
> Unfortunately (?) I get an exception well before my code has any chance
> to run:
> org.eclipse.core.launcher.Main at localhost:1833
> Thread [main] (Suspended (exception NullPointerException))
>
> ErrorParserBlock(AbstractErrorParserBlock).updateListControl (String[])
> line: 246
> ErrorParserBlock(AbstractErrorParserBlock).setValues() line: 231
> ErrorParserBlock(AbstractErrorParserBlock).initializeValues( )
> line: 207
>
> ErrorParserBlock(AbstractErrorParserBlock).createControl(Com posite)
> line: 287
> ErrorParserBlock.createControl(Composite) line: 50
>
> MakeProjectWizardOptionPage$MakeWizardOptionBlock(TabFolderO ptionBlock).addTab(ICOptionPage)
> line: 143
>
> MakeProjectWizardOptionPage$MakeWizardOptionBlock(MakeProjec tOptionBlock).addTabs()
> line: 44
> MakeProjectWizardOptionPage$MakeWizardOptionBlock.addTabs()
> line: 58
>
> MakeProjectWizardOptionPage$MakeWizardOptionBlock(TabFolderO ptionBlock).createContents(Composite)
> line: 98
>
> MakeProjectWizardOptionPage$MakeWizardOptionBlock(MakeProjec tOptionBlock).createContents(Composite)
> line: 54
>
> MakeProjectWizardOptionPage(NewCProjectWizardOptionPage).cre ateControl(Composite)
> line: 38
> NewMakeCProjectWizard(Wizard).createPageControls(Composite)
> line: 179
>
> NewMakeCProjectWizard(NewMakeProjectWizard).createPageContro ls(Composite)
> line: 67
> WizardDialog.createPageControls() line: 611
> WizardDialog.setWizard(IWizard) line: 965
> WizardDialog.updateForPage(IWizardPage) line: 1016
> WizardDialog.access$2(WizardDialog, IWizardPage) line: 1013
> WizardDialog$4.run() line: 1003
> BusyIndicator.showWhile(Display, Runnable) line: 69
> WizardDialog.showPage(IWizardPage) line: 1001
> WizardDialog.nextPressed() line: 753
> WizardDialog.buttonPressed(int) line: 345
> Dialog$2.widgetSelected(SelectionEvent) line: 556
> TypedListener.handleEvent(Event) line: 90
> EventTable.sendEvent(Event) line: 66
> Button(Widget).sendEvent(Event) line: 843
> Display.runDeferredEvents() line: 3080
> Display.readAndDispatch() line: 2713
> WizardDialog(Window).runEventLoop(Shell) line: 809
> WizardDialog(Window).open() line: 787
> NewProjectAction.run() line: 114
> NewProjectAction(Action).runWithEvent(Event) line: 996
> ActionContributionItem.handleWidgetSelection(Event, boolean)
> line: 538
> ActionContributionItem.access$2(ActionContributionItem, Event,
> boolean) line: 488
> ActionContributionItem$5.handleEvent(Event) line: 400
> EventTable.sendEvent(Event) line: 66
> MenuItem(Widget).sendEvent(Event) line: 843
> Display.runDeferredEvents() line: 3080
> Display.readAndDispatch() line: 2713
> Workbench.runEventLoop(Window$IExceptionHandler, Display) line:
> 1699
> Workbench.runUI() line: 1663
> Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line:
> 367
> PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor)
> line: 143
> IDEApplication.run(Object) line: 103
> PlatformActivator$1.run(Object) line: 226
> EclipseStarter.run(Object) line: 376
> EclipseStarter.run(String[], Runnable) line: 163
> NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line:
> not available [native method]
> NativeMethodAccessorImpl.invoke(Object, Object[]) line: not
> available
> DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not
> available
> Method.invoke(Object, Object[]) line: not available
> Main.invokeFramework(String[], URL[]) line: 334
> Main.basicRun(String[]) line: 278
> Main.run(String[]) line: 973
> Main.main(String[]) line: 948
> Thread [Framework Event Dispatcher] (Running)
> Thread [Start Level Event Dispatcher] (Running)
> Thread [Worker-0] (Running)
> Thread [Worker-5] (Running)
> Thread [Java indexing] (Running)
> Thread [C/C++ Indexer] (Running)
> ------------------------
> .. and now the big question: "what did I do wrong ?"
>
> Please advise me :)
>
> Best Regards,
> Thanks in Advance and (of course)
> Merry Christmas!!
>
> Mauro
>
>
Previous Topic:compile with -gdwarf-2
Next Topic:cdt gdb memory problem
Goto Forum:
  


Current Time: Wed Mar 12 00:44:44 EDT 2025

Powered by FUDForum. Page generated in 0.02747 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top