syntaxerrormessage.java
来自「Groovy动态语言 运行在JVM中的动态语言 可以方便的处理业务逻辑变化大的业」· Java 代码 · 共 60 行
JAVA
60 行
package org.codehaus.groovy.control.messages;
import java.io.PrintWriter;
import org.codehaus.groovy.control.Janitor;
import org.codehaus.groovy.control.SourceUnit;
import org.codehaus.groovy.syntax.SyntaxException;
/**
* A class for error messages produced by the parser system.
*
* @author <a href="mailto:cpoirier@dreaming.org">Chris Poirier</a>
* @version $Id: SyntaxErrorMessage.java 2392 2005-07-01 03:01:19Z fraz $
*/
public class SyntaxErrorMessage extends Message {
protected SyntaxException cause = null;
protected SourceUnit source;
public SyntaxErrorMessage(SyntaxException cause, SourceUnit source) {
this.cause = cause;
this.source = source;
cause.setSourceLocator(source.getName());
}
/**
* Returns the underlying SyntaxException.
*/
public SyntaxException getCause() {
return this.cause;
}
/**
* Writes out a nicely formatted summary of the syntax error.
*/
public void write(PrintWriter output, Janitor janitor) {
String name = source.getName();
int line = getCause().getStartLine();
int column = getCause().getStartColumn();
String sample = source.getSample(line, column, janitor);
output.print(name + ": " + line + ": " + getCause().getMessage());
if (sample != null) {
output.println();
output.print(sample);
output.println();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?