1 package org.codehaus.groovy.control.messages; 2 3 import java.io.PrintWriter ; 4 5 import org.codehaus.groovy.control.Janitor; 6 import org.codehaus.groovy.control.ProcessingUnit; 7 import org.codehaus.groovy.control.SourceUnit; 8 import org.codehaus.groovy.syntax.CSTNode; 9 10 11 12 19 20 public class LocatedMessage extends SimpleMessage 21 { 22 protected CSTNode context; 24 25 public LocatedMessage( String message, CSTNode context ) 26 { 27 super( message ); 28 this.context = context; 29 } 30 31 32 public LocatedMessage( String message, Object data, CSTNode context ) 33 { 34 super( message, data ); 35 this.context = context; 36 } 37 38 39 public void write( PrintWriter writer, ProcessingUnit owner, Janitor janitor ) 40 { 41 SourceUnit source = (SourceUnit)owner; 43 String name = source.getName(); 44 int line = context.getStartLine(); 45 int column = context.getStartColumn(); 46 String sample = source.getSample( line, column, janitor ); 47 48 if( sample != null ) 49 { 50 writer.println( source.getSample(line, column, janitor) ); 51 } 52 53 writer.println( name + ": " + line + ": " + this.message ); 54 writer.println(""); 55 } 56 57 } 58 59 60 61 62 | Popular Tags |