|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
SyntaxErrorMessage.java | 0% | 0% | 0% | 0% |
|
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.SyntaxException;
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
/**
|
|
13 |
* A class for error messages produced by the parser system.
|
|
14 |
*
|
|
15 |
* @author <a href="mailto:cpoirier@dreaming.org">Chris Poirier</a>
|
|
16 |
*
|
|
17 |
* @version $Id: SyntaxErrorMessage.java,v 1.1 2004/04/19 07:29:45 cpoirier Exp $
|
|
18 |
*/
|
|
19 |
|
|
20 |
public class SyntaxErrorMessage extends Message |
|
21 |
{ |
|
22 |
protected SyntaxException cause = null; |
|
23 |
|
|
24 | 0 |
public SyntaxErrorMessage( SyntaxException cause )
|
25 |
{ |
|
26 | 0 |
this.cause = cause;
|
27 |
} |
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
/**
|
|
32 |
* Returns the underlying SyntaxException.
|
|
33 |
*/
|
|
34 |
|
|
35 | 0 |
public SyntaxException getCause()
|
36 |
{ |
|
37 | 0 |
return this.cause; |
38 |
} |
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
/**
|
|
43 |
* Writes out a nicely formatted summary of the syntax error.
|
|
44 |
*/
|
|
45 |
|
|
46 | 0 |
public void write( PrintWriter output, ProcessingUnit context, Janitor janitor ) |
47 |
{ |
|
48 | 0 |
SourceUnit source = (SourceUnit)context; // This is reliably true
|
49 |
|
|
50 | 0 |
String name = source.getName(); |
51 | 0 |
int line = getCause().getStartLine();
|
52 | 0 |
int column = getCause().getStartColumn();
|
53 | 0 |
String sample = source.getSample( line, column, janitor ); |
54 |
|
|
55 | 0 |
output.println( name + ": " + line + ": " + getCause().getMessage() ); |
56 | 0 |
if( sample != null ) |
57 |
{ |
|
58 | 0 |
output.println( source.getSample(line, column, janitor) ); |
59 |
} |
|
60 | 0 |
output.println("");
|
61 |
} |
|
62 |
|
|
63 |
|
|
64 |
} |
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|