|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| TreeToken.java | - | 66.7% | 60% | 63.6% |
|
||||||||||||||
| 1 | /* | |
| 2 | * DynamicJava - Copyright (C) 1999-2001 | |
| 3 | * | |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a | |
| 5 | * copy of this software and associated documentation files | |
| 6 | * (the "Software"), to deal in the Software without restriction, including | |
| 7 | * without limitation the rights to use, copy, modify, merge, publish, | |
| 8 | * distribute, sublicense, and/or sell copies of the Software, and to permit | |
| 9 | * persons to whom the Software is furnished to do so, subject to the | |
| 10 | * following conditions: | |
| 11 | * The above copyright notice and this permission notice shall be included | |
| 12 | * in all copies or substantial portions of the Software. | |
| 13 | * | |
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
| 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
| 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
| 17 | * IN NO EVENT SHALL DYADE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
| 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
| 20 | * DEALINGS IN THE SOFTWARE. | |
| 21 | * | |
| 22 | * Except as contained in this notice, the name of Dyade shall not be | |
| 23 | * used in advertising or otherwise to promote the sale, use or other | |
| 24 | * dealings in this Software without prior written authorization from | |
| 25 | * Dyade. | |
| 26 | * | |
| 27 | */ | |
| 28 | ||
| 29 | package koala.dynamicjava.parser.wrapper; | |
| 30 | ||
| 31 | import java.io.File; | |
| 32 | ||
| 33 | import koala.dynamicjava.parser.impl.Token; | |
| 34 | import koala.dynamicjava.tree.IdentifierToken; | |
| 35 | import koala.dynamicjava.tree.SourceInfo; | |
| 36 | ||
| 37 | /** An IdentifierToken wrapping a javacc Token. */ | |
| 38 | ||
| 39 | public class TreeToken implements IdentifierToken { | |
| 40 | /** | |
| 41 | * The implementation | |
| 42 | */ | |
| 43 | private final Token token; | |
| 44 | ||
| 45 | private final SourceInfo sourceInfo; | |
| 46 | ||
| 47 | /** | |
| 48 | * Creates a new tree token | |
| 49 | * @param t the parser token | |
| 50 | */ | |
| 51 | 4318 | public TreeToken(Token t, File f) { |
| 52 | 4318 | token = t; |
| 53 | 4318 | sourceInfo = SourceInfo.range(f, t.beginLine, t.beginColumn, t.endLine, t.endColumn); |
| 54 | } | |
| 55 | ||
| 56 | /** | |
| 57 | * Returns the underlying token | |
| 58 | */ | |
| 59 | 0 | public Token getToken() { |
| 60 | 0 | return token; |
| 61 | } | |
| 62 | ||
| 63 | /** | |
| 64 | * Returns the representation of the identifier | |
| 65 | */ | |
| 66 | 10137 | public String image() { |
| 67 | 10137 | return token.image; |
| 68 | } | |
| 69 | ||
| 70 | 4038 | public SourceInfo getSourceInfo() { |
| 71 | 4038 | return sourceInfo; |
| 72 | } | |
| 73 | ||
| 74 | 0 | public String toString() { |
| 75 | 0 | return image(); |
| 76 | } | |
| 77 | } |
|
||||||||||