forked from pmd/pmd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TokenBasedNode, AbstractJjtreeNode
- Loading branch information
Showing
13 changed files
with
101 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/TokenBasedNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html | ||
*/ | ||
|
||
package net.sourceforge.pmd.lang.ast; | ||
|
||
/** | ||
* A {@link Node} that can provide access to the underlying | ||
* {@linkplain GenericToken tokens} produced by the lexer. | ||
*/ | ||
public interface TokenBasedNode<T extends GenericToken> { | ||
|
||
/** | ||
* Returns the first token producing this node. | ||
* This is not a special token. | ||
*/ | ||
T getFirstToken(); | ||
|
||
|
||
/** | ||
* Returns the last token producing this node. | ||
* This is not a special token. | ||
*/ | ||
T getLastToken(); | ||
|
||
|
||
} |
39 changes: 39 additions & 0 deletions
39
pmd-core/src/main/java/net/sourceforge/pmd/lang/java/ast/impl/javacc/AbstractJjtreeNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html | ||
*/ | ||
|
||
package net.sourceforge.pmd.lang.java.ast.impl.javacc; | ||
|
||
import net.sourceforge.pmd.lang.ast.AbstractNode; | ||
import net.sourceforge.pmd.lang.ast.GenericToken; | ||
import net.sourceforge.pmd.lang.ast.Node; | ||
import net.sourceforge.pmd.lang.ast.TokenBasedNode; | ||
|
||
/** | ||
* Base class for node produced by JJTree. JJTree specific functionality | ||
* present on the API of {@link Node} and {@link AbstractNode} will be | ||
* moved here for 7.0.0. | ||
*/ | ||
public abstract class AbstractJjtreeNode<T extends GenericToken> extends AbstractNode implements TokenBasedNode<T> { | ||
|
||
public AbstractJjtreeNode(int id) { | ||
super(id); | ||
} | ||
|
||
public AbstractJjtreeNode(int id, int theBeginLine, int theEndLine, int theBeginColumn, int theEndColumn) { | ||
super(id, theBeginLine, theEndLine, theBeginColumn, theEndColumn); | ||
} | ||
|
||
|
||
@Override | ||
@SuppressWarnings("unchecked") | ||
public T getFirstToken() { | ||
return (T) super.jjtGetFirstToken(); | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") | ||
public T getLastToken() { | ||
return (T) super.jjtGetLastToken(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters