1 package org.codehaus.groovy.control.messages; 2 3 import org.codehaus.groovy.control.Janitor; 4 import org.codehaus.groovy.control.ProcessingUnit; 5 import org.codehaus.groovy.control.SourceUnit; 6 import org.codehaus.groovy.syntax.SyntaxException; 7 8 import java.io.PrintWriter ; 9 10 11 17 18 public class SyntaxErrorMessage extends Message { 19 protected SyntaxException cause = null; 20 21 public SyntaxErrorMessage(SyntaxException cause) { 22 this.cause = cause; 23 } 24 25 26 29 30 public SyntaxException getCause() { 31 return this.cause; 32 } 33 34 35 38 39 public void write(PrintWriter output, ProcessingUnit context, Janitor janitor) { 40 SourceUnit source = (SourceUnit) context; 42 String name = source.getName(); 43 int line = getCause().getStartLine(); 44 int column = getCause().getStartColumn(); 45 String sample = source.getSample(line, column, janitor); 46 47 output.print(name + ": " + line + ": " + getCause().getMessage()); 48 if (sample != null) { 49 output.println(); 50 output.print(source.getSample(line, column, janitor)); 51 } 52 } 53 54 55 } 56 57 58 59 | Popular Tags |