diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AbstractNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AbstractNode.java
index ad80a49d1f..64762d30ef 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AbstractNode.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AbstractNode.java
@@ -14,6 +14,7 @@ import javax.xml.parsers.ParserConfigurationException;
import net.sourceforge.pmd.lang.ast.xpath.Attribute;
import net.sourceforge.pmd.lang.ast.xpath.DocumentNavigator;
import net.sourceforge.pmd.lang.dfa.DataFlowNode;
+import net.sourceforge.pmd.lang.ast.GenericToken;
import org.jaxen.BaseXPath;
import org.jaxen.JaxenException;
@@ -397,4 +398,22 @@ public abstract class AbstractNode implements Node {
public void setUserData(Object userData) {
this.userData = userData;
}
+
+ protected GenericToken firstToken, lastToken;
+
+ public GenericToken jjtGetFirstToken() {
+ return firstToken;
+ }
+
+ public void jjtSetFirstToken(GenericToken token) {
+ this.firstToken = token;
+ }
+
+ public GenericToken jjtGetLastToken() {
+ return lastToken;
+ }
+
+ public void jjtSetLastToken(GenericToken token) {
+ this.lastToken = token;
+ }
}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/GenericToken.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/GenericToken.java
new file mode 100644
index 0000000000..63404be451
--- /dev/null
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/GenericToken.java
@@ -0,0 +1,8 @@
+/**
+ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
+ */
+package net.sourceforge.pmd.lang.ast;
+
+public class GenericToken {
+
+}
diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt
index 092622beab..be347962b0 100644
--- a/pmd-java/etc/grammar/Java.jjt
+++ b/pmd-java/etc/grammar/Java.jjt
@@ -1,4 +1,8 @@
/**
+ * Added capability for Tracking Tokens.
+ *
+ * Amit Kumar Prasad 10/2015
+ *====================================================================
* Fix for Cast Expression not detected properly in Return statements
* Bug #1429
*
@@ -109,6 +113,7 @@ options {
MULTI = true;
VISITOR = true;
NODE_USES_PARSER = true;
+ TRACK_TOKENS = true;
NODE_PACKAGE="net.sourceforge.pmd.lang.java.ast";
//DEBUG_PARSER = true;
diff --git a/pmd-java/src/main/ant/alljavacc.xml b/pmd-java/src/main/ant/alljavacc.xml
index 5534549057..45c05dac70 100644
--- a/pmd-java/src/main/ant/alljavacc.xml
+++ b/pmd-java/src/main/ant/alljavacc.xml
@@ -81,6 +81,12 @@ public class]]>
}
]]>
+
+ public class Token
+
+
diff --git a/pmd-jsp/etc/grammar/JspParser.jjt b/pmd-jsp/etc/grammar/JspParser.jjt
index bb5cd931f7..d4022677d4 100644
--- a/pmd-jsp/etc/grammar/JspParser.jjt
+++ b/pmd-jsp/etc/grammar/JspParser.jjt
@@ -1,4 +1,9 @@
- /* JSP Parser for PMD.
+/*
+ * Added capability for Tracking Tokens.
+ *
+ * Amit Kumar Prasad 10/2015
+ *====================================================================
+ * JSP Parser for PMD.
* It supports supports more-or-less well written JSP files.
* The JSP Document style is supported, except for inline DTD.
* The JSP Page style (<% ... %>) is supported.
@@ -16,6 +21,7 @@ options {
MULTI=true;
VISITOR=true;
+ TRACK_TOKENS = true;
}
PARSER_BEGIN(JspParser)
diff --git a/pmd-jsp/src/main/ant/alljavacc.xml b/pmd-jsp/src/main/ant/alljavacc.xml
index 39402a662a..da338412b9 100644
--- a/pmd-jsp/src/main/ant/alljavacc.xml
+++ b/pmd-jsp/src/main/ant/alljavacc.xml
@@ -61,6 +61,12 @@
public class]]>
+
+ public class Token
+
+
diff --git a/src/site/markdown/overview/changelog.md b/src/site/markdown/overview/changelog.md
index 0d6fc2e6fb..a0f8ecc831 100644
--- a/src/site/markdown/overview/changelog.md
+++ b/src/site/markdown/overview/changelog.md
@@ -10,6 +10,8 @@
**Pull Requests:**
+* [#72](https://github.com/pmd/pmd/pull/72): Added capability in Java and JSP parser for tracking tokens.
+
**Bugfixes:**
* [#1429](https://sourceforge.net/p/pmd/bugs/1429/): Java - Parse Error: Cast in return expression