Clover coverage report - groovy - 1.0-beta-7
Coverage timestamp: Wed Sep 29 2004 16:55:52 BST
file stats: LOC: 107   Methods: 8
NCLOC: 84   Classes: 1
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
UnexpectedTokenException.java 0% 0% 0% 0%
coverage
 1   
 package org.codehaus.groovy.syntax.parser;
 2   
 
 3   
 import org.codehaus.groovy.syntax.Types;
 4   
 import org.codehaus.groovy.syntax.Token;
 5   
 
 6   
 public class UnexpectedTokenException extends ParserException {
 7   
     private Token unexpectedToken;
 8   
     private int[] expectedTypes;
 9   
     private String comment;
 10   
 
 11  0
     public UnexpectedTokenException(Token token) {
 12  0
         this(token, null, null );
 13   
     }
 14   
     
 15  0
     public UnexpectedTokenException(Token token, int expectedType) {
 16  0
         this(token, new int[] { expectedType });
 17   
     }
 18   
     
 19  0
     public UnexpectedTokenException(Token token, int[] expectedTypes) {
 20  0
         this(token, expectedTypes, null );
 21   
     }
 22   
 
 23  0
     public UnexpectedTokenException(Token token, int[] expectedTypes, String comment) {
 24  0
         super("Unexpected token", token);
 25  0
         this.unexpectedToken = token;
 26  0
         this.expectedTypes = expectedTypes;
 27  0
         this.comment       = comment;
 28   
     }
 29   
 
 30  0
     public Token getUnexpectedToken() {
 31  0
         return this.unexpectedToken;
 32   
     }
 33   
 
 34  0
     public int[] getExpectedTypes() {
 35  0
         return this.expectedTypes;
 36   
     }
 37   
 
 38  0
     public String getUnexpectedTokenText( ) {
 39  0
         String text = null;
 40  0
         if( this.unexpectedToken != null )
 41   
         {
 42  0
             text = this.unexpectedToken.getText();
 43   
         }
 44   
 
 45  0
         if( text == null )
 46   
         {
 47  0
             text = "";
 48   
         }
 49   
 
 50  0
         return text;
 51   
     }
 52   
 
 53  0
     public String getMessage() {
 54  0
         StringBuffer message = new StringBuffer();
 55   
 
 56  0
         if( expectedTypes != null ) {
 57  0
             message.append( "expected " );
 58   
 
 59  0
             if (this.expectedTypes.length == 1) {
 60  0
                 message.append( Types.getDescription(this.expectedTypes[0]) );
 61   
             }
 62   
             else {
 63  0
                 message.append("one of { ");
 64   
     
 65  0
                 for (int i = 0; i < expectedTypes.length; ++i) {
 66  0
                     message.append( Types.getDescription(this.expectedTypes[i]) );
 67   
     
 68  0
                     if ((i + 1) < expectedTypes.length) {
 69  0
                         if( expectedTypes.length > 2 ) {
 70  0
                             message.append(", ");
 71   
                         }
 72   
                         else {
 73  0
                             message.append(" ");
 74   
                         }
 75   
                     }
 76   
 
 77  0
                     if ((i + 2) == expectedTypes.length) {
 78  0
                         message.append("or ");
 79   
                     }
 80   
                 }
 81   
     
 82  0
                 message.append(" }");
 83   
             }
 84   
 
 85  0
             message.append( "; found '" );
 86   
         }
 87   
         else {
 88  0
             message.append( "could not use '" );
 89   
         }
 90   
 
 91  0
         message.append( getUnexpectedTokenText() ).append( "'" );
 92  0
         if( unexpectedToken != null ) {
 93  0
             message.append(" at " + unexpectedToken.getStartLine() + ":" + unexpectedToken.getStartColumn());
 94   
         }
 95   
         else {
 96  0
             message.append(" at unknown location (probably end of file)");
 97   
         }
 98   
 
 99  0
         if( comment != null ) {
 100  0
             message.append( "; " );
 101  0
             message.append( comment );
 102   
         }
 103   
 
 104  0
         return message.toString();
 105   
     }
 106   
 }
 107