|
|||||||||||||||||||
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 | |||||||||||||||
WarningMessage.java | - | 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.syntax.CSTNode;
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
/**
|
|
12 |
* A class for warning messages.
|
|
13 |
*
|
|
14 |
* @author <a href="mailto:cpoirier@dreaming.org">Chris Poirier</a>
|
|
15 |
*
|
|
16 |
* @version $Id: WarningMessage.java,v 1.1 2004/04/19 07:29:45 cpoirier Exp $
|
|
17 |
*/
|
|
18 |
|
|
19 |
public class WarningMessage extends LocatedMessage |
|
20 |
{ |
|
21 |
//---------------------------------------------------------------------------
|
|
22 |
// WARNING LEVELS
|
|
23 |
|
|
24 |
public static final int NONE = 0; // For querying, ignore all errors |
|
25 |
public static final int LIKELY_ERRORS = 1; // Warning indicates likely error |
|
26 |
public static final int POSSIBLE_ERRORS = 2; // Warning indicates possible error |
|
27 |
public static final int PARANOIA = 3; // Warning indicates paranoia on the part of the compiler |
|
28 |
|
|
29 |
|
|
30 |
/**
|
|
31 |
* Returns true if a warning would be relevant to the specified level.
|
|
32 |
*/
|
|
33 |
|
|
34 | 0 |
public static boolean isRelevant( int actual, int limit ) |
35 |
{ |
|
36 | 0 |
return actual <= limit;
|
37 |
} |
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
/**
|
|
42 |
* Returns true if this message is as or more important than the
|
|
43 |
* specified importance level.
|
|
44 |
*/
|
|
45 |
|
|
46 | 0 |
public boolean isRelevant( int importance ) |
47 |
{ |
|
48 | 0 |
return isRelevant( this.importance, importance ); |
49 |
} |
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
//---------------------------------------------------------------------------
|
|
54 |
// CONSTRUCTION AND DATA ACCESS
|
|
55 |
|
|
56 |
private int importance; // The warning level, for filtering |
|
57 |
|
|
58 |
|
|
59 |
/**
|
|
60 |
* Creates a new warning message.
|
|
61 |
*
|
|
62 |
* @param importance the warning level
|
|
63 |
* @param message the message text
|
|
64 |
* @param context context information for locating the offending source text
|
|
65 |
*/
|
|
66 |
|
|
67 | 0 |
public WarningMessage( int importance, String message, CSTNode context ) |
68 |
{ |
|
69 | 0 |
super( message, context );
|
70 | 0 |
this.importance = importance;
|
71 |
} |
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
/**
|
|
76 |
* Creates a new warning message.
|
|
77 |
*
|
|
78 |
* @param importance the warning level
|
|
79 |
* @param message the message text
|
|
80 |
* @param data additional data needed when generating the message
|
|
81 |
* @param context context information for locating the offending source text
|
|
82 |
*/
|
|
83 |
|
|
84 | 0 |
public WarningMessage( int importance, String message, Object data, CSTNode context ) |
85 |
{ |
|
86 | 0 |
super( message, data, context );
|
87 | 0 |
this.importance = importance;
|
88 |
} |
|
89 |
|
|
90 |
|
|
91 | 0 |
public void write( PrintWriter writer, ProcessingUnit owner, Janitor janitor ) |
92 |
{ |
|
93 | 0 |
writer.print( "warning: " );
|
94 | 0 |
super.write( writer, owner, janitor );
|
95 |
} |
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
} |
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|