|
|||||||||||||||||||
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 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 |
/**
|
|
12 |
* A class for error messages produced by the parser system.
|
|
13 |
*
|
|
14 |
* @author <a href="mailto:cpoirier@dreaming.org">Chris Poirier</a>
|
|
15 |
* @version $Id: SyntaxErrorMessage.java,v 1.2 2004/12/07 21:53:00 spullara Exp $
|
|
16 |
*/
|
|
17 |
|
|
18 |
public class SyntaxErrorMessage extends Message { |
|
19 |
protected SyntaxException cause = null; |
|
20 |
|
|
21 | 0 |
public SyntaxErrorMessage(SyntaxException cause) {
|
22 | 0 |
this.cause = cause;
|
23 |
} |
|
24 |
|
|
25 |
|
|
26 |
/**
|
|
27 |
* Returns the underlying SyntaxException.
|
|
28 |
*/
|
|
29 |
|
|
30 | 0 |
public SyntaxException getCause() {
|
31 | 0 |
return this.cause; |
32 |
} |
|
33 |
|
|
34 |
|
|
35 |
/**
|
|
36 |
* Writes out a nicely formatted summary of the syntax error.
|
|
37 |
*/
|
|
38 |
|
|
39 | 0 |
public void write(PrintWriter output, ProcessingUnit context, Janitor janitor) { |
40 | 0 |
SourceUnit source = (SourceUnit) context; // This is reliably true
|
41 |
|
|
42 | 0 |
String name = source.getName(); |
43 | 0 |
int line = getCause().getStartLine();
|
44 | 0 |
int column = getCause().getStartColumn();
|
45 | 0 |
String sample = source.getSample(line, column, janitor); |
46 |
|
|
47 | 0 |
output.print(name + ": " + line + ": " + getCause().getMessage()); |
48 | 0 |
if (sample != null) { |
49 | 0 |
output.println(); |
50 | 0 |
output.print(source.getSample(line, column, janitor)); |
51 |
} |
|
52 |
} |
|
53 |
|
|
54 |
|
|
55 |
} |
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|