Created
October 12, 2011 15:34
-
-
Save ifedorenko/1281538 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.antlr.mojo.antlr3; | |
import java.io.File; | |
import javax.inject.Inject; | |
import javax.inject.Named; | |
import org.antlr.tool.ANTLRErrorListener; | |
import org.antlr.tool.Message; | |
import org.antlr.tool.ToolMessage; | |
import org.eclipse.tesla.incremental.BuildContext; | |
import org.eclipse.tesla.incremental.maven.internal.MojoExecutionScoped; | |
import org.slf4j.Logger; | |
/** | |
* The Maven plexus container gives us a Log logging provider | |
* which we can use to install an error listener for the ANTLR | |
* tool to report errors by. | |
*/ | |
@Named | |
public class Antlr3ErrorLog implements ANTLRErrorListener { | |
@Inject @MojoExecutionScoped | |
private BuildContext buildContext; | |
@Inject | |
private Logger log; | |
/** | |
* Sends an informational message to the Maven log sink. | |
* @param s The message to send to Maven | |
*/ | |
public void info(String message) { | |
log.info(message); | |
} | |
/** | |
* Sends an error message from ANTLR analysis to the Maven Log sink. | |
* | |
* @param message The message to send to Maven. | |
*/ | |
public void error(Message message) { | |
if (message.file != null) | |
{ | |
buildContext.addMessage( new File( message.file ), message.line, message.column, message.toString(), | |
BuildContext.SEVERITY_ERROR, message.e ); | |
} | |
else | |
{ | |
log.error(message.toString()); | |
} | |
} | |
/** | |
* Sends a warning message to the Maven log sink. | |
* | |
* @param message | |
*/ | |
public void warning(Message message) { | |
if (message.file != null) | |
{ | |
buildContext.addMessage( new File( message.file ), message.line, message.column, message.toString(), | |
BuildContext.SEVERITY_WARNING, message.e ); | |
} | |
else | |
{ | |
log.warn(message.toString()); | |
} | |
} | |
/** | |
* Sends an error message from the ANTLR tool to the Maven Log sink. | |
* @param toolMessage | |
*/ | |
public void error(ToolMessage toolMessage) { | |
log.error(toolMessage.toString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
java.lang.NullPointerException
at org.antlr.mojo.antlr3.Antlr3ErrorLog.info(Antlr3ErrorLog.java:64)
at org.antlr.tool.ErrorManager.info(ErrorManager.java:576)
at org.antlr.Tool.process(Tool.java:421)
at org.antlr.mojo.antlr3.Antr3MavenTool.process(Antr3MavenTool.java:30)
at org.antlr.mojo.antlr3.Antlr3Mojo.doExecute(Antlr3Mojo.java:387)
at org.antlr.mojo.antlr3.Antlr3Mojo.execute(Antlr3Mojo.java:257)
at org.antlr.mojo.antlr3.tests.AbstractBuildAvoidanceTest.executeMojo(AbstractBuildAvoidanceTest.java:108)
at org.antlr.mojo.antlr3.tests.BuildAvoidanceTest.testNoChangesNoRebuild(BuildAvoidanceTest.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)